Пример #1
0
 internal static void ValidateEndpointReference(string endpoint, string endpointConfiguration, ContextInformation evaluationContext, ConfigurationElement configurationElement)
 {
     if (evaluationContext == null)
     {
         DiagnosticUtility.FailFast("ValidateEndpointReference() should only called with valid ContextInformation");
     }
     if (!string.IsNullOrEmpty(endpoint))
     {
         EndpointCollectionElement element = null;
         if (evaluationContext != null)
         {
             element = ConfigurationHelpers.UnsafeGetAssociatedEndpointCollectionElement(evaluationContext, endpoint);
         }
         else
         {
             element = ConfigurationHelpers.UnsafeGetEndpointCollectionElement(endpoint);
         }
         if (element == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidSection", new object[] { ConfigurationHelpers.GetEndpointsSectionPath(endpoint) }), configurationElement.ElementInformation.Source, configurationElement.ElementInformation.LineNumber));
         }
         if (!string.IsNullOrEmpty(endpointConfiguration) && !element.ContainsKey(endpointConfiguration))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidEndpointName", new object[] { endpointConfiguration, ConfigurationHelpers.GetEndpointsSectionPath(endpoint), "endpointConfiguration" }), configurationElement.ElementInformation.Source, configurationElement.ElementInformation.LineNumber));
         }
     }
 }
 internal void OnReset(ConfigurationElement parent)
 {
     this.reset            = true;
     this.inheritedContext = ConfigurationHelpers.GetOriginalEvaluationContext(parent as IConfigurationContextProviderInternal);
 }
 internal static CommonBehaviorsSection UnsafeGetAssociatedSection(ContextInformation contextEval)
 {
     return((CommonBehaviorsSection)ConfigurationHelpers.UnsafeGetAssociatedSection(contextEval, ConfigurationStrings.CommonBehaviorsSectionPath));
 }
Пример #4
0
 internal static ClientSection UnsafeGetSection()
 {
     return((ClientSection)ConfigurationHelpers.UnsafeGetSection(ConfigurationStrings.ClientSectionPath));
 }
 internal static MsmqIntegrationBindingCollectionElement GetBindingCollectionElement()
 {
     return((MsmqIntegrationBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement(ConfigurationStrings.MsmqIntegrationBindingCollectionElementName));
 }
Пример #6
0
        private string GetEndpointName()
        {
            string name = string.Empty;
            ExtensionElementCollection elements = null;
            Type type = base.GetType();

            elements = ExtensionsSection.UnsafeLookupCollection("endpointExtensions", ConfigurationHelpers.GetEvaluationContext(this));
            if (elements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigExtensionCollectionNotFound", new object[] { "endpointExtensions" }), base.ElementInformation.Source, base.ElementInformation.LineNumber));
            }
            for (int i = 0; i < elements.Count; i++)
            {
                ExtensionElement element = elements[i];
                if (element.Type.Equals(type.AssemblyQualifiedName, StringComparison.Ordinal))
                {
                    name = element.Name;
                    break;
                }
                Type o = Type.GetType(element.Type, false);
                if ((null != o) && type.Equals(o))
                {
                    name = element.Name;
                    break;
                }
            }
            if (string.IsNullOrEmpty(name))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigExtensionTypeNotRegisteredInCollection", new object[] { type.AssemblyQualifiedName, "endpointExtensions" }), base.ElementInformation.Source, base.ElementInformation.LineNumber));
            }
            return(name);
        }
Пример #7
0
 internal static BasicHttpContextBindingCollectionElement GetBindingCollectionElement()
 {
     return((BasicHttpContextBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement("basicHttpContextBinding"));
 }
Пример #8
0
 internal static BehaviorsSection GetSection()
 {
     return((BehaviorsSection)ConfigurationHelpers.GetSection(ConfigurationStrings.BehaviorsSectionPath));
 }
Пример #9
0
 internal static BehaviorsSection UnsafeGetAssociatedSection(ContextInformation evalContext)
 {
     return((BehaviorsSection)ConfigurationHelpers.UnsafeGetAssociatedSection(evalContext, ConfigurationStrings.BehaviorsSectionPath));
 }
 internal static ServiceHostingEnvironmentSection GetSection()
 {
     return((ServiceHostingEnvironmentSection)ConfigurationHelpers.GetSection(ConfigurationStrings.ServiceHostingEnvironmentSectionPath));
 }
        string GetConfigurationElementName()
        {
            string configurationElementName       = String.Empty;
            ExtensionElementCollection collection = null;
            Type extensionSectionType             = ThisType;

            ContextInformation evaluationContext = this.ContainingEvaluationContext;

            if (evaluationContext == null)
            {
                evaluationContext = ConfigurationHelpers.GetEvaluationContext(this);
            }

            if (String.IsNullOrEmpty(this.extensionCollectionName))
            {
#if DESKTOP
                if (DiagnosticUtility.ShouldTraceWarning)
                {
                    TraceUtility.TraceEvent(TraceEventType.Warning,
                                            TraceCode.ExtensionCollectionNameNotFound,
                                            SR.GetString(SR.TraceCodeExtensionCollectionNameNotFound),
                                            this,
                                            (Exception)null);
                }
#endif

                collection = ExtensionsSection.UnsafeLookupAssociatedCollection(ThisType, evaluationContext, out this.extensionCollectionName);
            }
            else
            {
                collection = ExtensionsSection.UnsafeLookupCollection(this.extensionCollectionName, evaluationContext);
            }

            if (null == collection)
            {
                if (String.IsNullOrEmpty(this.extensionCollectionName))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigNoExtensionCollectionAssociatedWithType,
                                                                                                                            extensionSectionType.AssemblyQualifiedName),
                                                                                                               this.ElementInformation.Source,
                                                                                                               this.ElementInformation.LineNumber));
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigExtensionCollectionNotFound,
                                                                                                                            this.extensionCollectionName),
                                                                                                               this.ElementInformation.Source,
                                                                                                               this.ElementInformation.LineNumber));
                }
            }

            for (int i = 0; i < collection.Count; i++)
            {
                ExtensionElement collectionElement = collection[i];

                // Optimize for assembly qualified names.
                if (collectionElement.Type.Equals(extensionSectionType.AssemblyQualifiedName, StringComparison.Ordinal))
                {
                    configurationElementName = collectionElement.Name;
                    break;
                }

                // Check type directly for the case that the extension is registered with something less than
                // an full assembly qualified name.
                Type collectionElementType = Type.GetType(collectionElement.Type, false);
                if (null != collectionElementType && extensionSectionType.Equals(collectionElementType))
                {
                    configurationElementName = collectionElement.Name;
                    break;
                }
            }

            if (String.IsNullOrEmpty(configurationElementName))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigExtensionTypeNotRegisteredInCollection,
                                                                                                                        extensionSectionType.AssemblyQualifiedName,
                                                                                                                        this.extensionCollectionName),
                                                                                                           this.ElementInformation.Source,
                                                                                                           this.ElementInformation.LineNumber));
            }

            return(configurationElementName);
        }
Пример #12
0
 internal static WSHttpContextBindingCollectionElement GetBindingCollectionElement()
 {
     return((WSHttpContextBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement("wsHttpContextBinding"));
 }
 internal static ComContractsSection GetSection()
 {
     return((ComContractsSection)ConfigurationHelpers.GetSection(ConfigurationStrings.ComContractsSectionPath));
 }
Пример #14
0
 internal static CustomBindingCollectionElement GetBindingCollectionElement()
 {
     return((CustomBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement("customBinding"));
 }
        internal static void ValidateEndpointReference(string endpoint, string endpointConfiguration, ContextInformation evaluationContext, ConfigurationElement configurationElement)
        {
            // ValidateEndpointReference built on assumption that evaluationContext is valid.
            // This should be protected at the callers site.  If assumption is invalid, then
            // configuration system is in an indeterminate state.  Need to stop in a manner that
            // user code can not capture.
            if (null == evaluationContext)
            {
                Fx.Assert("ValidateEndpointReference() should only called with valid ContextInformation");
                DiagnosticUtility.FailFast("ValidateEndpointReference() should only called with valid ContextInformation");
            }

            if (!String.IsNullOrEmpty(endpoint))
            {
                EndpointCollectionElement endpointCollectionElement = null;

                if (null != evaluationContext)
                {
                    endpointCollectionElement = ConfigurationHelpers.UnsafeGetAssociatedEndpointCollectionElement(evaluationContext, endpoint);
                }
                else
                {
                    endpointCollectionElement = ConfigurationHelpers.UnsafeGetEndpointCollectionElement(endpoint);
                }

                if (endpointCollectionElement == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidSection,
                                                                                                                            ConfigurationHelpers.GetEndpointsSectionPath(endpoint)),
                                                                                                               configurationElement.ElementInformation.Source,
                                                                                                               configurationElement.ElementInformation.LineNumber));
                }

                if (!String.IsNullOrEmpty(endpointConfiguration))
                {
                    if (!endpointCollectionElement.ContainsKey(endpointConfiguration))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidEndpointName,
                                                                                                                                endpointConfiguration,
                                                                                                                                ConfigurationHelpers.GetEndpointsSectionPath(endpoint),
                                                                                                                                ConfigurationStrings.EndpointConfiguration),
                                                                                                                   configurationElement.ElementInformation.Source,
                                                                                                                   configurationElement.ElementInformation.LineNumber));
                    }
                }
            }
        }
 internal static ProtocolMappingSection UnsafeGetSection()
 {
     return((ProtocolMappingSection)ConfigurationHelpers.UnsafeGetSection(ConfigurationStrings.ProtocolMappingSectionPath));
 }
 internal static MexNamedPipeBindingCollectionElement GetBindingCollectionElement()
 {
     return((MexNamedPipeBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement("mexNamedPipeBinding"));
 }
 internal static DiagnosticSection GetSection()
 {
     return((DiagnosticSection)ConfigurationHelpers.GetSection(ConfigurationStrings.DiagnosticSectionPath));
 }
 internal static NetNamedPipeBindingCollectionElement GetBindingCollectionElement()
 {
     return((NetNamedPipeBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement(ConfigurationStrings.NetNamedPipeBindingCollectionElementName));
 }
 internal static DiagnosticSection UnsafeGetSectionNoTrace()
 {
     return((DiagnosticSection)ConfigurationHelpers.UnsafeGetSectionNoTrace(ConfigurationStrings.DiagnosticSectionPath));
 }
        /// <summary>
        /// Returns the extension element, or null if the type cannot be loaded in certain situations (see the code for details).
        /// </summary>
        TServiceModelExtensionElement CreateNewSection(string name)
        {
            if (this.ContainsKey(name) && !(name == ConfigurationStrings.Clear || name == ConfigurationStrings.Remove))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigDuplicateItem,
                                                                                                                        name,
                                                                                                                        this.GetType().Name),
                                                                                                           this.ElementInformation.Source,
                                                                                                           this.ElementInformation.LineNumber));
            }

            TServiceModelExtensionElement retval = null;

            Type elementType;
            ContextInformation evaluationContext = ConfigurationHelpers.GetEvaluationContext(this);

            try
            {
                elementType = GetExtensionType(evaluationContext, name);
            }
            catch (ConfigurationErrorsException e)
            {
                // Work-around for

                if (System.ServiceModel.Channels.AppContainerInfo.IsRunningInAppContainer && evaluationContext.IsMachineLevel)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            if (null != elementType)
            {
                if (this.CollectionElementBaseType.IsAssignableFrom(elementType))
                {
                    retval = (TServiceModelExtensionElement)Activator.CreateInstance(elementType);
                    retval.ExtensionCollectionName  = this.extensionCollectionName;
                    retval.ConfigurationElementName = name;
                    retval.InternalInitializeDefault();
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidExtensionElement,
                                                                                                                            name,
                                                                                                                            this.CollectionElementBaseType.FullName),
                                                                                                               this.ElementInformation.Source,
                                                                                                               this.ElementInformation.LineNumber));
                }
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidExtensionElementName,
                                                                                                                        name,
                                                                                                                        this.extensionCollectionName),
                                                                                                           this.ElementInformation.Source,
                                                                                                           this.ElementInformation.LineNumber));
            }

            return(retval);
        }
 internal static MexHttpsBindingCollectionElement GetBindingCollectionElement()
 {
     return((MexHttpsBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement(ConfigurationStrings.MexHttpsBindingCollectionElementName));
 }
Пример #23
0
 internal static ClientSection UnsafeGetSection(ContextInformation contextInformation)
 {
     return((ClientSection)ConfigurationHelpers.UnsafeGetSectionFromContext(contextInformation, ConfigurationStrings.ClientSectionPath));
 }
 internal static ServicesSection UnsafeGetSection()
 {
     return((ServicesSection)ConfigurationHelpers.UnsafeGetSection(ConfigurationStrings.ServicesSectionPath));
 }
 private void SetIsPresent()
 {
     ConfigurationHelpers.SetIsPresent(this);
 }
 protected override bool OnDeserializeUnrecognizedElement(string elementName, XmlReader reader)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
               new ConfigurationErrorsException(SR.GetString(SR.ConfigEndpointExtensionNotFound,
                                                             ConfigurationHelpers.GetEndpointsSectionPath(elementName))));
 }
 internal static CommonBehaviorsSection UnsafeGetSection()
 {
     return((CommonBehaviorsSection)ConfigurationHelpers.UnsafeGetSection(ConfigurationStrings.CommonBehaviorsSectionPath));
 }
 void UpdateEndpointSections()
 {
     UpdateEndpointSections(ConfigurationHelpers.GetEvaluationContext(this));
 }
Пример #29
0
 internal static WSDualHttpBindingCollectionElement GetBindingCollectionElement()
 {
     return((WSDualHttpBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement(ConfigurationStrings.WSDualHttpBindingCollectionElementName));
 }
Пример #30
0
 internal static NetTcpContextBindingCollectionElement GetBindingCollectionElement()
 {
     return((NetTcpContextBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement(netTcpContextBindingName));
 }