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


C# CodeDom.CodeTypeOfExpression类代码示例

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


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

示例1: Serialize

        public override object Serialize(IDesignerSerializationManager manager, object value) {
            var baseSerializer = (CodeDomSerializer)manager
                .GetSerializer(typeof(ResourceManagerSetter).BaseType, typeof(CodeDomSerializer));
            object codeObject = baseSerializer.Serialize(manager, value);

            var statements = codeObject as CodeStatementCollection;
            if (statements != null) {
                CodeExpression leftCodeExpression = new CodeVariableReferenceExpression("resources");
                var classTypeDeclaration = (CodeTypeDeclaration)manager.GetService(typeof(CodeTypeDeclaration));
                CodeExpression typeofExpression = new CodeTypeOfExpression(classTypeDeclaration.Name);
                CodeExpression rightCodeExpression =
                    new CodeObjectCreateExpression(typeof(XafComponentResourceManager),
                                                                  new[] { typeofExpression });
                //CodeExpression rightCodeExpression =
                //    new CodeTypeReferenceExpression(
                //        "new DevExpress.ExpressApp.Win.Templates"),
                //        "XafComponentResourceManager", new[] { typeofExpression });

                statements.Insert(0, new CodeAssignStatement(leftCodeExpression, rightCodeExpression));
            }

            return codeObject;


        }
开发者ID:aries544,项目名称:eXpand,代码行数:25,代码来源:ResourceManagerSetter.cs

示例2: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeTypeReference type = new CodeTypeReference ("System.Void");
			CodeTypeOfExpression ctm = new CodeTypeOfExpression (type);
			Assert.AreSame (type, ctm.Type, "Type");
			ctm.Type = new CodeTypeReference ("System.Int32");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeTypeOfExpressionCas.cs

示例3: CodeRectangularArrayCreateExpression

 public CodeRectangularArrayCreateExpression(CodeTypeReference createType, params CodeExpression[] lengths)
 {
     _typeOfExpr = new CodeTypeOfExpression(createType);
     _lengths = new CodeNotificationExpressionCollection(Refresh, lengths);
     Initialize();
     Refresh();
 }
开发者ID:Saleslogix,项目名称:SLXMigration,代码行数:7,代码来源:CodeRectangularArrayCreateExpression.cs

示例4: BindingElementExtensionSectionGenerator

        internal BindingElementExtensionSectionGenerator(Type bindingElementType, Assembly userAssembly, CodeDomProvider provider)
        {
            this.bindingElementType = bindingElementType;
            this.userAssembly = userAssembly;
            this.provider = provider;

            string typePrefix = bindingElementType.Name.Substring(0, bindingElementType.Name.IndexOf(TypeNameConstants.BindingElement));
            this.generatedClassName = typePrefix + Constants.ElementSuffix;
            this.constantsClassName = bindingElementType.Name.Substring(0, bindingElementType.Name.IndexOf(TypeNameConstants.BindingElement)) + Constants.ConfigurationStrings;
            this.defaultValuesClassName = bindingElementType.Name.Substring(0, bindingElementType.Name.IndexOf(TypeNameConstants.BindingElement)) + Constants.Defaults;

            this.customBEVarInstance = Helpers.TurnFirstCharLower(bindingElementType.Name);
            customBEArgRef = new CodeArgumentReferenceExpression(customBEVarInstance);

            this.customBETypeRef = new CodeTypeReference(bindingElementType.Name);
            this.customBETypeOfRef = new CodeTypeOfExpression(customBETypeRef);
            this.customBENewVarAssignRef = new CodeVariableDeclarationStatement(
                                                customBETypeRef,
                                                customBEVarInstance,
                                                new CodeObjectCreateExpression(customBETypeRef));
            this.bindingElementMethodParamRef = new CodeParameterDeclarationExpression(
                                                    CodeDomHelperObjects.bindingElementTypeRef,
                                                    Constants.bindingElementParamName);

        }
开发者ID:ssickles,项目名称:archive,代码行数:25,代码来源:BindingElementExtensionSectionGenerator.cs

示例5: Clone

 public static CodeTypeOfExpression Clone(this CodeTypeOfExpression expression)
 {
     if (expression == null) return null;
     CodeTypeOfExpression e = new CodeTypeOfExpression();
     e.Type = expression.Type.Clone();
     e.UserData.AddRange(expression.UserData);
     return e;
 }
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:8,代码来源:CodeTypeOfExpressionExtensions.cs

示例6: TypescriptTypeOfExpression

 public TypescriptTypeOfExpression(
     CodeTypeOfExpression codeExpression, 
     CodeGeneratorOptions options, 
     ITypescriptTypeMapper typescriptTypeMapper)
 {
     _codeExpression = codeExpression;
     _options = options;
     _typescriptTypeMapper = typescriptTypeMapper;
     System.Diagnostics.Debug.WriteLine("TypescriptTypeOfExpression Created");
 }
开发者ID:s2quake,项目名称:TypescriptCodeDom,代码行数:10,代码来源:TypescriptTypeOfExpression.cs

示例7: GetCodeExpression

 /// <summary>
 /// When overridden in a derived class, returns code that is used during page execution to obtain the evaluated expression.
 /// </summary>
 /// <param name="entry">The object that represents information about the property bound to by the expression.</param>
 /// <param name="parsedData">The object containing parsed data as returned by <see cref="M:System.Web.Compilation.ExpressionBuilder.ParseExpression(System.String,System.Type,System.Web.Compilation.ExpressionBuilderContext)" />.</param>
 /// <param name="context">Contextual information for the evaluation of the expression.</param>
 /// <returns>
 /// A <see cref="T:System.CodeDom.CodeExpression" /> that is used for property assignment.
 /// </returns>
 public override CodeExpression GetCodeExpression( BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context )
 {
     // from http://msdn.microsoft.com/en-us/library/system.web.compilation.expressionbuilder.getcodeexpression.aspx
     Type type1 = entry.DeclaringType;
     PropertyDescriptor descriptor1 = TypeDescriptor.GetProperties( type1 )[entry.PropertyInfo.Name];
     CodeExpression[] expressionArray1 = new CodeExpression[3];
     expressionArray1[0] = new CodePrimitiveExpression( entry.Expression.Trim() );
     expressionArray1[1] = new CodeTypeOfExpression( type1 );
     expressionArray1[2] = new CodePrimitiveExpression( entry.Name );
     return new CodeCastExpression( descriptor1.PropertyType, new CodeMethodInvokeExpression( new CodeTypeReferenceExpression( base.GetType() ), "GetEvalData", expressionArray1 ) );
 }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:20,代码来源:FingerprintExpressionBuilder.cs

示例8: Constructor2

		public void Constructor2 ()
		{
			string baseType = "mono";

			CodeTypeOfExpression ctoe = new CodeTypeOfExpression (baseType);
			Assert.IsNotNull (ctoe.Type, "#1");
			Assert.AreEqual (baseType, ctoe.Type.BaseType, "#2");

			ctoe = new CodeTypeOfExpression ((string) null);
			Assert.IsNotNull (ctoe.Type, "#3");
			Assert.AreEqual (typeof (void).FullName, ctoe.Type.BaseType, "#4");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:CodeTypeOfExpressionTest.cs

示例9: GetCodeExpression

        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            var expression = new CodeExpression[3];

            expression[0] = new CodePrimitiveExpression(entry.Expression.Trim());
            expression[1] = new CodeTypeOfExpression(typeof(string));
            expression[2] = new CodePrimitiveExpression(entry.Name);

            return new CodeCastExpression(typeof(string),
                                          new CodeMethodInvokeExpression(
                                              new CodeTypeReferenceExpression(GetType()), "GetEvalData",
                                              expression));
        }
开发者ID:benmcevoy,项目名称:FatDividends,代码行数:13,代码来源:FatExpressionBuilder.cs

示例10: Constructor0

		public void Constructor0 ()
		{
			CodeTypeOfExpression ctoe = new CodeTypeOfExpression ();
			Assert.IsNotNull (ctoe.Type, "#1");
			Assert.AreEqual (typeof (void).FullName, ctoe.Type.BaseType, "#2");

			CodeTypeReference type = new CodeTypeReference ("mono");
			ctoe.Type = type;
			Assert.IsNotNull (ctoe.Type, "#3");
			Assert.AreSame (type, ctoe.Type, "#4");

			ctoe.Type = null;
			Assert.IsNotNull (ctoe.Type, "#5");
			Assert.AreEqual (typeof (void).FullName, ctoe.Type.BaseType, "#6");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:CodeTypeOfExpressionTest.cs

示例11: StandardBindingSectionGenerator

        internal StandardBindingSectionGenerator(Type standardBindingType, Assembly userAssembly, CodeDomProvider provider)
        {
            this.standardBindingType = standardBindingType;
            this.userAssembly = userAssembly;
            this.provider = provider;

            this.generatedElementClassName = standardBindingType.Name + Constants.ElementSuffix;
            this.constantsClassName = standardBindingType.Name.Substring(0, standardBindingType.Name.IndexOf(TypeNameConstants.Binding)) + Constants.ConfigurationStrings;
            this.defaultValuesClassName = standardBindingType.Name.Substring(0, standardBindingType.Name.IndexOf(TypeNameConstants.Binding)) + Constants.Defaults;
            this.generatedCollectionElementClassName = standardBindingType.Name + Constants.CollectionElementSuffix;

            this.customSBTypeRef = new CodeTypeReference(standardBindingType.Name);
            this.customSBTypeOfRef = new CodeTypeOfExpression(customSBTypeRef);
            this.bindingMethodParamRef = new CodeParameterDeclarationExpression(
                                            CodeDomHelperObjects.bindingTypeRef, 
                                            Constants.bindingParamName);
        }
开发者ID:ssickles,项目名称:archive,代码行数:17,代码来源:StandardBindingSectionGenerator.cs

示例12: Generate

		public CodeExpression[] Generate(Table table, HardwireCodeGenerationContext generator,
			CodeTypeMemberCollection members)
		{
			List<CodeExpression> initializers = new List<CodeExpression>();

			generator.DispatchTablePairs(table.Get("overloads").Table, members, exp =>
			{
				initializers.Add(exp);
			});

			var name = new CodePrimitiveExpression((table["name"] as string));
			var type = new CodeTypeOfExpression(table["decltype"] as string);

			var array = new CodeArrayCreateExpression(typeof(IOverloadableMemberDescriptor), initializers.ToArray());

			return new CodeExpression[] {
					new CodeObjectCreateExpression(typeof(OverloadedMethodMemberDescriptor), name, type, array)
			};
		}
开发者ID:InfectedBytes,项目名称:moonsharp,代码行数:19,代码来源:OverloadedMethodMemberDescriptorGenerator.cs

示例13: Constructor1

		public void Constructor1 ()
		{
			CodeTypeReference type1 = new CodeTypeReference ("mono1");

			CodeTypeOfExpression ctoe = new CodeTypeOfExpression (type1);
			Assert.IsNotNull (ctoe.Type, "#1");
			Assert.AreSame (type1, ctoe.Type, "#2");

			ctoe.Type = null;
			Assert.IsNotNull (ctoe.Type, "#3");
			Assert.AreEqual (typeof (void).FullName, ctoe.Type.BaseType, "#4");

			CodeTypeReference type2 = new CodeTypeReference ("mono2");
			ctoe.Type = type2;
			Assert.IsNotNull (ctoe.Type, "#5");
			Assert.AreSame (type2, ctoe.Type, "#6");

			ctoe = new CodeTypeOfExpression ((CodeTypeReference) null);
			Assert.IsNotNull (ctoe.Type, "#7");
			Assert.AreEqual (typeof (void).FullName, ctoe.Type.BaseType, "#8");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:21,代码来源:CodeTypeOfExpressionTest.cs

示例14: HardwireParameterDescriptor

		public HardwireParameterDescriptor(Table tpar)
		{
			CodeExpression ename = new CodePrimitiveExpression(tpar.Get("name").String);
			CodeExpression etype = new CodeTypeOfExpression(tpar.Get("origtype").String);
			CodeExpression hasDefaultValue = new CodePrimitiveExpression(tpar.Get("default").Boolean);
			CodeExpression defaultValue = tpar.Get("default").Boolean ? (CodeExpression)(new CodeObjectCreateExpression(typeof(DefaultValue))) :
				(CodeExpression)(new CodePrimitiveExpression(null));
			CodeExpression isOut = new CodePrimitiveExpression(tpar.Get("out").Boolean);
			CodeExpression isRef = new CodePrimitiveExpression(tpar.Get("ref").Boolean);
			CodeExpression isVarArg = new CodePrimitiveExpression(tpar.Get("varargs").Boolean);
			CodeExpression restrictType = tpar.Get("restricted").Boolean ? (CodeExpression)(new CodeTypeOfExpression(tpar.Get("type").String)) :
				(CodeExpression)(new CodePrimitiveExpression(null));

			Expression = new CodeObjectCreateExpression(typeof(ParameterDescriptor), new CodeExpression[] {
					ename, etype, hasDefaultValue, defaultValue, isOut, isRef,
					isVarArg }
			);

			ParamType = tpar.Get("origtype").String;
			HasDefaultValue = tpar.Get("default").Boolean;
			IsOut = tpar.Get("out").Boolean;
			IsRef = tpar.Get("ref").Boolean;
		}
开发者ID:InfectedBytes,项目名称:moonsharp,代码行数:23,代码来源:HardwireParameterDescriptor.cs

示例15: BuildExpression

        private CodeExpression BuildExpression(XSharpParser.PrimaryExpressionContext expression)
        {
            CodeExpression expr = null;
            XSharpParser.PrimaryContext ctx = expression.Expr;
            //
            if (ctx is XSharpParser.SelfExpressionContext) // Self
            {
                expr = new CodeThisReferenceExpression();
            }
            else if (ctx is XSharpParser.SuperExpressionContext) // Super
            {
                expr = new CodeBaseReferenceExpression();
            }
            else if (ctx is XSharpParser.LiteralExpressionContext)
            {
                XSharpParser.LiteralExpressionContext lit = (XSharpParser.LiteralExpressionContext)ctx;
                expr = BuildLiteralValue(lit.Literal);
            }
            else if (ctx is XSharpParser.LiteralArrayExpressionContext) // { expr [, expr] }
            {
                XSharpParser.LiteralArrayContext arr = ((XSharpParser.LiteralArrayExpressionContext)ctx).LiteralArray;
                // Typed Array ?
                if (arr.Type != null)
                {
                    List<CodeExpression> exprlist = new List<CodeExpression>();
                    foreach (var Element in arr._Elements)
                    {
                        exprlist.Add(BuildExpression(Element.Expr,true));
                    }
                    expr = new CodeArrayCreateExpression(BuildDataType(arr.Type), exprlist.ToArray());
                }
                else
                {
                    expr = new CodeSnippetExpression(arr.GetText());
                }
            }
            else if (ctx is XSharpParser.DelegateCtorCallContext)
            {
                XSharpParser.DelegateCtorCallContext delg = (XSharpParser.DelegateCtorCallContext)ctx;
                //
                CodeTypeReference ctr = BuildDataType(delg.Type);
                CodeExpression ce = BuildExpression(delg.Obj,false);
                //
                expr = new CodeDelegateCreateExpression(BuildDataType(delg.Type), BuildExpression(delg.Obj,false), delg.Func.GetText());

            }
            else if (ctx is XSharpParser.CtorCallContext)
            {
                XSharpParser.CtorCallContext ctor = (XSharpParser.CtorCallContext)ctx;
                CodeTypeReference ctr = BuildDataType(ctor.Type);
                List<CodeExpression> exprlist = new List<CodeExpression>();
                if (ctor.ArgList != null)
                {
                    foreach (var arg in ctor.ArgList._Args)
                    {
                        // We should handle arg.Name if arg.ASSIGN_OP is not null...
                        exprlist.Add(BuildExpression(arg.Expr,false));
                    }
                }
                expr = new CodeObjectCreateExpression(ctr.BaseType, exprlist.ToArray());
            }
            else if (ctx is XSharpParser.TypeOfExpressionContext)
            {
                CodeTypeReference ctr = BuildDataType(((XSharpParser.TypeOfExpressionContext)ctx).Type);
                expr = new CodeTypeOfExpression(ctr);
            }
            else if (ctx is XSharpParser.NameExpressionContext)
            {
                String name = ((XSharpParser.NameExpressionContext)ctx).Name.Id.GetText();
                // Sometimes, we will need to do it that way....
                if (name.ToLower() == "self")
                {
                    expr = new CodeThisReferenceExpression();
                }
                else if (name.ToLower() == "super")
                {
                    expr = new CodeBaseReferenceExpression();
                }
                else
                {
                    CodeTypeReference ctr = BuildSimpleName(((XSharpParser.NameExpressionContext)ctx).Name);
                    expr = new CodeVariableReferenceExpression(name);
                }
            }
            else
            {
                expr = new CodeSnippetExpression(ctx.GetText());
            }
            return expr;
        }
开发者ID:X-Sharp,项目名称:XSharpPublic,代码行数:90,代码来源:XSharpTreeDiscover.cs


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