• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CodeDom.CodeBinaryOperatorExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CreateInstanceForType

		private static BinaryOperatorType CreateInstanceForType (Type l, CodeBinaryOperatorExpression code, object right, object left)
		{
			if (l == typeof (Int32))
				return new BinaryOperatorTypeInt32 (code, right, left);

			if (l == typeof (Int16))
				return new BinaryOperatorTypeInt16 (code, right, left);

			if (l == typeof (Int64))
				return new BinaryOperatorTypeInt64 (code, right, left);

			if (l == typeof (sbyte))
				return new BinaryOperatorTypeSbyte (code, right, left);

			if (l == typeof (float))
				return new BinaryOperatorTypeFloat (code, right, left);

			if (l == typeof (char))
				return new BinaryOperatorTypeChar (code, right, left);

			if (l == typeof (byte))
				return new BinaryOperatorTypeByte (code, right, left);

			throw new InvalidOperationException ("Type not suported as binary operator");
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:25,代码来源:RuleExpressionBinaryOperatorResolver.cs


示例2: AddCallbackImplementation

 internal static void AddCallbackImplementation(CodeTypeDeclaration codeClass, string callbackName, string handlerName, string handlerArgs, bool methodHasOutParameters)
 {
     CodeFlags[] parameterFlags = new CodeFlags[1];
     CodeMemberMethod method = AddMethod(codeClass, callbackName, parameterFlags, new string[] { typeof(object).FullName }, new string[] { "arg" }, typeof(void).FullName, null, (CodeFlags) 0);
     CodeEventReferenceExpression left = new CodeEventReferenceExpression(new CodeThisReferenceExpression(), handlerName);
     CodeBinaryOperatorExpression condition = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
     CodeStatement[] trueStatements = new CodeStatement[2];
     trueStatements[0] = new CodeVariableDeclarationStatement(typeof(InvokeCompletedEventArgs), "invokeArgs", new CodeCastExpression(typeof(InvokeCompletedEventArgs), new CodeArgumentReferenceExpression("arg")));
     CodeVariableReferenceExpression targetObject = new CodeVariableReferenceExpression("invokeArgs");
     CodeObjectCreateExpression expression4 = new CodeObjectCreateExpression();
     if (methodHasOutParameters)
     {
         expression4.CreateType = new CodeTypeReference(handlerArgs);
         expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "Results"));
     }
     else
     {
         expression4.CreateType = new CodeTypeReference(typeof(AsyncCompletedEventArgs));
     }
     expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "Error"));
     expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "Cancelled"));
     expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "UserState"));
     trueStatements[1] = new CodeExpressionStatement(new CodeDelegateInvokeExpression(new CodeEventReferenceExpression(new CodeThisReferenceExpression(), handlerName), new CodeExpression[] { new CodeThisReferenceExpression(), expression4 }));
     method.Statements.Add(new CodeConditionStatement(condition, trueStatements, new CodeStatement[0]));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:WebCodeGenerator.cs


示例3: GenerateSetMappedPropertyCode

        protected CodeStatementCollection GenerateSetMappedPropertyCode(CodeExpression targetObj, CodeExpression value)
        {
            CodeStatementCollection statements = new CodeStatementCollection();

            CodePropertyReferenceExpression property = new CodePropertyReferenceExpression(targetObj, MappedProperty.Name);

            if (_mappedProperty.PropertyType.IsArray)
            {
                statements.Add(new CodeAssignStatement(
                    new CodeIndexerExpression(property, new CodePrimitiveExpression(_index)), value));
                return statements;
            }

            if (IsCollection(_mappedProperty.PropertyType))
            {
                CodeBinaryOperatorExpression isNull =
                    new CodeBinaryOperatorExpression(property, CodeBinaryOperatorType.ValueEquality, new CodeSnippetExpression("null"));
                CodeAssignStatement create = new CodeAssignStatement(property, new CodeObjectCreateExpression(_mappedProperty.PropertyType));

                statements.Add(new CodeConditionStatement(isNull, create));
                statements.Add(new CodeMethodInvokeExpression(property, "Add", value));
                return statements;
            }

            statements.Add(new CodeAssignStatement(property, value));
            return statements;
        }
开发者ID:anddudek,项目名称:anjlab.fx,代码行数:27,代码来源:MapElement.cs


示例4: AddAsyncMethod

 internal static CodeMemberMethod AddAsyncMethod(CodeTypeDeclaration codeClass, string methodName, string[] parameterTypeNames, string[] parameterNames, string callbackMember, string callbackName, string userState)
 {
     CodeMemberMethod method = AddMethod(codeClass, methodName, new CodeFlags[parameterNames.Length], parameterTypeNames, parameterNames, typeof(void).FullName, null, CodeFlags.IsPublic);
     method.Comments.Add(new CodeCommentStatement(Res.GetString("CodeRemarks"), true));
     CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), methodName, new CodeExpression[0]);
     for (int i = 0; i < parameterNames.Length; i++)
     {
         expression.Parameters.Add(new CodeArgumentReferenceExpression(parameterNames[i]));
     }
     expression.Parameters.Add(new CodePrimitiveExpression(null));
     method.Statements.Add(expression);
     method = AddMethod(codeClass, methodName, new CodeFlags[parameterNames.Length], parameterTypeNames, parameterNames, typeof(void).FullName, null, CodeFlags.IsPublic);
     method.Comments.Add(new CodeCommentStatement(Res.GetString("CodeRemarks"), true));
     method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), userState));
     CodeFieldReferenceExpression left = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), callbackMember);
     CodeBinaryOperatorExpression condition = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(null));
     CodeDelegateCreateExpression right = new CodeDelegateCreateExpression {
         DelegateType = new CodeTypeReference(typeof(SendOrPostCallback)),
         TargetObject = new CodeThisReferenceExpression(),
         MethodName = callbackName
     };
     CodeStatement[] trueStatements = new CodeStatement[] { new CodeAssignStatement(left, right) };
     method.Statements.Add(new CodeConditionStatement(condition, trueStatements, new CodeStatement[0]));
     return method;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:WebCodeGenerator.cs


示例5: TypeReferenceExpressionTest

		public void TypeReferenceExpressionTest ()
		{
			StringBuilder sb = new StringBuilder();

			using (StringWriter sw = new StringWriter (sb)) {
				CodeThisReferenceExpression thisRef = new CodeThisReferenceExpression();
				CodeFieldReferenceExpression parentField = new CodeFieldReferenceExpression();
				parentField.TargetObject = thisRef;
				parentField.FieldName = "Parent";

				CodeBinaryOperatorExpression expression = new CodeBinaryOperatorExpression(
					parentField,
					CodeBinaryOperatorType.IdentityInequality,
					new CodePrimitiveExpression(null));

				Assert.AreEqual ("(Not (Me.Parent) Is Nothing)", Generate (expression, sw), "#1");
				sw.Close ();
			}

			sb = new StringBuilder();
			using (StringWriter sw = new StringWriter (sb)) {
				CodeThisReferenceExpression thisRef = new CodeThisReferenceExpression();
				CodeFieldReferenceExpression parentField = new CodeFieldReferenceExpression();
				parentField.TargetObject = thisRef;
				parentField.FieldName = "Parent";

				CodeBinaryOperatorExpression expression = new CodeBinaryOperatorExpression(
					new CodePrimitiveExpression(null),
					CodeBinaryOperatorType.IdentityInequality,
					parentField);

				Assert.AreEqual ("(Not (Me.Parent) Is Nothing)", Generate (expression, sw), "#2");
				sw.Close ();
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:35,代码来源:CodeGeneratorFromBinaryOperatorTest.cs


示例6: GenerateBinaryOperatorExpression

 protected virtual void GenerateBinaryOperatorExpression(CodeBinaryOperatorExpression e)
 {
     bool flag = false;
     this.Output.Write("(");
     this.GenerateExpression(e.Left);
     this.Output.Write(" ");
     if ((e.Left is CodeBinaryOperatorExpression) || (e.Right is CodeBinaryOperatorExpression))
     {
         if (!this.inNestedBinary)
         {
             flag = true;
             this.inNestedBinary = true;
             this.Indent += 3;
         }
         this.ContinueOnNewLine("");
     }
     this.OutputOperator(e.Operator);
     this.Output.Write(" ");
     this.GenerateExpression(e.Right);
     this.Output.Write(")");
     if (flag)
     {
         this.Indent -= 3;
         this.inNestedBinary = false;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:CodeGenerator.cs


示例7: Serialize

		public override object Serialize (IDesignerSerializationManager manager, object value)
		{
			if (manager == null)
				throw new ArgumentNullException ("manager");
			if (value == null)
				throw new ArgumentNullException ("value");

			Enum[] enums = null;
			TypeConverter converter = TypeDescriptor.GetConverter (value);
			if (converter.CanConvertTo (typeof (Enum[])))
				enums = (Enum[]) converter.ConvertTo (value, typeof (Enum[]));
			else
				enums = new Enum[] { (Enum) value };
			CodeExpression left = null;
			CodeExpression right = null;
			foreach (Enum e in enums) {
				right = GetEnumExpression (e);
				if (left == null) // just the first time
					left = right;
				else
					left = new CodeBinaryOperatorExpression (left, CodeBinaryOperatorType.BitwiseOr, right);
			}

			return left;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:25,代码来源:EnumCodeDomSerializer.cs


示例8: CreateWithApiKey

        /// <summary>
        /// if (string.IsNullOrEmpty(APIKey) == false)
        ///    request = request.WithAPIKey(APIKey)
        /// </summary>
        /// <returns></returns>
        internal CodeConditionStatement CreateWithApiKey()
        {
            // !string.IsNullOrEmpty(Key)
            var condition = new CodeBinaryOperatorExpression(
                new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(string)), "IsNullOrEmpty",
                        new CodeVariableReferenceExpression(ApiKeyServiceDecorator.PropertyName)),
                CodeBinaryOperatorType.ValueEquality,
                new CodePrimitiveExpression(false));

            //var condition =
                //new CodeSnippetExpression("!string.IsNullOrEmpty(" + ApiKeyServiceDecorator.PropertyName + ")");

            // if (...) {
            var block = new CodeConditionStatement(condition);

            // request = request.WithKey(APIKey)
            var getProperty = new CodePropertyReferenceExpression(
                new CodeThisReferenceExpression(), ApiKeyServiceDecorator.PropertyName);
            var request = new CodeMethodInvokeExpression(
                new CodeVariableReferenceExpression("request"), "WithKey", getProperty);

            var trueCase = new CodeAssignStatement(new CodeVariableReferenceExpression("request"), request);

            // }
            block.TrueStatements.Add(trueCase);

            return block;
        }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:33,代码来源:CreateRequestMethodServiceDecorator.cs


示例9: BuildConditionalExpression

 protected virtual CodeExpression BuildConditionalExpression(
     conditionalContainer container, ItemsChoiceType choiceType)
 {
     //grab the children
     List<CodeExpression> children = new List<CodeExpression>();
     for (int i = 0; i < container.Items.Length; i++)
     {
         if (container.Items[i] is conditionalContainer)
         {
             children.Add(BuildConditionalExpression((conditionalContainer)container.Items[i],
                 container.ItemsElementName[i]));
         }
         else if (container.Items[i] is actionEquals)
         {
             children.Add(BuildConditionalExpression((actionEquals)container.Items[i]));
         }
         else if (container.Items[i] is valueEquals)
         {
             children.Add(BuildConditionalExpression((valueEquals)container.Items[i],
                 container.ItemsElementName[i]));
         }
         else
         {
             throw new GatException("Unrecognized conditional item type: " +
                 container.Items[i].GetType());
         }
     }
     //get the full expression
     CodeExpression expr = null;
     if (choiceType == ItemsChoiceType.none)
     {
         expr = new CodeBinaryOperatorExpression(children[0],
             CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(false));
         for (int i = 1; i < children.Count; i++)
         {
             expr = new CodeBinaryOperatorExpression(expr,
                 CodeBinaryOperatorType.BooleanAnd,
                 new CodeBinaryOperatorExpression(children[i],
                     CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(false)));
         }
     }
     else if (choiceType == ItemsChoiceType.all ||
         choiceType == ItemsChoiceType.any)
     {
         CodeBinaryOperatorType opType = choiceType == ItemsChoiceType.all ?
             CodeBinaryOperatorType.BooleanAnd : CodeBinaryOperatorType.BooleanOr;
         expr = children[0];
         for (int i = 1; i < children.Count; i++)
         {
             expr = new CodeBinaryOperatorExpression(expr,
                 CodeBinaryOperatorType.BooleanOr, children[i]);
         }
     }
     else
     {
         throw new GatException("Unrecognized choice type: " + choiceType);
     }
     return expr;
 }
开发者ID:cretz,项目名称:gat-cdc,代码行数:59,代码来源:CodeBuilder.cs


示例10: AddDisposalOfMember

        public static void AddDisposalOfMember(CodeMemberMethod disposeMethod, string memberName)
        {
            CodeBinaryOperatorExpression isnull = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression(memberName), CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
            CodeExpressionStatement callDispose = new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeVariableReferenceExpression(memberName), "Dispose"));

            //add dispose code
            disposeMethod.Statements.Add(new CodeConditionStatement(isnull, callDispose));
        }
开发者ID:RadioSpace,项目名称:Tamarack,代码行数:8,代码来源:ClassHelper.cs


示例11: BasePlusN

	static CodeExpression BasePlusN (int n)
	{
	    CodeBinaryOperatorExpression idexpr = new CodeBinaryOperatorExpression ();
	    idexpr.Left = new CodeVariableReferenceExpression ("base_total");
	    idexpr.Operator = CodeBinaryOperatorType.Add;
	    idexpr.Right = new CodePrimitiveExpression (n);
	    return idexpr;
	}
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:ResultBuilder.cs


示例12: BeginLoop

        public void BeginLoop()
        {
            var cond = new CodeBinaryOperatorExpression(_expr_memory_pointer, CodeBinaryOperatorType.IdentityInequality, _expr_value_zero);
            var loop = new CodeIterationStatement(new CodeSnippetStatement(), cond, new CodeSnippetStatement());
            _nest.Peek().Add(loop);
            _nest.Push(loop.Statements);

            IncrementInstructionPointer();
        }
开发者ID:nk0t,项目名称:BrainBreak,代码行数:9,代码来源:BBCodeGenerator.cs


示例13: Clone

 public static CodeBinaryOperatorExpression Clone(this CodeBinaryOperatorExpression expression)
 {
     if (expression == null) return null;
     CodeBinaryOperatorExpression e = new CodeBinaryOperatorExpression();
     e.Left = expression.Left.Clone();
     e.Operator = expression.Operator;
     e.Right = expression.Right.Clone();
     e.UserData.AddRange(expression.UserData);
     return e;
 }
开发者ID:svejdo1,项目名称:CodeDomExtensions,代码行数:10,代码来源:CodeBinaryOperatorExpressionExtensions.cs


示例14: Constructor0_Deny_Unrestricted

		public void Constructor0_Deny_Unrestricted ()
		{
			CodeBinaryOperatorExpression cboe = new CodeBinaryOperatorExpression ();
			Assert.IsNull (cboe.Left, "Left");
			cboe.Left = new CodeExpression ();
			Assert.IsNull (cboe.Right, "Right");
			cboe.Right = new CodeExpression ();
			Assert.AreEqual (CodeBinaryOperatorType.Add, cboe.Operator, "Operator");
			cboe.Operator = CodeBinaryOperatorType.Divide;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:CodeBinaryOperatorExpressionCas.cs


示例15: ThrowWhenArgumentMatchesExpression

 public static void ThrowWhenArgumentMatchesExpression(this CodeStatementCollection self, string argument, CodeBinaryOperatorExpression expression)
 {
     self.Add (
             new CodeConditionStatement (
                 expression,
                 new CodeThrowExceptionStatement (
                     new CodeObjectCreateExpression (
                         new CodeTypeReference ("System.ArgumentNullException"),
                         new CodePrimitiveExpression (argument)))));
 }
开发者ID:rikkus,项目名称:cadenza,代码行数:10,代码来源:CodeStatementCollectionCoda.cs


示例16: TypescriptBinaryOperatorExpression

 public TypescriptBinaryOperatorExpression(
     IExpressionFactory expressionFactory,
     CodeBinaryOperatorExpression codeExpression, 
     CodeGeneratorOptions options)
 {
     _expressionFactory = expressionFactory;
     _codeExpression = codeExpression;
     _options = options;
     System.Diagnostics.Debug.WriteLine("TypescriptBinaryOperatorExpression Created");
 }
开发者ID:s2quake,项目名称:TypescriptCodeDom,代码行数:10,代码来源:TypescriptBinaryOperatorExpression.cs


示例17: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeExpression left = new CodeExpression ();
			CodeExpression right = new CodeExpression ();
			CodeBinaryOperatorExpression cboe = new CodeBinaryOperatorExpression (left, CodeBinaryOperatorType.Subtract, right);
			Assert.AreSame (left, cboe.Left, "Left");
			cboe.Left = new CodeExpression ();
			Assert.AreSame (right, cboe.Right, "Right");
			cboe.Right = new CodeExpression ();
			Assert.AreEqual (CodeBinaryOperatorType.Subtract, cboe.Operator, "Operator");
			cboe.Operator = CodeBinaryOperatorType.Multiply;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:CodeBinaryOperatorExpressionCas.cs


示例18: GenerateConstructorStatements

 internal static void GenerateConstructorStatements(CodeConstructor ctor, string url, string appSettingUrlKey, string appSettingBaseUrl, bool soap11)
 {
     bool flag = (url != null) && (url.Length > 0);
     bool flag2 = (appSettingUrlKey != null) && (appSettingUrlKey.Length > 0);
     CodeAssignStatement statement = null;
     if (flag || flag2)
     {
         CodeExpression expression;
         CodePropertyReferenceExpression left = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Url");
         if (flag)
         {
             expression = new CodePrimitiveExpression(url);
             statement = new CodeAssignStatement(left, expression);
         }
         if (flag && !flag2)
         {
             ctor.Statements.Add(statement);
         }
         else if (flag2)
         {
             CodeVariableReferenceExpression expression3 = new CodeVariableReferenceExpression("urlSetting");
             CodeTypeReferenceExpression targetObject = new CodeTypeReferenceExpression(typeof(ConfigurationManager));
             CodePropertyReferenceExpression expression5 = new CodePropertyReferenceExpression(targetObject, "AppSettings");
             expression = new CodeIndexerExpression(expression5, new CodeExpression[] { new CodePrimitiveExpression(appSettingUrlKey) });
             ctor.Statements.Add(new CodeVariableDeclarationStatement(typeof(string), "urlSetting", expression));
             if ((appSettingBaseUrl == null) || (appSettingBaseUrl.Length == 0))
             {
                 expression = expression3;
             }
             else
             {
                 if ((url == null) || (url.Length == 0))
                 {
                     throw new ArgumentException(Res.GetString("IfAppSettingBaseUrlArgumentIsSpecifiedThen0"));
                 }
                 string str = new Uri(appSettingBaseUrl).MakeRelative(new Uri(url));
                 CodeExpression[] parameters = new CodeExpression[] { expression3, new CodePrimitiveExpression(str) };
                 expression = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(string)), "Concat", parameters);
             }
             CodeStatement[] trueStatements = new CodeStatement[] { new CodeAssignStatement(left, expression) };
             CodeBinaryOperatorExpression condition = new CodeBinaryOperatorExpression(expression3, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
             if (flag)
             {
                 ctor.Statements.Add(new CodeConditionStatement(condition, trueStatements, new CodeStatement[] { statement }));
             }
             else
             {
                 ctor.Statements.Add(new CodeConditionStatement(condition, trueStatements));
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:ProtocolImporterUtil.cs


示例19: FormatEnumValue

        /// <summary>
        /// Formats an enum value to a code expression.
        /// </summary>
        /// <param name="value">The value to be formatted</param>
        /// <returns>A code expression representing one single enumeration value, or a collection of two or more values concatenated with the <c>Or</c> operator.</returns>
        public static CodeExpression FormatEnumValue(Enum value)
        {
            Type valueType = value.GetType();
            bool isFlags = valueType.HasCustomAttribute(typeof(FlagsAttribute));
            
            long enumValue = Convert.ToInt64(value);

            if (isFlags && enumValue > 0)
            {
                CodeExpression returnExpression = null;

                foreach (FieldInfo field in valueType.GetFields())
                {
                    if (field.IsLiteral)
                    {
                        long fieldValue = Convert.ToInt64(field.GetValue(null));

                        if ((enumValue & fieldValue) == fieldValue)
                        {
                            CodeFieldReferenceExpression fieldExpression = new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(valueType), field.Name);

                            if (returnExpression == null)
                                returnExpression = fieldExpression;
                            else
                                returnExpression = new CodeBinaryOperatorExpression(returnExpression, CodeBinaryOperatorType.BitwiseOr, fieldExpression);

                            enumValue ^= fieldValue;
                        }
                    }
                }

                if (enumValue == 0)
                    return returnExpression;
                else
                    return new CodeCastExpression(valueType, new CodePrimitiveExpression(Convert.ToInt64(value)));
            }
            else
            {
                foreach (FieldInfo field in valueType.GetFields())
                {
                    if (field.IsLiteral)
                    {
                        long fieldValue = Convert.ToInt64(field.GetValue(null));
                        if (fieldValue == enumValue)
                            return new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(valueType), field.Name);
                    }
                }
            }

            return new CodeCastExpression(valueType, new CodePrimitiveExpression(Convert.ToInt64(value)));
        }
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:56,代码来源:CodeDomTypeFormatter.cs


示例20: MergeAssignmentAt

        private void MergeAssignmentAt(List<object> parts, int i)
        {
            int x = i - 1, y = i + 1;
            bool right = y < parts.Count;

            if (parts[i] as CodeBinaryOperatorType? != CodeBinaryOperatorType.Assign)
                return;

            if (i > 0 && IsJsonObject(parts[x]))
            {
                MergeObjectAssignmentAt(parts, i);
                return;
            }
            else if (i > 0 && IsArrayExtension(parts[x]))
            {
                var extend = (CodeMethodInvokeExpression) parts[x];
                extend.Parameters.Add(right ? VarMixedExpr(parts[y]) : new CodePrimitiveExpression(null));
                if (right)
                    parts.RemoveAt(y);
                parts.RemoveAt(i);
                return;
            }

            var assign = new CodeBinaryOperatorExpression
            {
                Operator = CodeBinaryOperatorType.Assign
            };
            parts[i] = assign;

            if (assign.Left != null)
                return;

            if (parts[x] is CodeBinaryOperatorExpression)
            {
                var binary = (CodeBinaryOperatorExpression) parts[x];
                assign.Left = (CodeArrayIndexerExpression) binary.Left;
            }
            else if (IsVarReference(parts[x]))
                assign.Left = (CodeArrayIndexerExpression) parts[x];
            else if (parts[x] is CodePropertyReferenceExpression)
                assign.Left = (CodePropertyReferenceExpression) parts[x];
            else
                assign.Left = VarId((CodeExpression) parts[x]);
            assign.Right = right ? VarMixedExpr(parts[y]) : new CodePrimitiveExpression(null);

            parts[x] = assign;

            if (right)
                parts.RemoveAt(y);
            parts.RemoveAt(i);
        }
开发者ID:Tyelpion,项目名称:IronAHK,代码行数:51,代码来源:Assignments.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeDom.CodeCastExpression类代码示例发布时间:2022-05-26
下一篇:
C# CodeDom.CodeAttributeDeclarationCollection类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap