Пример #1
0
        protected override void GenerateTransformCode(string directiveName, global::System.Text.StringBuilder codeBuffer, global::System.CodeDom.Compiler.CodeDomProvider languageProvider, global::System.Collections.Generic.IDictionary <string, string> requiresArguments, global::System.Collections.Generic.IDictionary <string, string> providesArguments)
        {
            if ((global::System.StringComparer.OrdinalIgnoreCase.Compare(directiveName, supportedDirectiveName) == 0))
            {
                if (languageProvider != null)
                {
                    // Create a field to store the model once it is loaded
                    global::System.CodeDom.CodeMemberField rootElement = new global::System.CodeDom.CodeMemberField();
                    rootElement.Name       = providesArguments[providesModelParameter].ToLower(global::System.Globalization.CultureInfo.InvariantCulture) + "Value";
                    rootElement.Type       = new global::System.CodeDom.CodeTypeReference(typeof(global::BizTalkMessaging.BizTalkMessagingModel));
                    rootElement.Attributes = global::System.CodeDom.MemberAttributes.Private;

                    // Create a property for the Model that delay-loads the model
                    global::System.CodeDom.CodeMemberProperty rootElementProperty = new global::System.CodeDom.CodeMemberProperty();
                    rootElementProperty.Name       = providesArguments[providesModelParameter];
                    rootElementProperty.Type       = new global::System.CodeDom.CodeTypeReference(typeof(global::BizTalkMessaging.BizTalkMessagingModel));
                    rootElementProperty.Attributes = global::System.CodeDom.MemberAttributes.Private;
                    rootElementProperty.HasSet     = false;
                    rootElementProperty.HasGet     = true;
                    rootElementProperty.GetStatements.Add(new global::System.CodeDom.CodeMethodReturnStatement(new global::System.CodeDom.CodeFieldReferenceExpression(new global::System.CodeDom.CodeThisReferenceExpression(), rootElement.Name)));

                    // Create a helper method for resolving relative paths
                    global::System.CodeDom.CodeMemberMethod resolver = null;
                    if (!this.oneTimeCodeGenerated && global::System.IO.File.Exists(this.Host.TemplateFile))
                    {
                        resolver            = new global::System.CodeDom.CodeMemberMethod();
                        resolver.Name       = "Convert" + "BizTalkMessagingModel" + "RelativePathToTemplateRelativePath";
                        resolver.ReturnType = new global::System.CodeDom.CodeTypeReference(typeof(string));
                        resolver.Parameters.Add(new global::System.CodeDom.CodeParameterDeclarationExpression(typeof(string), "path"));
                        resolver.Attributes = global::System.CodeDom.MemberAttributes.Public;
                        global::System.CodeDom.CodeVariableDeclarationStatement declaration = new global::System.CodeDom.CodeVariableDeclarationStatement(typeof(string), "modelPath", new global::System.CodeDom.CodePrimitiveExpression((string)(requiresArguments[requiresFileParameter])));
                        resolver.Statements.Add(declaration);
                        declaration = new global::System.CodeDom.CodeVariableDeclarationStatement(typeof(string), "templatePath", new global::System.CodeDom.CodePrimitiveExpression((string)(this.Host.TemplateFile)));
                        resolver.Statements.Add(declaration);
                        global::System.CodeDom.CodeMethodReturnStatement returnStatement = new global::System.CodeDom.CodeMethodReturnStatement(
                            new global::System.CodeDom.CodeMethodInvokeExpression(
                                new global::System.CodeDom.CodeMethodReferenceExpression(new global::System.CodeDom.CodeTypeReferenceExpression("Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation"), "ConvertModelRelativePathToTemplateRelativePath"),
                                new global::System.CodeDom.CodeVariableReferenceExpression("modelPath"),
                                new global::System.CodeDom.CodeVariableReferenceExpression("templatePath"),
                                new global::System.CodeDom.CodeVariableReferenceExpression("path")));
                        resolver.Statements.Add(returnStatement);
                    }

                    // Generate the actual code using the CodeDomProvider
                    global::System.CodeDom.Compiler.CodeGeneratorOptions options = new global::System.CodeDom.Compiler.CodeGeneratorOptions();
                    options.BlankLinesBetweenMembers = true;
                    options.IndentString             = "    ";
                    options.VerbatimOrder            = true;
                    options.BracingStyle             = "C";
                    using (global::System.IO.StringWriter writer = new global::System.IO.StringWriter(codeBuffer, global::System.Globalization.CultureInfo.InvariantCulture))
                    {
                        languageProvider.GenerateCodeFromMember(rootElement, writer, options);
                        languageProvider.GenerateCodeFromMember(rootElementProperty, writer, options);
                        if (resolver != null)
                        {
                            languageProvider.GenerateCodeFromMember(resolver, writer, options);
                        }
                    }
                    this.oneTimeCodeGenerated = true;
                }
            }
        }
Пример #2
0
		protected override void GenerateTransformCode(string directiveName, global::System.Text.StringBuilder codeBuffer, global::System.CodeDom.Compiler.CodeDomProvider languageProvider, global::System.Collections.Generic.IDictionary<string, string> requiresArguments, global::System.Collections.Generic.IDictionary<string, string> providesArguments)
		{
			if ((global::System.StringComparer.OrdinalIgnoreCase.Compare(directiveName, supportedDirectiveName) == 0))
			{
				if (languageProvider != null)
				{
					// Create a field to store the model once it is loaded
					global::System.CodeDom.CodeMemberField rootElement = new global::System.CodeDom.CodeMemberField();
					rootElement.Name = providesArguments[providesModelParameter].ToLower(global::System.Globalization.CultureInfo.InvariantCulture) + "Value";
					rootElement.Type = new global::System.CodeDom.CodeTypeReference(typeof(global::Architect.ScheduledTasks.Group));
					rootElement.Attributes = global::System.CodeDom.MemberAttributes.Private;
	
					// Create a property for the Model that delay-loads the model
					global::System.CodeDom.CodeMemberProperty rootElementProperty = new global::System.CodeDom.CodeMemberProperty();
					rootElementProperty.Name = providesArguments[providesModelParameter];
					rootElementProperty.Type = new global::System.CodeDom.CodeTypeReference(typeof(global::Architect.ScheduledTasks.Group));
					rootElementProperty.Attributes = global::System.CodeDom.MemberAttributes.Private;
					rootElementProperty.HasSet = false;
					rootElementProperty.HasGet = true;
					rootElementProperty.GetStatements.Add(new global::System.CodeDom.CodeMethodReturnStatement(new global::System.CodeDom.CodeFieldReferenceExpression(new global::System.CodeDom.CodeThisReferenceExpression(), rootElement.Name)));
	
					// Create a helper method for resolving relative paths
					global::System.CodeDom.CodeMemberMethod resolver = null;
					if (!this.oneTimeCodeGenerated && global::System.IO.File.Exists(this.Host.TemplateFile))
					{
						resolver = new global::System.CodeDom.CodeMemberMethod();
						resolver.Name = "Convert" + "Group" + "RelativePathToTemplateRelativePath";
						resolver.ReturnType = new global::System.CodeDom.CodeTypeReference(typeof(string));
						resolver.Parameters.Add(new global::System.CodeDom.CodeParameterDeclarationExpression(typeof(string), "path"));
						resolver.Attributes = global::System.CodeDom.MemberAttributes.Public;
						global::System.CodeDom.CodeVariableDeclarationStatement declaration = new global::System.CodeDom.CodeVariableDeclarationStatement(typeof(string), "modelPath", new global::System.CodeDom.CodePrimitiveExpression((string)(requiresArguments[requiresFileParameter])));
						resolver.Statements.Add(declaration);
						declaration = new global::System.CodeDom.CodeVariableDeclarationStatement(typeof(string), "templatePath", new global::System.CodeDom.CodePrimitiveExpression((string)(this.Host.TemplateFile)));
						resolver.Statements.Add(declaration);
						global::System.CodeDom.CodeMethodReturnStatement returnStatement = new global::System.CodeDom.CodeMethodReturnStatement(
							new global::System.CodeDom.CodeMethodInvokeExpression(
								new global::System.CodeDom.CodeMethodReferenceExpression(new global::System.CodeDom.CodeTypeReferenceExpression("Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation"), "ConvertModelRelativePathToTemplateRelativePath"),
								new global::System.CodeDom.CodeVariableReferenceExpression("modelPath"),
								new global::System.CodeDom.CodeVariableReferenceExpression("templatePath"),
								new global::System.CodeDom.CodeVariableReferenceExpression("path")));
						resolver.Statements.Add(returnStatement);
					}
	
					// Generate the actual code using the CodeDomProvider
					global::System.CodeDom.Compiler.CodeGeneratorOptions options = new global::System.CodeDom.Compiler.CodeGeneratorOptions();
					options.BlankLinesBetweenMembers = true;
					options.IndentString = "    ";
					options.VerbatimOrder = true;
					options.BracingStyle = "C";
					using (global::System.IO.StringWriter writer = new global::System.IO.StringWriter(codeBuffer, global::System.Globalization.CultureInfo.InvariantCulture))
					{
						languageProvider.GenerateCodeFromMember(rootElement, writer, options);
						languageProvider.GenerateCodeFromMember(rootElementProperty, writer, options);
						if (resolver != null)
						{
							languageProvider.GenerateCodeFromMember(resolver, writer, options);
						}
					}
					this.oneTimeCodeGenerated = true;
				}
			}
		}