1
要的CodeDOM创建支持字段属性,我们可以使用一个建筑像这样:C#CodeDOM的新属性,它返回一个字典元素
CodeMemberProperty property = new CodeMemberProperty;
property.GetStatements.Add(
new CodeMethodReturnStatement(
new CodeFieldReferenceExpression(
new CodeThisReferenceExpression(),
fieldName)));
但必须是什么建筑内部“CodeMethodReturnStatement”像一个结果:
public string SomeProp { get { return _someDict[_someKey]; } }
其中:
_someDict = new Dictionary<string, string>();
_someKey = "someKey";
_someDict和_someKey是SA成员我生成类。
我认为你需要CodeIndexerExpression类。 – john
您不应编辑您的问题以包含答案。相反,你应该把它作为答案发布,然后你可以接受它。 – svick