如何从课外检索CSLA属性的友好名称?

时间:2010-06-28 20:25:31

标签: c# csla

该属性如下所示:

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); }
}

我想从课外收到“食物友好名称”。

1 个答案:

答案 0 :(得分:3)

取消静态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;