是否有任何框架可以帮助我:(认为也许 StructureMap 可以帮助我)
每当我创建“MyClass”的新实例或从 IMyInterface 继承的任何其他类时,我希望所有用 [MyPropertyAttribute] 修饰的属性都使用属性中的属性名称填充数据库或其他数据存储中的值。
public class MyClass : IMyInterface
{
[MyPropertyAttribute("foo")]
public string Foo { get; set; }
}
[AttributeUsage(AttributeTargets.Property)]
public sealed class MyPropertyAttribute : System.Attribute
{
public string Name
{
get;
private set;
}
public MyPropertyAttribute(string name)
{
Name = name;
}
}