コード例 #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));
         }
     }
 }
コード例 #2
0
 internal void OnReset(ConfigurationElement parent)
 {
     this.reset            = true;
     this.inheritedContext = ConfigurationHelpers.GetOriginalEvaluationContext(parent as IConfigurationContextProviderInternal);
 }
コード例 #3
0
 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));
 }
コード例 #5
0
 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"));
 }
コード例 #13
0
 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));
                    }
                }
            }
        }
コード例 #16
0
 internal static ProtocolMappingSection UnsafeGetSection()
 {
     return((ProtocolMappingSection)ConfigurationHelpers.UnsafeGetSection(ConfigurationStrings.ProtocolMappingSectionPath));
 }
 internal static MexNamedPipeBindingCollectionElement GetBindingCollectionElement()
 {
     return((MexNamedPipeBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement("mexNamedPipeBinding"));
 }
コード例 #18
0
 internal static DiagnosticSection GetSection()
 {
     return((DiagnosticSection)ConfigurationHelpers.GetSection(ConfigurationStrings.DiagnosticSectionPath));
 }
コード例 #19
0
 internal static NetNamedPipeBindingCollectionElement GetBindingCollectionElement()
 {
     return((NetNamedPipeBindingCollectionElement)ConfigurationHelpers.GetBindingCollectionElement(ConfigurationStrings.NetNamedPipeBindingCollectionElementName));
 }
コード例 #20
0
 internal static DiagnosticSection UnsafeGetSectionNoTrace()
 {
     return((DiagnosticSection)ConfigurationHelpers.UnsafeGetSectionNoTrace(ConfigurationStrings.DiagnosticSectionPath));
 }
コード例 #21
0
        /// <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);
        }
コード例 #22
0
 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));
 }
コード例 #24
0
 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))));
 }
コード例 #27
0
 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));
 }