示例#1
0
        protected bool RemoveAllServicesForContract(Configuration config, string interfaceID)
        {
            ServiceModelSectionGroup sg          = ServiceModelSectionGroup.GetSectionGroup(config);
            ServiceElementCollection serviceColl = sg.Services.Services;
            bool removed = false;
            // Iterate over every serviceElement
            // in the services collection
            // and delete the specific interface
            ServiceElementCollection svcColl = new ServiceElementCollection();

            foreach (ServiceElement el in serviceColl)
            {
                ServiceEndpointElementCollection endpointCollection = new ServiceEndpointElementCollection();
                foreach (ServiceEndpointElement ee in el.Endpoints)
                {
                    if (interfaceID.ToUpperInvariant() == ee.Contract.ToUpperInvariant())
                    {
                        // found it !
                        removed = true;
                        endpointCollection.Add(ee);
                    }
                }
                foreach (ServiceEndpointElement elementEndpoint in endpointCollection)
                {
                    el.Endpoints.Remove(elementEndpoint);
                    if (el.Endpoints.Count == 1)
                    {
                        if (el.Endpoints[0].Contract == ServiceMetadataBehavior.MexContractName)
                        {
                            el.Endpoints.Remove(el.Endpoints[0]); // if Mex endpoint remove it.
                        }
                    }
                    if (el.Endpoints.Count == 0)
                    {
                        svcColl.Add(el);
                    }
                }
            }
            foreach (ServiceElement service in svcColl)
            {
                sg.Services.Services.Remove(service);
            }
            if (serviceColl.Count == 0)
            {
                EnsureComMetaDataExchangeBehaviorRemoved(config);
                RemoveBinding(config);
            }
            return(removed);
        }
示例#2
0
 // Token: 0x06000085 RID: 133 RVA: 0x000043D0 File Offset: 0x000025D0
 private static ServiceEndpointElement TryFindEndpointByNameAndContract(ServiceEndpointElementCollection endpoints, string name, string contract)
 {
     if (endpoints != null)
     {
         foreach (object obj in endpoints)
         {
             ServiceEndpointElement serviceEndpointElement = (ServiceEndpointElement)obj;
             if (serviceEndpointElement.Name == name && serviceEndpointElement.Contract == contract)
             {
                 return(serviceEndpointElement);
             }
         }
     }
     return(null);
 }
示例#3
0
        protected bool RemoveAllServicesForContract(Configuration config, string interfaceID)
        {
            ServiceModelSectionGroup sg = ServiceModelSectionGroup.GetSectionGroup(config);
            ServiceElementCollection serviceColl = sg.Services.Services;
            bool removed = false;
            // Iterate over every serviceElement 
            // in the services collection
            // and delete the specific interface
            ServiceElementCollection svcColl = new ServiceElementCollection();
            foreach (ServiceElement el in serviceColl)
            {
                ServiceEndpointElementCollection endpointCollection = new ServiceEndpointElementCollection();
                foreach (ServiceEndpointElement ee in el.Endpoints)
                {
                    if (interfaceID.ToUpperInvariant() == ee.Contract.ToUpperInvariant())
                    {
                        // found it !
                        removed = true;
                        endpointCollection.Add(ee);
                    }
                }
                foreach (ServiceEndpointElement elementEndpoint in endpointCollection)
                {
                    el.Endpoints.Remove(elementEndpoint);
                    if (el.Endpoints.Count == 1)
                        if (el.Endpoints[0].Contract == ServiceMetadataBehavior.MexContractName)
                            el.Endpoints.Remove(el.Endpoints[0]); // if Mex endpoint remove it.
                    if (el.Endpoints.Count == 0)
                        svcColl.Add(el);
                }

            }
            foreach (ServiceElement service in svcColl)
            {
                sg.Services.Services.Remove(service);
            }
            if (serviceColl.Count == 0)
            {
                EnsureComMetaDataExchangeBehaviorRemoved(config);
                RemoveBinding(config);
            }
            return removed;
        }
示例#4
0
 /// <summary>
 /// The exists pure WCF endpoint.
 /// </summary>
 /// <param name="endpointsElements">
 /// The endpoints elements.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 protected bool ExistsPureWCFEndpoint(ServiceEndpointElementCollection endpointsElements)
 {
     return(endpointsElements.Cast <ServiceEndpointElement>().Any(element => element.BehaviorConfiguration != AMFBinding));
 }