/// <summary>
        /// Applies the decorator to the extended CodeDom tree.
        /// </summary>
        /// <param name="code">The extended CodeDom tree.</param>
        /// <param name="options">The custom code generation options.</param>
        public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
        {
            foreach (CodeTypeExtension dataContract in code.DataContracts)
            {
                foreach (CodeTypeMemberExtension memberExtension in dataContract.Properties)
                {
                    CodeMemberProperty property = memberExtension.ExtendedObject as CodeMemberProperty;
                    if (property == null)
                    {
                        continue;
                    }

                    CodeMemberProperty specifiedProperty = FindMatchingSpecifiedProperty(dataContract, property.Name);

                    if (specifiedProperty == null)
                    {
                        continue;
                    }

                    // Change the Statements of set part of the property; add a statement to set "this.____Specified = true;"
                    CodeStatement specifiedPropertySetTrueStatement = new CodeAssignStatement(
                        new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), specifiedProperty.Name),
                        new CodePrimitiveExpression(true));
                    property.SetStatements.Add(specifiedPropertySetTrueStatement);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Applies the decorator to the extended CodeDom tree.
        /// </summary>
        /// <param name="code">The extended CodeDom tree.</param>
        /// <param name="options">The custom code generation options.</param>
        public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
        {
            if (!options.FormatSoapActions)
            {
                return;
            }

            foreach (CodeTypeExtension serviceContract in code.ServiceContracts)
            {
                CodeAttributeDeclaration serviceContractAttribute = serviceContract.FindAttribute("System.ServiceModel.ServiceContractAttribute");
                if (serviceContractAttribute == null)
                {
                    continue;
                }

                CodeAttributeArgument namespaceArgument = serviceContractAttribute.FindArgument("Namespace");
                if (namespaceArgument == null)
                {
                    continue;
                }

                string serviceNamespace = (string)((CodePrimitiveExpression)namespaceArgument.Value).Value;
                string serviceName      = serviceContract.ExtendedObject.Name;

                UpdateActions(serviceNamespace, serviceName, serviceContract);
            }
        }
        /// <summary>
        /// Decorates the specified code.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="options">The options.</param>
        public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
        {
            // Get the substitution groups that are in different schema namespaces

            GenerateSubstGroupMap();

            GenerateSchemaTypeElementMap(_metadataSet);

            DecorateCodeNamespace(code.CodeNamespace);
        }
Example #4
0
        /// <summary>
        /// Applies the decorator to the extended CodeDom tree.
        /// </summary>
        /// <param name="code">The extended CodeDom tree.</param>
        /// <param name="options">The custom code generation options.</param>
        public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
        {
            if (!options.VirtualProperties) return;

            foreach (CodeTypeMemberExtension memberExtension in code.DataContracts.SelectMany(dataContract => dataContract.Properties))
            {
                CodeMemberProperty property = memberExtension.ExtendedObject as CodeMemberProperty;
                if (property != null)
                {
                    property.Attributes = MemberAttributes.Public;
                }
            }
        }
Example #5
0
 /// <summary>
 /// Decorates the specified code.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="options">The options.</param>
 public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
 {
     if (options.GenerateService && options.GenerateSvcFile)
     {
         foreach (CodeTypeExtension type in code.ServiceTypes)
         {
             string fqTypeName = GetFullyQulifiedTypeName(options, type.ExtendedObject.Name);
             string content = string.Format("<%@ ServiceHost Service=\"{0}\" %>", fqTypeName);
             string filename = string.Format("{0}.svc", type.ExtendedObject.Name);
             TextFile svcFile = new TextFile(filename, content);
             code.TextFiles.Add(svcFile);
         }
     }
 }
Example #6
0
 /// <summary>
 /// Decorates the specified code.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="options">The options.</param>
 public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
 {
     if (options.GenerateService && options.GenerateSvcFile)
     {
         foreach (CodeTypeExtension type in code.ServiceTypes)
         {
             string   fqTypeName = string.Format("{0}.{1}", options.ClrNamespace, type.ExtendedObject.Name);
             string   content    = string.Format("<%@ ServiceHost Service=\"{0}\" %>", fqTypeName);
             string   filename   = string.Format("{0}.svc", type.ExtendedObject.Name);
             TextFile svcFile    = new TextFile(filename, content);
             code.TextFiles.Add(svcFile);
         }
     }
 }
Example #7
0
        /// <summary>
        /// Applies the decorator to the extended CodeDom tree.
        /// </summary>
        /// <param name="code">The extended CodeDom tree.</param>
        /// <param name="options">The custom code generation options.</param>
        public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
        {
            if (!options.VirtualProperties)
            {
                return;
            }

            foreach (CodeTypeMemberExtension memberExtension in code.DataContracts.SelectMany(dataContract => dataContract.Properties))
            {
                CodeMemberProperty property = memberExtension.ExtendedObject as CodeMemberProperty;
                if (property != null)
                {
                    property.Attributes = MemberAttributes.Public;
                }
            }
        }
Example #8
0
        /// <summary>
        /// Applies the decorator to the extended CodeDom tree.
        /// </summary>
        /// <param name="code">The extended CodeDom tree.</param>
        /// <param name="options">The custom code generation options.</param>
        public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
        {
            if (!options.FormatSoapActions) return;

            foreach (CodeTypeExtension serviceContract in code.ServiceContracts)
            {
                CodeAttributeDeclaration serviceContractAttribute = serviceContract.FindAttribute("System.ServiceModel.ServiceContractAttribute");
                if (serviceContractAttribute == null) continue;

                CodeAttributeArgument namespaceArgument = serviceContractAttribute.FindArgument("Namespace");
                if (namespaceArgument == null) continue;

                string serviceNamespace = (string)((CodePrimitiveExpression)namespaceArgument.Value).Value;
                string serviceName = serviceContract.ExtendedObject.Name;

                UpdateActions(serviceNamespace, serviceName, serviceContract);
            }
        }
        /// <summary>
        /// Applies the decorator to the extended CodeDom tree.
        /// </summary>
        /// <param name="code">The extended CodeDom tree.</param>
        /// <param name="options">The custom code generation options.</param>
        public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
        {
            foreach (CodeTypeExtension dataContract in code.DataContracts)
            {
                foreach (CodeTypeMemberExtension memberExtension in dataContract.Properties)
                {
                    CodeMemberProperty property = memberExtension.ExtendedObject as CodeMemberProperty;
                    if (property == null) continue;

                    CodeMemberProperty specifiedProperty = FindMatchingSpecifiedProperty(dataContract, property.Name);

                    if (specifiedProperty == null) continue;

                    // Change the Statements of set part of the property; add a statement to set "this.____Specified = true;"
                    CodeStatement specifiedPropertySetTrueStatement = new CodeAssignStatement(
                        new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), specifiedProperty.Name),
                        new CodePrimitiveExpression(true));
                    property.SetStatements.Add(specifiedPropertySetTrueStatement);
                }
            }
        }
Example #10
0
 private string GetFullyQulifiedTypeName(CustomCodeGenerationOptions options, string typeName)
 {
     return (options.Language == CodeLanguage.VisualBasic)
         ? string.Format("{0}.{1}.{2}", options.ProjectName, options.ClrNamespace, typeName)
         : string.Format("{0}.{1}", options.ClrNamespace, typeName);
 }
 /// <summary>
 /// Decorates the specified code.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="options">The options.</param>
 public void Decorate(ExtendedCodeDomTree code, CustomCodeGenerationOptions options)
 {
     DecorateCodeNamespace(code.CodeNamespace);
 }
Example #12
0
 private string GetFullyQulifiedTypeName(CustomCodeGenerationOptions options, string typeName)
 {
     return((options.Language == CodeLanguage.VisualBasic)
                         ? string.Format("{0}.{1}.{2}", options.ProjectName, options.ClrNamespace, typeName)
                         : string.Format("{0}.{1}", options.ClrNamespace, typeName));
 }