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


C# PrimitiveExpression类代码示例

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


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

示例1: GenerateCode

		protected override string GenerateCode(ITypeDefinition currentClass)
		{
//			string[] fields = listBox.SelectedItems.OfType<PropertyOrFieldWrapper>().Select(f2 => f2.MemberName).ToArray();
			string[] fields = parameterList.Where(f => f.IsIncluded).Select(f2 => f2.MemberName).ToArray();
			
			PrimitiveExpression formatString = new PrimitiveExpression(GenerateFormatString(currentClass, editor.Language.CodeGenerator, fields));
			List<Expression> param = new List<Expression>() { formatString };
			ReturnStatement ret = new ReturnStatement(new InvocationExpression(
				new MemberReferenceExpression(new TypeReferenceExpression(ConvertType(KnownTypeCode.String)), "Format"),
				param.Concat(fields.Select(f => new IdentifierExpression(f))).ToList()
			));
			
			if (baseCallNode != null) {
				MethodDeclaration insertedOverrideMethod = refactoringContext.GetNode().PrevSibling as MethodDeclaration;
				if (insertedOverrideMethod == null) {
					// We are not inside of a method declaration
					return null;
				}
				
				using (Script script = refactoringContext.StartScript()) {
					NewLineNode nextNewLineNode = insertedOverrideMethod.NextSibling as NewLineNode;
					
					// Find base method call and replace it by return statement
					script.AddTo(insertedOverrideMethod.Body, ret);
					AppendNewLine(script, insertedOverrideMethod, nextNewLineNode);
				}
			}
			
			return null;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:30,代码来源:OverrideToStringMethodDialog.xaml.cs

示例2: VisitPrimitiveExpression

		public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			if (primitiveExpression.Value is bool)
				return (bool)primitiveExpression.Value ? SymbolDefined : null;
			else
				return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:ConditionalCompilation.cs

示例3: PrimitiveEmitter

 internal PrimitiveEmitter(PrimitiveExpression primitiveExpression, ILGenerator ilGenerator, IOpCodeIndexer instructionsIndexer)
     : base(ilGenerator, instructionsIndexer) {
     
     PrimitiveExpression = primitiveExpression;
     Type = PrimitiveExpression.Value.GetType();
     PrimitiveInstruction = InstructionsIndexer.GetInstruction(PrimitiveExpression);
 }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:7,代码来源:PrimitiveEmitter.cs

示例4: VisitPrimitiveExpression

 public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
 {
     if (primitiveExpression.LiteralValue.Contains("\\"))
     {
         UnlockWith(primitiveExpression);
     }
     return base.VisitPrimitiveExpression(primitiveExpression, data);
 }
开发者ID:vlad2135,项目名称:strokes,代码行数:8,代码来源:DeclareEscapeChar.cs

示例5: VisitPrimitiveExpression

 public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
 {
     if(primitiveExpression.LiteralValue.StartsWith("'\\x"))
     {
         UnlockWith(primitiveExpression);
     }
     return base.VisitPrimitiveExpression(primitiveExpression, data);
 }
开发者ID:clausjoergensen,项目名称:strokes,代码行数:8,代码来源:DeclareHexShorthandChar.cs

示例6: Visit

 public override object Visit(PrimitiveExpression primitiveExpression, object data)
 {
     if (primitiveExpression.Value != null) {
     //				Console.WriteLine("Visiting " + primitiveExpression.Value);
         return new ReturnType(primitiveExpression.Value.GetType().FullName);
     }
     return null;
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:8,代码来源:TypeVisitor.cs

示例7: AddFormatCallToInvocation

		void AddFormatCallToInvocation (RefactoringContext context, Script script, PrimitiveExpression pExpr, InvocationExpression invocation)
		{
			var newInvocation = (InvocationExpression)invocation.Clone ();
			
			newInvocation.Arguments.First ().ReplaceWith (CreateFormatString (context, pExpr, newInvocation.Arguments.Count () - 1));
			newInvocation.Arguments.Add (CreateFormatArgument (context));
			
			script.Replace (invocation, newInvocation);
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:9,代码来源:IntroduceFormatItemAction.cs

示例8: GetActions

			IEnumerable<CodeAction> GetActions(ObjectCreateExpression objectCreateExpression,
			                                   PrimitiveExpression firstParam, PrimitiveExpression secondParam)
			{
				yield return new CodeAction(context.TranslateString("Swap parameters"), script =>  {
					var newOCE = objectCreateExpression.Clone() as ObjectCreateExpression;
					newOCE.Arguments.Clear();
					newOCE.Arguments.Add(secondParam.Clone());
					newOCE.Arguments.Add(firstParam.Clone());
					script.Replace(objectCreateExpression, newOCE);
				});
			}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:11,代码来源:IncorrectExceptionParameterOrderingIssue.cs

示例9: FindMatching

        private IEnumerable<PrimitiveExpression> FindMatching(LanguageElement scope, PrimitiveExpression primitiveExpression)
        {
            if (scope == null || primitiveExpression == null)
                yield break;

            ElementEnumerable primitivesEnumerable = new ElementEnumerable(scope, new PrimitiveFilter(primitiveExpression), true);
            if (primitivesEnumerable == null)
                yield break;

            foreach (object element in primitivesEnumerable)
                if (element is PrimitiveExpression)
                    yield return (PrimitiveExpression)element;
        }
开发者ID:modulexcite,项目名称:CR_PrimitiveTab,代码行数:13,代码来源:PlugIn1.cs

示例10: GetPrimitiveExpressionAndProperty

		/// <summary>
		/// Gets a PrimitiveExpression and a parenting property provided the PrimitiveExpression is of type System.String and the caret is inside that string.
		/// Returns true if both values are found and the contents of the string matches the name of the property.
		/// </summary>
		private static bool GetPrimitiveExpressionAndProperty(LanguageElement element, out PrimitiveExpression primitiveExpression, out Property property)
		{
			property = null;
			primitiveExpression = element as PrimitiveExpression;
			if (primitiveExpression == null)
				return false;

			if (primitiveExpression.ExpressionTypeName != "System.String")
				return false;

			property = primitiveExpression.GetParentProperty();
			if (property == null)
				return false;

			return property.Name == (string)primitiveExpression.PrimitiveValue;
		}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:20,代码来源:PlugIn1.cs

示例11: SortFormatTokens_CheckAvailability

 private void SortFormatTokens_CheckAvailability(Object sender, CheckContentAvailabilityEventArgs ea)
 {
     _PrimitiveString = (CodeRush.Source.Active as PrimitiveExpression);
     if (_PrimitiveString == null)
         return;
     if (_PrimitiveString.PrimitiveType != PrimitiveType.String)
         return;
     LanguageElement Parent = _PrimitiveString.Parent;
     if (Parent == null)
         return;
     MethodCallExpression MCE = (Parent as MethodCallExpression);
     if (MCE == null)
         return;
     if (MCE.Name != "Format")
         return;
     _tokens = new TokenGatherer().GetTokens(_PrimitiveString.Name);
     if (!SequenceRenumberer.RequiresRenumbering(from item in _tokens select item.Index))
         return;
     ea.Available = true;
 }
开发者ID:RoryBecker,项目名称:CR_SortFormatTokens,代码行数:20,代码来源:PlugIn1.cs

示例12: AddArgument

		static void AddArgument(InvocationExpression newNode, IParameter parameterToAdd, bool isNextInSequence)
		{
			Expression defaultValue;
			if (parameterToAdd.ConstantValue == null) {
				defaultValue = new NullReferenceExpression();
			}
			else {
				defaultValue = new PrimitiveExpression(parameterToAdd.ConstantValue);
			}
			Expression newArgument;
			if (newNode.Arguments.Any(argument => argument is NamedExpression) || !isNextInSequence) {
				newArgument = new NamedArgumentExpression(parameterToAdd.Name, defaultValue);
			}
			else {
				newArgument = defaultValue;
			}
			newNode.Arguments.Add(newArgument);
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:18,代码来源:AddOptionalParameterToInvocationAction.cs

示例13: BuildOperatorArgumentsList

        private void BuildOperatorArgumentsList(IList<Expression> arguments, IMethod method)
        {
            if (method != null)
            {
                var parameters = method.Parameters;

                Expression[] result = new Expression[parameters.Count];
                string[] names = new string[result.Length];

                int i = 0;
                foreach (var arg in arguments)
                {
                    if (arg is NamedArgumentExpression)
                    {
                        NamedArgumentExpression namedArg = (NamedArgumentExpression)arg;
                        var namedParam = parameters.First(p => p.Name == namedArg.Name);
                        var index = parameters.IndexOf(namedParam);

                        result[index] = namedArg.Expression;
                        names[index] = namedArg.Name;
                    }
                    else
                    {
                        if (i >= result.Length)
                        {
                            var list = result.ToList();
                            list.AddRange(new Expression[arguments.Count - i]);

                            var strList = names.ToList();
                            strList.AddRange(new string[arguments.Count - i]);

                            result = list.ToArray();
                            names = strList.ToArray();
                        }

                        result[i] = arg;
                        names[i] = parameters[i].Name;
                    }

                    i++;
                }

                for (i = 0; i < result.Length; i++)
                {
                    if (result[i] == null)
                    {
                        var p = parameters[i];

                        if (p.Type.Kind == TypeKind.Enum)
                        {
                            result[i] = new PrimitiveExpression(Helpers.GetEnumValue(this.Emitter, p.Type, p.ConstantValue));
                        }
                        else
                        {
                            result[i] = new PrimitiveExpression(p.ConstantValue);
                        }
                        names[i] = parameters[i].Name;
                    }
                }

                this.ArgumentsExpressions = result;
                this.ArgumentsNames = names;
                this.NamedExpressions = this.CreateNamedExpressions(names, result);
            }
            else
            {
                this.ArgumentsExpressions = arguments.ToArray();
            }
        }
开发者ID:RashmiPankaj,项目名称:Bridge,代码行数:69,代码来源:ArgumentsInfo.cs

示例14: BuildArgumentsList

        private void BuildArgumentsList(IList<Expression> arguments)
        {
            Expression paramsArg = null;
            string paramArgName = null;
            var resolveResult = this.ResolveResult;

            if (resolveResult != null)
            {
                var parameters = resolveResult.Member.Parameters;
                var resolvedMethod = resolveResult.Member as IMethod;
                var invocationResult = resolveResult as CSharpInvocationResolveResult;
                int shift = 0;

                if (resolvedMethod != null && invocationResult != null &&
                    resolvedMethod.IsExtensionMethod && invocationResult.IsExtensionMethodInvocation)
                {
                    shift = 1;
                    this.ThisName = resolvedMethod.Parameters[0].Name;
                    this.IsExtensionMethod = true;
                }

                Expression[] result = new Expression[parameters.Count - shift];
                string[] names = new string[result.Length];

                int i = 0;
                foreach (var arg in arguments)
                {
                    if (arg is NamedArgumentExpression)
                    {
                        NamedArgumentExpression namedArg = (NamedArgumentExpression)arg;
                        var namedParam = parameters.First(p => p.Name == namedArg.Name);
                        var index = parameters.IndexOf(namedParam);

                        result[index] = namedArg.Expression;
                        names[index] = namedArg.Name;
                    }
                    else
                    {
                        if (paramsArg == null && (parameters.Count > (i + shift)) && parameters[i + shift].IsParams)
                        {
                            if (resolvedMethod.DeclaringTypeDefinition == null || !this.Emitter.Validator.IsIgnoreType(resolvedMethod.DeclaringTypeDefinition))
                            {
                                paramsArg = arg;
                            }

                            paramArgName = parameters[i + shift].Name;
                        }

                        if (i >= result.Length)
                        {
                            var list = result.ToList();
                            list.AddRange(new Expression[arguments.Count - i]);

                            var strList = names.ToList();
                            strList.AddRange(new string[arguments.Count - i]);

                            result = list.ToArray();
                            names = strList.ToArray();
                        }

                        result[i] = arg;
                        names[i] = (i + shift) < parameters.Count ? parameters[i + shift].Name : paramArgName;
                    }

                    i++;
                }

                for (i = 0; i < result.Length; i++)
                {
                    if (result[i] == null)
                    {
                        var p = parameters[i + shift];

                        if (p.Type.Kind == TypeKind.Enum)
                        {
                            result[i] = new PrimitiveExpression(Helpers.GetEnumValue(this.Emitter, p.Type, p.ConstantValue));
                        }
                        else
                        {
                            result[i] = new PrimitiveExpression(p.ConstantValue);
                        }
                        names[i] = parameters[i + shift].Name;
                    }
                }

                this.ArgumentsExpressions = result;
                this.ArgumentsNames = names;
                this.ParamsExpression = paramsArg;
                this.NamedExpressions = this.CreateNamedExpressions(names, result);
            }
            else
            {
                this.ArgumentsExpressions = arguments.ToArray();
            }
        }
开发者ID:RashmiPankaj,项目名称:Bridge,代码行数:95,代码来源:ArgumentsInfo.cs

示例15: VisitPrimitiveExpression

		public void VisitPrimitiveExpression(PrimitiveExpression primitiveExpression)
		{
			StartNode(primitiveExpression);
			writer.WritePrimitiveValue(primitiveExpression.Value, primitiveExpression.UnsafeLiteralValue);
			EndNode(primitiveExpression);
		}
开发者ID:jeremiahyan,项目名称:ILSpy,代码行数:6,代码来源:CSharpOutputVisitor.cs


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