本文整理汇总了C#中System.ServiceModel.Description.MetadataSet类的典型用法代码示例。如果您正苦于以下问题:C# MetadataSet类的具体用法?C# MetadataSet怎么用?C# MetadataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataSet类属于System.ServiceModel.Description命名空间,在下文中一共展示了MetadataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMetadataSet
/// <summary>
/// Retrieves and imports meta data for a given WSDL document specified by
/// WsdlDocument property.
/// </summary>
/// <param name="options">The metadata resolving options.</param>
/// <returns>A collection of service metadata in XML form.</returns>
public static MetadataSet GetMetadataSet(MetadataResolverOptions options)
{
if (options == null)
{
throw new ArgumentException("options could not be null.");
}
if (string.IsNullOrEmpty(options.MetadataLocation))
{
throw new ArgumentException("MetadataLocation option could not be null or an empty string.");
}
try
{
// First download the contracts if they are accessed over the web.
DownloadContract(options);
// Try to run RPC2DocumentLiteral converter.
TryTranslateRpc2DocumentLiteral(options);
MetadataSet metadataSet = new MetadataSet();
XmlDocument doc = new XmlDocument();
doc.Load(options.MetadataLocation);
MetadataSection ms = new MetadataSection(null, null, doc);
metadataSet.MetadataSections.Add(ms);
ResolveImports(options, metadataSet);
return metadataSet;
}
catch (Exception ex)
{
// TODO: Log exception.
throw new MetadataResolveException("Could not resolve metadata", ex);
}
}
示例2: NoExtensionsSetup
void NoExtensionsSetup ()
{
XmlReaderSettings xs = new XmlReaderSettings ();
xs.IgnoreWhitespace = true;
xtr = XmlTextReader.Create ("Test/System.ServiceModel.Description/dump.xml", xs);
xtr.Read ();
//FIXME: skipping Headers
while (xtr.LocalName != "Body") {
if (!xtr.Read ())
return;
}
//Move to <Metadata ..
xtr.Read ();
ms = MetadataSet.ReadFrom (xtr);
//MyWsdlImportExtension mw = new MyWsdlImportExtension ();
List<IWsdlImportExtension> list = new List<IWsdlImportExtension> ();
//list.Add (mw);
list.Add (new DataContractSerializerMessageContractImporter ());
/*list.Add (new MessageEncodingBindingElementImporter ());
list.Add (new TransportBindingElementImporter ());
list.Add (new StandardBindingImporter ());*/
wi = new WsdlImporter (ms, null, list);
}
示例3: CodeGeneratorContext
/// <summary>
/// Initializes a new instance of the <see cref="CodeGeneratorContext"/> class.
/// </summary>
/// <param name="metadataSet">The metadata set.</param>
/// <param name="codeGeneratorOptions">The code generator options.</param>
public CodeGeneratorContext(MetadataSet metadataSet, CodeGeneratorOptions codeGeneratorOptions)
{
MetadataSet = metadataSet;
CodeDomProvider = CodeDomProvider.CreateProvider(codeGeneratorOptions.CodeLanguage.ToString());
CodeCompileUnit = new CodeCompileUnit();
CodeGeneratorOptions = codeGeneratorOptions;
}
示例4: CreateHttpGetChannelDispatcher
private static void CreateHttpGetChannelDispatcher(ServiceHostBase host, Uri listenUri, MetadataSet metadata)
{
//创建Binding
TextMessageEncodingBindingElement messageEncodingElement = new TextMessageEncodingBindingElement() { MessageVersion = MessageVersion.None };
HttpTransportBindingElement transportElement = new HttpTransportBindingElement();
Utility.SetPropertyValue(transportElement, "Method", "GET");
Binding binding = new CustomBinding(messageEncodingElement, transportElement);
//创建ChannelListener
IChannelListener listener = binding.BuildChannelListener<IReplyChannel>(listenUri, string.Empty, ListenUriMode.Explicit, new BindingParameterCollection());
ChannelDispatcher dispatcher = new ChannelDispatcher(listener, "ServiceMetadataBehaviorHttpGetBinding", binding) { MessageVersion = binding.MessageVersion };
//创建EndpointDispatcher
EndpointDispatcher endpoint = new EndpointDispatcher(new EndpointAddress(listenUri), "IHttpGetMetadata", "http://www.artech.com/");
//创建DispatchOperation,并设置DispatchMessageFormatter和OperationInvoker
DispatchOperation operation = new DispatchOperation(endpoint.DispatchRuntime, "Get", "*", "*");
operation.Formatter = Utility.CreateInstance<IDispatchMessageFormatter>(MessageOperationFormatterType, Type.EmptyTypes, new object[0]);
MethodInfo method = typeof(IHttpGetMetadata).GetMethod("Get");
operation.Invoker = Utility.CreateInstance<IOperationInvoker>(SyncMethodInvokerType, new Type[] { typeof(MethodInfo) }, new object[] { method });
endpoint.DispatchRuntime.Operations.Add(operation);
//设置SingletonInstanceContext和InstanceContextProvider
MetadataProvisionService serviceInstance = new MetadataProvisionService(metadata);
endpoint.DispatchRuntime.SingletonInstanceContext = new InstanceContext(host, serviceInstance);
endpoint.DispatchRuntime.InstanceContextProvider = Utility.CreateInstance<IInstanceContextProvider>(SingletonInstanceContextProviderType, new Type[] { typeof(DispatchRuntime) }, new object[] { endpoint.DispatchRuntime });
dispatcher.Endpoints.Add(endpoint);
//设置ContractFilter和AddressFilter
endpoint.ContractFilter = new MatchAllMessageFilter();
endpoint.AddressFilter = new MatchAllMessageFilter();
host.ChannelDispatchers.Add(dispatcher);
}
示例5: AddDocumentToSet
private void AddDocumentToSet(MetadataSet metadataSet, object document)
{
System.Web.Services.Description.ServiceDescription serviceDescription = document as System.Web.Services.Description.ServiceDescription;
System.Xml.Schema.XmlSchema schema = document as System.Xml.Schema.XmlSchema;
XmlElement policy = document as XmlElement;
if (serviceDescription != null)
{
metadataSet.MetadataSections.Add(MetadataSection.CreateFromServiceDescription(serviceDescription));
}
else if (schema != null)
{
metadataSet.MetadataSections.Add(MetadataSection.CreateFromSchema(schema));
}
else if ((policy != null) && MetadataSection.IsPolicyElement(policy))
{
metadataSet.MetadataSections.Add(MetadataSection.CreateFromPolicy(policy, null));
}
else
{
MetadataSection item = new MetadataSection {
Metadata = document
};
metadataSet.MetadataSections.Add(item);
}
}
示例6: WebServiceDiscoveryResultWCF
public WebServiceDiscoveryResultWCF (DiscoveryClientProtocol protocol, MetadataSet metadata, WebReferenceItem item, ReferenceGroup refGroup, ClientOptions defaultOptions): base (WebReferencesService.WcfEngine, item)
{
this.refGroup = refGroup;
this.protocol = protocol;
this.metadata = metadata;
this.defaultOptions = defaultOptions;
}
示例7: WriterMetadata
private static void WriterMetadata(MetadataSet metadata)
{
using (XmlWriter writer = new XmlTextWriter("metadata.xml", Encoding.UTF8))
{
metadata.WriteTo(writer);
}
Process.Start("metadata.xml");
}
示例8: TestMetadata
static TestMetadata()
{
DataContractSerializer serializer = new DataContractSerializer(typeof(MetadataSet));
using (MemoryStream stream = new MemoryStream(Encoding.Default.GetBytes(Resources.RestaurantMetadata)))
{
metadataSet = (MetadataSet)serializer.ReadObject(stream);
}
}
示例9: GetServices
void GetServices(MetadataSet metadata)
{
foreach (MetadataSection section in metadata.MetadataSections) {
var service = section.Metadata as WebServices.ServiceDescription;
if (service != null) {
Services.Add(service);
}
}
}
示例10: GetMetadataSet
public static MetadataSet GetMetadataSet (Stream stream)
{
var dr = new ContractReference ();
var doc = (WebServices.Description.ServiceDescription) dr.ReadDocument (stream);
var metadata = new MetadataSet ();
metadata.MetadataSections.Add (
new MetadataSection (MetadataSection.ServiceDescriptionDialect, "", doc));
return metadata;
}
示例11: ClientServiceGenerator
public ClientServiceGenerator(MetadataSet metadataSet, PrimaryCodeGenerationOptions options, CodeDomProvider codeProvider)
{
Enforce.IsNotNull(metadataSet, "metadataSet");
this.options = Enforce.IsNotNull(options, "options");
this.codeProvider = Enforce.IsNotNull(codeProvider, "codeProvider");
compileUnit = new CodeCompileUnit();
wsdlImporter = new WsdlImporter(metadataSet);
InitializeConfiguration();
}
示例12: GetFlattenedServiceDescription
public ServiceDescription GetFlattenedServiceDescription(MetadataSet metadataSet)
{
var obj = Assembly.GetAssembly(typeof(WsdlExporter)).GetType("System.ServiceModel.Description.WsdlHelper", true)
.GetMethod("GetSingleWsdl", BindingFlags.Static | BindingFlags.Public)
.Invoke(null, new object[1] { metadataSet });
if (obj is ServiceDescription)
return (ServiceDescription)obj;
return null;
}
示例13: CreateGenerator
void CreateGenerator()
{
metadata = new MetadataSet();
fakeProject = MockRepository.GenerateStub<IProjectWithServiceReferences>();
fakeProxyGenerator = MockRepository.GenerateStub<IServiceReferenceProxyGenerator>();
fakeReferenceMapGenerator = MockRepository.GenerateStub<IServiceReferenceMapGenerator>();
fileGenerator = new ServiceReferenceFileGenerator(fakeProxyGenerator, fakeReferenceMapGenerator);
fakeFileSystem = MockRepository.GenerateStub<IFileSystem>();
generator = new ServiceReferenceGenerator(fakeProject, fileGenerator, fakeFileSystem);
}
示例14: CreateDataContractSerializerImporter
public WsdlImporter CreateDataContractSerializerImporter(MetadataSet metaData)
{
Collection<IWsdlImportExtension> wsdlImportExtensions = ClientSection.GetSection().Metadata.LoadWsdlImportExtensions();
for (int i = 0; i < wsdlImportExtensions.Count; i++)
{
if (wsdlImportExtensions[i].GetType() == typeof(XmlSerializerMessageContractImporter))
{
wsdlImportExtensions.RemoveAt(i);
}
}
return new WsdlImporter(metaData, null, wsdlImportExtensions);
}
示例15: GetMetadataViaHttpGet
private static void GetMetadataViaHttpGet()
{
MetadataSet metadata = new MetadataSet();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:3721/calculatorservice/metadata");
request.Method = "Get";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (XmlReader reader = XmlDictionaryReader.CreateTextReader(response.GetResponseStream(), new XmlDictionaryReaderQuotas()))
{
System.Web.Services.Description.ServiceDescription serviceDesc = System.Web.Services.Description.ServiceDescription.Read(reader);
metadata.MetadataSections.Add(MetadataSection.CreateFromServiceDescription(serviceDesc));
}
WriterMetadata(metadata);
}