internal static void AddServiceBehavior(IList <Attribute> attributes, KeyedByTypeCollection <IServiceBehavior> behaviors, List <IServiceBehavior> serviceBehaviorPlugins) { if (attributes == null || attributes.Count == 0 || attributes.Count(a => Types.Contains(a.GetType())) == 0) { serviceBehaviorPlugins.ForEach(sb => behaviors.Add(sb)); return; } if (attributes.Count(a => Types.Contains(a.GetType())) > 1) { throw new ConflictingAttributesException(Types); } var attribute = attributes.Single(a => Types.Contains(a.GetType())); foreach (var serviceBehavior in serviceBehaviorPlugins) { var serviceBehaviorBase = serviceBehavior as ServiceBehaviorBase; if (serviceBehaviorBase == null) { if (IsIncluded(serviceBehavior, attribute) || !IsExcluded(serviceBehavior, attribute)) { behaviors.Add(serviceBehavior); } } if (IsIncluded(serviceBehaviorBase, attribute) || !IsExcluded(serviceBehaviorBase, attribute)) { behaviors.Add(serviceBehavior); } } }
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 ()); }
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 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 KeyedByTypeCollection <object> Read <T1, T2>() where T1 : new() where T2 : new() { var result = new KeyedByTypeCollection <object>(); using (var reader = GetReader()) { result.Add(Read <T1>(reader)); reader.Position = 0; result.Add(Read <T2>(reader)); } return(result); }
void Verify() { var first = new Subject(); var second = new Subject(); var other = new Other(); var sut = new KeyedByTypeCollection <ISubject>(); sut.Add(first); sut.Add(second); sut.Add(other); sut[typeof(Other)].Should().BeSameAs(other); sut[typeof(Subject)].Should().BeSameAs(second); }
void IChannelCredentials.SetDefaultServiceCertificateFromFile(string fileName, string password, string keyStorageFlags) { lock (channelBuilderSettings) { KeyedByTypeCollection <IEndpointBehavior> behaviors = channelBuilderSettings.Behaviors; X509Certificate2 cert; if (!String.IsNullOrEmpty(keyStorageFlags)) { X509KeyStorageFlags flags = (X509KeyStorageFlags)Enum.Parse(typeof(X509KeyStorageFlags), keyStorageFlags); cert = new X509Certificate2(fileName, password, flags); } else { cert = new X509Certificate2(fileName, password); } ClientCredentials channelCredentials = behaviors.Find <ClientCredentials>(); if (channelCredentials == null) { channelCredentials = new ClientCredentials(); behaviors.Add(channelCredentials); } channelCredentials.ServiceCertificate.DefaultCertificate = cert; } }
void IChannelCredentials.SetServiceCertificateAuthentication(string storeLocation, string revocationMode, string certificationValidationMode) { lock (channelBuilderSettings) { StoreLocation location = (StoreLocation)Enum.Parse(typeof(StoreLocation), storeLocation); X509RevocationMode mode = (X509RevocationMode)Enum.Parse(typeof(X509RevocationMode), revocationMode); X509CertificateValidationMode validationMode = X509ServiceCertificateAuthentication.DefaultCertificateValidationMode; if (!String.IsNullOrEmpty(certificationValidationMode)) { validationMode = (X509CertificateValidationMode)Enum.Parse(typeof(X509CertificateValidationMode), certificationValidationMode); } KeyedByTypeCollection <IEndpointBehavior> behaviors = channelBuilderSettings.Behaviors; ClientCredentials channelCredentials = behaviors.Find <ClientCredentials>(); if (channelCredentials == null) { channelCredentials = new ClientCredentials(); behaviors.Add(channelCredentials); } channelCredentials.ServiceCertificate.Authentication.TrustedStoreLocation = location; channelCredentials.ServiceCertificate.Authentication.RevocationMode = mode; channelCredentials.ServiceCertificate.Authentication.CertificateValidationMode = validationMode; } }
void IChannelCredentials.SetWindowsCredential(string domain, string userName, string password, int impersonationLevel, bool allowNtlm) { lock (this.channelBuilderSettings) { KeyedByTypeCollection <IEndpointBehavior> behaviors = this.channelBuilderSettings.Behaviors; NetworkCredential credential = null; if ((!string.IsNullOrEmpty(domain) || !string.IsNullOrEmpty(userName)) || !string.IsNullOrEmpty(password)) { if (string.IsNullOrEmpty(userName)) { userName = ""; } System.ServiceModel.Security.SecurityUtils.PrepareNetworkCredential(); credential = new NetworkCredential(userName, password, domain); } ClientCredentials item = behaviors.Find <ClientCredentials>(); if (item == null) { item = new ClientCredentials(); behaviors.Add(item); } item.Windows.AllowedImpersonationLevel = (TokenImpersonationLevel)impersonationLevel; item.Windows.AllowNtlm = allowNtlm; item.Windows.ClientCredential = credential; } }
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); } }
internal void CreateFactories() { CloseFactories(); BroadcastChannels = new BroadcastChannels <T>(Settings.Server, Settings.Port, BroadcastInstance); BroadcastChannels.OpenChannelAction = delegate { KeyedByTypeCollection <IEndpointBehavior> behaviors = BroadcastChannels.ChannelBroadcastFactory.Endpoint.Behaviors; if (behaviors.Find <ErrorClientBehavior>() == null) { var handler = new ClientErrorHandler <MT, T>(this, BroadcastChannels.ChannelBroadcastFactory); BroadcastChannels.ChannelBroadcastFactory .Opening += (delegate { behaviors.Add(new ErrorClientBehavior(handler)); }); } }; NetTcpBinding binding = Channels.GetBinding(); MainChannelFactory = new DuplexChannelFactory <MT, T> (BroadcastChannels.Callback, binding, new EndpointAddress(ServerAddress)); MainChannelFactory.Opened += delegate { AfterMainChannelOpened(); }; AfterCreateChannels(binding); }
/// <summary> /// Adds the service authorization behavior based on configuration /// </summary> /// <param name="serviceBehaviors"></param> public static void SetServiceAuthorizationBehavior( this KeyedByTypeCollection <IServiceBehavior> serviceBehaviors ) { bool addNewEntry = false; var serviceAuthorizationBehavior = serviceBehaviors.Find <ServiceAuthorizationBehavior>(); if (serviceAuthorizationBehavior == null) { addNewEntry = true; serviceAuthorizationBehavior = new ServiceAuthorizationBehavior(); } Console.WriteLine("Added service behavior with user group access"); serviceAuthorizationBehavior.PrincipalPermissionMode = PrincipalPermissionMode.UseWindowsGroups; serviceAuthorizationBehavior.ServiceAuthorizationManager = new SecuredServiceAuthorizationManager(new List <string>() { "BUILTIN\\Administrators", "NT AUTHORITY\\SYSTEM", "CODE1\\gd_IN_Employees_HT" }, new List <string>() { "Test1" }); if (addNewEntry) { serviceBehaviors.Add(serviceAuthorizationBehavior); } }
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); }
void IChannelCredentials.SetWindowsCredential(string domain, string userName, string password, int impersonationLevel, bool allowNtlm) { lock (channelBuilderSettings) { KeyedByTypeCollection <IEndpointBehavior> behaviors = channelBuilderSettings.Behaviors; NetworkCredential newCredentials = null; if ((!String.IsNullOrEmpty(domain)) || (!String.IsNullOrEmpty(userName)) || (!String.IsNullOrEmpty(password))) { if (String.IsNullOrEmpty(userName)) { userName = ""; } System.ServiceModel.Security.SecurityUtils.PrepareNetworkCredential(); newCredentials = new NetworkCredential(userName, password, domain); } ClientCredentials channelCredentials = behaviors.Find <ClientCredentials>(); if (channelCredentials == null) { channelCredentials = new ClientCredentials(); behaviors.Add(channelCredentials); } channelCredentials.Windows.AllowedImpersonationLevel = (TokenImpersonationLevel)impersonationLevel; // To disable AllowNtlm warning. #pragma warning disable 618 channelCredentials.Windows.AllowNtlm = allowNtlm; #pragma warning restore 618 channelCredentials.Windows.ClientCredential = newCredentials; } }
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"); }
private static void GetIServiceBehaviorAttributes(Type currentServiceType, KeyedByTypeCollection <IServiceBehavior> behaviors) { foreach (IServiceBehavior behaviorAttribute in ServiceReflector.GetCustomAttributes(currentServiceType, typeof(IServiceBehavior))) { behaviors.Add(behaviorAttribute); } }
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); } } }
static Serializer() { var serializers = Assembly.GetAssembly(typeof(Serializer)).GetTypes().Where(x => x.IsClass && !x.IsAbstract && x.GetInterfaces().Contains(typeof(ISerializer))); foreach (var serializer in serializers) { SerializerCollection.Add(Activator.CreateInstance(serializer) as ISerializer); } }
private void ApplyCommonServiceHostBehaviors() { KeyedByTypeCollection <IServiceBehavior> serviceBehaviors = Description.Behaviors; if (!ServiceHostContainsBehavior(typeof(UnhandledExceptionsLoggingBehaviorAttribute))) { serviceBehaviors.Add(new UnhandledExceptionsLoggingBehaviorAttribute()); } }
public static void ApplyServiceBehaviors(KeyedByTypeCollection <IServiceBehavior> behaviors, IUnityContainer container) { var registeredServiceBehaviors = container.ResolveAll <IServiceBehavior>(); foreach (var serviceBehavior in registeredServiceBehaviors) { behaviors.Add(serviceBehavior); } }
private KeyedByTypeCollection <IEndpointBehavior> GetBehaviorCollection(KeyedByTypeCollection <IEndpointBehavior> behaviors) { KeyedByTypeCollection <IEndpointBehavior> types = new KeyedByTypeCollection <IEndpointBehavior>(); foreach (IEndpointBehavior behavior in behaviors) { types.Add(behavior); } return(types); }
KeyedByTypeCollection <IEndpointBehavior> GetBehaviorCollection(KeyedByTypeCollection <IEndpointBehavior> behaviors) { KeyedByTypeCollection <IEndpointBehavior> result = new KeyedByTypeCollection <IEndpointBehavior>(); foreach (IEndpointBehavior behavior in behaviors) { result.Add(behavior); } return(result); }
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 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); }
public static void Subscribe <T>(IMyMessageReceiver <T> receiver) where T : IMyMessage { IList <IMyMessageReceiver <T> > listeners = Subscribers.Find <IList <IMyMessageReceiver <T> > >(); if (listeners == null) { listeners = new List <IMyMessageReceiver <T> >(); Subscribers.Add(listeners); } // Now you can use currentList listeners.Add(receiver); }
/// <summary> /// Returns a list of key value pairs. Key -> Enum Value; Value -> Attribute /// Example: /// <code> /// var attr = PickWaveHelpers.GetEnumMemberAttributes<PickslipDimension, DisplayAttribute>()[PickslipDimenstion.DcCancelDate]; /// </code> /// </summary> /// <typeparam name="TEnum"></typeparam> /// <typeparam name="TAttr">Type of the attribute needed</typeparam> /// <returns></returns> public static IDictionary <TEnum, TAttr> GetEnumMemberAttributes <TEnum, TAttr>() { if (!__coll.Contains(typeof(Dictionary <TEnum, TAttr>))) { var query = from MemberInfo member in typeof(TEnum).GetMembers() from TAttr attr in member.GetCustomAttributes(typeof(TAttr), false) let dim = (TEnum)Enum.Parse(typeof(TEnum), member.Name) select new KeyValuePair <TEnum, TAttr>(dim, attr); __coll.Add(query.ToDictionary(p => p.Key, p => p.Value)); } return((IDictionary <TEnum, TAttr>)__coll[typeof(Dictionary <TEnum, TAttr>)]); }
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); } }
void Initialize(RoutingEndpointTrait endpointTrait, RoutingConfiguration routingConfig, bool impersonating) { this.thisLock = new object(); this.Key = endpointTrait; if (TD.RoutingServiceCreatingClientForEndpointIsEnabled()) { TD.RoutingServiceCreatingClientForEndpoint(this.Key.ToString()); } ServiceEndpoint clientEndpoint = endpointTrait.Endpoint; ServiceEndpoint endpoint = this.Endpoint; KeyedByTypeCollection <IEndpointBehavior> behaviors = endpoint.Behaviors; endpoint.ListenUri = clientEndpoint.ListenUri; endpoint.ListenUriMode = clientEndpoint.ListenUriMode; endpoint.Name = clientEndpoint.Name; foreach (IEndpointBehavior behavior in clientEndpoint.Behaviors) { // Remove if present, ok to call if not there (will simply return false) behaviors.Remove(behavior.GetType()); behaviors.Add(behavior); } // If the configuration doesn't explicitly add MustUnderstandBehavior (to override us) // add it here, with mustunderstand = false. if (behaviors.Find <MustUnderstandBehavior>() == null) { behaviors.Add(new MustUnderstandBehavior(false)); } // If the configuration doesn't explicitly turn off marshaling we add it here. if (routingConfig.SoapProcessingEnabled && behaviors.Find <SoapProcessingBehavior>() == null) { behaviors.Add(new SoapProcessingBehavior()); } ConfigureTransactionFlow(endpoint); ConfigureImpersonation(endpoint, impersonating); }
static void AddWorkflowOperationBehaviors(OperationDescription operation, string bookmarkName, bool canCreateInstance) { KeyedByTypeCollection <IOperationBehavior> behaviors = operation.Behaviors; WorkflowOperationBehavior workflowOperationBehavior = behaviors.Find <WorkflowOperationBehavior>(); if (workflowOperationBehavior == null) { behaviors.Add(new WorkflowOperationBehavior(new Bookmark(bookmarkName), canCreateInstance)); } else { workflowOperationBehavior.CanCreateInstance = workflowOperationBehavior.CanCreateInstance || canCreateInstance; } }
public static void AddReceiveToFormatterBehavior(Receive receive, OperationDescription operation) { Fx.Assert(receive != null && operation != null, "Argument cannot be null!"); KeyedByTypeCollection <IOperationBehavior> behaviors = operation.Behaviors; WorkflowFormatterBehavior formatterBehavior = behaviors.Find <WorkflowFormatterBehavior>(); if (formatterBehavior == null) { formatterBehavior = new WorkflowFormatterBehavior(); behaviors.Add(formatterBehavior); } formatterBehavior.Receives.Add(receive); }
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); } }
void IChannelCredentials.SetUserNameCredential(string userName, string password) { lock (this.channelBuilderSettings) { KeyedByTypeCollection <IEndpointBehavior> behaviors = this.channelBuilderSettings.Behaviors; ClientCredentials item = behaviors.Find <ClientCredentials>(); if (item == null) { item = new ClientCredentials(); behaviors.Add(item); } item.UserName.UserName = userName; item.UserName.Password = password; } }
void IChannelCredentials.SetUserNameCredential(string userName, string password) { lock (channelBuilderSettings) { KeyedByTypeCollection <IEndpointBehavior> behaviors = channelBuilderSettings.Behaviors; ClientCredentials channelCredentials = behaviors.Find <ClientCredentials>(); if (channelCredentials == null) { channelCredentials = new ClientCredentials(); behaviors.Add(channelCredentials); } channelCredentials.UserName.UserName = userName; channelCredentials.UserName.Password = password; } }
KeyedByTypeCollection<IEndpointBehavior> GetBehaviorCollection(KeyedByTypeCollection<IEndpointBehavior> behaviors) { KeyedByTypeCollection<IEndpointBehavior> result = new KeyedByTypeCollection<IEndpointBehavior>(); foreach (IEndpointBehavior behavior in behaviors) { result.Add(behavior); } return result; }
private static void GetIServiceBehaviorAttributes(Type currentServiceType, KeyedByTypeCollection<IServiceBehavior> behaviors) { foreach (IServiceBehavior behavior in ServiceReflector.GetCustomAttributes(currentServiceType, typeof(IServiceBehavior))) { behaviors.Add(behavior); } }
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; }