Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Description / MetadataSection.cs / 1 / MetadataSection.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Description { using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Xml; using WsdlNS = System.Web.Services.Description; using XsdNS = System.Xml.Schema; using System.Reflection; using System.Xml.Serialization; [XmlRoot(ElementName = MetadataStrings.MetadataExchangeStrings.MetadataSection, Namespace = MetadataStrings.MetadataExchangeStrings.Namespace)] public class MetadataSection { Collectionattributes = new Collection (); string dialect; string identifier; object metadata; string sourceUrl; static XmlDocument xmlDocument = new XmlDocument(); public MetadataSection() : this(null, null, null) { } public MetadataSection(string dialect, string identifier, object metadata) { this.dialect = dialect; this.identifier = identifier; this.metadata = metadata; } static public string ServiceDescriptionDialect { get { return System.Web.Services.Description.ServiceDescription.Namespace; } } static public string XmlSchemaDialect { get { return System.Xml.Schema.XmlSchema.Namespace; } } static public string PolicyDialect { get { return MetadataStrings.WSPolicy.NamespaceUri; } } static public string MetadataExchangeDialect { get { return MetadataStrings.MetadataExchangeStrings.Namespace; } } [XmlAnyAttribute] public Collection Attributes { get { return attributes; } } [XmlAttribute] public string Dialect { get { return this.dialect; } set { this.dialect = value; } } [XmlAttribute] public string Identifier { get { return this.identifier; } set { this.identifier = value; } } [XmlAnyElement] [XmlElement(MetadataStrings.XmlSchema.Schema, typeof(XsdNS.XmlSchema), Namespace = XsdNS.XmlSchema.Namespace)] //typeof(WsdlNS.ServiceDescription) produces an XmlSerializer which can't export / import the Extensions in the ServiceDescription. //We use change this to typeof(string) and then fix the generated serializer to use the Read/Write //methods provided by WsdlNS.ServiceDesciption which use a pregenerated serializer which can export / import the Extensions. [XmlElement(MetadataStrings.ServiceDescription.Definitions, typeof(WsdlNS.ServiceDescription), Namespace = WsdlNS.ServiceDescription.Namespace)] [XmlElement(MetadataStrings.MetadataExchangeStrings.MetadataReference, typeof(MetadataReference), Namespace = MetadataStrings.MetadataExchangeStrings.Namespace)] [XmlElement(MetadataStrings.MetadataExchangeStrings.Location, typeof(MetadataLocation), Namespace = MetadataStrings.MetadataExchangeStrings.Namespace)] [XmlElement(MetadataStrings.MetadataExchangeStrings.Metadata, typeof(MetadataSet), Namespace = MetadataStrings.MetadataExchangeStrings.Namespace)] public object Metadata { get { return this.metadata; } set { this.metadata = value; } } internal string SourceUrl { get { return sourceUrl; } set { sourceUrl = value; } } public static MetadataSection CreateFromPolicy(XmlElement policy, string identifier) { if (policy == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policy"); } if (!IsPolicyElement(policy)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("policy", #pragma warning suppress 56506 // [....], policy cannot be null at this point since it has been validated above. SR.GetString(SR.SFxBadMetadataMustBePolicy, MetadataStrings.WSPolicy.NamespaceUri, MetadataStrings.WSPolicy.Elements.Policy, policy.NamespaceURI, policy.LocalName)); } MetadataSection section = new MetadataSection(); section.Dialect = policy.NamespaceURI; section.Identifier = identifier; section.Metadata = policy; return section; } public static MetadataSection CreateFromSchema(XsdNS.XmlSchema schema) { if (schema == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("schema"); } MetadataSection section = new MetadataSection(); section.Dialect = MetadataSection.XmlSchemaDialect; section.Identifier = schema.TargetNamespace; section.Metadata = schema; return section; } public static MetadataSection CreateFromServiceDescription(WsdlNS.ServiceDescription serviceDescription) { if (serviceDescription == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceDescription"); } MetadataSection section = new MetadataSection(); section.Dialect = MetadataSection.ServiceDescriptionDialect; section.Identifier = serviceDescription.TargetNamespace; section.Metadata = serviceDescription; return section; } internal static bool IsPolicyElement(XmlElement policy) { return (policy.NamespaceURI == MetadataStrings.WSPolicy.NamespaceUri || policy.NamespaceURI == MetadataStrings.WSPolicy.NamespaceUri15) && policy.LocalName == MetadataStrings.WSPolicy.Elements.Policy; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CapabilitiesState.cs
- WebPartDesigner.cs
- SimpleHandlerFactory.cs
- RangeBaseAutomationPeer.cs
- ObjectDataSourceStatusEventArgs.cs
- wgx_commands.cs
- DivideByZeroException.cs
- ReflectionTypeLoadException.cs
- ProfessionalColors.cs
- ZipIOLocalFileDataDescriptor.cs
- ChoiceConverter.cs
- XmlQueryOutput.cs
- ControllableStoryboardAction.cs
- MetadataSource.cs
- WebPartTransformerCollection.cs
- ProviderConnectionPointCollection.cs
- Brush.cs
- DataRowView.cs
- AdPostCacheSubstitution.cs
- BufferAllocator.cs
- SHA256Managed.cs
- ActivityDesigner.cs
- _StreamFramer.cs
- CompressionTransform.cs
- CompiledRegexRunnerFactory.cs
- _AutoWebProxyScriptWrapper.cs
- GPRECTF.cs
- EventSourceCreationData.cs
- ScriptReference.cs
- MessageQueuePermissionEntryCollection.cs
- Line.cs
- ConfigXmlSignificantWhitespace.cs
- DataStreams.cs
- Soap.cs
- StylusButtonEventArgs.cs
- NativeCppClassAttribute.cs
- FilterQuery.cs
- LineServicesRun.cs
- RegexRunner.cs
- TextEditorSpelling.cs
- SmiGettersStream.cs
- HttpResponseBase.cs
- TemplatedControlDesigner.cs
- SqlRowUpdatedEvent.cs
- CustomLineCap.cs
- EllipseGeometry.cs
- SchemaImporterExtension.cs
- SpellerStatusTable.cs
- MoveSizeWinEventHandler.cs
- DataGridViewCellValidatingEventArgs.cs
- HttpsTransportElement.cs
- ContentDisposition.cs
- MailMessage.cs
- XmlAnyElementAttributes.cs
- SqlNodeAnnotations.cs
- User.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- ParallelTimeline.cs
- WsdlBuildProvider.cs
- AssertUtility.cs
- ManagementDateTime.cs
- XmlElementAttribute.cs
- UnsafeNativeMethodsTablet.cs
- OletxResourceManager.cs
- Font.cs
- XNodeNavigator.cs
- Root.cs
- QilInvokeLateBound.cs
- XmlNodeList.cs
- PkcsMisc.cs
- precedingquery.cs
- ProfileGroupSettingsCollection.cs
- HttpApplicationFactory.cs
- PropertyTabChangedEvent.cs
- LOSFormatter.cs
- Codec.cs
- ListViewGroupItemCollection.cs
- TraceInternal.cs
- ModelEditingScope.cs
- LayoutExceptionEventArgs.cs
- DeferredRunTextReference.cs
- CommandExpr.cs
- ReturnType.cs
- RoutedUICommand.cs
- Rule.cs
- MetafileEditor.cs
- FieldReference.cs
- TimeStampChecker.cs
- ToolStripGrip.cs
- SecondaryIndexDefinition.cs
- WebPartConnectionsCancelEventArgs.cs
- ArgumentOutOfRangeException.cs
- WebPartRestoreVerb.cs
- TabItem.cs
- Rect3D.cs
- HttpRequest.cs
- XmlEncodedRawTextWriter.cs
- StylusCaptureWithinProperty.cs
- ChannelManagerBase.cs
- StorageAssociationSetMapping.cs