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


C# Ast.TypeReference类代码示例

本文整理汇总了C#中ICSharpCode.NRefactory.Ast.TypeReference的典型用法代码示例。如果您正苦于以下问题:C# TypeReference类的具体用法?C# TypeReference怎么用?C# TypeReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypeReference类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了TypeReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: add_Method

        public static MethodDeclaration add_Method(this TypeDeclaration typeDeclaration, string methodName, Dictionary<string, object> invocationParameters, BlockStatement body)
        {
            var newMethod = new MethodDeclaration
            {
                Name = methodName,
                //Modifier = Modifiers.None | Modifiers.Public | Modifiers.Static,
                Modifier = Modifiers.None | Modifiers.Public,
                Body = body
            };
            newMethod.setReturnType();
            if (invocationParameters != null)

                foreach (var invocationParameter in invocationParameters)
                {
                    var parameterType = new TypeReference(
                        (invocationParameter.Value != null && invocationParameter.Key != "returnData")
                        ? invocationParameter.Value.typeFullName()
                        : "System.Object", true);
                    var parameter = new ParameterDeclarationExpression(parameterType, invocationParameter.Key);
                    newMethod.Parameters.Add(parameter);

                }
            typeDeclaration.AddChild(newMethod);
            return newMethod;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:25,代码来源:MethodDeclaration_ExtensionMethods.cs

示例2: LocalLookupVariable

		public LocalLookupVariable(TypeReference typeRef, Location startPos, Location endPos, bool isConst)
		{
			this.typeRef = typeRef;
			this.startPos = startPos;
			this.endPos = endPos;
			this.isConst = isConst;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:LookupTableVisitor.cs

示例3: add_Variable

 public static VariableDeclaration add_Variable(this BlockStatement blockDeclaration, string name, Expression expression, TypeReference typeReference)
 {
     var variableDeclaration = new VariableDeclaration(name, expression) {TypeReference = typeReference};
     var localVariableDeclaration = new LocalVariableDeclaration(variableDeclaration);
     blockDeclaration.append(localVariableDeclaration);
     return variableDeclaration;
 }
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:7,代码来源:VariableDeclaration_ExtensionMethods.cs

示例4: TrackedVisitInvocationExpression

        public override object TrackedVisitInvocationExpression(InvocationExpression invocationExpression, object data)
        {
            if (invocationExpression.TargetObject is FieldReferenceExpression)
            {
                FieldReferenceExpression targetObject = (FieldReferenceExpression) invocationExpression.TargetObject;

                if (targetObject.FieldName == "toArray" || targetObject.FieldName == "ToArray")
                {
                    Expression invoker = targetObject.TargetObject;
                    TypeReference invokerType = GetExpressionType(invoker);
                    if (invokerType != null && collectionTypes.Contains(invokerType.Type))
                    {
                        if (invocationExpression.Arguments.Count == 1)
                        {
                            Expression argExpression = (Expression) invocationExpression.Arguments[0];
                            if (argExpression is ArrayCreateExpression)
                            {
                                InvocationExpression newInvocation = invocationExpression;
                                TypeReference old = ((ArrayCreateExpression) argExpression).CreateType;
                                TypeReference tr = new TypeReference(old.Type);
                                TypeOfExpression tof = new TypeOfExpression(tr);
                                tr.Parent = tof;
                                tof.Parent = newInvocation;
                                newInvocation.Arguments.Clear();
                                newInvocation.Arguments.Add(tof);

                                ReplaceCurrentNode(newInvocation);
                            }
                        }
                    }
                }
            }
            return base.TrackedVisitInvocationExpression(invocationExpression, data);
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:34,代码来源:ToArrayTransformer.cs

示例5: CreateReturnType

 public static IReturnType CreateReturnType(TypeReference reference, NRefactoryResolver resolver)
 {
     return CreateReturnType(reference,
                             resolver.CallingClass, resolver.CallingMember,
                             resolver.CaretLine, resolver.CaretColumn,
                             resolver.ProjectContent, ReturnTypeOptions.None);
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:7,代码来源:TypeVisitor.cs

示例6: TrackedVisitTypeReference

 public override object TrackedVisitTypeReference(TypeReference typeReference, object data)
 {
     string name = typeReference.Type;
     if (name.IndexOf('.') != -1)
         Add(name);
     return base.TrackedVisitTypeReference(typeReference, data);
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:7,代码来源:UsingVisitor.cs

示例7: AddParameter

 /// <summary>
 /// Adds a <see cref="ParameterDeclarationExpression"/> to <see cref="ParametrizedNode.Parameters"/> in a single
 /// call, for convenience.
 /// </summary>
 /// 
 /// <param name="node">
 /// The method or constructor to add the parameter to.
 /// </param>
 /// 
 /// <param name="parameterType">
 /// The <see cref="TypeReference"/> of the parameter to add.
 /// </param>
 /// 
 /// <param name="parameterName">
 /// The name of the parameter to add.
 /// </param>
 /// 
 /// <returns>
 /// The <see cref="ParameterDeclarationExpression"/> instance that was created and added to
 /// <paramref name="node"/>.
 /// </returns>
 public static ParameterDeclarationExpression AddParameter(this ParametrizedNode node,
     TypeReference parameterType, string parameterName)
 {
     var parameter = new ParameterDeclarationExpression(parameterType, parameterName);
     node.Parameters.Add(parameter);
     return parameter;
 }
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:28,代码来源:RefactoryExtensions.cs

示例8: CreateDefaultValueForType

		public static Expression CreateDefaultValueForType(TypeReference type)
		{
			if (type != null && !type.IsArrayType) {
				switch (type.Type) {
					case "System.SByte":
					case "System.Byte":
					case "System.Int16":
					case "System.UInt16":
					case "System.Int32":
					case "System.UInt32":
					case "System.Int64":
					case "System.UInt64":
					case "System.Single":
					case "System.Double":
						return new PrimitiveExpression(0, "0");
					case "System.Char":
						return new PrimitiveExpression('\0', "'\\0'");
					case "System.Object":
					case "System.String":
						return new PrimitiveExpression(null, "null");
					case "System.Boolean":
						return new PrimitiveExpression(false, "false");
					default:
						return new DefaultValueExpression(type);
				}
			} else {
				return new PrimitiveExpression(null, "null");
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:29,代码来源:ExpressionBuilder.cs

示例9: GenerateCode

		public override void GenerateCode(List<AbstractNode> nodes, IList items)
		{
			TypeReference stringReference = new TypeReference("System.String");
			MethodDeclaration method = new MethodDeclaration("ToString",
			                                                 Modifiers.Public | Modifiers.Override,
			                                                 stringReference,
			                                                 null, null);
			method.Body = new BlockStatement();
			Expression target = new FieldReferenceExpression(new TypeReferenceExpression(stringReference),
			                                                 "Format");
			InvocationExpression methodCall = new InvocationExpression(target);
			StringBuilder formatString = new StringBuilder();
			formatString.Append('[');
			formatString.Append(currentClass.Name);
			for (int i = 0; i < items.Count; i++) {
				formatString.Append(' ');
				formatString.Append(codeGen.GetPropertyName(((FieldWrapper)items[i]).Field.Name));
				formatString.Append("={");
				formatString.Append(i);
				formatString.Append('}');
			}
			formatString.Append(']');
			methodCall.Arguments.Add(new PrimitiveExpression(formatString.ToString(), formatString.ToString()));
			foreach (FieldWrapper w in items) {
				methodCall.Arguments.Add(new FieldReferenceExpression(new ThisReferenceExpression(), w.Field.Name));
			}
			method.Body.AddChild(new ReturnStatement(methodCall));
			nodes.Add(method);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:29,代码来源:ToStringCodeGenerator.cs

示例10: HasAssignmentsVisitor

		public HasAssignmentsVisitor(string name, TypeReference type, Location startRange, Location endRange)
		{
			this.name = name;
			this.type = type;
			this.startRange = startRange;
			this.endRange = endRange;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:HasAssignmentsVisitor.cs

示例11: TrackedVisitBlockStatement

 public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data)
 {
     blockStatement.Children.Clear();
     TypeReference notImplmentedException = new TypeReference("System.NotImplementedException");
     ObjectCreateExpression objectCreate = new ObjectCreateExpression(notImplmentedException, new List<Expression>());
     blockStatement.Children.Add(new ThrowStatement(objectCreate));
     return null;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:8,代码来源:StubTransformer.cs

示例12: GetArgumentTypes

 public TypeReference[] GetArgumentTypes(string sig)
 {
     Match m = methodRegex.Match(sig);
     int count = m.Groups["param"].Captures.Count;
     TypeReference[] arguments = new TypeReference[count];
     for (int i = 0; i < count; i++)
         arguments[i] = GetTypeReference(m.Groups["param"].Captures[i].Value);
     return arguments;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:9,代码来源:SignatureParser.cs

示例13: HasReturnValue_HasVoid

        public void HasReturnValue_HasVoid()
        {
            var methodToTest = new MethodDeclaration();
            var retval = new TypeReference("void");
            methodToTest.TypeReference = retval;
            var victim = new TestableMethodTemplate(methodToTest, null);

            Assert.IsFalse(victim.HasReturnValue);
        }
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:9,代码来源:AbstractMethodTemplate.cs

示例14: HasReturnValue_HasOne

        public void HasReturnValue_HasOne()
        {
            var methodToTest = new MethodDeclaration();
            var retval = new TypeReference("string", new[] { 0 });
            methodToTest.TypeReference = retval;
            var victim = new TestableMethodTemplate(methodToTest, null);

            Assert.IsTrue(victim.HasReturnValue);
        }
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:9,代码来源:AbstractMethodTemplate.cs

示例15: IsIn

		bool IsIn(TypeReference type, List<TypeReference> list)
		{
			foreach (TypeReference tr in list) {
				if (tr.Type == type.Type)
					return true;
			}
			
			return false;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:9,代码来源:FindReferenceVisitor.cs


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