Generate custom setter using attributes

后端 未结 2 1065
有刺的猬
有刺的猬 2021-02-15 23:31

In classes whose instances I persist using an object database, I keep having to do this:

private string _name;
public string Name
    {
    get { return this._na         


        
2条回答
  •  被撕碎了的回忆
    2021-02-16 00:12

    This requires aspect oriented programming. While not directly supported in .NET, it can be done via third party tooling, such as PostSharp.

    For intellisense to work, however, this must be done in a library, as the (final) compiled code will be unrolled into the full property getter/setter.

提交回复
热议问题