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


C# CodeDom.CodeThisReferenceExpression类代码示例

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


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

示例1: Generate

        /// <summary>
        /// Generates control fields
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="classType">Type of the class.</param>
        /// <param name="method">The initialize method.</param>
        /// <param name="generateField">if set to <c>true</c> [generate field].</param>
        /// <returns></returns>
        public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField)
        {
            CodeExpression fieldReference = new CodeThisReferenceExpression();

            CodeComHelper.GenerateBrushField(method, fieldReference, source, Control.BackgroundProperty);
            CodeComHelper.GenerateBrushField(method, fieldReference, source, Control.BorderBrushProperty);
            CodeComHelper.GenerateThicknessField(method, fieldReference, source, Control.BorderThicknessProperty);
            CodeComHelper.GenerateThicknessField(method, fieldReference, source, Control.PaddingProperty);
            CodeComHelper.GenerateBrushField(method, fieldReference, source, Control.ForegroundProperty);
            CodeComHelper.GenerateField<bool>(method, fieldReference, source, UIRoot.IsTabNavigationEnabledProperty);
            CodeComHelper.GenerateColorField(method, fieldReference, source, UIRoot.MessageBoxOverlayProperty);

            CodeComHelper.GenerateTemplateStyleField(classType, method, fieldReference, source, FrameworkElement.StyleProperty);

            Control control = source as Control;
            if (!CodeComHelper.IsDefaultValue(source, Control.FontFamilyProperty) ||
                !CodeComHelper.IsDefaultValue(source, Control.FontSizeProperty) ||
                !CodeComHelper.IsDefaultValue(source, Control.FontStyleProperty) ||
                !CodeComHelper.IsDefaultValue(source, Control.FontWeightProperty))
            {
                FontGenerator.Instance.AddFont(control.FontFamily, control.FontSize, control.FontStyle, control.FontWeight, method);
            }

            CodeComHelper.GenerateFontFamilyField(method, fieldReference, source, Control.FontFamilyProperty);
            CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, Control.FontSizeProperty);
            CodeComHelper.GenerateFontStyleField(method, fieldReference, source, Control.FontStyleProperty, Control.FontWeightProperty);

            return fieldReference;
        }
开发者ID:EmptyKeys,项目名称:UI_Generator,代码行数:37,代码来源:UIRootGeneratorType.cs

示例2: 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

示例3: TypescriptThisReferenceExpression

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

示例4: Generate

        /// <summary>
        /// Generates control fields
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="classType">Type of the class.</param>
        /// <param name="initMethod">The initialize method.</param>
        /// <param name="generateField">if set to <c>true</c> [generate field].</param>
        /// <returns></returns>
        public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField)
        {
            CodeExpression fieldReference = new CodeThisReferenceExpression();

            CodeComHelper.GenerateTemplateStyleField(classType, initMethod, fieldReference, source, FrameworkElement.StyleProperty);

            return fieldReference;
        }
开发者ID:fearfullymade,项目名称:UI_Generator,代码行数:16,代码来源:UserControlGeneratorType.cs

示例5: GetCodeExpression

		public override CodeExpression GetCodeExpression (BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
		{
			if (entry == null)
				throw new NullReferenceException (".NET emulation (entry == null)");
			
			var ret = new CodeMethodInvokeExpression ();
			ret.Method = new CodeMethodReferenceExpression (new CodeTypeReferenceExpression (typeof (RouteValueExpressionBuilder)), "GetRouteValue");

			var thisref = new CodeThisReferenceExpression ();
			CodeExpressionCollection parameters = ret.Parameters;
			parameters.Add (new CodePropertyReferenceExpression (thisref, "Page"));
			parameters.Add (new CodePrimitiveExpression (entry.Expression));
			parameters.Add (new CodeTypeOfExpression (new CodeTypeReference (entry.DeclaringType)));
			parameters.Add (new CodePrimitiveExpression (entry.Name));
			
			return ret;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:RouteValueExpressionBuilder.cs

示例6: CreateConstructorBody

        private void CreateConstructorBody(GMethod constructor, CodeConstructor con, string uName)
        {
            if (!type.IsRootType)
            {
                con.BaseConstructorArgs.Add(
                    new CodeCastExpression(TypeReference("net.sf.jni4net.inj.INJEnv"), new CodePrimitiveExpression(null)));
                con.BaseConstructorArgs.Add(new CodePrimitiveExpression(0));
            }

            var parameters = new CodeExpression[constructor.Parameters.Count + 1];
            for (int p = 0; p < constructor.Parameters.Count; p++)
            {
                parameters[p + 1] = new CodeVariableReferenceExpression(constructor.ParameterNames[p]);
            }
            parameters[0] = new CodeThisReferenceExpression();
            con.Statements.Add(
                new CodeMethodInvokeExpression(CurrentTypeEx, uName, parameters));
        }
开发者ID:Mazrick,项目名称:jni4net,代码行数:18,代码来源:CLRClassGenerator.cs

示例7: GenerateConstructor

        public static void GenerateConstructor(CodeTypeDeclaration classDecl)
        {
            CodeConstructor constructorMember = new CodeConstructor() ;

            constructorMember.Attributes = MemberAttributes.Public;

            CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(new CodeTypeReference("IContext"), "context");
            constructorMember.Parameters.Add(parameter);

            CodeThisReferenceExpression thisExp = new CodeThisReferenceExpression();
            CodeFieldReferenceExpression ctxFieldExp = new CodeFieldReferenceExpression(thisExp, "context");

            CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression("context");
            CodeAssignStatement assignStatement = new CodeAssignStatement(ctxFieldExp, argExp);
            constructorMember.Statements.Add(assignStatement);

            classDecl.Members.Add(constructorMember);
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:18,代码来源:CodeDomGenerator.cs

示例8: AddBodyParameter

        internal void AddBodyParameter(CodeConstructor constructor, IMethod request)
        {
            const string varName = "body";
            if (!request.HasBody)
            {
                return; // No body parameter required.
            }

            CodeTypeReference bodyType = objectTypeProvider.GetBodyType(request);
            var thisRef = new CodeThisReferenceExpression();

            // TBody body
            constructor.Parameters.Add(new CodeParameterDeclarationExpression(bodyType, varName));

            // this.Body = body;
            var assign = new CodeAssignStatement();
            assign.Left = new CodePropertyReferenceExpression(thisRef, BodyPropertyDecorator.BodyPropertyName);
            assign.Right = new CodeVariableReferenceExpression(varName);
            constructor.Statements.Add(assign);
        }
开发者ID:jithuin,项目名称:infogeezer,代码行数:20,代码来源:BaseRequestConstructorDecorator.cs

示例9: GetIndexer

        static CodeMemberProperty GetIndexer()
        {
            var indexer = new CodeMemberProperty();
            indexer.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            indexer.Name = "Item";
            indexer.Type = new CodeTypeReference(typeof(object));
            indexer.HasSet = true;
            indexer.HasGet = true;
            indexer.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(string)), "field"));

            //return RecordHelper.Get(this, field);
            //RecordHelper.Set(this, field, value);
            var helper = new CodeTypeReferenceExpression("RecordHelper");
            var field = new CodeVariableReferenceExpression("field");
            var _this = new CodeThisReferenceExpression();
            var value = new CodeVariableReferenceExpression("value");

            var g = new CodeMethodInvokeExpression(helper, "Get", _this, field);
            indexer.GetStatements.Add(new CodeMethodReturnStatement(g));

            var s = new CodeMethodInvokeExpression(helper, "Set", _this, field, value);
            indexer.SetStatements.Add(s);
            return indexer;
        }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:24,代码来源:Table.cs

示例10: GenerateAndStoreViews

        /// <summary>
        /// Generates the code to store the views in a C# or a VB file based on the
        /// options passed in by the user.
        /// </summary>
        /// <param name="mappingCollection"></param>
        /// <param name="generatedViews"></param>
        /// <param name="sourceWriter"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        private static void GenerateAndStoreViews(StorageMappingItemCollection mappingCollection,
            Dictionary<EntitySetBase, string> generatedViews, TextWriter sourceWriter, CodeDomProvider provider, IList<EdmSchemaError> schemaErrors)
        {
            EdmItemCollection edmCollection = mappingCollection.EdmItemCollection;
            StoreItemCollection storeCollection = mappingCollection.StoreItemCollection;

            //Create an emtpty compile unit and build up the generated code
            CodeCompileUnit compileUnit = new CodeCompileUnit();

            //Add the namespace for generated code
            CodeNamespace codeNamespace = new CodeNamespace(EntityViewGenerationConstants.NamespaceName);
            //Add copyright notice to the namespace comment.
            compileUnit.Namespaces.Add(codeNamespace);

            foreach (var storageEntityContainerMapping in mappingCollection.GetItems<StorageEntityContainerMapping>())
            {
                //Throw warning when containerMapping contains query view for bug 547285.
                if (HasQueryView(storageEntityContainerMapping))
                {
                    schemaErrors.Add(new EdmSchemaError(
                        Strings.UnsupportedQueryViewInEntityContainerMapping(storageEntityContainerMapping.Identity), 
                        (int)StorageMappingErrorCode.UnsupportedQueryViewInEntityContainerMapping, 
                        EdmSchemaErrorSeverity.Warning));
                    continue;
                }

                #region Class Declaration

                string edmContainerName = storageEntityContainerMapping.EdmEntityContainer.Name;
                string storeContainerName = storageEntityContainerMapping.StorageEntityContainer.Name;

                string hashOverMappingClosure = MetadataMappingHasherVisitor.GetMappingClosureHash(edmCollection.EdmVersion, storageEntityContainerMapping);

                StringBuilder inputForTypeNameContent = new StringBuilder(hashOverMappingClosure);

                string viewStorageTypeName = EntityViewGenerationConstants.ViewGenerationTypeNamePrefix + StringHashBuilder.ComputeHash(MetadataHelper.CreateMetadataHashAlgorithm(edmCollection.EdmVersion),  inputForTypeNameContent.ToString()).ToUpperInvariant();

                //Add typeof expression to get the type that contains ViewGen type. This will help us in avoiding to go through 
                //all the types in the assembly. I have also verified that this works with VB with a root namespace prepended to the
                //namespace since VB is picking up the type correctly as long as it is in the same assembly even with out the root namespace.
                CodeTypeOfExpression viewGenTypeOfExpression = new CodeTypeOfExpression(EntityViewGenerationConstants.NamespaceName + "." + viewStorageTypeName);
                //Add the assembly attribute that marks the assembly as the one that contains the generated views
                CodeAttributeDeclaration viewGenAttribute = new CodeAttributeDeclaration(EntityViewGenerationConstants.ViewGenerationCustomAttributeName);
                CodeAttributeArgument viewGenTypeArgument = new CodeAttributeArgument(viewGenTypeOfExpression);
                viewGenAttribute.Arguments.Add(viewGenTypeArgument);
                compileUnit.AssemblyCustomAttributes.Add(viewGenAttribute);

                //Add the type which will be the class that contains all the views in this assembly
                CodeTypeDeclaration viewStoringType = CreateTypeForStoringViews(viewStorageTypeName);

                //Add the constructor, this will be the only method that this type will contain
                //Create empty constructor.
                CodeConstructor viewStoringTypeConstructor = CreateConstructorForViewStoringType();
                viewStoringType.Attributes = MemberAttributes.Public;


                //Get an expression that expresses this instance
                CodeThisReferenceExpression thisRef = new CodeThisReferenceExpression();


                string viewHash = MetadataHelper.GenerateHashForAllExtentViewsContent(edmCollection.EdmVersion, GenerateDictionaryForEntitySetNameAndView(generatedViews));


                CodeAssignStatement EdmEntityContainerNameStatement = 
                    new CodeAssignStatement(
                        new CodeFieldReferenceExpression(thisRef, EntityViewGenerationConstants.EdmEntityContainerName), 
                        new CodePrimitiveExpression(edmContainerName));
                CodeAssignStatement StoreEntityContainerNameStatement =
                    new CodeAssignStatement(
                        new CodeFieldReferenceExpression(thisRef, EntityViewGenerationConstants.StoreEntityContainerName),
                        new CodePrimitiveExpression(storeContainerName));
                CodeAssignStatement HashOverMappingClosureStatement =
                    new CodeAssignStatement(
                        new CodeFieldReferenceExpression(thisRef, EntityViewGenerationConstants.HashOverMappingClosure),
                        new CodePrimitiveExpression(hashOverMappingClosure));
                CodeAssignStatement HashOverAllExtentViewsStatement =
                    new CodeAssignStatement(
                        new CodeFieldReferenceExpression(thisRef, EntityViewGenerationConstants.HashOverAllExtentViews),
                        new CodePrimitiveExpression(viewHash));
                CodeAssignStatement ViewCountStatement =
                    new CodeAssignStatement(
                        new CodeFieldReferenceExpression(thisRef, EntityViewGenerationConstants.ViewCountPropertyName),
                        new CodePrimitiveExpression(generatedViews.Count));

                viewStoringTypeConstructor.Statements.Add(EdmEntityContainerNameStatement);
                viewStoringTypeConstructor.Statements.Add(StoreEntityContainerNameStatement);
                viewStoringTypeConstructor.Statements.Add(HashOverMappingClosureStatement);
                viewStoringTypeConstructor.Statements.Add(HashOverAllExtentViewsStatement);
                viewStoringTypeConstructor.Statements.Add(ViewCountStatement);

                //Add the constructor to the type
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:EntityViewGenerator.cs

示例11: BuildInvokeAsync

		internal override CodeExpression BuildInvokeAsync (string messageName, CodeArrayCreateExpression paramsArray, CodeExpression delegateField, CodeExpression userStateVar)
		{
			HttpOperationBinding httpOper = OperationBinding.Extensions.Find (typeof (HttpOperationBinding)) as HttpOperationBinding;
			
			CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
			
			CodeExpression thisURlExp = new CodeFieldReferenceExpression (ethis, "Url");
			CodePrimitiveExpression metUrl = new CodePrimitiveExpression (httpOper.Location);
			CodeBinaryOperatorExpression expMethodLocation = new CodeBinaryOperatorExpression (thisURlExp, CodeBinaryOperatorType.Add, metUrl);
			
			CodeMethodInvokeExpression inv2 = new CodeMethodInvokeExpression (ethis, "InvokeAsync");
			inv2.Parameters.Add (new CodePrimitiveExpression (messageName));
			inv2.Parameters.Add (expMethodLocation);
			inv2.Parameters.Add (paramsArray);
			inv2.Parameters.Add (delegateField);
			inv2.Parameters.Add (userStateVar);
			return inv2;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:18,代码来源:HttpSimpleProtocolImporter.cs

示例12: GenerateMethod

		CodeMemberMethod GenerateMethod (CodeIdentifiers memberIds, HttpOperationBinding httpOper, XmlMembersMapping inputMembers, XmlTypeMapping outputMember)
		{
			CodeIdentifiers pids = new CodeIdentifiers ();
			CodeMemberMethod method = new CodeMemberMethod ();
			CodeMemberMethod methodBegin = new CodeMemberMethod ();
			CodeMemberMethod methodEnd = new CodeMemberMethod ();
			method.Attributes = MemberAttributes.Public;
			methodBegin.Attributes = MemberAttributes.Public;
			methodEnd.Attributes = MemberAttributes.Public;
			
			// Find unique names for temporary variables
			
			for (int n=0; n<inputMembers.Count; n++)
				pids.AddUnique (inputMembers[n].MemberName, inputMembers[n]);

			string varAsyncResult = pids.AddUnique ("asyncResult","asyncResult");
			string varCallback = pids.AddUnique ("callback","callback");
			string varAsyncState = pids.AddUnique ("asyncState","asyncState");

			string messageName = memberIds.AddUnique(CodeIdentifier.MakeValid(Operation.Name),method);

			method.Name = Operation.Name;
			methodBegin.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("Begin" + Operation.Name),method);
			methodEnd.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("End" + Operation.Name),method);

			method.ReturnType = new CodeTypeReference (typeof(void));
			methodEnd.ReturnType = new CodeTypeReference (typeof(void));
			methodEnd.Parameters.Add (new CodeParameterDeclarationExpression (typeof (IAsyncResult),varAsyncResult));

			CodeExpression[] paramArray = new CodeExpression [inputMembers.Count];

			for (int n=0; n<inputMembers.Count; n++)
			{
				string ptype = GetSimpleType (inputMembers[n]);
				CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (ptype, inputMembers[n].MemberName);
				
				param.Direction = FieldDirection.In;
				method.Parameters.Add (param);
				methodBegin.Parameters.Add (param);
				paramArray [n] = new CodeVariableReferenceExpression (param.Name);
			}

			bool isVoid = true;
			if (outputMember != null)
			{
				method.ReturnType = new CodeTypeReference (outputMember.TypeFullName);
				methodEnd.ReturnType = new CodeTypeReference (outputMember.TypeFullName);
				xmlExporter.AddMappingMetadata (method.ReturnTypeCustomAttributes, outputMember, "");
				isVoid = false;
			}

			methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (AsyncCallback),varCallback));
			methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (object),varAsyncState));
			methodBegin.ReturnType = new CodeTypeReference (typeof(IAsyncResult));

			// Array of input parameters
			
			CodeArrayCreateExpression methodParams;
			if (paramArray.Length > 0)
				methodParams = new CodeArrayCreateExpression (typeof(object), paramArray);
			else
				methodParams = new CodeArrayCreateExpression (typeof(object), 0);

			// Generate method url
			
			CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
			
			CodeExpression thisURlExp = new CodeFieldReferenceExpression (ethis, "Url");
			CodePrimitiveExpression metUrl = new CodePrimitiveExpression (httpOper.Location);
			CodeBinaryOperatorExpression expMethodLocation = new CodeBinaryOperatorExpression (thisURlExp, CodeBinaryOperatorType.Add, metUrl);
			
			// Invoke call
			
			CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
			CodeMethodInvokeExpression inv;

			inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, expMethodLocation, methodParams);
			if (!isVoid)
				method.Statements.Add (new CodeMethodReturnStatement (new CodeCastExpression (method.ReturnType, inv)));
			else
				method.Statements.Add (inv);
			
			// Begin Invoke Call
			
			CodeExpression expCallb = new CodeVariableReferenceExpression (varCallback);
			CodeExpression expAsyncs = new CodeVariableReferenceExpression (varAsyncState);
			inv = new CodeMethodInvokeExpression (ethis, "BeginInvoke", varMsgName, expMethodLocation, methodParams, expCallb, expAsyncs);
			methodBegin.Statements.Add (new CodeMethodReturnStatement (inv));
			
			// End Invoke call
			
			CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
			inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
			if (!isVoid)
				methodEnd.Statements.Add (new CodeMethodReturnStatement (new CodeCastExpression (methodEnd.ReturnType, inv)));
			else
				methodEnd.Statements.Add (inv);
			
			// Attributes

//.........这里部分代码省略.........
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:101,代码来源:HttpSimpleProtocolImporter.cs

示例13: GenerateMethod


//.........这里部分代码省略.........

			// Array of input parameters
			
			CodeArrayCreateExpression methodParams;
			if (paramArray.Length > 0)
				methodParams = new CodeArrayCreateExpression (typeof(object), paramArray);
			else
				methodParams = new CodeArrayCreateExpression (typeof(object), 0);

			// Assignment of output parameters
			
			CodeStatementCollection outAssign = new CodeStatementCollection ();
			CodeVariableReferenceExpression arrVar = new CodeVariableReferenceExpression (varResults);
			for (int n=0; n<outParams.Length; n++)
			{
				CodeExpression index = new CodePrimitiveExpression (n);
				if (outParams[n] == null)
				{
					CodeExpression res = new CodeCastExpression (method.ReturnType, new CodeArrayIndexerExpression (arrVar, index));
					outAssign.Add (new CodeMethodReturnStatement (res));
				}
				else
				{
					CodeExpression res = new CodeCastExpression (outParams[n].Type, new CodeArrayIndexerExpression (arrVar, index));
					CodeExpression var = new CodeVariableReferenceExpression (outParams[n].Name);
					outAssign.Insert (0, new CodeAssignStatement (var, res));
				}
			}
			
			if (Style == ServiceDescriptionImportStyle.Client) 
			{
				// Invoke call
				
				CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
				CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
				CodeMethodInvokeExpression inv;
				CodeVariableDeclarationStatement dec;
	
				inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, methodParams);
				if (outputMembers != null && outputMembers.Count > 0)
				{
					dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
					method.Statements.Add (dec);
					method.Statements.AddRange (outAssign);
				}
				else
					method.Statements.Add (inv);
				
				// Begin Invoke Call
				
				CodeExpression expCallb = new CodeVariableReferenceExpression (varCallback);
				CodeExpression expAsyncs = new CodeVariableReferenceExpression (varAsyncState);
				inv = new CodeMethodInvokeExpression (ethis, "BeginInvoke", varMsgName, methodParams, expCallb, expAsyncs);
				methodBegin.Statements.Add (new CodeMethodReturnStatement (inv));
				
				// End Invoke call
				
				CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
				inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
				if (outputMembers != null && outputMembers.Count > 0)
				{
					dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
					methodEnd.Statements.Add (dec);
					methodEnd.Statements.AddRange (outAssign);
				}
				else
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:67,代码来源:SoapProtocolImporter.cs

示例14: ParseWidget

        void ParseWidget(XmlElement widgetNode, CodeTypeDeclaration formClass, CodeExpression parentWidgetReference, CodeExpression parentLayoutReference, XmlElement parentItemNode)
        {
            string widgetClass = widgetNode.GetAttribute("class");
            string widgetName  = widgetNode.GetAttribute("name");

            CodeExpression widgetReference;

            if (parentWidgetReference == null) {
                widgetReference = new CodeThisReferenceExpression();
            } else {
                if (widgetClass == "Line")
                    widgetClass = "QFrame";

                CodeMemberField widgetField = new CodeMemberField(widgetClass, widgetName);
                widgetField.Attributes = MemberAttributes.Family;
                formClass.Members.Add(widgetField);
                widgetReference = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), widgetName);

                m_SetupUiMethod.Statements.Add(new CodeAssignStatement(widgetReference, new CodeObjectCreateExpression(widgetClass, parentWidgetReference)));
                m_SetupUiMethod.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(widgetReference, "ObjectName"), new CodePrimitiveExpression(widgetName)));
            }

            ParseProperties(widgetNode, widgetReference, widgetReference);

            XmlElement layoutNode = (XmlElement)widgetNode.SelectSingleNode("layout");
            if (layoutNode != null) {
                ParseLayout(layoutNode, formClass, widgetReference, null);
            }

            if (parentWidgetReference != null) {
                if (parentItemNode == null || parentItemNode.Attributes["row"] == null || parentItemNode.Attributes["column"] == null) {
                    if (parentLayoutReference != null) {
                        m_SetupUiMethod.Statements.Add(new CodeMethodInvokeExpression(parentLayoutReference, "AddWidget", widgetReference));
                    } else {
                        var parentWidgetNode = (XmlElement)widgetNode.ParentNode;
                        if (GetClassName(parentWidgetNode) == "QTabWidget") {
                            string tabLabel = widgetNode.SelectSingleNode("attribute[@name='title']/string").InnerText;
                            m_SetupUiMethod.Statements.Add(new CodeMethodInvokeExpression(parentWidgetReference, "AddTab", widgetReference,
                                                                                        new CodePrimitiveExpression(tabLabel)));
                        } else if (GetClassName(parentWidgetNode) == "QScrollArea") {
                            m_SetupUiMethod.Statements.Add(new CodeMethodInvokeExpression(parentWidgetReference, "SetWidget", widgetReference));
                        } else {
                            m_SetupUiMethod.Statements.Add(new CodeMethodInvokeExpression(parentWidgetReference, "AddWidget", widgetReference));
                        }
                    }
                } else {
                    int row    = Convert.ToInt32(parentItemNode.GetAttribute("row"));
                    int column = Convert.ToInt32(parentItemNode.GetAttribute("column"));

                    var parentLayoutNode = (XmlElement)parentItemNode.ParentNode;
                    if (GetClassName(parentLayoutNode) == "QFormLayout") {

                        var roleName = (column == 0) ? "LabelRole" : "FieldRole";
                        var roleExpression = new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("QFormLayout.ItemRole"), roleName);
                        m_SetupUiMethod.Statements.Add(new CodeMethodInvokeExpression(parentLayoutReference, "SetWidget",
                                                                                    new CodePrimitiveExpression(row),
                                                                                    roleExpression,
                                                                                    widgetReference));
                    } else {
                        var colSpan = parentItemNode.Attributes["colspan"] != null ? Convert.ToInt32(parentItemNode.GetAttribute("colspan")) : 1;
                        var rowSpan = parentItemNode.Attributes["rowspan"] != null ? Convert.ToInt32(parentItemNode.GetAttribute("rowspan")) : 1;
                        m_SetupUiMethod.Statements.Add(new CodeMethodInvokeExpression(parentLayoutReference,
                                                                                    "AddWidget",
                                                                                     widgetReference,
                                                                                     new CodePrimitiveExpression(row),
                                                                                     new CodePrimitiveExpression(column),
                                                                                     new CodePrimitiveExpression(rowSpan),
                                                                                     new CodePrimitiveExpression(colSpan)));
                    }
                }
            }

            if (widgetClass == "QComboBox") {
                List<CodeExpression> itemTextExpressions = new List<CodeExpression>();
                foreach (XmlElement itemElement in widgetNode.GetElementsByTagName("item")) {
                    string text = itemElement.SelectSingleNode("property[@name='text']").InnerText;
                    itemTextExpressions.Add(new CodePrimitiveExpression(text));
                }

                if (itemTextExpressions.Count > 0) {
                    m_SetupUiMethod.Statements.Add(new CodeMethodInvokeExpression(widgetReference, "InsertItems",
                                                      new CodePrimitiveExpression(0),
                                                      new CodeObjectCreateExpression(typeof (List<string>), new CodeArrayCreateExpression(typeof(string[]), itemTextExpressions.ToArray()))));
                }
            }

            foreach (XmlElement childWidgetNode in widgetNode.SelectNodes("widget")) {
                ParseWidget(childWidgetNode, formClass, widgetReference, null);
            }
        }
开发者ID:codebutler,项目名称:qyotodevelop,代码行数:90,代码来源:QyotoCodeGenerator.cs

示例15: AddApplicationEvent

        internal void AddApplicationEvent(MarkupEventInfo mei)
        {
            // validate the event handler name per C# grammar for identifiers
            ValidateEventHandlerName(mei.eventName, mei.eventHandler);

            // this.FooEvent += new FooEventHandlerDelegate(this.OnFoo);
            CodeThisReferenceExpression ctre = new CodeThisReferenceExpression();
            CodeStatement csEvent = AddCLREvent(_ccRoot, ctre, mei);

            Debug.Assert(_ccRoot == (_codeContexts.Peek() as CodeContextRoot));
            _ccRoot.EnsureInitializeComponentFn.Statements.Add(csEvent);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:12,代码来源:MarkupCompiler.cs


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