问题来自两个要求:
所以我现在的代码是:
public static class SomeClassExtender
{
public static string GetSomeProp(this SomeClass instance) { ... }
public static void SetSomeProp(this SomeClass instance, string value) { ... }
}
public class SomeClassWrapper
{
private SomeClass instance;
public SomeClassWrapper(SomeClass instance) { this.instance = instance; }
public string SomeProp
{
get { return this.instance.GetSomeProp(); }
set { this.instance.SetSomeProp(value); }
}
}
这些代码确实有效,但是如果有更好的方法可以实现这一点我感兴趣,可能是属性还是什么?