Esempio n. 1
0
 public System.CodeDom.CodeTypeDeclaration ProcessImportedType(
     System.CodeDom.CodeTypeDeclaration typeDeclaration,
     System.CodeDom.CodeCompileUnit compileUnit)
 {
     // Console.WriteLine("ProcessImportedType invoked")
     // Not used in this sample.
     // You could use this method to construct an entirely new CLR
     // type when a certain type is imported, or modify a
     // generated type in some way.
     return(typeDeclaration);
 }
Esempio n. 2
0
		} // end private void BuildOnInitMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
		
		/// <summary>
		/// Build the code-behind InitializeComponent method.
		/// </summary>
		/// <param name="typeDeclaration"></param>
		private void BuildInitializeComponentMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
		{
			System.CodeDom.CodeMemberMethod codeMethodInitializeComponent;
			System.CodeDom.CodeAttachEventStatement attachEventStatement;
			codeMethodInitializeComponent = new System.CodeDom.CodeMemberMethod();
			codeMethodInitializeComponent.Name = "InitializeComponent";
			attachEventStatement = new System.CodeDom.CodeAttachEventStatement();
			attachEventStatement.Event = new System.CodeDom.CodeEventReferenceExpression(new System.CodeDom.CodeThisReferenceExpression(), "Load");
			attachEventStatement.Listener = new System.CodeDom.CodeDelegateCreateExpression(new System.CodeDom.CodeTypeReference(typeof(System.EventHandler)), new System.CodeDom.CodeThisReferenceExpression(), "Page_Load");
			codeMethodInitializeComponent.Statements.Add(attachEventStatement);
			typeDeclaration.Members.Add(codeMethodInitializeComponent);
		} // end private void BuildInitializeComponentMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
Esempio n. 3
0
 public void SetUp()
 {
     this.codeNamespace        = new System.CodeDom.CodeNamespace();
     this.testClassDeclaration = new System.CodeDom.CodeTypeDeclaration();
     this.typeMember           = new System.CodeDom.CodeTypeMember();
     this.buildData            = new NStub.CSharp.ObjectGeneration.BuildDataDictionary();
     this.mocks       = new MockRepository();
     this.builderData = this.mocks.StrictMock <IBuilderData>();
     this.buildData.AddDataItem("CAT", "TheKey", builderData);
     this.setUpTearDownContext = this.mocks.StrictMock <NStub.CSharp.BuildContext.ISetupAndTearDownContext>();
     this.testObject           = this.mocks.Stub <MemberBuildContextBase>(this.codeNamespace, this.testClassDeclaration, this.typeMember, this.buildData, this.setUpTearDownContext);
 }
Esempio n. 4
0
 public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
 {
     if (element == mCtrlClassLinkHandle_Out)
     {
         if (mCtrlClassLinkHandle_In.HasLink)
         {
             if (!mCtrlClassLinkHandle_In.GetLinkedObject(0, true).IsOnlyReturnValue)
             {
                 await mCtrlClassLinkHandle_In.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlClassLinkHandle_In.GetLinkedPinControl(0, true), context);
             }
         }
     }
 }
Esempio n. 5
0
		} // end private void GenerateFields(System.CodeDom.CodeTypeDeclaration typeDeclaration)
		
		/// <summary>
		/// Build the code-behind Page_Load method.
		/// </summary>
		private void BuildPageLoadMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
		{
			System.CodeDom.CodeMemberMethod codeMethodPageLoad;
			System.CodeDom.CodeParameterDeclarationExpression codeParameterExpression;
			// Add Page_Load method
			codeMethodPageLoad = new System.CodeDom.CodeMemberMethod();
			codeMethodPageLoad.Name = "Page_Load";
			// Add sender parameter
			codeParameterExpression = new System.CodeDom.CodeParameterDeclarationExpression(typeof(object), "sender");
			codeMethodPageLoad.Parameters.Add(codeParameterExpression);
			// Add eventargs parameter
			codeParameterExpression = new System.CodeDom.CodeParameterDeclarationExpression(typeof(System.EventArgs), "e");
			codeMethodPageLoad.Parameters.Add(codeParameterExpression);
			typeDeclaration.Members.Add(codeMethodPageLoad);
		} // end private void BuildPageLoadMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
Esempio n. 6
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var codeSC = codeStatementCollection;

            foreach (ConditionControl cc in mChildNodes)
            {
                await cc.GCode_CodeDom_GenerateCode(codeClass, codeSC, null, context);

                codeSC = cc.ElseStatementCollection;
            }

            if (mCtrlMethodLink_False.HasLink)
            {
                await mCtrlMethodLink_False.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeSC, mCtrlMethodLink_False.GetLinkedPinControl(0, false), context);
            }
        }
Esempio n. 7
0
		} // end private void BuildPageLoadMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
		
		/// <summary>
		/// Build the code-behind OnInit method.
		/// </summary>
		/// <param name="typeDeclaration"></param>
		private void BuildOnInitMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
		{
			System.CodeDom.CodeMemberMethod codeMethodOnInit;
			System.CodeDom.CodeMethodInvokeExpression codeMethodInvoke;
			System.CodeDom.CodeParameterDeclarationExpression codeParameterExpression;
			codeMethodOnInit = new System.CodeDom.CodeMemberMethod();
			codeMethodOnInit.Name = "OnInit";
			codeMethodOnInit.Attributes = System.CodeDom.MemberAttributes.Family | System.CodeDom.MemberAttributes.Override;
			codeParameterExpression = new System.CodeDom.CodeParameterDeclarationExpression(typeof(System.EventArgs), "e");
			codeMethodOnInit.Parameters.Add(codeParameterExpression);
			codeMethodInvoke = new System.CodeDom.CodeMethodInvokeExpression(new System.CodeDom.CodeThisReferenceExpression(), "InitializeComponent");
			codeMethodOnInit.Statements.Add(codeMethodInvoke);
			codeMethodInvoke = new System.CodeDom.CodeMethodInvokeExpression(new System.CodeDom.CodeBaseReferenceExpression(), "OnInit", new System.CodeDom.CodeExpression[]{new System.CodeDom.CodeFieldReferenceExpression(null, "e")});
			codeMethodOnInit.Statements.Add(codeMethodInvoke);
			typeDeclaration.Members.Add(codeMethodOnInit);
		} // end private void BuildOnInitMethod(System.CodeDom.CodeTypeDeclaration typeDeclaration)
Esempio n. 8
0
        public override void GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, FrameworkElement element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == UpLink || element == null)
            {
                foreach (MethodControl mc in mChildNodes)
                {
                    CodeGenerateSystem.Base.LinkObjInfo info = mc.GetLinkObjInfo(mc.methodEll);
                    if (!info.HasLink)
                    {
                        continue;
                    }

                    info.GetLinkObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, info.GetLinkElement(0, true), context);
                }
            }
        }
Esempio n. 9
0
		} // end private string BuildCodeBehind()
		
		/// <summary>
		/// Generate the declaration for all WebControls that are stored in the Arraylist _WebControls.
		/// </summary>
		/// <param name="typeDeclaration"></param>
		private void GenerateFields(System.CodeDom.CodeTypeDeclaration typeDeclaration)
		{
			System.CodeDom.CodeMemberField memberField;
			
			foreach(System.Web.UI.Control webControl in this._WebControls)
			{
				memberField = new System.CodeDom.CodeMemberField(webControl.GetType(), webControl.ID);
				memberField.Attributes = System.CodeDom.MemberAttributes.Family;
				typeDeclaration.Members.Add(memberField);
			} // end foreach(System.Web.UI.WebControls.WebControl webControl in this._WebControls)
			
			// The following placeholder declaration is required by the Web Form Designer.
			// it is only necessary for Vb.Net
			if(this._SourceLanguage == suite4.net.WinForms2WebForms.SourceLanguages.VbNet)
			{
				memberField = new System.CodeDom.CodeMemberField(typeof(System.Object), "designerPlaceholderDeclaration");
				memberField.Attributes = System.CodeDom.MemberAttributes.Family;
				typeDeclaration.Members.Add(memberField);
			} // end if(this._SourceLanguage == suite4.net.WinForms2WebForms.SourceLanguages.VbNet)
		} // end private void GenerateFields(System.CodeDom.CodeTypeDeclaration typeDeclaration)
        private void TestGenerate <G>(string language,
                                      out int hr,
                                      out IntPtr[] fileContents,
                                      out uint bytesOutput,
                                      out System.CodeDom.CodeCompileUnit compileUnit,
                                      out System.CodeDom.CodeTypeDeclaration typeDeclaration)
            where G : Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGeneratorBase, new()
        {
            SettingsSingleFileGeneratorSite site = new SettingsSingleFileGeneratorSite(language);
            string inputFile = site.DefaultSettingsFilePath;

            Mock <G> generatorMock = new Mock <G>();

            System.CodeDom.CodeCompileUnit     actualCompileUnit     = null;
            System.CodeDom.CodeTypeDeclaration actualTypeDeclaration = null;

            generatorMock.Implement("GetProjectRootNamespace", "MyLittleNamespace");
            generatorMock.Implement("AddRequiredReferences", new object[] { (Shell.Interop.IVsGeneratorProgress)null });
            generatorMock.Implement("OnCompileUnitCreated",
                                    new object[] { MockConstraint.IsAnything <System.CodeDom.CodeCompileUnit>(), MockConstraint.IsAnything <System.CodeDom.CodeTypeDeclaration>() },
                                    delegate(object obj, System.Reflection.MethodInfo method, object[] arguments)
            {
                actualCompileUnit     = (System.CodeDom.CodeCompileUnit)arguments[0];
                actualTypeDeclaration = (System.CodeDom.CodeTypeDeclaration)arguments[1];
                return(null);
            });

            IVsSingleFileGenerator generator = generatorMock.Instance;

            ((Microsoft.VisualStudio.OLE.Interop.IObjectWithSite)generator).SetSite(site);

            fileContents = new IntPtr[] { new IntPtr() };
            bytesOutput  = 0;
            hr           = generator.Generate(inputFile, "", "", fileContents, out bytesOutput, null);

            compileUnit     = actualCompileUnit;
            typeDeclaration = actualTypeDeclaration;
        }
 public ServiceContractGenerationContext(ServiceContractGenerator serviceContractGenerator, ContractDescription contract, System.CodeDom.CodeTypeDeclaration contractType)
 {
 }
Esempio n. 12
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == mCtrlMethodLink_Pre)
            {
                // 正常逻辑执行代码
                if (mCtrlValueElement.HasLink && mCtrlSetValueElement.HasLink)
                {
                    var codeAss = new System.CodeDom.CodeAssignStatement();
                    codeAss.Left = mCtrlValueElement.GetLinkedObject(0, false).GCode_CodeDom_GetValue(mCtrlValueElement.GetLinkedPinControl(0, false), context);

                    if (!mCtrlSetValueElement.GetLinkedObject(0, true).IsOnlyReturnValue)
                    {
                        await mCtrlSetValueElement.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlSetValueElement.GetLinkedPinControl(0, true), context);
                    }

                    string valueTypeStr = mCtrlSetValueElement.GetLinkedObject(0, true).GCode_GetTypeString(mCtrlSetValueElement.GetLinkedPinControl(0, true), context);
                    var    valueType    = mCtrlSetValueElement.GetLinkedObject(0, true).GCode_GetType(mCtrlSetValueElement.GetLinkedPinControl(0, true), context);
                    var    tempValName  = "assign_" + EngineNS.Editor.Assist.GetValuedGUIDString(this.Id);
                    if (!context.Method.Statements.Contains(mVariableDeclarationStatement))
                    {
                        var type = EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueTypeStr);
                        mVariableDeclarationStatement = new System.CodeDom.CodeVariableDeclarationStatement(
                            valueTypeStr,
                            tempValName,
                            CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(type));
                        context.Method.Statements.Insert(0, mVariableDeclarationStatement);
                    }
                    var assignStatement = new System.CodeDom.CodeAssignStatement(
                        new System.CodeDom.CodeVariableReferenceExpression(tempValName),
                        mCtrlSetValueElement.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlSetValueElement.GetLinkedPinControl(0, true), context));
                    codeStatementCollection.Add(assignStatement);

                    // 收集用于调试的数据的代码
                    var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);

                    CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlSetValueElement.GetLinkPinKeyName(),
                                                                           new System.CodeDom.CodeVariableReferenceExpression(tempValName),
                                                                           valueTypeStr, context);
                    // 调试用代码
                    var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                    // 设置数据代码
                    CodeDomNode.BreakPoint.GetSetDataValueCodeStatement(breakCondStatement.TrueStatements, mCtrlSetValueElement.GetLinkPinKeyName(),
                                                                        new System.CodeDom.CodeVariableReferenceExpression(tempValName),
                                                                        valueType);
                    if (!mCtrlValueElement.GetLinkedObject(0, false).IsOnlyReturnValue)
                    {
                        await mCtrlValueElement.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, element, context);
                    }
                    codeAss.Right = new CodeGenerateSystem.CodeDom.CodeCastExpression(mCtrlValueElement.GetLinkedObject(0, false).GCode_GetType(mCtrlValueElement.GetLinkedPinControl(0, false), context),
                                                                                      new System.CodeDom.CodeVariableReferenceExpression(tempValName));

                    codeStatementCollection.Add(codeAss);

                    // 收集结果代码
                    CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlValueElement.GetLinkPinKeyName(),
                                                                           mCtrlValueElement.GetLinkedObject(0, false).GCode_CodeDom_GetValue(mCtrlValueElement.GetLinkedPinControl(0, false), context),
                                                                           mCtrlValueElement.GetLinkedObject(0, false).GCode_GetTypeString(mCtrlValueElement.GetLinkedPinControl(0, false), context), context);
                    CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
                }

                if (context.GenerateNext)
                {
                    if (mCtrlMethodLink_Next.HasLink)
                    {
                        await mCtrlMethodLink_Next.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlMethodLink_Next.GetLinkedPinControl(0, false), context);
                    }
                }
            }
        }
Esempio n. 13
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (!mCtrlValue1.HasLink)
            {
                return;
            }

            // 计算结果
            if (!context.Method.Statements.Contains(mVariableDeclaration))
            {
                var valueType = GCode_GetTypeString(mCtrlResultLink, context);
                var type      = EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueType);
                mVariableDeclaration = new System.CodeDom.CodeVariableDeclarationStatement(
                    valueType,
                    GCode_GetValueName(mCtrlResultLink, context),
                    CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(type));
                context.Method.Statements.Insert(0, mVariableDeclaration);
            }

            // 参数1
            var linkObj1 = mCtrlValue1.GetLinkedObject(0, true);
            var linkElm1 = mCtrlValue1.GetLinkedPinControl(0, true);

            if (!linkObj1.IsOnlyReturnValue)
            {
                await linkObj1.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, linkElm1, context);
            }

            System.CodeDom.CodeExpression valueExp1 = null;
            var valueType1    = typeof(bool);
            var valueType1Str = valueType1.FullName;

            if (linkObj1.Pin_UseOrigionParamName(linkElm1))
            {
                if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(false));
                    valueExp1 = condition;
                }
                else if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    valueExp1 = condition;
                }
            }
            else
            {
                var tempValueName1 = "InverterControl_" + EngineNS.Editor.Assist.GetValuedGUIDString(this.Id) + "_Value1";
                if (!context.Method.Statements.Contains(mVariableDeclarationStatement_Value1))
                {
                    mVariableDeclarationStatement_Value1 = new System.CodeDom.CodeVariableDeclarationStatement(
                        valueType1Str,
                        tempValueName1,
                        CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueType1Str)));
                    context.Method.Statements.Insert(0, mVariableDeclarationStatement_Value1);
                }


                if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(false));
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName1),
                                                    condition));
                }
                else if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName1),
                                                    condition));
                }
                valueExp1 = new System.CodeDom.CodeVariableReferenceExpression(tempValueName1);
            }
            //var valueExp1 = linkObj1.GCode_CodeDom_GetValue(linkElm1, context);

            // 收集用于调试的数据的代码
            var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);

            if (linkObj1.Pin_UseOrigionParamName(linkElm1))
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1Str, context);
            }
            else
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1Str, context);
            }
            // 调试用代码
            var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);

            // 设置数据代码
            if (!linkObj1.Pin_UseOrigionParamName(this.mCtrlValue1))
            {
                CodeDomNode.BreakPoint.GetSetDataValueCodeStatement(breakCondStatement.TrueStatements, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1);
            }
            CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);

            if (element == mCtrlResultLink)
            {
                // 创建结果并赋值
                if (mAssignStatement == null)
                {
                    mAssignStatement      = new System.CodeDom.CodeAssignStatement();
                    mAssignStatement.Left = new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context));
                }
                mAssignStatement.Right = valueExp1;

                if (codeStatementCollection.Contains(mAssignStatement))
                {
                    //var assign = new System.CodeDom.CodeAssignStatement(GCode_CodeDom_GetValue(null) , InverterControlExp);
                    //codeStatementCollection.Add(assign);
                }
                else
                {
                    codeStatementCollection.Add(mAssignStatement);
                }

                debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlResultLink.GetLinkPinKeyName(), GCode_CodeDom_GetValue(mCtrlResultLink, context), GCode_GetTypeString(mCtrlResultLink, context), context);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
            }
        }
Esempio n. 14
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            MethodInvokeParameterControl retCtrl = null;
            Dictionary <CodeGenerateSystem.Base.BaseNodeControl, System.CodeDom.CodeExpression> paramCodeExps = new Dictionary <CodeGenerateSystem.Base.BaseNodeControl, System.CodeDom.CodeExpression>();
            var rcParam = CSParam as ReturnCustomConstructParam;

            if (rcParam.MethodInfo.IsAsync)
            {
                // 异步不能有out,只能有一个返回值
                if (mChildNodes.Count == 1)
                {
                    retCtrl = mChildNodes[0] as MethodInvokeParameterControl;
                }
            }
            else
            {
                foreach (var paramNode in mChildNodes)
                {
                    if (paramNode is MethodInvokeParameterControl)
                    {
                        var pm    = paramNode as MethodInvokeParameterControl;
                        var param = pm.CSParam as MethodInvokeParameterControl.MethodInvokeParameterConstructionParams;
                        if (param.ParamInfo.ParamName == "Return")
                        {
                            retCtrl = pm;
                            continue;
                        }
                        if (pm.HasLink())
                        {
                            await pm.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, pm.ParamPin, context);

                            var exp = new CodeGenerateSystem.CodeDom.CodeCastExpression(param.ParamInfo.ParameterType, pm.GCode_CodeDom_GetValue(pm.ParamPin, context));
                            paramCodeExps[paramNode] = exp;
                            codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                            new System.CodeDom.CodeVariableReferenceExpression(param.ParamInfo.ParamName),
                                                            exp));
                        }
                        else if (mTemplateClassInstance != null)
                        {
                            var    proInfo = mTemplateClassInstance.GetType().GetProperty(param.ParamInfo.ParamName);
                            object proValue;
                            if (proInfo == null)
                            {
                                proValue = CodeGenerateSystem.Program.GetDefaultValueFromType(param.ParamInfo.ParameterType);
                            }
                            else
                            {
                                proValue = proInfo.GetValue(mTemplateClassInstance);
                            }
                            var valueExp = Program.GetValueCode(codeStatementCollection, param.ParamInfo.ParameterType, proValue);
                            paramCodeExps[paramNode] = valueExp;
                            codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(new System.CodeDom.CodeVariableReferenceExpression(param.ParamInfo.ParamName), valueExp));
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }

            if (retCtrl != null)
            {
                if (retCtrl.HasLink())
                {
                    await retCtrl.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, retCtrl.ParamPin, context);
                }

                System.CodeDom.CodeExpression retExp = null;
                if (retCtrl.HasLink())
                {
                    var retStatement = new System.CodeDom.CodeMethodReturnStatement();
                    retExp = retCtrl.GCode_CodeDom_GetValue(retCtrl.ParamPin, context);
                    paramCodeExps[retCtrl] = retExp;
                }
                else if (mTemplateClassInstance != null)
                {
                    var    param   = retCtrl.CSParam as MethodInvokeParameterControl.MethodInvokeParameterConstructionParams;
                    var    proInfo = mTemplateClassInstance.GetType().GetProperty(param.ParamInfo.ParamName);
                    object proValue;
                    if (proInfo == null)
                    {
                        proValue = CodeGenerateSystem.Program.GetDefaultValueFromType(param.ParamInfo.ParameterType);
                    }
                    else
                    {
                        proValue = proInfo.GetValue(mTemplateClassInstance);
                    }
                    retExp = Program.GetValueCode(codeStatementCollection, param.ParamInfo.ParameterType, proValue);
                    paramCodeExps[retCtrl] = retExp;
                }

                #region Debug
                var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                foreach (var paramNode in mChildNodes)
                {
                    if (paramNode is MethodInvokeParameterControl)
                    {
                        var pm = paramNode as MethodInvokeParameterControl;
                        System.CodeDom.CodeExpression exp;
                        if (paramCodeExps.TryGetValue(paramNode, out exp))
                        {
                            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, pm.ParamPin.GetLinkPinKeyName(), exp, pm.GCode_GetTypeString(pm.ParamPin, context), context);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException("未实现");
                    }
                }
                var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
                #endregion

                codeStatementCollection.Add(new System.CodeDom.CodeMethodReturnStatement(retExp));
            }
            else
            {
                #region Debug
                var debugCodes         = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
                #endregion
                codeStatementCollection.Add(new System.CodeDom.CodeMethodReturnStatement());
            }
        }
Esempio n. 15
0
 public override void ProcessGeneratedCode(System.CodeDom.CodeCompileUnit codeCompileUnit, System.CodeDom.CodeNamespace generatedNamespace, System.CodeDom.CodeTypeDeclaration generatedClass, System.CodeDom.CodeMemberMethod executeMethod)
 {
     base.ProcessGeneratedCode(codeCompileUnit, generatedNamespace, generatedClass, executeMethod);
 }
Esempio n. 16
0
 public void SetUp()
 {
     this.codeNamespace = new System.CodeDom.CodeNamespace();
     this.testClassDeclaration = new System.CodeDom.CodeTypeDeclaration();
     this.typeMember = new System.CodeDom.CodeTypeMember();
     this.buildData = new NStub.CSharp.ObjectGeneration.BuildDataDictionary();
     this.mocks = new MockRepository();
     this.builderData = this.mocks.StrictMock<IBuilderData>();
     this.buildData.AddDataItem("CAT", "TheKey", builderData);
     this.setUpTearDownContext = this.mocks.StrictMock<NStub.CSharp.BuildContext.ISetupAndTearDownContext>();
     this.testObject = this.mocks.Stub<MemberBuildContextBase>(this.codeNamespace, this.testClassDeclaration, this.typeMember, this.buildData, this.setUpTearDownContext);
 }
Esempio n. 17
0
 void System.CodeDom.Compiler.ICodeGenerator.GenerateCodeFromType(System.CodeDom.CodeTypeDeclaration e, TextWriter w, CodeGeneratorOptions o)
 {
 }
Esempio n. 18
0
 System.CodeDom.CodeTypeDeclaration IDataContractSurrogate.ProcessImportedType(System.CodeDom.CodeTypeDeclaration typeDeclaration, System.CodeDom.CodeCompileUnit compileUnit)
 {
     if (prevSurrogate != null)
     {
         return(prevSurrogate.ProcessImportedType(typeDeclaration, compileUnit));
     }
     return(typeDeclaration);
 }
 public System.CodeDom.CodeTypeDeclaration ProcessImportedType(System.CodeDom.CodeTypeDeclaration typeDeclaration, System.CodeDom.CodeCompileUnit compileUnit)
 {
     throw new NotImplementedException();
 }
 public virtual void GenerateCodeFromType(System.CodeDom.CodeTypeDeclaration codeType, System.IO.TextWriter writer, System.CodeDom.Compiler.CodeGeneratorOptions options)
 {
 }
Esempio n. 21
0
		} // end private void AddProperties(System.Windows.Forms.Control control, System.Text.StringBuilder stringBuilder)

		/// <summary>
		/// The method builds the CodeDom and returns a string with the source.
		/// </summary>
		/// <returns></returns>
		private string BuildCodeBehind()
		{
			string resultString;
			System.IO.StringWriter stringWriter;
			System.CodeDom.CodeNamespace codeUsing;
			System.CodeDom.CodeNamespace codeNamespace;
			System.CodeDom.CodeCompileUnit codeCompileUnit;
			System.CodeDom.CodeTypeDeclaration codeTypeDeclaration;
			System.CodeDom.Compiler.CodeDomProvider codeDomProvider = null;
			System.CodeDom.Compiler.CodeGeneratorOptions codeGeneratorOptions;
			// Initialize Header with namespace and using declarations
			codeCompileUnit = new System.CodeDom.CodeCompileUnit();
			codeUsing = new System.CodeDom.CodeNamespace();
			codeUsing.Imports.Add(new System.CodeDom.CodeNamespaceImport("System"));
			codeNamespace = new System.CodeDom.CodeNamespace(this._Namespace);
			// Initialize TypeDeclaration private declaration
			codeTypeDeclaration = new System.CodeDom.CodeTypeDeclaration(this._RootName);
			
			switch(this._AspxType)
			{
				case suite4.net.WinForms2WebForms.AspxTypes.Page :
					codeTypeDeclaration.BaseTypes.Add(typeof(System.Web.UI.Page));
					break;
				case suite4.net.WinForms2WebForms.AspxTypes.UserControl :
					codeTypeDeclaration.BaseTypes.Add(typeof(System.Web.UI.UserControl));
					break;
			} // end switch(this._AspxType)
			
			this.GenerateFields(codeTypeDeclaration);
			this.BuildOnInitMethod(codeTypeDeclaration);
			this.BuildPageLoadMethod(codeTypeDeclaration);
			this.BuildInitializeComponentMethod(codeTypeDeclaration);
			codeNamespace.Types.Add(codeTypeDeclaration);
			codeCompileUnit.Namespaces.Add(codeUsing);
			codeCompileUnit.Namespaces.Add(codeNamespace);
			
			switch(this._SourceLanguage)
			{
				case suite4.net.WinForms2WebForms.SourceLanguages.C_Sharp :
					codeDomProvider = new Microsoft.CSharp.CSharpCodeProvider();
					break;
				case suite4.net.WinForms2WebForms.SourceLanguages.VbNet :
					codeDomProvider = new Microsoft.VisualBasic.VBCodeProvider();
					break;
			} // end switch(this._SourceLanguage)
			
			if(codeDomProvider != null)
			{
				// init codeGeneratorOptions
				codeGeneratorOptions = new System.CodeDom.Compiler.CodeGeneratorOptions();
				codeGeneratorOptions.BlankLinesBetweenMembers = false;
				codeGeneratorOptions.BracingStyle = "C";
				codeGeneratorOptions.ElseOnClosing = true;
				codeGeneratorOptions.IndentString = "\t";
				stringWriter = new System.IO.StringWriter();
				codeDomProvider.CreateGenerator().GenerateCodeFromCompileUnit(codeCompileUnit, stringWriter, codeGeneratorOptions);
				resultString = stringWriter.ToString();
				stringWriter.Close();
				return resultString;
			} // end if(codeDomProvider != null)
			
			return null;
		} // end private string BuildCodeBehind()
Esempio n. 22
0
 public System.CodeDom.CodeTypeDeclaration ProcessImportedType(System.CodeDom.CodeTypeDeclaration typeDeclaration, System.CodeDom.CodeCompileUnit compileUnit)
 {
     // Not used in this sample.
     // We could use this method to construct an entirely new CLR type when a certain type is imported.
     return(typeDeclaration);
 }
 public virtual new void GenerateCodeFromType(System.CodeDom.CodeTypeDeclaration codeType, TextWriter writer, CodeGeneratorOptions options)
 {
 }
Esempio n. 24
0
 /// <summary>
 /// Create data contract attribute
 /// </summary>
 /// <param name="type">Code type declaration</param>
 /// <param name="schema">XML schema</param>
 protected override void CreateDataContractAttribute(System.CodeDom.CodeTypeDeclaration type, System.Xml.Schema.XmlSchema schema)
 {
     // No data contracts in the Net.20
 }
 // Methods
 public virtual object Deserialize(IDesignerSerializationManager manager, System.CodeDom.CodeTypeDeclaration declaration)
 {
 }
Esempio n. 26
0
 public virtual void ProcessGeneratedCode(System.CodeDom.CodeCompileUnit codeCompileUnit, System.CodeDom.CodeTypeDeclaration baseType, System.CodeDom.CodeTypeDeclaration derivedType, System.CodeDom.CodeMemberMethod buildMethod, System.CodeDom.CodeMemberMethod dataBindingMethod)
 {
 }
Esempio n. 27
0
 protected abstract void GenerateProperty(System.CodeDom.CodeMemberProperty e, System.CodeDom.CodeTypeDeclaration c);
 public System.CodeDom.CodeTypeDeclaration ProcessImportedType(System.CodeDom.CodeTypeDeclaration typeDeclaration, System.CodeDom.CodeCompileUnit compileUnit)
 {
     //not used
     return(typeDeclaration);
 }
Esempio n. 29
0
 protected abstract void GenerateTypeStart(System.CodeDom.CodeTypeDeclaration e);
Esempio n. 30
0
 public virtual System.CodeDom.CodeTypeDeclaration ProcessImportedType(System.CodeDom.CodeTypeDeclaration typeDeclaration, System.CodeDom.CodeCompileUnit compileUnit)
 {
     return(null);
 }
Esempio n. 31
0
 protected abstract void GenerateMethod(System.CodeDom.CodeMemberMethod e, System.CodeDom.CodeTypeDeclaration c);