我非常绝望地找到了下面提到的问题的解决方案.
我有一个跨平台解决方案,有4个项目,
3 OS特定
MyApp.android,
MyApp.Winphone,
MyApp.IOS
和PCL项目
MyApp.BLL
在MyApp.BLLbll中,我正在使用MyApp命名空间,在根目录中我有TranslateExtension.cs类
namespace MyApp
{
[ContentProperty("Text")]
public class TranslateExtension: IMarkupExtension
{
readonly CultureInfo ci;
const string ResourceId = "MyApp.Resources.AppResource";
public TranslateExtension()
{
ci = DependencyService.Get<ILocalize>().GetCurrentCultureInfo();
}
public string Text { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
if (Text == null)
return "";
ResourceManager resmgr = new ResourceManager(ResourceId
, typeof(TranslateExtension).GetTypeInfo().Assembly);
var translation = resmgr.GetString(Text, ci);
try
{
if (translation == null)
{
#if DEBUG
throw new ArgumentException( …Run Code Online (Sandbox Code Playgroud)