当前位置: 首页>>代码示例>>C#>>正文


C# CodeExpression.Property方法代码示例

本文整理汇总了C#中System.CodeDom.CodeExpression.Property方法的典型用法代码示例。如果您正苦于以下问题:C# CodeExpression.Property方法的具体用法?C# CodeExpression.Property怎么用?C# CodeExpression.Property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.CodeDom.CodeExpression的用法示例。


在下文中一共展示了CodeExpression.Property方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddVisitCode

		static bool AddVisitCode(EasyMethod m, FieldInfo field, CodeExpression var, List<CodeStatement> assertions, bool transformer)
		{
			CodeExpression prop = var.Property(GetPropertyName(field.Name));
			CodeExpression nodeStack = Easy.Var("nodeStack");
			if (field.FieldType.FullName.StartsWith("System.Collections.Generic.List")) {
				Type elType = field.FieldType.GetGenericArguments()[0];
				if (!typeof(INode).IsAssignableFrom(elType))
					return false;
				assertions.Add(AssertIsNotNull(prop));
				string code;
				if (transformer) {
					code = CreateTransformerLoop(GetCode(prop), ConvertType(elType).BaseType);
				} else {
					code =
						"\t\t\tforeach (" + ConvertType(elType).BaseType + " o in " + GetCode(prop) + ") {\n" +
						"\t\t\t\tDebug.Assert(o != null);\n" +
						"\t\t\t\to.AcceptVisitor(this, data);\n" +
						"\t\t\t}";
				}
				m.Statements.Add(new CodeSnippetStatement(code));
				return true;
			}
			if (!typeof(INode).IsAssignableFrom(field.FieldType))
				return false;
			assertions.Add(AssertIsNotNull(prop));
			if (transformer) {
				m.Statements.Add(nodeStack.InvokeMethod("Push", prop));
			}
			m.Statements.Add(prop.InvokeMethod("AcceptVisitor",
			                                   Easy.This,
			                                   Easy.Var("data")));
			if (transformer) {
				m.Body.Assign(prop, nodeStack.InvokeMethod("Pop").CastTo(ConvertType(field.FieldType)));
			}
			return true;
		}
开发者ID:ThomasZitzler,项目名称:ILSpy,代码行数:36,代码来源:Main.cs

示例2: AddVisitCode

 static bool AddVisitCode(EasyMethod m, FieldInfo field, CodeExpression var, List<CodeStatement> assertions, bool transformer)
 {
     CodeExpression prop = var.Property(GetPropertyName(field.Name));
     CodeExpression nodeStack = Easy.Var("nodeStack");
     if (field.FieldType.FullName.StartsWith("System.Collections.Generic.List")) {
         Type elType = field.FieldType.GetGenericArguments()[0];
         if (!typeof(INode).IsAssignableFrom(elType))
             return false;
         assertions.Add(IfNullSetFailure(prop));
         string code;
         string propertyName = GetCode(prop);
         if (transformer) {
             code = CreateTransformerLoop(propertyName, ConvertType(elType).BaseType);
         } else {
             code =
                 "\t\t\tif (" + propertyName + ".Count == data." + GetPropertyName(field.Name) + ".Count) {\n" +
                 "\t\t\tfor (int i=0; i<" + propertyName + ".Count;i++) {\n" +
                 "\t\t\t\t" + ConvertType(elType).BaseType + " o = " + propertyName + "[i];\n" +
                 "\t\t\t\tif(o == null){return SetFailure();}\n" + "\t\t\t\tif((bool)o.AcceptVisitor(this, data." + GetPropertyName(field.Name) + "[i]) == false) return SetFailure();\n" +
                 "\t\t\t}" +
                 "\t\t\t}" +
                 "\t\t\telse { return SetFailure(); }";
         }
         m.Statements.Add(new CodeSnippetStatement(code));
         return true;
     }
     if (!typeof(INode).IsAssignableFrom(field.FieldType))
         return false;
     assertions.Add(IfNullSetFailure(prop));
     if (transformer) {
         m.Statements.Add(nodeStack.InvokeMethod("Push", prop));
     }
     m.Statements.Add(prop.InvokeMethod("AcceptVisitor",
                                        Easy.This,
                                        Easy.Var("data." + var.Property(GetPropertyName(field.Name)).PropertyName)));
     if (transformer) {
         m.Body.Assign(prop, nodeStack.InvokeMethod("Pop").CastTo(ConvertType(field.FieldType)));
     }
     return true;
 }
开发者ID:jbuedel,项目名称:AgentRalphPlugin,代码行数:40,代码来源:Main.cs


注:本文中的System.CodeDom.CodeExpression.Property方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。