该属性如下所示:
private static PropertyInfo<bool> FooProperty=
RegisterProperty<bool>(c => c.Foo, "Foo Friendly Name");
public bool Foo
{
get { return GetProperty(FooProperty); }
private set { SetProperty(FooProperty, value); }
}
我想从课堂之外获得“食品友好名称”。
最佳答案
放松对静态FooProperty
的访问:
//access FooProperty from inside the assembly where it is defined
internal static PropertyInfo<bool> FooProperty=
RegisterProperty<bool>(c => c.Foo, "Foo Friendly Name");
要么
//access FooProperty from anywhere
public static PropertyInfo<bool> FooProperty=
RegisterProperty<bool>(c => c.Foo, "Foo Friendly Name");
然后从类之外访问它:
string fooName = FooClass.FooProperty.Name;