Exemplo n.º 1
0
        void AddStateForDataContractSerializerImport(WsdlImporter importer)
        {
            XsdDataContractImporter xsdDataContractImporter =
                new XsdDataContractImporter(this.codeCompileUnit);

            xsdDataContractImporter.Options = new ImportOptions();
            xsdDataContractImporter.Options.ImportXmlType =
                (this.options.FormatMode ==
                 DynamicProxyFactoryOptions.FormatModeOptions.DataContractSerializer);

            xsdDataContractImporter.Options.CodeProvider = this.codeDomProvider;
            importer.State.Add(typeof(XsdDataContractImporter),
                               xsdDataContractImporter);

            foreach (IWsdlImportExtension importExtension in importer.WsdlImportExtensions)
            {
                DataContractSerializerMessageContractImporter dcConverter =
                    importExtension as DataContractSerializerMessageContractImporter;

                if (dcConverter != null)
                {
                    if (this.options.FormatMode ==
                        DynamicProxyFactoryOptions.FormatModeOptions.XmlSerializer)
                    {
                        dcConverter.Enabled = false;
                    }
                    else
                    {
                        dcConverter.Enabled = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Remove(s) DataContract serialization extension(s). Because we only generate XmlSerializer serializable types in
 /// order to support broader set of XSD constructs.
 /// </summary>
 private void RemoveDataContractSerializerExtension()
 {
     for (int i = 0; i < wsdlImporter.WsdlImportExtensions.Count; i++)
     {
         IWsdlImportExtension iext = wsdlImporter.WsdlImportExtensions[i];
         DataContractSerializerMessageContractImporter dcsmci = iext as DataContractSerializerMessageContractImporter;
         if (dcsmci != null)
         {
             wsdlImporter.WsdlImportExtensions.RemoveAt(i);
             break;
         }
     }
 }
        private static void AddStateForDataContractSerializerImport(WsdlImporter importer, MetadataImporterSerializerFormatMode formatMode, CodeCompileUnit codeCompileUnit, CodeDomProvider codeDomProvider)
        {
            XsdDataContractImporter xsdDataContractImporter = new XsdDataContractImporter(codeCompileUnit);
            xsdDataContractImporter.Options = CreateDataContractImportOptions(formatMode, codeDomProvider);
            importer.State.Add(typeof(XsdDataContractImporter), xsdDataContractImporter);

            for (int i = 0; i < importer.WsdlImportExtensions.Count; i++)
            {
                IWsdlImportExtension importExtension = importer.WsdlImportExtensions[i];
                DataContractSerializerMessageContractImporter dataContractSerializerMessageContractImporter = importExtension as DataContractSerializerMessageContractImporter;

                if (dataContractSerializerMessageContractImporter != null)
                {
                    dataContractSerializerMessageContractImporter.Enabled = formatMode != MetadataImporterSerializerFormatMode.XmlSerializer;
                }
            }
        }