public void HttpOperationDescription_Default_Ctor() { HttpOperationDescription hod = new HttpOperationDescription(); HttpParameter returnValue = hod.ReturnValue; Assert.IsNull(returnValue, "ReturnValue should initialize to null"); Collection <Attribute> attributes = hod.Attributes; Assert.IsNotNull(attributes, "Attributes should initialize to non-null"); Assert.AreEqual(0, attributes.Count, "Attributes should initialize to empty collection"); IList <HttpParameter> inputs = hod.InputParameters; Assert.IsNotNull(inputs, "InputParameters should initialize to non-null"); Assert.AreEqual(0, inputs.Count, "InputParameters should initialize to empty collection"); IList <HttpParameter> outputs = hod.OutputParameters; Assert.IsNotNull(outputs, "OutputParameters should initialize to non-null"); Assert.AreEqual(0, outputs.Count, "OutputParameters should initialize to empty collection"); KeyedByTypeCollection <IOperationBehavior> behaviors = hod.Behaviors; Assert.IsNotNull(behaviors, "Behaviors should initialize to non-null"); Assert.AreEqual(0, behaviors.Count, "Behaviors should initialize to empty"); Collection <Type> knownTypes = hod.KnownTypes; Assert.IsNotNull(knownTypes, "knownTypes should initialize to non-null"); Assert.AreEqual(0, knownTypes.Count, "knownTypes should initialize to empty"); Assert.IsNull(hod.DeclaringContract, "DeclaringContract should initialize to null"); }
void AddServiceBehaviors(string configurationName, bool throwIfNotFound) { if (configurationName == null) { return; } ServiceBehaviorElement behavior = ConfigUtil.BehaviorsSection.ServiceBehaviors [configurationName]; if (behavior == null) { if (throwIfNotFound) { throw new ArgumentException(String.Format("Service behavior configuration '{0}' was not found", configurationName)); } return; } KeyedByTypeCollection <IServiceBehavior> behaviors = Description.Behaviors; foreach (var bxe in behavior) { IServiceBehavior b = (IServiceBehavior)bxe.CreateBehavior(); if (behaviors.Contains(b.GetType())) { continue; } behaviors.Add(b); } }
private static void AddErrorHandlers(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden) { var errorHandlers = new KeyedByTypeCollection <IErrorHandler>(); WcfUtils.AddBehaviors(kernel, WcfExtensionScope.Services, errorHandlers, burden, errorHandler => WcfUtils.RegisterErrorHandler(serviceHost, errorHandler, true)); }
public void HttpOperationDescription_All_Properties_Mutable() { HttpOperationDescription hod = new HttpOperationDescription(); MethodInfo methodInfo = MethodInfo.GetCurrentMethod() as MethodInfo; ContractDescription cd = new ContractDescription("SampleContract"); hod.DeclaringContract = cd; Assert.AreSame(cd, hod.DeclaringContract, "DeclaringContract was not settable"); hod.DeclaringContract = null; Assert.IsNull(hod.DeclaringContract, "DeclaringContract was not resettable"); Collection <Attribute> attributes = hod.Attributes; Attribute attr = new DescriptionAttribute("SampleAttr"); attributes.Add(attr); Assert.AreEqual(1, hod.Attributes.Count, "Failed to add to Attributes"); Assert.AreSame(attr, hod.Attributes[0], "Attribute added but not readable"); Collection <Type> knownTypes = hod.KnownTypes; Type kt = this.GetType(); knownTypes.Add(kt); Assert.AreEqual(1, hod.KnownTypes.Count, "Failed to add to KnownTypes"); Assert.AreSame(kt, hod.KnownTypes[0], "KnownType added but not readable"); KeyedByTypeCollection <IOperationBehavior> behaviors = hod.Behaviors; IOperationBehavior opBehavior = new MockOperationBehavior(); behaviors.Add(opBehavior); Assert.AreEqual(1, hod.Behaviors.Count, "Failed to add to Behaviors"); Assert.AreSame(opBehavior, hod.Behaviors[0], "Behaviors added but not readable"); }
internal IssuedTokenClientCredential(IssuedTokenClientCredential other) { this.defaultKeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy; this.cacheIssuedTokens = true; this.maxIssuedTokenCachingTime = IssuanceTokenProviderBase <SspiNegotiationTokenProviderState> .DefaultClientMaxTokenCachingTime; this.issuedTokenRenewalThresholdPercentage = 60; this.defaultKeyEntropyMode = other.defaultKeyEntropyMode; this.cacheIssuedTokens = other.cacheIssuedTokens; this.issuedTokenRenewalThresholdPercentage = other.issuedTokenRenewalThresholdPercentage; this.maxIssuedTokenCachingTime = other.maxIssuedTokenCachingTime; this.localIssuerAddress = other.localIssuerAddress; this.localIssuerBinding = (other.localIssuerBinding != null) ? new CustomBinding(other.localIssuerBinding) : null; if (other.localIssuerChannelBehaviors != null) { this.localIssuerChannelBehaviors = this.GetBehaviorCollection(other.localIssuerChannelBehaviors); } if (other.issuerChannelBehaviors != null) { this.issuerChannelBehaviors = new Dictionary <Uri, KeyedByTypeCollection <IEndpointBehavior> >(); foreach (Uri uri in other.issuerChannelBehaviors.Keys) { this.issuerChannelBehaviors.Add(uri, this.GetBehaviorCollection(other.issuerChannelBehaviors[uri])); } } this.isReadOnly = other.isReadOnly; }
public CoreFederatedTokenProvider(SafeFreeCredentials credentialsHandle) : base() { this.credentialsHandle = credentialsHandle; this.channelBehaviors = new KeyedByTypeCollection <IEndpointBehavior>(); this.addTargetServiceAppliesTo = true; this.keyEntropyMode = defaultKeyEntropyMode; }
private static void GetIServiceBehaviorAttributes(Type currentServiceType, KeyedByTypeCollection <IServiceBehavior> behaviors) { foreach (IServiceBehavior behavior in ServiceReflector.GetCustomAttributes(currentServiceType, typeof(IServiceBehavior))) { behaviors.Add(behavior); } }
internal ServiceInfo(ServiceHostBase service) { this.service = service; this.behaviors = service.Description.Behaviors; this.serviceName = service.Description.Name; this.endpoints = new EndpointInfoCollection(service.Description.Endpoints, this.ServiceName); }
public static ItemModule AddModule(ItemTemplate template, Type type, KeyedByTypeCollection <ItemModule> keyedModules = null) { if (template == null || type == null) { return(null); } if (keyedModules == null) { keyedModules = new KeyedByTypeCollection <ItemModule>(template.modules.Where(x => x is not CommonModule)); } if (!CommonModule.IsCommon(type) && keyedModules.Contains(type)) { return(null); } var attr = type.GetCustomAttribute <ItemModule.RequireAttribute>(); if (attr != null) { foreach (var m in attr.modules) { if (m != type) { AddModule(template, m, keyedModules); } } } ItemModule module = Activator.CreateInstance(type) as ItemModule; template.modules.Add(module); if (!CommonModule.IsCommon(type)) { keyedModules.Add(module); } return(module); }
private static void AddErrorHandlers(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden) { var errorHandlers = new KeyedByTypeCollection<IErrorHandler>(); WcfUtils.AddBehaviors(kernel, WcfExtensionScope.Services, errorHandlers, burden, errorHandler => { return WcfUtils.RegisterErrorHandler(serviceHost, errorHandler, true); }); }
public void ConfigureBehavior(KeyedByTypeCollection<IServiceBehavior> behaviors) { var serviceDebugBehavior = behaviors.Find<ServiceDebugBehavior>(); if (serviceDebugBehavior != null) { serviceDebugBehavior.IncludeExceptionDetailInFaults = Config.Wcf.ExceptionDetails; } }
public void ConfigureBehavior(KeyedByTypeCollection <IServiceBehavior> behaviors) { var serviceDebugBehavior = behaviors.Find <ServiceDebugBehavior>(); if (serviceDebugBehavior != null) { serviceDebugBehavior.IncludeExceptionDetailInFaults = Config.Wcf.ExceptionDetails; } }
private void ApplyCommonServiceHostBehaviors() { KeyedByTypeCollection <IServiceBehavior> serviceBehaviors = Description.Behaviors; if (!ServiceHostContainsBehavior(typeof(UnhandledExceptionsLoggingBehaviorAttribute))) { serviceBehaviors.Add(new UnhandledExceptionsLoggingBehaviorAttribute()); } }
private static void AddServiceHostExtensions(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden) { var extensions = new KeyedByTypeCollection<IExtension<ServiceHostBase>>(); WcfUtils.AddBehaviors(kernel, WcfExtensionScope.Services, extensions, burden, extension => { serviceHost.Extensions.Add(extension); return true; }); }
public TConfig Get <TConfig>() where TConfig : class, new() { if (_keyedByTypeCollection == null) { _keyedByTypeCollection = _configReader.ReadConfigs(TxtLocalStorage.GetConfigFiles()); } return(_objectCreator.Create <TConfig>(_keyedByTypeCollection.Get(typeof(TConfig)))); }
public static void ApplyServiceBehaviors(KeyedByTypeCollection <IServiceBehavior> behaviors, IUnityContainer container) { var registeredServiceBehaviors = container.ResolveAll <IServiceBehavior>(); foreach (var serviceBehavior in registeredServiceBehaviors) { behaviors.Add(serviceBehavior); } }
/// <summary> /// Initializes a new instance of the <see cref="ScanContext"/> class. /// </summary> public ScanContext(IScannerFactory factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } Factory = factory; Options = new KeyedByTypeCollection <IScanOption>(); }
private static void AddServiceHostExtensions(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden) { var extensions = new KeyedByTypeCollection <IExtension <ServiceHostBase> >(); WcfUtils.AddBehaviors(kernel, WcfExtensionScope.Services, extensions, burden, extension => { serviceHost.Extensions.Add(extension); return(true); }); }
KeyedByTypeCollection <IEndpointBehavior> GetBehaviorCollection(KeyedByTypeCollection <IEndpointBehavior> behaviors) { KeyedByTypeCollection <IEndpointBehavior> result = new KeyedByTypeCollection <IEndpointBehavior>(); foreach (IEndpointBehavior behavior in behaviors) { result.Add(behavior); } return(result); }
public static bool AttachExtension <T>(KeyedByTypeCollection <T> candidates, object extension) { Type owner = null; if (IsExtension(extension, ref owner)) { return(AttachExtension(candidates, extension, owner)); } return(false); }
public static bool AttachExtension <T>(KeyedByTypeCollection <T> candidates, object extension, Type owner) { if (typeof(T).IsAssignableFrom(owner)) { var helper = (IWcfExtensionHelper)Activator.CreateInstance(typeof(WcfExtensionHelper <,>) .MakeGenericType(typeof(T), owner), candidates); return(helper.AddExtension(extension)); } return(false); }
private KeyedByTypeCollection <IEndpointBehavior> GetBehaviorCollection(KeyedByTypeCollection <IEndpointBehavior> behaviors) { KeyedByTypeCollection <IEndpointBehavior> types = new KeyedByTypeCollection <IEndpointBehavior>(); foreach (IEndpointBehavior behavior in behaviors) { types.Add(behavior); } return(types); }
internal ServiceDescription(string serviceName) { this.behaviors = new KeyedByTypeCollection <IServiceBehavior>(); this.endpoints = new ServiceEndpointCollection(); this.serviceNamespace = "http://tempuri.org/"; if (string.IsNullOrEmpty(serviceName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceName"); } this.Name = serviceName; }
internal ServiceDescription(string serviceName) { this.behaviors = new KeyedByTypeCollection<IServiceBehavior>(); this.endpoints = new ServiceEndpointCollection(); this.serviceNamespace = "http://tempuri.org/"; if (string.IsNullOrEmpty(serviceName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceName"); } this.Name = serviceName; }
public ContractDescription(string name, string ns) { this.behaviors = new KeyedByTypeCollection<IContractBehavior>(); this.Name = name; if (!string.IsNullOrEmpty(ns)) { NamingHelper.CheckUriParameter(ns, "ns"); } this.operations = new OperationDescriptionCollection(); this.ns = ns ?? "http://tempuri.org/"; }
public void HostingMockedService() { var mock = MockRepository.Partial <ServiceClassImpl>(); ServiceHost host = new ServiceHost((IServiceClassInterface)mock, new Uri("net.tcp://localhost:9876/MyService")); ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IServiceClassInterface), new NetTcpBinding(), "net.tcp://localhost:9876/MyService"); KeyedByTypeCollection <IEndpointBehavior> behaviors = endpoint.Behaviors; host.Open(); host.Close(); }
public ContractDescription(string name, string ns) { this.behaviors = new KeyedByTypeCollection <IContractBehavior>(); this.Name = name; if (!string.IsNullOrEmpty(ns)) { NamingHelper.CheckUriParameter(ns, "ns"); } this.operations = new OperationDescriptionCollection(); this.ns = ns ?? "http://tempuri.org/"; }
internal EndpointInfo(ServiceEndpoint endpoint, string serviceName) { this.endpoint = endpoint; this.address = endpoint.Address.Uri; this.headers = endpoint.Address.Headers; this.identity = endpoint.Address.Identity; this.behaviors = endpoint.Behaviors; this.serviceName = serviceName; this.binding = (endpoint.Binding == null) ? new CustomBinding() : new CustomBinding(endpoint.Binding); this.contract = endpoint.Contract; }
public ServiceEndpoint(ContractDescription contract, Binding binding, EndpointAddress address) { if (contract == null) throw new ArgumentNullException ("contract"); this.contract = contract; this.binding = binding; this.address = address; behaviors = new KeyedByTypeCollection<IEndpointBehavior> (); }
internal EndpointInfo(ServiceEndpoint endpoint, string serviceName) { this.endpoint = endpoint; this.address = endpoint.Address.Uri; this.headers = endpoint.Address.Headers; this.identity = endpoint.Address.Identity; this.behaviors = endpoint.Behaviors; this.serviceName = serviceName; this.binding = (endpoint.Binding == null) ? new CustomBinding() : new CustomBinding(endpoint.Binding); this.contract = endpoint.Contract; }
public static void RemoveReceiveFromFormatterBehavior(Receive receive, OperationDescription operation) { Fx.Assert(receive != null && operation != null, "Arguments cannot be null!"); KeyedByTypeCollection <IOperationBehavior> behaviors = operation.Behaviors; WorkflowFormatterBehavior formatterBehavior = behaviors.Find <WorkflowFormatterBehavior>(); if (formatterBehavior != null) { formatterBehavior.Receives.Remove(receive); } }
public static void AddReceiveToFormatterBehavior(Receive receive, OperationDescription operation) { KeyedByTypeCollection <IOperationBehavior> behaviors = operation.Behaviors; WorkflowFormatterBehavior item = behaviors.Find <WorkflowFormatterBehavior>(); if (item == null) { item = new WorkflowFormatterBehavior(); behaviors.Add(item); } item.Receives.Add(receive); }
internal MetadataImporter (IEnumerable<IPolicyImportExtension> policyImportExtensions) { if (policyImportExtensions != null) { policy_extensions = new KeyedByTypeCollection<IPolicyImportExtension> (policyImportExtensions); return; } //FIXME: Complete the list policy_extensions = new KeyedByTypeCollection<IPolicyImportExtension> (); policy_extensions.Add (new TransportBindingElementImporter ()); policy_extensions.Add (new MessageEncodingBindingElementImporter ()); }
private static void AddErrorHandler(KeyedByTypeCollection <IServiceBehavior> behaviors, ICollection <IErrorHandler> errorHandlers) { var wcfErrorBehavior = behaviors.Find <WcfErrorBehavior>(); if (wcfErrorBehavior == null) { behaviors.Add(new WcfErrorBehavior(errorHandlers)); } else { wcfErrorBehavior.Add(errorHandlers); } }
internal MetadataImporter(IEnumerable <IPolicyImportExtension> policyImportExtensions) { if (policyImportExtensions != null) { policy_extensions = new KeyedByTypeCollection <IPolicyImportExtension> (policyImportExtensions); return; } //FIXME: Complete the list policy_extensions = new KeyedByTypeCollection <IPolicyImportExtension> (); policy_extensions.Add(new TransportBindingElementImporter()); policy_extensions.Add(new MessageEncodingBindingElementImporter()); }
public ServiceEndpoint(ContractDescription contract, Binding binding, EndpointAddress address) { if (contract == null) { throw new ArgumentNullException("contract"); } this.contract = contract; this.binding = binding; this.address = address; behaviors = new KeyedByTypeCollection <IEndpointBehavior> (); }
public WsdlImporter( MetadataSet metadata, IEnumerable <IPolicyImportExtension> policyImportExtensions, IEnumerable <IWsdlImportExtension> wsdlImportExtensions) : base(policyImportExtensions) { if (metadata == null) { throw new ArgumentNullException("metadata"); } if (wsdlImportExtensions == null) { wsdl_extensions = new KeyedByTypeCollection <IWsdlImportExtension> (); wsdl_extensions.Add(new DataContractSerializerMessageContractImporter()); wsdl_extensions.Add(new XmlSerializerMessageContractImporter()); wsdl_extensions.Add(new MessageEncodingBindingElementImporter()); wsdl_extensions.Add(new TransportBindingElementImporter()); wsdl_extensions.Add(new StandardBindingImporter()); } else { wsdl_extensions = new KeyedByTypeCollection <IWsdlImportExtension> (wsdlImportExtensions); } // It is okay to fill these members immediately when WsdlImporter.ctor() is invoked // i.e. after this .ctor(), those metadata docs are not considered anymore. this.metadata = metadata; this.wsdl_documents = new ServiceDescriptionCollection(); this.xmlschemas = new XmlSchemaSet(); this.policies = new List <XmlElement> (); this.contractHash = new Dictionary <PortType, ContractDescription> (); this.bindingHash = new Dictionary <WSBinding, ServiceEndpoint> (); this.endpointHash = new Dictionary <Port, ServiceEndpoint> (); foreach (MetadataSection ms in metadata.MetadataSections) { if (ms.Dialect == MetadataSection.ServiceDescriptionDialect && ms.Metadata.GetType() == typeof(WSServiceDescription)) { wsdl_documents.Add((WSServiceDescription)ms.Metadata); } else if (ms.Dialect == MetadataSection.XmlSchemaDialect && ms.Metadata.GetType() == typeof(XmlSchema)) { xmlschemas.Add((XmlSchema)ms.Metadata); } } }
internal EndpointInfo(ServiceEndpoint endpoint, string serviceName) { Fx.Assert(null != endpoint, "endpoint cannot be null"); this.endpoint = endpoint; this.address = endpoint.Address.Uri; this.headers = endpoint.Address.Headers; this.identity = endpoint.Address.Identity; this.behaviors = endpoint.Behaviors; this.serviceName = serviceName; this.binding = null == endpoint.Binding ? new CustomBinding() : new CustomBinding(endpoint.Binding); this.contract = endpoint.Contract; }
private void CheckDefaultWsdlImportExtensions(KeyedByTypeCollection <IWsdlImportExtension> list) { Assert.IsNotNull(list, "#CN20"); // 5 in 3.0, 6 in 3.5 // Assert.AreEqual (6, list.Count, "#CN21"); Assert.AreEqual(typeof(DataContractSerializerMessageContractImporter), list [0].GetType(), "#CN22"); Assert.AreEqual(typeof(XmlSerializerMessageContractImporter), list [1].GetType(), "#CN23"); Assert.AreEqual(typeof(MessageEncodingBindingElementImporter), list [2].GetType(), "#CN24"); Assert.AreEqual(typeof(TransportBindingElementImporter), list [3].GetType(), "#CN25"); Assert.AreEqual(typeof(StandardBindingImporter), list [4].GetType(), "#CN26"); // It is in System.WorkflowServices.dll (3.5) //Assert.AreEqual (typeof (ContextBindingElementImporter), list [5].GetType (), "#CN27"); }
internal EndpointInfo(ServiceEndpoint endpoint, string serviceName) { Fx.Assert(null != endpoint, "endpoint cannot be null"); this.endpoint = endpoint; this.address = endpoint.Address.Uri; this.headers = endpoint.Address.Headers; this.identity = endpoint.Address.Identity; this.behaviors = endpoint.Behaviors; this.serviceName = serviceName; this.binding = null == endpoint.Binding ? new CustomBinding() : new CustomBinding(endpoint.Binding); this.contract = endpoint.Contract; }
private void CopyIssuerChannelBehaviorsAndAddSecurityCredentials(IssuedSecurityTokenProvider federationTokenProvider, KeyedByTypeCollection<IEndpointBehavior> issuerChannelBehaviors, EndpointAddress issuerAddress) { if (issuerChannelBehaviors != null) { foreach (IEndpointBehavior behavior in issuerChannelBehaviors) { if (behavior is SecurityCredentialsManager) { throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("IssuerChannelBehaviorsCannotContainSecurityCredentialsManager", new object[] { issuerAddress, typeof(SecurityCredentialsManager) }))); } federationTokenProvider.IssuerChannelBehaviors.Add(behavior); } } federationTokenProvider.IssuerChannelBehaviors.Add(this.parent); }
internal MetadataImporter(IEnumerable<IPolicyImportExtension> policyImportExtensions, MetadataImporterQuotas quotas) { if (quotas == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("quotas"); } if (policyImportExtensions == null) { policyImportExtensions = LoadPolicyExtensionsFromConfig(); } this.Quotas = quotas; this.policyExtensions = new KeyedByTypeCollection<IPolicyImportExtension>(policyImportExtensions); }
public override IChannelFactory<IRequestChannel> CreateFederationProxy(EndpointAddress address, Binding binding, KeyedByTypeCollection<IEndpointBehavior> channelBehaviors) { if (channelBehaviors == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelBehaviors"); } ChannelFactory<IWsTrustDec2005SecurityTokenService> innerChannelFactory = new ChannelFactory<IWsTrustDec2005SecurityTokenService>(binding, address); base.SetProtectionLevelForFederation(innerChannelFactory.Endpoint.Contract.Operations); innerChannelFactory.Endpoint.Behaviors.Remove<ClientCredentials>(); for (int i = 0; i < channelBehaviors.Count; i++) { innerChannelFactory.Endpoint.Behaviors.Add(channelBehaviors[i]); } innerChannelFactory.Endpoint.Behaviors.Add(new WSTrustFeb2005.DriverFeb2005.InteractiveInitializersRemovingBehavior()); return new WSTrustFeb2005.DriverFeb2005.RequestChannelFactory<IWsTrustDec2005SecurityTokenService>(innerChannelFactory); }
internal IssuedTokenClientCredential(IssuedTokenClientCredential other) { this.defaultKeyEntropyMode = other.defaultKeyEntropyMode; this.cacheIssuedTokens = other.cacheIssuedTokens; this.issuedTokenRenewalThresholdPercentage = other.issuedTokenRenewalThresholdPercentage; this.maxIssuedTokenCachingTime = other.maxIssuedTokenCachingTime; this.localIssuerAddress = other.localIssuerAddress; this.localIssuerBinding = (other.localIssuerBinding != null) ? new CustomBinding(other.localIssuerBinding) : null; if (other.localIssuerChannelBehaviors != null) this.localIssuerChannelBehaviors = GetBehaviorCollection(other.localIssuerChannelBehaviors); if (other.issuerChannelBehaviors != null) { this.issuerChannelBehaviors = new Dictionary<Uri, KeyedByTypeCollection<IEndpointBehavior>>(); foreach (Uri uri in other.issuerChannelBehaviors.Keys) { this.issuerChannelBehaviors.Add(uri, GetBehaviorCollection(other.issuerChannelBehaviors[uri])); } } this.isReadOnly = other.isReadOnly; }
public WsdlImporter ( MetadataSet metadata, IEnumerable<IPolicyImportExtension> policyImportExtensions, IEnumerable<IWsdlImportExtension> wsdlImportExtensions) : base (policyImportExtensions) { if (metadata == null) throw new ArgumentNullException ("metadata"); if (wsdlImportExtensions == null) { wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> (); wsdl_extensions.Add (new DataContractSerializerMessageContractImporter ()); wsdl_extensions.Add (new XmlSerializerMessageContractImporter ()); wsdl_extensions.Add (new MessageEncodingBindingElementImporter ()); wsdl_extensions.Add (new TransportBindingElementImporter ()); wsdl_extensions.Add (new StandardBindingImporter ()); } else { wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> (wsdlImportExtensions); } // It is okay to fill these members immediately when WsdlImporter.ctor() is invoked // i.e. after this .ctor(), those metadata docs are not considered anymore. this.metadata = metadata; this.wsdl_documents = new ServiceDescriptionCollection (); this.xmlschemas = new XmlSchemaSet (); this.policies = new List<XmlElement> (); this.contractHash = new Dictionary<PortType, ContractDescription> (); this.bindingHash = new Dictionary<WSBinding, ServiceEndpoint> (); this.endpointHash = new Dictionary<Port, ServiceEndpoint> (); foreach (MetadataSection ms in metadata.MetadataSections) { if (ms.Dialect == MetadataSection.ServiceDescriptionDialect && ms.Metadata.GetType () == typeof (WSServiceDescription)) wsdl_documents.Add ((WSServiceDescription) ms.Metadata); else if (ms.Dialect == MetadataSection.XmlSchemaDialect && ms.Metadata.GetType () == typeof (XmlSchema)) xmlschemas.Add ((XmlSchema) ms.Metadata); } }
public OperationDescription(string name, ContractDescription declaringContract) { if (name == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name"); } if (name.Length == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("name", SR.SFxOperationDescriptionNameCannotBeEmpty)); } _name = new XmlName(name, true /*isEncoded*/); if (declaringContract == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringContract"); } _declaringContract = declaringContract; _isInitiating = true; _faults = new FaultDescriptionCollection(); _messages = new MessageDescriptionCollection(); _behaviors = new KeyedByTypeCollection<IOperationBehavior>(); _knownTypes = new Collection<Type>(); }
internal void ApplyConfiguration(IssuedTokenClientCredential issuedToken) { if (issuedToken == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuedToken"); } issuedToken.CacheIssuedTokens = this.CacheIssuedTokens; issuedToken.DefaultKeyEntropyMode = this.DefaultKeyEntropyMode; issuedToken.MaxIssuedTokenCachingTime = this.MaxIssuedTokenCachingTime; issuedToken.IssuedTokenRenewalThresholdPercentage = this.IssuedTokenRenewalThresholdPercentage; if (base.ElementInformation.Properties["localIssuer"].ValueOrigin != PropertyValueOrigin.Default) { this.LocalIssuer.Validate(); issuedToken.LocalIssuerAddress = ConfigLoader.LoadEndpointAddress(this.LocalIssuer); if (!string.IsNullOrEmpty(this.LocalIssuer.Binding)) { issuedToken.LocalIssuerBinding = ConfigLoader.LookupBinding(this.LocalIssuer.Binding, this.LocalIssuer.BindingConfiguration, base.EvaluationContext); } } if (!string.IsNullOrEmpty(this.LocalIssuerChannelBehaviors)) { ConfigLoader.LoadChannelBehaviors(this.LocalIssuerChannelBehaviors, base.EvaluationContext, issuedToken.LocalIssuerChannelBehaviors); } if (base.ElementInformation.Properties["issuerChannelBehaviors"].ValueOrigin != PropertyValueOrigin.Default) { foreach (IssuedTokenClientBehaviorsElement element in this.IssuerChannelBehaviors) { if (!string.IsNullOrEmpty(element.BehaviorConfiguration)) { KeyedByTypeCollection<IEndpointBehavior> channelBehaviors = new KeyedByTypeCollection<IEndpointBehavior>(); ConfigLoader.LoadChannelBehaviors(element.BehaviorConfiguration, base.EvaluationContext, channelBehaviors); issuedToken.IssuerChannelBehaviors.Add(new Uri(element.IssuerAddress), channelBehaviors); } } } }
// Methods public OperationDescription(string name, ContractDescription declaringContract) { this.validateRpcWrapperName = true; if (name == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name"); } if (name.Length == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("name", SR.GetString("SFxOperationDescriptionNameCannotBeEmpty"))); } this.name = new XmlName(name, true); if (declaringContract == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringContract"); } this.declaringContract = declaringContract; this.isInitiating = true; this.isTerminating = false; this.faults = new FaultDescriptionCollection(); this.messages = new MessageDescriptionCollection(); this.behaviors = new KeyedByTypeCollection<IOperationBehavior>(); this.knownTypes = new Collection<Type>(); }
public WsdlImporter ( MetadataSet metadata, IEnumerable<IPolicyImportExtension> policyImportExtensions, IEnumerable<IWsdlImportExtension> wsdlImportExtensions) : base (policyImportExtensions) { if (metadata == null) throw new ArgumentNullException ("metadata"); if (wsdlImportExtensions == null) { wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> (); wsdl_extensions.Add (new StandardBindingImporter ()); wsdl_extensions.Add (new TransportBindingElementImporter ()); //wsdl_extensions.Add (new MessageEncodingBindingElementImporter ()); wsdl_extensions.Add (new XmlSerializerMessageContractImporter ()); wsdl_extensions.Add (new DataContractSerializerMessageContractImporter ()); } else { wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> (wsdlImportExtensions); } this.metadata = metadata; this.wsdl_documents = new ServiceDescriptionCollection (); this.xmlschemas = new XmlSchemaSet (); this.policies = new List<XmlElement> (); foreach (MetadataSection ms in metadata.MetadataSections) { if (ms.Dialect == MetadataSection.ServiceDescriptionDialect && ms.Metadata.GetType () == typeof (WSServiceDescription)) wsdl_documents.Add ((WSServiceDescription) ms.Metadata); else if (ms.Dialect == MetadataSection.XmlSchemaDialect && ms.Metadata.GetType () == typeof (XmlSchema)) xmlschemas.Add ((XmlSchema) ms.Metadata); } }
private static void FillBehaviorsInfo(IWmiInstance operation, KeyedByTypeCollection<IOperationBehavior> behaviors) { List<IWmiInstance> list = new List<IWmiInstance>(behaviors.Count); foreach (IOperationBehavior behavior in behaviors) { IWmiInstance instance; FillBehaviorInfo(behavior, operation, out instance); if (instance != null) { list.Add(instance); } } operation.SetProperty("Behaviors", list.ToArray()); }
internal virtual void AddMetadataBindingParameters(Uri listenUri, KeyedByTypeCollection<IServiceBehavior> serviceBehaviors, BindingParameterCollection bindingParameters) { bindingParameters.Add(new ServiceMetadataExtension.MetadataBindingParameter()); }
public ServiceDescription() { this.behaviors = new KeyedByTypeCollection<IServiceBehavior>(); this.endpoints = new ServiceEndpointCollection(); this.serviceNamespace = "http://tempuri.org/"; }
public ContractDescription (string name, string ns) { if (name == null) throw new ArgumentNullException ("name"); if (name.Length == 0) throw new ArgumentOutOfRangeException ("ContractDescription's Name must be a non-empty string."); if (ns == null) ns = "http://tempuri.org/"; this.name = name; this.ns = ns; behaviors = new KeyedByTypeCollection<IContractBehavior> (); operations = new OperationDescriptionCollection (); }
private void CheckDefaultPolicyImportExtensions (KeyedByTypeCollection<IPolicyImportExtension> list) { Assert.IsNotNull (list, "#CN1"); // 9 in 3.0, 10 in 3.5 // Assert.AreEqual (10, list.Count, "#CN2"); Assert.AreEqual (typeof (PrivacyNoticeBindingElementImporter), list [0].GetType (), "#CN3"); Assert.AreEqual (typeof (UseManagedPresentationBindingElementImporter), list [1].GetType (), "#CN4"); Assert.AreEqual (typeof (TransactionFlowBindingElementImporter), list [2].GetType (), "#CN5"); Assert.AreEqual (typeof (ReliableSessionBindingElementImporter), list [3].GetType (), "#CN6"); Assert.AreEqual (typeof (SecurityBindingElementImporter), list [4].GetType (), "#CN7"); Assert.AreEqual (typeof (CompositeDuplexBindingElementImporter), list [5].GetType (), "#CN8"); Assert.AreEqual (typeof (OneWayBindingElementImporter), list [6].GetType (), "#CN9"); Assert.AreEqual (typeof (MessageEncodingBindingElementImporter), list [7].GetType (), "#CN10"); Assert.AreEqual (typeof (TransportBindingElementImporter), list [8].GetType (), "#CN11"); // It is in System.WorkflowServices.dll (3.5) //Assert.AreEqual (typeof (ContextBindingElementImporter), list [9].GetType (), "#CN12"); }
private void CheckDefaultWsdlImportExtensions (KeyedByTypeCollection<IWsdlImportExtension> list) { Assert.IsNotNull (list, "#CN20"); // 5 in 3.0, 6 in 3.5 // Assert.AreEqual (6, list.Count, "#CN21"); Assert.AreEqual (typeof (DataContractSerializerMessageContractImporter), list [0].GetType (), "#CN22"); Assert.AreEqual (typeof (XmlSerializerMessageContractImporter), list [1].GetType (), "#CN23"); Assert.AreEqual (typeof (MessageEncodingBindingElementImporter), list [2].GetType (), "#CN24"); Assert.AreEqual (typeof (TransportBindingElementImporter), list [3].GetType (), "#CN25"); Assert.AreEqual (typeof (StandardBindingImporter), list [4].GetType (), "#CN26"); // It is in System.WorkflowServices.dll (3.5) //Assert.AreEqual (typeof (ContextBindingElementImporter), list [5].GetType (), "#CN27"); }
static void FillBehaviorsInfo(IWmiInstance operation, KeyedByTypeCollection<IContractBehavior> behaviors) { List<IWmiInstance> behaviorInstances = new List<IWmiInstance>(behaviors.Count); foreach (IContractBehavior behavior in behaviors) { IWmiInstance behaviorInstance; FillBehaviorInfo(behavior, operation, out behaviorInstance); if (null != behaviorInstance) { behaviorInstances.Add(behaviorInstance); } } operation.SetProperty(AdministrationStrings.Behaviors, behaviorInstances.ToArray()); }
public override IChannelFactory<IRequestChannel> CreateFederationProxy(EndpointAddress address, Binding binding, KeyedByTypeCollection<IEndpointBehavior> channelBehaviors) { if (channelBehaviors == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelBehaviors"); ChannelFactory<IWsTrustDec2005SecurityTokenService> result = new ChannelFactory<IWsTrustDec2005SecurityTokenService>(binding, address); SetProtectionLevelForFederation(result.Endpoint.Contract.Operations); // remove the default client credentials that gets added to channel factories result.Endpoint.Behaviors.Remove<ClientCredentials>(); for (int i = 0; i < channelBehaviors.Count; ++i) { result.Endpoint.Behaviors.Add(channelBehaviors[i]); } // add a behavior that removes the UI channel initializer added by the client credentials since there should be no UI // initializer popped up as part of obtaining the federation token (the UI should already have been popped up for the main channel) result.Endpoint.Behaviors.Add(new WSTrustFeb2005.DriverFeb2005.InteractiveInitializersRemovingBehavior()); return new WSTrustFeb2005.DriverFeb2005.RequestChannelFactory<IWsTrustDec2005SecurityTokenService>(result); }
public static KeyedByTypeCollection<System.ServiceModel.Description.IEndpointBehavior> CreateEndpointBehaviors (string bindingConfiguration) { var ec = BehaviorsSection.EndpointBehaviors [bindingConfiguration]; if (ec == null) return null; var c = new KeyedByTypeCollection<System.ServiceModel.Description.IEndpointBehavior> (); foreach (var bxe in ec) c.Add ((System.ServiceModel.Description.IEndpointBehavior) bxe.CreateBehavior ()); return c; }
internal override void AddMetadataBindingParameters(Uri listenUri, KeyedByTypeCollection<IServiceBehavior> serviceBehaviors, BindingParameterCollection bindingParameters) { if (serviceBehaviors.Find<HostedBindingBehavior>() != null) { bindingParameters.Add(new HostedMetadataBindingParameter()); } VirtualPathExtension virtualPathExtension = bindingParameters.Find<VirtualPathExtension>(); if (virtualPathExtension != null) { AuthenticationSchemes hostSupportedAuthenticationSchemes = AspNetEnvironment.Current.GetAuthenticationSchemes(listenUri); if (hostSupportedAuthenticationSchemes != AuthenticationSchemes.None) { if (bindingParameters.Find<AuthenticationSchemesBindingParameter>() == null) { bindingParameters.Add(new AuthenticationSchemesBindingParameter(hostSupportedAuthenticationSchemes)); } } } base.AddMetadataBindingParameters(listenUri, serviceBehaviors, bindingParameters); }
KeyedByTypeCollection<IEndpointBehavior> GetBehaviorCollection(KeyedByTypeCollection<IEndpointBehavior> behaviors) { KeyedByTypeCollection<IEndpointBehavior> result = new KeyedByTypeCollection<IEndpointBehavior>(); foreach (IEndpointBehavior behavior in behaviors) { result.Add(behavior); } return result; }