本文整理汇总了C#中System.ServiceModel.Description.MetadataSet类的典型用法代码示例。如果您正苦于以下问题:C# MetadataSet类的具体用法?C# MetadataSet怎么用?C# MetadataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataSet类属于System.ServiceModel.Description命名空间,在下文中一共展示了MetadataSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:40,代码来源:MetadataFactory.cs
示例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);
}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:WsdlImporterTest.cs
示例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;
}
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:12,代码来源:CodeGeneratorContext.cs
示例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);
}
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:34,代码来源:ServiceMetadataBehaviorAttribute.cs
示例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);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:MexServiceChannelBuilder.cs
示例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;
}
开发者ID:riverans,项目名称:monodevelop,代码行数:7,代码来源:WebServiceDiscoveryResultWCF.cs
示例7: WriterMetadata
private static void WriterMetadata(MetadataSet metadata)
{
using (XmlWriter writer = new XmlTextWriter("metadata.xml", Encoding.UTF8))
{
metadata.WriteTo(writer);
}
Process.Start("metadata.xml");
}
开发者ID:gauge2009,项目名称:RPC,代码行数:8,代码来源:Program.cs
示例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);
}
}
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:8,代码来源:TestMetadata.cs
示例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);
}
}
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:9,代码来源:ServiceReferenceDiscoveryEventArgs.cs
示例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;
}
开发者ID:nicolas-raoul,项目名称:mono,代码行数:10,代码来源:WsdlHelper.cs
示例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();
}
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:11,代码来源:ClientServiceGenerator.cs
示例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;
}
开发者ID:camiloarthur,项目名称:WsdlFlattener,代码行数:11,代码来源:Flattener.cs
示例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);
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:12,代码来源:ServiceReferenceGeneratorTests.cs
示例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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:WsdlServiceChannelBuilder.cs
示例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);
}
开发者ID:gauge2009,项目名称:RPC,代码行数:13,代码来源:Program.cs
示例16: GenerateConfig
public static void GenerateConfig(MetadataSet metadata, Configuration config)
{
WsdlImporter importer = new WsdlImporter (metadata);
var endpoints = importer.ImportAllEndpoints ();
var generator = new ServiceContractGenerator (config);
generator.Options = ServiceContractGenerationOptions.None;
foreach (var endpoint in endpoints) {
ChannelEndpointElement channelElement;
generator.GenerateServiceEndpoint (endpoint, out channelElement);
}
}
开发者ID:baulig,项目名称:Provcon-Faust,代码行数:14,代码来源:Utils.cs
示例17: GenerateServiceReferenceProxy
void GenerateServiceReferenceProxy(MetadataSet metadata)
{
ServiceReferenceFileName referenceFileName = project.GetServiceReferenceFileName(Namespace);
CreateFolderForFileIfFolderMissing(referenceFileName.Path);
fileGenerator.ServiceReferenceNamespace = Namespace;
fileGenerator.GenerateProxyFile(metadata, referenceFileName.Path);
ServiceReferenceMapFileName mapFileName = project.GetServiceReferenceMapFileName(Namespace);
var mapFile = new ServiceReferenceMapFile(mapFileName);
fileGenerator.GenerateServiceReferenceMapFile(mapFile);
project.AddServiceReferenceProxyFile(referenceFileName);
project.AddServiceReferenceMapFile(mapFileName);
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:15,代码来源:ServiceReferenceGenerator.cs
示例18: CustomizeMexEndpoints
private static void CustomizeMexEndpoints(ServiceDescription description, ServiceHostBase host, MetadataSet metadata)
{
foreach (ChannelDispatcher channelDispatcher in host.ChannelDispatchers)
{
foreach (EndpointDispatcher endpoint in channelDispatcher.Endpoints)
{
if (endpoint.ContractName == MexContractName && endpoint.ContractNamespace == MexContractNamespace)
{
DispatchRuntime dispatchRuntime = endpoint.DispatchRuntime;
dispatchRuntime.InstanceContextProvider = Utility.CreateInstance<IInstanceContextProvider>(SingletonInstanceContextProviderType, new Type[] { typeof(DispatchRuntime) }, new object[] { dispatchRuntime });
MetadataProvisionService serviceInstance = new MetadataProvisionService(metadata);
dispatchRuntime.SingletonInstanceContext = new InstanceContext(host, serviceInstance);
}
}
}
}
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:16,代码来源:ServiceMetadataBehaviorAttribute.cs
示例19: GetGeneratedMetadata
public override MetadataSet GetGeneratedMetadata ()
{
if (metadata != null)
return metadata;
metadata = new MetadataSet ();
foreach (WSServiceDescription sd in GeneratedWsdlDocuments)
metadata.MetadataSections.Add (
MetadataSection.CreateFromServiceDescription (sd));
foreach (XmlSchema xs in GeneratedXmlSchemas.Schemas ())
metadata.MetadataSections.Add (
MetadataSection.CreateFromSchema (xs));
return metadata;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:16,代码来源:WsdlExporter.cs
示例20: Resolve
/// <summary>
/// Resolves metadata from the specified URL.
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>A list of metadata sections.</returns>
public static IEnumerable<MetadataSection> Resolve(string url)
{
MetadataSet metadataSet = new MetadataSet();
DiscoveryClientProtocol discoveryClient = new DiscoveryClientProtocol
{
UseDefaultCredentials = true,
AllowAutoRedirect = true
};
discoveryClient.DiscoverAny(url);
discoveryClient.ResolveAll();
foreach (object document in discoveryClient.Documents.Values)
{
AddDocumentToSet(metadataSet, document);
}
return metadataSet.MetadataSections;
}
开发者ID:gtri-iead,项目名称:LEXS-NET-Sample-Implementation-3.1.4,代码行数:22,代码来源:DiscoveryMetadataResolver.cs
注:本文中的System.ServiceModel.Description.MetadataSet类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论