當前位置: 首頁>>代碼示例>>C#>>正文


C# CodeGeneration.CodeExpression類代碼示例

本文整理匯總了C#中Mono.CodeGeneration.CodeExpression的典型用法代碼示例。如果您正苦於以下問題:C# CodeExpression類的具體用法?C# CodeExpression怎麽用?C# CodeExpression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CodeExpression類屬於Mono.CodeGeneration命名空間,在下文中一共展示了CodeExpression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CodeNewArray

		public CodeNewArray (Type type, CodeExpression size)
		{
			this.elemType = type;
			this.size = size;
			if (size.GetResultType () != typeof(int))
				throw new InvalidOperationException ("Array size must be an Int32");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:7,代碼來源:CodeNewArray.cs

示例2: CodeFieldReference

		public CodeFieldReference (CodeExpression target, FieldInfo field)
		{
			if (field.IsStatic)
				throw new InvalidOperationException ("Static member '" + field.Name + "' cannot be accessed with an instance reference.");
			this.target = target;
			this.field = field;		
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:7,代碼來源:CodeFieldReference.cs

示例3: GetParameterTypes

		Type[] GetParameterTypes (CodeExpression[] parameters)
		{
			Type[] ts = new Type [parameters.Length];
			for (int n=0; n<ts.Length; n++)
				ts [n] = parameters[n].GetResultType ();
			return ts;
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:7,代碼來源:CodeMethodCall.cs

示例4: CodeSubstractOne

		public CodeSubstractOne (CodeExpression exp)
		{
			this.exp = exp;
			if (!exp.IsNumber) {
				decMet = exp.GetResultType ().GetMethod ("op_Decrement");
				if (decMet == null)
					throw new InvalidOperationException ("Operator '--' cannot be applied to operand of type '" + exp.GetResultType().FullName + "'");
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:9,代碼來源:CodeDecrement.cs

示例5: CodeArrayItem

		public CodeArrayItem (CodeExpression array, CodeExpression index)
		{
			if (array == null)
				throw new ArgumentNullException ("array");
			if (index == null)
				throw new ArgumentNullException ("index");
			this.array = array;
			this.index = index;		
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:9,代碼來源:CodeArrayItem.cs

示例6: CodeFor

		public CodeFor (CodeExpression initExp, CodeExpression conditionExp, CodeExpression nextExp)
		{
			this.initExp = initExp;	
			this.conditionExp = conditionExp;
			this.nextExp = nextExp;
			
			if (conditionExp.GetResultType () != typeof(bool))
				throw new InvalidOperationException ("Condition expression is not boolean"); 
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:9,代碼來源:CodeFor.cs

示例7: CodeAssignment

 public CodeAssignment(CodeValueReference var, CodeExpression exp)
 {
     if (var == null)
         throw new ArgumentNullException ("var");
     if (exp == null)
         throw new ArgumentNullException ("exp");
     this.exp = exp;
     this.var = var;
 }
開發者ID:yudhitech,項目名稱:xamarin-android,代碼行數:9,代碼來源:CodeAssignment.cs

示例8: CodeWhen

		public CodeWhen (CodeExpression condition, CodeExpression trueResult, CodeExpression falseResult)
		{
			this.condition = condition;
			if (condition.GetResultType () != typeof(bool))
				throw new InvalidOperationException ("Condition expression is not boolean");
			if (trueResult.GetResultType() != falseResult.GetResultType())
				throw new InvalidOperationException ("The types of the true and false expressions must be the same");
			trueBlock = trueResult;
			falseBlock = falseResult;
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:10,代碼來源:CodeWhen.cs

示例9: CodeMethodCall

		public CodeMethodCall (CodeExpression target, string name, params CodeExpression[] parameters)
		{
			this.target = target;
			this.parameters = parameters;
			Type[] types = GetParameterTypes (parameters);
			method = target.GetResultType().GetMethod (name, types);
			if (method == null) {
				throw new InvalidOperationException ("Method " + GetSignature(target.GetResultType(), name, parameters) + " not found");
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:10,代碼來源:CodeMethodCall.cs

示例10: CodeAnd

		public CodeAnd (CodeExpression exp1, CodeExpression exp2)
		{
			this.exp1 = exp1;
			this.exp2 = exp2;
			
 			if (exp1.GetResultType () != typeof(bool) || exp1.GetResultType () != typeof(bool)) {
				if (t1 != t2)
					throw new InvalidOperationException ("Can't compare values of different primitive types");
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:10,代碼來源:CodeAnd.cs

示例11: GenerateMethodCall

		public static void GenerateMethodCall (ILGenerator gen, CodeExpression target, MethodBase method, params CodeExpression[] parameters)
		{
			Type[] ptypes = Type.EmptyTypes;
			// It could raise an error since GetParameters() on MethodBuilder is not supported.
			if (parameters.Length > 0) {
				ParameterInfo[] pars = method.GetParameters ();
				ptypes = new Type[pars.Length];
				for (int n=0; n<ptypes.Length; n++) ptypes[n] = pars[n].ParameterType;
			}
			GenerateMethodCall (gen, target, method, ptypes, parameters);
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:11,代碼來源:CodeGenerationHelper.cs

示例12: CodeForeach

		public CodeForeach (CodeExpression array, Type itemType)
		{
			this.array = array;
			this.itemType = itemType;
			
			Type t = array.GetResultType ();
			if (!t.IsArray && t.GetMethod ("GetEnumerator", Type.EmptyTypes) == null)
				throw new InvalidOperationException ("foreach statement cannot operate on variables of type `" + t + "' because that class does not provide a GetEnumerator method or it is inaccessible");
			
			itemDec = new CodeVariableDeclaration (itemType, "item");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:11,代碼來源:CodeForeach.cs

示例13: CodeAdd

		public CodeAdd (CodeExpression exp1, CodeExpression exp2)
		{
			this.symbol = "+";
			this.exp1 = exp1;
			this.exp2 = exp2;
			
			t1 = exp1.GetResultType ();
			t2 = exp2.GetResultType ();
			
			if ((!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) && (t1 != typeof(string) || t2 != typeof(string))) {
				throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:13,代碼來源:CodeArithmeticOperation.cs

示例14: CodeBinaryOperation

        public CodeBinaryOperation(CodeExpression exp1, CodeExpression exp2, string symbol)
        {
            this.symbol = symbol;
            this.exp1 = exp1;
            this.exp2 = exp2;

            t1 = exp1.GetResultType ();
            t2 = exp2.GetResultType ();

            if (!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) {
                throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
            }
        }
開發者ID:yudhitech,項目名稱:xamarin-android,代碼行數:13,代碼來源:CodeBinaryOperation.cs

示例15: CodeNotEquals

		public CodeNotEquals (CodeExpression exp1, CodeExpression exp2)
		{
			this.exp1 = exp1;
			this.exp2 = exp2;
			
			t1 = exp1.GetResultType ();
			t2 = exp2.GetResultType ();
			
			if (t1.IsValueType && t2.IsValueType) {
				if (t1 != t2)
					throw new InvalidOperationException ("Can't compare values of different primitive types");
			}
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:13,代碼來源:CodeNotEquals.cs


注:本文中的Mono.CodeGeneration.CodeExpression類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。