Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -0,0 +1,32 @@
//------------------------------------------------------------------------------
// <copyright file="IWcfReferenceReceiveContextInformation.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace System.Web.Compilation
{
/// <summary>
/// This interface should be implemented by a wsdl or policy import extension if it wants to receive
/// extra context information from the WCF Service Reference tools. Any extension
/// files associated with the .svcmap file of a WCF service reference (e.g., Reference.config or
/// custom extension files added through extensibility) may be received through this interface.
/// In addition, a service provider is passed in which may be queried for additional information.
/// Note that any changes made to the information in serviceReferenceExtensionFileContents will
/// not be persisted.
///
/// Important note: any interface received from the service provider which is specific to Visual
/// Studio will not be available to an import extension when being run in the context of an ASP.NET
/// build provider, which is the case when a WCF service reference is being compiled in an ASP.NET
/// project. The extension files are always available, so they do not have this limitation.
/// </summary>
public interface IWcfReferenceReceiveContextInformation
{
void ReceiveImportContextInformation(
IDictionary<string, byte[]> serviceReferenceExtensionFileContents,
IServiceProvider serviceProvider);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,161 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Security;
using System.Security.Permissions;
using System.Web.Services.Description;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// Wsdl import extension to remove the soap1.2 endpoint for ASMX services.
/// By default, ASMX services expose two endpoints, soap & soap1.2. In order
/// to have easy-of-use-parity with VS2005 ASMX web service consumption
/// we remove one of the endpoints for this special case.
/// </summary>
[SecurityCritical]
[PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")]
internal class AsmxEndpointPickerExtension : System.ServiceModel.Description.IWsdlImportExtension
{
[SecuritySafeCritical]
void System.ServiceModel.Description.IWsdlImportExtension.ImportContract(System.ServiceModel.Description.WsdlImporter importer, System.ServiceModel.Description.WsdlContractConversionContext context)
{
// We don't really care...
}
[SecuritySafeCritical]
void System.ServiceModel.Description.IWsdlImportExtension.ImportEndpoint(System.ServiceModel.Description.WsdlImporter importer, System.ServiceModel.Description.WsdlEndpointConversionContext context)
{
// We don't really care...
}
/// <summary>
/// Remove the Soap1.2 endpoint for ASMX web services if the service exposes
/// both a soap and a soap 1.2 endpoint
/// </summary>
/// <param name="wsdlDocuments">WSDL documents to modify</param>
/// <param name="xmlSchemas">Ignored</param>
/// <param name="policy">Ignored</param>
[SecuritySafeCritical]
void System.ServiceModel.Description.IWsdlImportExtension.BeforeImport(System.Web.Services.Description.ServiceDescriptionCollection wsdlDocuments, System.Xml.Schema.XmlSchemaSet xmlSchemas, System.Collections.Generic.ICollection<System.Xml.XmlElement> policy)
{
if (wsdlDocuments == null)
{
throw new ArgumentNullException("wsdlDocuments");
}
foreach (ServiceDescription document in wsdlDocuments)
{
foreach (Service service in document.Services)
{
// We only touch services that have exactly two endpoints
// (soap & soap 1.2)
if (service.Ports.Count != 2) continue;
Port portToDelete = null;
// Check both ports to see if they are a soap & soap 1.2 pair
if (IsSoapAsmxPort(typeof(SoapAddressBinding), service.Ports[0]) && IsSoapAsmxPort(typeof(Soap12AddressBinding), service.Ports[1]))
{
portToDelete = service.Ports[1];
}
else if (IsSoapAsmxPort(typeof(SoapAddressBinding), service.Ports[1]) && IsSoapAsmxPort(typeof(Soap12AddressBinding), service.Ports[0]))
{
portToDelete = service.Ports[0];
}
if (portToDelete != null)
{
service.Ports.Remove(portToDelete);
if (portToDelete.Binding != null)
{
// Find any associated bindings so that we can remove
// them as well...
List<Binding> bindingsToDelete = new List<Binding>();
foreach (Binding binding in document.Bindings)
{
if (String.Equals(binding.Name, portToDelete.Binding.Name, StringComparison.Ordinal))
{
bindingsToDelete.Add(binding);
}
}
foreach (Binding bindingToDelete in bindingsToDelete)
{
document.Bindings.Remove(bindingToDelete);
}
}
}
}
}
}
/// <summary>
/// Is the given port an ASMX endpoint with the given SOAP address type?
/// </summary>
/// <param name="addressType"></param>
/// <param name="port"></param>
/// <returns></returns>
private bool IsSoapAsmxPort(System.Type addressType, Port port)
{
SoapAddressBinding addressBinding = port.Extensions.Find(addressType) as SoapAddressBinding;
if (addressBinding != null && addressBinding.GetType() == addressType && IsAsmxUri(addressBinding.Location))
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// Is the given location an URL that has a .asmx file extension
/// </summary>
/// <param name="location"></param>
/// <returns></returns>
private bool IsAsmxUri(string location)
{
Uri uri = null;
// Invalid URI - that can't be an ASMX service...
if (!System.Uri.TryCreate(location, UriKind.Absolute, out uri))
{
return false;
}
// Check if the "filename" part of the URL has a .asmx file extension
string[] segments = uri.Segments;
if (segments.Length > 0)
{
try
{
string fileName = segments[segments.Length - 1];
if (String.Equals(System.IO.Path.GetExtension(fileName), ".asmx", StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
catch (System.ArgumentException)
{
// This was most likely an invalid path... well, let's just treat this as if
// this is not an ASMX endpoint...
}
}
return false;
}
}
}

View File

@ -0,0 +1,451 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Collections.Generic;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
#if WEB_EXTENSIONS_CODE
internal class ClientOptions
#else
[CLSCompliant(true)]
public class ClientOptions
#endif
{
private bool m_GenerateAsynchronousMethods;
private bool m_GenerateTaskBasedAsynchronousMethod;
private bool m_GenerateTaskBasedAsynchronousMethodSpecified;
private bool m_EnableDataBinding;
private List<ReferencedType> m_ExcludedTypeList;
private bool m_ImportXmlTypes;
private bool m_GenerateInternalTypes;
private bool m_GenerateMessageContracts;
private List<NamespaceMapping> m_NamespaceMappingList;
private List<ReferencedCollectionType> m_CollectionMappingList;
private bool m_GenerateSerializableTypes;
private ProxySerializerType m_Serializer;
private bool m_ReferenceAllAssemblies;
private List<ReferencedAssembly> m_ReferencedAssemblyList;
private List<ReferencedType> m_ReferencedDataContractTypeList;
private List<ContractMapping> m_ServiceContractMappingList;
private bool m_UseSerializerForFaults;
private bool m_UseSerializerForFaultsSpecified;
private bool m_Wrapped;
private bool m_WrappedSpecified;
/// <summary>
/// Control whether asynchronous proxy will be generated
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool GenerateAsynchronousMethods
{
get
{
return m_GenerateAsynchronousMethods;
}
set
{
m_GenerateAsynchronousMethods = value;
// GenerateAsynchronousMethods and GenerateTaskBasedAsynchronousMethod are mutually exclusive.
if (GenerateAsynchronousMethods)
{
GenerateTaskBasedAsynchronousMethod = false;
}
}
}
/// <summary>
/// Control whether task-based async operations will be generated
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool GenerateTaskBasedAsynchronousMethod
{
get
{
return m_GenerateTaskBasedAsynchronousMethod;
}
set
{
// In order to maximally keep compatible with Dev10 and previous VS, if GenerateTaskBasedAsynchronousMethod is false,
// we will not persist it.
m_GenerateTaskBasedAsynchronousMethod = value;
m_GenerateTaskBasedAsynchronousMethodSpecified = value;
// GenerateAsynchronousMethods and GenerateTaskBasedAsynchronousMethod are mutually exclusive.
if (GenerateTaskBasedAsynchronousMethod)
{
GenerateAsynchronousMethods = false;
}
}
}
/// <summary>
/// Is GenerateTaskBasedAsynchronousMethod specified?
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlIgnore()]
public bool GenerateTaskBasedAsynchronousMethodSpecified
{
get
{
return m_GenerateTaskBasedAsynchronousMethodSpecified;
}
}
/// <summary>
/// control whether to generate INotifyPropertyChanged interface on data contract types
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool EnableDataBinding
{
get
{
return m_EnableDataBinding;
}
set
{
m_EnableDataBinding = value;
}
}
/// <summary>
/// contains a list of types which will be excluded when the design time tool matches types automatically
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlArray(ElementName = "ExcludedTypes")]
[XmlSerialization.XmlArrayItem("ExcludedType", typeof(ReferencedType))]
public List<ReferencedType> ExcludedTypeList
{
get
{
if (m_ExcludedTypeList == null)
{
m_ExcludedTypeList = new List<ReferencedType>();
}
return m_ExcludedTypeList;
}
}
/// <summary>
/// control whether the data contract serializer should import non-DataContract types as IXmlSerializable types
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool ImportXmlTypes
{
get
{
return m_ImportXmlTypes;
}
set
{
m_ImportXmlTypes = value;
}
}
/// <summary>
/// control whether to generate internal types
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool GenerateInternalTypes
{
get
{
return m_GenerateInternalTypes;
}
set
{
m_GenerateInternalTypes = value;
}
}
/// <summary>
/// control whether to generate message contract types
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool GenerateMessageContracts
{
get
{
return m_GenerateMessageContracts;
}
set
{
m_GenerateMessageContracts = value;
}
}
/// <summary>
/// namespace mapping between metadata namespace and clr namespace
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlArray(ElementName = "NamespaceMappings")]
[XmlSerialization.XmlArrayItem("NamespaceMapping", typeof(NamespaceMapping))]
public List<NamespaceMapping> NamespaceMappingList
{
get
{
if (m_NamespaceMappingList == null)
{
m_NamespaceMappingList = new List<NamespaceMapping>();
}
return m_NamespaceMappingList;
}
}
/// <summary>
/// known collection types which will be used by code generator
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlArray(ElementName = "CollectionMappings")]
[XmlSerialization.XmlArrayItem("CollectionMapping", typeof(ReferencedCollectionType))]
public List<ReferencedCollectionType> CollectionMappingList
{
get
{
if (m_CollectionMappingList == null)
{
m_CollectionMappingList = new List<ReferencedCollectionType>();
}
return m_CollectionMappingList;
}
}
/// <summary>
/// whether class need be marked with Serializable attribute
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool GenerateSerializableTypes
{
get
{
return m_GenerateSerializableTypes;
}
set
{
m_GenerateSerializableTypes = value;
}
}
/// <summary>
/// select serializer between DataContractSerializer or XmlSerializer
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public ProxySerializerType Serializer
{
get
{
return m_Serializer;
}
set
{
m_Serializer = value;
}
}
/// <summary>
/// Control whether or not to UseSerializerForFaults. The System.ServiceModel.FaultImportOptions
/// will set its UseMessageFormat Property using this value.
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool UseSerializerForFaults
{
get
{
if (m_UseSerializerForFaultsSpecified)
{
return m_UseSerializerForFaults;
}
else
{
return false;
}
}
set
{
m_UseSerializerForFaultsSpecified = true;
m_UseSerializerForFaults = value;
}
}
/// <summary>
/// Is UseSerializerForFaults specified?
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlIgnore()]
public bool UseSerializerForFaultsSpecified
{
get
{
return m_UseSerializerForFaultsSpecified;
}
}
/// <summary>
/// Control whether or not to WrappedOption. The System.ServiceModel.Channels.WrappedOption
/// will set its WrappedFlag Property using this value.
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool Wrapped
{
get
{
if (m_WrappedSpecified)
{
return m_Wrapped;
}
else
{
return false;
}
}
set
{
m_WrappedSpecified = true;
m_Wrapped = value;
}
}
/// <summary>
/// Is WrappedOption specified?
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlIgnore()]
public bool WrappedSpecified
{
get
{
return m_WrappedSpecified;
}
}
/// <summary>
/// Whether we will scan all dependent assemblies for type sharing
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlElement()]
public bool ReferenceAllAssemblies
{
get
{
return m_ReferenceAllAssemblies;
}
set
{
m_ReferenceAllAssemblies = value;
}
}
/// <summary>
/// controll DataContract type sharing
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlArray(ElementName = "ReferencedAssemblies")]
[XmlSerialization.XmlArrayItem("ReferencedAssembly", typeof(ReferencedAssembly))]
public List<ReferencedAssembly> ReferencedAssemblyList
{
get
{
if (m_ReferencedAssemblyList == null)
{
m_ReferencedAssemblyList = new List<ReferencedAssembly>();
}
return m_ReferencedAssemblyList;
}
}
/// <summary>
/// controll DataContract type sharing
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlArray(ElementName = "ReferencedDataContractTypes")]
[XmlSerialization.XmlArrayItem("ReferencedDataContractType", typeof(ReferencedType))]
public List<ReferencedType> ReferencedDataContractTypeList
{
get
{
if (m_ReferencedDataContractTypeList == null)
{
m_ReferencedDataContractTypeList = new List<ReferencedType>();
}
return m_ReferencedDataContractTypeList;
}
}
/// <summary>
/// control service contract type sharing
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlArray(ElementName = "ServiceContractMappings")]
[XmlSerialization.XmlArrayItem("ServiceContractMapping", typeof(ContractMapping))]
public List<ContractMapping> ServiceContractMappingList
{
get
{
if (m_ServiceContractMappingList == null)
{
m_ServiceContractMappingList = new List<ContractMapping>();
}
return m_ServiceContractMappingList;
}
}
/// <summary>
/// Serializer used in proxy generator
/// </summary>
/// <remarks></remarks>
public enum ProxySerializerType
{
[XmlSerialization.XmlEnum(Name = "Auto")]
Auto = 0,
[XmlSerialization.XmlEnum(Name = "DataContractSerializer")]
DataContractSerializer = 1,
[XmlSerialization.XmlEnum(Name = "XmlSerializer")]
XmlSerializer = 2,
}
}
}

View File

@ -0,0 +1,86 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// a contract type sharing record
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class ContractMapping
#else
[CLSCompliant(true)]
public class ContractMapping
#endif
{
private string m_Name;
private string m_TargetNamespace;
private string m_TypeName;
/// <summary>
/// type name in metadata
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string Name
{
get
{
return m_Name;
}
set
{
m_Name = value;
}
}
/// <summary>
/// targetNamespace in metadata
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string TargetNamespace
{
get
{
return m_TargetNamespace;
}
set
{
m_TargetNamespace = value;
}
}
/// <summary>
/// assembly qualified type name, or '-' which blocks type sharing
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string TypeName
{
get
{
return m_TypeName;
}
set
{
m_TypeName = value;
}
}
}
}

View File

@ -0,0 +1,186 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
#if WEB_EXTENSIONS_CODE
internal class DataSvcMapFile : MapFile
#else
[CLSCompliant(true)]
public class DataSvcMapFile : MapFile
#endif
{
private DataSvcMapFileImpl _impl;
public DataSvcMapFileImpl Impl
{
get
{
return _impl;
}
}
public DataSvcMapFile()
{
_impl = new DataSvcMapFileImpl();
}
public DataSvcMapFile(DataSvcMapFileImpl impl)
{
Debug.Assert(impl != null, "impl is null!");
_impl = impl;
}
public override string ID
{
get
{
return _impl.ID;
}
set
{
_impl.ID = value;
}
}
public override List<MetadataSource> MetadataSourceList
{
get
{
return _impl.MetadataSourceList;
}
}
public override List<MetadataFile> MetadataList
{
get
{
return _impl.MetadataList;
}
}
public override List<ExtensionFile> Extensions
{
get
{
return _impl.Extensions;
}
}
public List<Parameter> Parameters
{
get
{
return _impl.Parameters;
}
}
}
[XmlRoot(Namespace = DataSvcMapFileImpl.NamespaceUri, ElementName = "ReferenceGroup")]
#if WEB_EXTENSIONS_CODE
internal class DataSvcMapFileImpl
#else
[CLSCompliant(true)]
public class DataSvcMapFileImpl
#endif
{
public const string NamespaceUri = "urn:schemas-microsoft-com:xml-dataservicemap";
private string _id;
private List<MetadataSource> _metadataSourceList;
private List<MetadataFile> _metadataList;
private List<ExtensionFile> _extensionFileList;
private List<Parameter> _parameters;
[XmlAttribute]
public string ID
{
get
{
if (_id == null)
{
_id = Guid.NewGuid().ToString();
}
return _id;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
_id = value;
}
}
[XmlArray(ElementName = "MetadataSources", Order = 0)]
[XmlArrayItem("MetadataSource", typeof(MetadataSource))]
public List<MetadataSource> MetadataSourceList
{
get
{
if (_metadataSourceList == null)
{
_metadataSourceList = new List<MetadataSource>();
}
return _metadataSourceList;
}
}
[XmlArray(ElementName = "Metadata", Order = 1)]
[XmlArrayItem("MetadataFile", typeof(MetadataFile))]
public List<MetadataFile> MetadataList
{
get
{
if (_metadataList == null)
{
_metadataList = new List<MetadataFile>();
}
return _metadataList;
}
}
[XmlArray(ElementName = "Extensions", Order = 2)]
[XmlArrayItem("ExtensionFile", typeof(ExtensionFile))]
public List<ExtensionFile> Extensions
{
get
{
if (_extensionFileList == null)
{
_extensionFileList = new List<ExtensionFile>();
}
return _extensionFileList;
}
}
[XmlArray(ElementName = "Parameters", Order = 3)]
[XmlArrayItem("Parameter", typeof(Parameter))]
public List<Parameter> Parameters
{
get
{
if (_parameters == null)
{
_parameters = new List<Parameter>();
}
return _parameters;
}
}
}
}

View File

@ -0,0 +1,99 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System.Diagnostics;
using System.IO;
using System.Xml.Schema;
using System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
#if WEB_EXTENSIONS_CODE
internal class DataSvcMapFileLoader : MapFileLoader
#else
public class DataSvcMapFileLoader : MapFileLoader
#endif
{
private string _mapFilePath;
private XmlSchemaSet _mapFileSchemaSet;
private XmlSerializer _mapFileSerializer;
public DataSvcMapFileLoader(string mapFilePath)
{
Debug.Assert(!string.IsNullOrEmpty(mapFilePath), "mapFilePath is null!");
_mapFilePath = mapFilePath;
}
#region protected overrides methods
protected override string MapFileName
{
get { return _mapFilePath; }
}
protected override MapFile Wrap(object mapFileImpl)
{
return mapFileImpl is DataSvcMapFileImpl ? new DataSvcMapFile((DataSvcMapFileImpl)mapFileImpl) : null;
}
protected override object Unwrap(MapFile mapFile)
{
return mapFile is DataSvcMapFile ? ((DataSvcMapFile)mapFile).Impl : null;
}
protected override XmlSchemaSet GetMapFileSchemaSet()
{
if (_mapFileSchemaSet == null)
{
_mapFileSchemaSet = new XmlSchemaSet();
using (var stream = typeof(DataSvcMapFileImpl).Assembly.GetManifestResourceStream(typeof(DataSvcMapFileImpl), @"Schema.DataServiceMapSchema.xsd"))
{
_mapFileSchemaSet.Add(XmlSchema.Read(stream, null));
}
}
return _mapFileSchemaSet;
}
protected override XmlSerializer GetMapFileSerializer()
{
if (_mapFileSerializer == null)
{
#if WEB_EXTENSIONS_CODE
_mapFileSerializer = new System.Web.Compilation.WCFModel.DataSvcMapFileXmlSerializer.DataSvcMapFileImplSerializer();
#else
_mapFileSerializer = new XmlSerializer(typeof(DataSvcMapFileImpl), DataSvcMapFileImpl.NamespaceUri);
#endif
}
return _mapFileSerializer;
}
protected override TextReader GetMapFileReader()
{
return File.OpenText(_mapFilePath);
}
protected override byte[] ReadMetadataFile(string name)
{
return File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_mapFilePath), name));
}
protected override byte[] ReadExtensionFile(string name)
{
return File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_mapFilePath), name));
}
#endregion protected overrides methods
}
}

View File

@ -0,0 +1,123 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// This class presents a single file referenced by a svcmap file
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class ExtensionFile : ExternalFile
#else
[CLSCompliant(true)]
public class ExtensionFile : ExternalFile
#endif
{
// Extension Item Name
private string m_Name;
// content buffer
private byte[] m_ContentBuffer;
/// <summary>
/// Constructor
/// </summary>
/// <remarks> Must support a default construct for XmlSerializer</remarks>
public ExtensionFile()
{
m_Name = string.Empty;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">name of extension item</param>
/// <param name="fileName">Suggested File Name</param>
public ExtensionFile(string name, string fileName, byte[] content)
: base(fileName)
{
this.Name = name;
m_ContentBuffer = content;
IsExistingFile = false;
}
/// <summary>
/// Content of the extension file
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlIgnore()]
public byte[] ContentBuffer
{
get
{
return m_ContentBuffer;
}
set
{
m_ContentBuffer = value;
ErrorInLoading = null;
}
}
/// <summary>
/// whether the content is buffered
/// </summary>
/// <value></value>
/// <remarks></remarks>
internal bool IsBufferValid
{
get
{
return (m_ContentBuffer != null);
}
}
/// <summary>
/// Name in the storage
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string Name
{
get
{
return m_Name;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
m_Name = value;
}
}
/// <summary>
/// the function is called when the metadata is removed, and we need clean up the content
/// </summary>
/// <remarks></remarks>
internal void CleanUpContent()
{
ErrorInLoading = null;
m_ContentBuffer = null;
}
}
}

View File

@ -0,0 +1,149 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Globalization;
using System.IO;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
using System.Web.Resources;
#else
using Microsoft.VSDesigner.WCF.Resources;
#endif
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// This class presents a single file referenced by a svcmap file
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class ExternalFile
#else
[CLSCompliant(true)]
public class ExternalFile
#endif
{
// File Name
private string m_FileName;
// Is the MeatadataFile loaded from the file? If it is false, we need create a new file when we save to the disket
private bool m_IsExistingFile;
// error happens when the file is loaded
private Exception m_ErrorInLoading;
/// <summary>
/// Constructor
/// </summary>
/// <remarks> Must support a default construct for XmlSerializer</remarks>
public ExternalFile()
{
m_FileName = String.Empty;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="fileName">File Name</param>
public ExternalFile(string fileName)
{
this.FileName = fileName;
}
/// <summary>
/// Error happens when the file is loaded
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlIgnore()]
public Exception ErrorInLoading
{
get
{
return m_ErrorInLoading;
}
set
{
m_ErrorInLoading = value;
}
}
/// <summary>
/// FileName in the storage
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string FileName
{
get
{
return m_FileName;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
if (!IsLocalFileName(value))
{
throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture, WCFModelStrings.ReferenceGroup_InvalidFileName, value));
}
m_FileName = value;
}
}
/// <summary>
/// Is the item loaded from the file? If it is false, we need create a new file when we save to the disket
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlIgnore()]
public bool IsExistingFile
{
get
{
return m_IsExistingFile;
}
set
{
m_IsExistingFile = value;
}
}
/// <summary>
/// Check the file name is a real file name but not a path
/// </summary>
/// <param name="fileName"></param>
/// <remarks></remarks>
public static bool IsLocalFileName(string fileName)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (fileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || fileName.IndexOfAny(new Char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, Path.VolumeSeparatorChar }) >= 0)
{
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,133 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// Map between (targetNamespace, PortTypeName) --> CLR TypeName
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class GeneratedContractType
#else
[CLSCompliant(true)]
public class GeneratedContractType
#endif
{
private string m_TargetNamespace;
private string m_Name;
private string m_ContractType;
private string m_ConfigurationName;
/// <summary>
/// Constructor
/// </summary>
/// <remarks>required by xml serializer</remarks>
public GeneratedContractType()
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="targetNamespace"></param>
/// <param name="portName"></param>
/// <param name="contractType"></param>
/// <param name="configurationName"></param>
/// <remarks></remarks>
public GeneratedContractType(string targetNamespace, string portName, string contractType, string configurationName)
{
m_TargetNamespace = targetNamespace;
m_Name = portName;
m_ContractType = contractType;
m_ConfigurationName = configurationName;
}
/// <summary>
/// The TargetNamespace of this contract type in the WSDL file
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string TargetNamespace
{
get
{
return m_TargetNamespace;
}
set
{
m_TargetNamespace = value;
}
}
/// <summary>
/// The portTypeName of this contract type in the WSDL file
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string Name
{
get
{
return m_Name;
}
set
{
m_Name = value;
}
}
/// <summary>
/// The generated CLR type name of this contract type
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string ContractType
{
get
{
return m_ContractType;
}
set
{
m_ContractType = value;
}
}
/// <summary>
/// The name of this contract in the config file
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string ConfigurationName
{
get
{
return m_ConfigurationName;
}
set
{
m_ConfigurationName = value;
}
}
}
}

View File

@ -0,0 +1,74 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Security;
using System.Security.Permissions;
using System.ServiceModel.Description;
using System.Xml;
using System.Xml.Schema;
using WsdlNS = System.Web.Services.Description;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// Wsdl import extension to remove HttpGet and HttpPost bindings for ASMX services.
/// See detail in dev10 792007
/// </summary>
[SecurityCritical]
[PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")]
internal class HttpBindingExtension : IWsdlImportExtension
{
readonly HashSet<ContractDescription> httpBindingContracts = new HashSet<ContractDescription>();
static bool ContainsHttpBindingExtension(WsdlNS.Binding wsdlBinding)
{
//avoiding using wsdlBinding.Extensions.Find(typeof(WsdlNS.HttpBinding)) so the extension won't be marked as handled
foreach (object extension in wsdlBinding.Extensions)
{
if (extension is WsdlNS.HttpBinding)
{
string httpVerb = ((WsdlNS.HttpBinding)extension).Verb;
if (httpVerb.Equals("GET", StringComparison.OrdinalIgnoreCase) || httpVerb.Equals("POST", StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
return false;
}
public bool IsHttpBindingContract(ContractDescription contract)
{
return contract != null && httpBindingContracts.Contains(contract);
}
[SecuritySafeCritical]
void IWsdlImportExtension.BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, XmlSchemaSet xmlSchemas, ICollection<XmlElement> policy)
{
}
[SecuritySafeCritical]
void IWsdlImportExtension.ImportContract(WsdlImporter importer, WsdlContractConversionContext context)
{
}
[SecuritySafeCritical]
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
{
if (context != null && context.WsdlBinding != null && ContainsHttpBindingExtension(context.WsdlBinding))
{
httpBindingContracts.Add(context.ContractConversionContext.Contract);
}
}
}
}

View File

@ -0,0 +1,51 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Reflection;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// It loads a specific type from a referenced assembly.
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal interface IContractGeneratorReferenceTypeLoader
#else
[CLSCompliant(true)]
public interface IContractGeneratorReferenceTypeLoader
#endif
{
// function should throw if type can't be loaded
Type LoadType(string typeName);
// function should throw if the assembly can't be loaded
Assembly LoadAssembly(string assemblyName);
void LoadAllAssemblies(out IEnumerable<Assembly> loadedAssemblies, out IEnumerable<Exception> loadingErrors);
}
#if WEB_EXTENSIONS_CODE
internal interface IContractGeneratorReferenceTypeLoader2
#else
[CLSCompliant(true)]
public interface IContractGeneratorReferenceTypeLoader2
#endif
{
/// <summary>
/// Given an assembly which is supported in the target framework, loads all the exported type in it that are also supported in the target framework.
/// </summary>
IEnumerable<Type> LoadExportedTypes(Assembly assembly);
}
}

View File

@ -0,0 +1,62 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
#if WEB_EXTENSIONS_CODE
internal abstract class MapFile
#else
[CLSCompliant(true)]
public abstract class MapFile
#endif
{
private List<ProxyGenerationError> _loadErrors;
/// <summary>
/// Errors encountered during load
/// </summary>
public IEnumerable<ProxyGenerationError> LoadErrors
{
get
{
return _loadErrors != null ? _loadErrors : Enumerable.Empty<ProxyGenerationError>();
}
internal set
{
_loadErrors = new List<ProxyGenerationError>(value);
}
}
/// <summary>
/// Unique ID of the reference group. It is a GUID string.
/// </summary>
public abstract string ID { get; set; }
/// <summary>
/// Metadata source item list
/// </summary>
public abstract List<MetadataSource> MetadataSourceList { get; }
/// <summary>
/// Metadata item list
/// </summary>
public abstract List<MetadataFile> MetadataList { get; }
/// <summary>
/// Extension item list
/// </summary>
public abstract List<ExtensionFile> Extensions { get; }
}
}

View File

@ -0,0 +1,356 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
using System.Web.Resources;
#else
using Microsoft.VSDesigner.WCF.Resources;
#endif
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// Map file loader
/// </summary>
/// <remarks>
/// MapFileLoader instance and MapFile instance should be 1:1 mapping.
/// </remarks>
#if WEB_EXTENSIONS_CODE
internal abstract class MapFileLoader
#else
[CLSCompliant(true)]
public abstract class MapFileLoader
#endif
{
/// <summary>
/// Save the given map file.
/// </summary>
/// <param name="mapFile">The map file to be saved</param>
public void SaveMapFile(MapFile mapFile)
{
Debug.Assert(mapFile != null, "mapFile is null!");
SaveExternalFiles(mapFile);
using (var mapFileWriter = GetMapFileWriter())
{
GetMapFileSerializer().Serialize(mapFileWriter, Unwrap(mapFile));
}
}
/// <summary>
/// Load the map file.
/// </summary>
/// <returns>Concrete map file instance.</returns>
public MapFile LoadMapFile()
{
MapFile mapFile = null;
using (var mapFileReader = GetMapFileReader())
{
var proxyGenerationErrors = new List<ProxyGenerationError>();
ValidationEventHandler handler =
(sender, e) =>
{
bool isError = (e.Severity == XmlSeverityType.Error);
proxyGenerationErrors.Add(
new ProxyGenerationError(ProxyGenerationError.GeneratorState.LoadMetadata,
MapFileName,
e.Exception,
!isError));
if (isError)
{
throw e.Exception;
}
};
var readerSettings = new XmlReaderSettings()
{
Schemas = GetMapFileSchemaSet(),
ValidationType = ValidationType.Schema,
ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings,
};
using (XmlReader reader = XmlReader.Create(mapFileReader, readerSettings, string.Empty))
{
try
{
readerSettings.ValidationEventHandler += handler;
mapFile = ReadMapFile(reader);
SetMapFileLoadErrors(mapFile, proxyGenerationErrors);
}
finally
{
readerSettings.ValidationEventHandler -= handler;
}
}
}
if (mapFile != null)
{
LoadExternalFiles(mapFile);
}
return mapFile;
}
/// <summary>
/// Load metadata file from file system
/// </summary>
public void LoadMetadataFile(MetadataFile metadataFile)
{
try
{
metadataFile.CleanUpContent();
metadataFile.LoadContent(ReadMetadataFile(metadataFile.FileName));
}
catch (Exception ex)
{
metadataFile.ErrorInLoading = ex;
}
}
/// <summary>
/// Load extension file
/// </summary>
public void LoadExtensionFile(ExtensionFile extensionFile)
{
try
{
extensionFile.CleanUpContent();
extensionFile.ContentBuffer = ReadExtensionFile(extensionFile.FileName);
}
catch (Exception ex)
{
extensionFile.ErrorInLoading = ex;
}
}
#region protected abstract methods
/// <summary>
/// The name of the file where the MapFile instance is loaded.
/// </summary>
protected abstract string MapFileName { get; }
/// <summary>
/// Wrap the map file impl.
/// </summary>
protected abstract MapFile Wrap(object mapFileImpl);
/// <summary>
/// Unwrap the map file.
/// </summary>
protected abstract object Unwrap(MapFile mapFile);
/// <summary>
/// Get the map file schema set
/// </summary>
/// <return>Xml schema set of the map file</return>
protected abstract XmlSchemaSet GetMapFileSchemaSet();
/// <summary>
/// Get the map file serializer
/// </summary>
/// <returns>Xml serializer of the map file</returns>
protected abstract XmlSerializer GetMapFileSerializer();
/// <summary>
/// Get access to a text reader that gets access to the map file byte stream
/// </summary>
/// <returns>Text reader of the map file</returns>
protected virtual TextReader GetMapFileReader()
{
throw new NotImplementedException();
}
/// <summary>
/// Get access to a text writer that writes the map file byte stream.
/// </summary>
/// <returns>Text writer of the map file</returns>
protected virtual TextWriter GetMapFileWriter()
{
throw new NotImplementedException();
}
/// <summary>
/// Get access to a byte array that contain the contents of the given metadata
/// file
/// </summary>
/// <param name="name">
/// Name of the metadata file. Could be a path relative to the svcmap file location
/// or the name of an item in a metadata storage.
/// </param>
/// <returns>Content of the metadata file</returns>
protected virtual byte[] ReadMetadataFile(string name)
{
throw new NotImplementedException();
}
/// <summary>
/// Write the metadata file.
/// </summary>
/// <param name="file">The metadata file to be written</param>
protected virtual void WriteMetadataFile(MetadataFile file)
{
throw new NotImplementedException();
}
/// <summary>
/// Get access to a byte array that contain the contents of the given extension
/// file
/// </summary>
/// <param name="name">
/// Name of the extension file. Could be a path relative to the svcmap file location
/// or the name of an item in a metadata storage.
/// </param>
/// <returns>Content of the extension file</returns>
protected virtual byte[] ReadExtensionFile(string name)
{
throw new NotImplementedException();
}
/// <summary>
/// Write the extension file.
/// </summary>
/// <param name="file">The extension file to be written</param>
protected virtual void WriteExtensionFile(ExtensionFile file)
{
throw new NotImplementedException();
}
#endregion protected abstract methods
#region private methods
private MapFile ReadMapFile(XmlReader reader)
{
try
{
return Wrap(GetMapFileSerializer().Deserialize(reader));
}
catch (InvalidOperationException ex)
{
XmlException xmlException = ex.InnerException as XmlException;
if (xmlException != null)
{
// the innerException contains detail error message
throw xmlException;
}
XmlSchemaException schemaException = ex.InnerException as XmlSchemaException;
if (schemaException != null)
{
if (schemaException.LineNumber > 0)
{
// append line/position to the message
throw new XmlSchemaException(String.Format(CultureInfo.CurrentCulture,
WCFModelStrings.ReferenceGroup_AppendLinePosition,
schemaException.Message,
schemaException.LineNumber,
schemaException.LinePosition),
schemaException,
schemaException.LineNumber,
schemaException.LinePosition);
}
else
{
throw schemaException;
}
}
// It's something we can't handle, throw it.
throw;
}
}
private void SaveExternalFiles(MapFile mapFile)
{
// KEEP the order! The name of metadata files could be adjusted when we save them.
foreach (MetadataFile metadataFile in mapFile.MetadataList)
{
if (metadataFile.ErrorInLoading == null)
{
WriteMetadataFile(metadataFile);
}
}
foreach (ExtensionFile extensionFile in mapFile.Extensions)
{
if (extensionFile.ErrorInLoading == null)
{
WriteExtensionFile(extensionFile);
}
}
}
private void LoadExternalFiles(MapFile mapFile)
{
// Do basic check for metadata files and extension files.
ValidateMapFile(mapFile);
foreach (MetadataFile metadataFile in mapFile.MetadataList)
{
metadataFile.IsExistingFile = true;
LoadMetadataFile(metadataFile);
}
foreach (ExtensionFile extensionFile in mapFile.Extensions)
{
extensionFile.IsExistingFile = true;
LoadExtensionFile(extensionFile);
}
}
private void ValidateMapFile(MapFile mapFile)
{
var metadataFileNames = mapFile.MetadataList.Select(p => p.FileName).Where(p => !string.IsNullOrEmpty(p));
var extensionFileNames = mapFile.Extensions.Select(p => p.FileName).Where(p => !string.IsNullOrEmpty(p));
var fileNameSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (string fileName in metadataFileNames.Concat(extensionFileNames))
{
if (!fileNameSet.Contains(fileName))
{
fileNameSet.Add(fileName);
}
else
{
throw new FormatException(String.Format(CultureInfo.CurrentCulture,
WCFModelStrings.ReferenceGroup_TwoExternalFilesWithSameName,
fileName));
}
}
}
private void SetMapFileLoadErrors(MapFile mapFile, IEnumerable<ProxyGenerationError> proxyGenerationErrors)
{
mapFile.LoadErrors = proxyGenerationErrors;
}
#endregion private methods
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,160 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.Diagnostics;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
using System.Web.Resources;
#else
using Microsoft.VSDesigner.WCF.Resources;
#endif
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// This class implements a MetadataSource item in the svcmap file
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class MetadataSource
#else
[CLSCompliant(true)]
public class MetadataSource
#endif
{
// URL of metadata source
private string m_Address;
// protocol to download it
private string m_Protocol;
// ID of this source
private int m_SourceId;
/// <summary>
/// Constructor
/// </summary>
/// <remarks> Must support a default construct for XmlSerializer</remarks>
public MetadataSource()
{
m_Address = String.Empty;
m_Protocol = String.Empty;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="protocol"></param>
/// <param name="address"></param>
/// <param name="sourceId"></param>
public MetadataSource(string protocol, string address, int sourceId)
{
if (protocol == null)
{
throw new ArgumentNullException("protocol");
}
if (address == null)
{
throw new ArgumentNullException("address");
}
if (protocol.Length == 0)
{
throw new ArgumentException(WCFModelStrings.ReferenceGroup_EmptyProtocol);
}
if (address == null)
{
throw new ArgumentException(WCFModelStrings.ReferenceGroup_EmptyAddress);
}
m_Protocol = protocol;
m_Address = address;
if (sourceId < 0)
{
Debug.Fail("Source ID shouldn't be a nagtive number");
throw new ArgumentException(WCFModelStrings.ReferenceGroup_InvalidSourceId);
}
m_SourceId = sourceId;
}
/// <summary>
/// URL address to download metadata
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string Address
{
get
{
return m_Address;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
m_Address = value;
}
}
/// <summary>
/// protocol used to download metadata
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string Protocol
{
get
{
return m_Protocol;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
m_Protocol = value;
}
}
/// <summary>
/// generated ID for this metadata source
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public int SourceId
{
get
{
return m_SourceId;
}
set
{
if (value < 0)
{
Debug.Fail("Source ID shouldn't be a nagtive number");
throw new ArgumentException(WCFModelStrings.ReferenceGroup_InvalidSourceId);
}
m_SourceId = value;
}
}
}
}

View File

@ -0,0 +1,69 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// mapping between metadata namespace and CLR namespace
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class NamespaceMapping
#else
[CLSCompliant(true)]
public class NamespaceMapping
#endif
{
private string m_TargetNamespace;
private string m_ClrNamespace;
/// <summary>
/// Target Namespace
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string TargetNamespace
{
get
{
return m_TargetNamespace;
}
set
{
m_TargetNamespace = value;
}
}
/// <summary>
/// Clr Namespace
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string ClrNamespace
{
get
{
return m_ClrNamespace;
}
set
{
m_ClrNamespace = value;
}
}
}
}

View File

@ -0,0 +1,74 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// This class presents a single file referenced by a svcmap file
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class Parameter
#else
[CLSCompliant(true)]
public class Parameter
#endif
{
private string m_Name;
private string m_Value;
public Parameter()
{
m_Name = string.Empty;
m_Value = string.Empty;
}
/// <summary>
/// Name in the storage
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string Name
{
get
{
return m_Name;
}
set
{
m_Name = value;
}
}
/// <summary>
/// Name in the storage
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string Value
{
get
{
return m_Value;
}
set
{
m_Value = value;
}
}
}
}

View File

@ -0,0 +1,229 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using System.ServiceModel.Description;
using System.Xml;
using System.Xml.Schema;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
/// <summary>
/// This class represents an error message happens when we generate code
/// </summary>
/// <remarks></remarks>
#if WEB_EXTENSIONS_CODE
internal class ProxyGenerationError
#else
[CLSCompliant(true)]
public class ProxyGenerationError
#endif
{
private bool m_IsWarning;
private string m_Message;
private string m_MetadataFile;
private int m_LineNumber;
private int m_LinePosition;
private GeneratorState m_ErrorGeneratorState;
/// <summary>
/// Constructor
/// </summary>
/// <param name="errorMessage">MetadataConversionError</param>
/// <remarks> </remarks>
public ProxyGenerationError(MetadataConversionError errorMessage)
{
m_ErrorGeneratorState = GeneratorState.GenerateCode;
m_IsWarning = errorMessage.IsWarning;
m_Message = errorMessage.Message;
m_MetadataFile = String.Empty;
m_LineNumber = -1;
m_LinePosition = -1;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="generatorState"></param>
/// <param name="fileName"></param>
/// <param name="errorException">An IOException</param>
/// <remarks> </remarks>
public ProxyGenerationError(GeneratorState generatorState, string fileName, Exception errorException)
{
m_ErrorGeneratorState = generatorState;
m_IsWarning = false;
m_Message = errorException.Message;
m_MetadataFile = fileName;
m_LineNumber = -1;
m_LinePosition = -1;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="generatorState"></param>
/// <param name="fileName"></param>
/// <param name="errorException">An IOException</param>
/// <param name="isWarning">An IOException</param>
/// <remarks> </remarks>
public ProxyGenerationError(GeneratorState generatorState, string fileName, Exception errorException, bool isWarning)
{
m_ErrorGeneratorState = generatorState;
m_IsWarning = isWarning;
m_Message = errorException.Message;
m_MetadataFile = fileName;
m_LineNumber = -1;
m_LinePosition = -1;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="generatorState"></param>
/// <param name="fileName"></param>
/// <param name="errorException">An XmlException</param>
/// <remarks> </remarks>
public ProxyGenerationError(GeneratorState generatorState, string fileName, XmlException errorException)
{
m_ErrorGeneratorState = generatorState;
m_IsWarning = false;
m_Message = errorException.Message;
m_MetadataFile = fileName;
m_LineNumber = errorException.LineNumber;
m_LinePosition = errorException.LinePosition;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="generatorState"></param>
/// <param name="fileName"></param>
/// <param name="errorException">An XmlException</param>
/// <remarks> </remarks>
public ProxyGenerationError(GeneratorState generatorState, string fileName, XmlSchemaException errorException)
{
m_ErrorGeneratorState = generatorState;
m_IsWarning = false;
m_Message = errorException.Message;
m_MetadataFile = fileName;
m_LineNumber = errorException.LineNumber;
m_LinePosition = errorException.LinePosition;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="generatorState"></param>
/// <param name="fileName"></param>
/// <param name="errorException">An XmlException</param>
/// <param name="isWarning">An XmlException</param>
/// <remarks> </remarks>
public ProxyGenerationError(GeneratorState generatorState, string fileName, XmlSchemaException errorException, bool isWarning)
{
m_ErrorGeneratorState = generatorState;
m_IsWarning = isWarning;
m_Message = errorException.Message;
m_MetadataFile = fileName;
m_LineNumber = errorException.LineNumber;
m_LinePosition = errorException.LinePosition;
}
/// <summary>
/// This property represents when an error message happens
/// </summary>
/// <value></value>
/// <remarks></remarks>
public GeneratorState ErrorGeneratorState
{
get
{
return m_ErrorGeneratorState;
}
}
/// <summary>
/// True: if it is a warning message, otherwise, an error
/// </summary>
/// <value></value>
/// <remarks></remarks>
public bool IsWarning
{
get
{
return m_IsWarning;
}
}
/// <summary>
/// Line Number when error happens
/// </summary>
/// <value></value>
/// <remarks></remarks>
public int LineNumber
{
get
{
return m_LineNumber;
}
}
/// <summary>
/// Column Number in the line when error happens
/// </summary>
/// <value></value>
/// <remarks></remarks>
public int LinePosition
{
get
{
return m_LinePosition;
}
}
/// <summary>
/// return the error message
/// </summary>
/// <value></value>
/// <remarks></remarks>
public string Message
{
get
{
return m_Message;
}
}
/// <summary>
/// return the error message
/// </summary>
/// <value></value>
/// <remarks></remarks>
public string MetadataFile
{
get
{
return m_MetadataFile;
}
}
/// <summary>
/// This enum represents when an error message happens
/// </summary>
/// <remarks></remarks>
public enum GeneratorState
{
LoadMetadata = 0,
MergeMetadata = 1,
GenerateCode = 2,
}
}
}

View File

@ -0,0 +1,66 @@
#region Copyright (c) Microsoft Corporation
/// <copyright company='Microsoft Corporation'>
/// Copyright (c) Microsoft Corporation. All Rights Reserved.
/// Information Contained Herein is Proprietary and Confidential.
/// </copyright>
#endregion
using System;
using XmlSerialization = System.Xml.Serialization;
#if WEB_EXTENSIONS_CODE
namespace System.Web.Compilation.WCFModel
#else
namespace Microsoft.VSDesigner.WCFModel
#endif
{
#if WEB_EXTENSIONS_CODE
internal class ReferencedAssembly
#else
[CLSCompliant(true)]
public class ReferencedAssembly
#endif
{
private string m_AssemblyName;
/// <summary>
/// Constructor
/// </summary>
public ReferencedAssembly()
{
m_AssemblyName = String.Empty;
}
/// <summary>
/// Constructor
/// </summary>
public ReferencedAssembly(string assemblyName)
{
if (assemblyName == null)
{
throw new ArgumentNullException("assemblyName");
}
m_AssemblyName = assemblyName;
}
/// <summary>
/// assembly name
/// </summary>
/// <value></value>
/// <remarks></remarks>
[XmlSerialization.XmlAttribute()]
public string AssemblyName
{
get
{
return m_AssemblyName;
}
set
{
m_AssemblyName = value;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More