//+
 //- @Info -//
 //+
 //- @OnPreHttpHandlerExecute -//
 public override InitProcessor Execute()
 {
     ProcessingSection cs = ProcessingSection.GetConfigSection();
     if (cs == null)
     {
         return null;
     }
     try
     {
         ConfigurationReaderWriterLockSlim.EnterUpgradeableReadLock();
         //+
         if (SequenceDataList.AllSequenceData == null)
         {
             ConfigurationReaderWriterLockSlim.EnterWriteLock();
             try
             {
                 if (SequenceDataList.AllSequenceData == null)
                 {
                     //+ sequence
                     SequenceDataList.AllSequenceData = new SequenceDataList();
                     ConfigurationLoader.LoadSequenceData(SequenceDataList.AllSequenceData, cs.Sequences);
                 }
             }
             finally
             {
                 ConfigurationReaderWriterLockSlim.ExitWriteLock();
             }
         }
         if (WebDomainDataList.AllWebDomainData == null)
         {
             ConfigurationReaderWriterLockSlim.EnterWriteLock();
             try
             {
                 if (WebDomainDataList.AllWebDomainData == null)
                 {
                     WebDomainCollection webDomainCollection = cs.WebDomain;
                     var webDomainDataList = new WebDomainDataList();
                     //+ dupe?
                     var duplicate = webDomainCollection.GroupBy(p => p.Name).Select(p => new
                                                                                          {
                                                                                              Name = p.Key,
                                                                                              Count = p.Count()
                                                                                          }).FirstOrDefault(p => p.Count > 1);
                     if (duplicate != null)
                     {
                         throw new InvalidOperationException(String.Format(Resource.WebDomain_DuplicateName, duplicate.Name));
                     }
                     //+ abstract
                     IEnumerable<WebDomainElement> abstractWebDomainElementEnumerable = webDomainCollection.Where(p => p.IsAbstract);
                     foreach (WebDomainElement element in abstractWebDomainElementEnumerable)
                     {
                         element.ValidateAbstract();
                         ConfigurationLoader.InitWebDomain(element.Name, element, webDomainDataList);
                     }
                     //+ root
                     WebDomainElement rootWebDomainElement = webDomainCollection.FirstOrDefault(p => String.IsNullOrEmpty(p.Name) || p.Name.Equals(Info.Root, StringComparison.OrdinalIgnoreCase));
                     if (rootWebDomainElement != null)
                     {
                         String webDomainName = rootWebDomainElement.Name;
                         if (String.IsNullOrEmpty(webDomainName))
                         {
                             webDomainName = Info.Root;
                         }
                         else
                         {
                             webDomainName = webDomainName.ToLower(CultureInfo.CurrentCulture);
                         }
                         ConfigurationLoader.InitWebDomain(webDomainName, rootWebDomainElement, webDomainDataList);
                     }
                     else
                     {
                         ConfigurationLoader.InitWebDomain(Info.Root, new WebDomainElement
                                                                      {
                                                                          Name = Info.Root,
                                                                          Path = String.Empty
                                                                      }, webDomainDataList);
                     }
                     if (cs.EnableConfigViewer)
                     {
                         webDomainDataList[Info.Root].EndpointDataList.Add(new EndpointData
                                                                           {
                                                                               Type = "ConfigViewer",
                                                                               Text = "/__viewconfig",
                                                                               Selector = SelectorType.PathStartsWith
                                                                           });
                     }
                     if (cs.EnableConfigEditor)
                     {
                         webDomainDataList[Info.Root].EndpointDataList.Add(new EndpointData
                                                                           {
                                                                               Type = "ConfigEditor",
                                                                               Text = "/__editconfig",
                                                                               Selector = SelectorType.PathStartsWith
                                                                           });
                     }
                     //+ other
                     IEnumerable<WebDomainElement> concreteWebDomainElementEnumerable = webDomainCollection.Where(p => !p.IsAbstract);
     #if DEBUG
                     List<WebDomainElement> list = concreteWebDomainElementEnumerable.ToList();
     #endif
                     foreach (WebDomainElement element in concreteWebDomainElementEnumerable)
                     {
                         String webDomainName = element.Name;
                         if (String.IsNullOrEmpty(webDomainName))
                         {
                             webDomainName = Info.Root;
                         }
                         else
                         {
                             webDomainName = webDomainName.ToLower(CultureInfo.CurrentCulture);
                         }
                         if (webDomainName != Info.Root)
                         {
                             ConfigurationLoader.InitWebDomain(element.Name, element, webDomainDataList);
                         }
                     }
                     //+
                     WebDomainDataList.AllWebDomainData = webDomainDataList;
                 }
             }
             finally
             {
                 ConfigurationReaderWriterLockSlim.ExitWriteLock();
             }
         }
     }
     finally
     {
         ConfigurationReaderWriterLockSlim.ExitUpgradeableReadLock();
     }
     //+
     return null;
 }
Пример #2
0
 //+
 //- ~InitWebDomain -//
 internal static void InitWebDomain(String webDomainName, WebDomainElement webDomainElement, WebDomainDataList webDomainDataList)
 {
     //+ based on
     WebDomainData data = null;
     if (!webDomainElement.IsAbstract && webDomainName != Info.Root)
     {
         if (String.IsNullOrEmpty(webDomainElement.Path) && String.IsNullOrEmpty(webDomainElement.Subdomain))
         {
             throw new ConfigurationErrorsException(Resource.WebDomain_PathAndSubdomainNotFound);
         }
     }
     if (!String.IsNullOrEmpty(webDomainElement.BasedOn))
     {
         data = CopyWebDomain(webDomainElement.BasedOn.ToLower(CultureInfo.CurrentCulture), webDomainDataList);
         if (data == null)
         {
             throw new InvalidOperationException(String.Format(Resource.WebDomain_Invalid, webDomainElement.BasedOn));
         }
         data.BasedOn = webDomainElement.BasedOn;
         //++ non-subdomain web domain based on subdomain web domain?
         if (String.IsNullOrEmpty(webDomainElement.Subdomain) && !String.IsNullOrEmpty(data.Subdomain))
         {
             data.Subdomain = String.Empty;
         }
     }
     if (data == null)
     {
         data = new WebDomainData();
     }
     //++ important note:
     //++  there is no way to know if the person wants to set false or just didn't set it.
     //++  therefore, you cannot disable this setting in web domain inheritance.  You must
     //++  create the web domain fresh.
     data.CatchAllMode = webDomainElement.CatchAllMode;
     data.CatchAllInitParameter = webDomainElement.CatchAllInitParameter;
     data.Name = webDomainName;
     if (!String.IsNullOrEmpty(webDomainElement.AccessRuleGroup))
     {
         data.AccessRuleGroup = webDomainElement.AccessRuleGroup;
     }
     if (!String.IsNullOrEmpty(webDomainElement.Default))
     {
         DefaultType type;
         String parameter;
         String customParameter;
         ParseDefault(webDomainElement.Default, webDomainElement.DefaultParameter, out parameter, out type, out customParameter);
         //+
         if (String.IsNullOrEmpty(parameter))
         {
             parameter = webDomainElement.DefaultParameter;
         }
         if (!String.IsNullOrEmpty(customParameter))
         {
             data.CustomParameter = customParameter;
         }
         data.DefaultParameter = UrlCleaner.CleanWebPathHead(parameter);
         data.DefaultType = type;
     }
     if (webDomainName == Info.Root)
     {
         data.Path = String.Empty;
         data.Subdomain = String.Empty;
     }
     else
     {
         data.Path = UrlCleaner.CleanWebPath(webDomainElement.Path.ToLower(CultureInfo.CurrentCulture));
         data.Subdomain = webDomainElement.Subdomain;
     }
     data.IsSealed = webDomainElement.IsSealed;
     data.ProcessorDataList = new ProcessorDataList();
     data.FactoryDataList = new FactoryDataList();
     //+ parameter
     data.ParameterDataList = GetWebDomainParameterData(webDomainElement.Parameters);
     //+ reset
     ResetFlags flags = ResetFlagReader.Read(webDomainElement.ResetSeries);
     if (data.ComponentDataList == null || (flags & ResetFlags.Component) == ResetFlags.Component)
     {
         data.ComponentDataList = new ComponentDataList();
     }
     if (data.InitProcessorDataList == null || (flags & ResetFlags.Init) == ResetFlags.Init)
     {
         data.InitProcessorDataList = new InitProcessorDataList();
     }
     if (data.ErrorProcessorDataList == null || (flags & ResetFlags.Error) == ResetFlags.Error)
     {
         data.ErrorProcessorDataList = new ErrorProcessorDataList();
     }
     if (data.SelectionProcessorDataList == null || (flags & ResetFlags.Selection) == ResetFlags.Selection)
     {
         data.SelectionProcessorDataList = new SelectionProcessorDataList();
     }
     if (data.OverrideProcessorDataList == null || (flags & ResetFlags.Override) == ResetFlags.Override)
     {
         data.OverrideProcessorDataList = new OverrideProcessorDataList();
     }
     if (data.StateProcessorDataList == null || (flags & ResetFlags.State) == ResetFlags.State)
     {
         data.StateProcessorDataList = new StateProcessorDataList();
     }
     if (data.PostRenderProcessorDataList == null || (flags & ResetFlags.PostRender) == ResetFlags.PostRender)
     {
         data.PostRenderProcessorDataList = new PostRenderProcessorDataList();
     }
     if (data.HandlerFactoryDataList == null || (flags & ResetFlags.HandlerFactory) == ResetFlags.HandlerFactory)
     {
         data.HandlerFactoryDataList = new EndpointFactoryDataList();
     }
     if (data.ProcessorFactoryDataList == null || (flags & ResetFlags.ProcessorFactory) == ResetFlags.ProcessorFactory)
     {
         data.ProcessorFactoryDataList = new ProcessorFactoryDataList();
     }
     if (data.EndpointDataList == null || (flags & ResetFlags.Endpoint) == ResetFlags.Endpoint)
     {
         data.EndpointDataList = new EndpointDataList();
     }
     if (data.ObjectFactoryDataList == null || (flags & ResetFlags.ObjectFactory) == ResetFlags.ObjectFactory)
     {
         data.ObjectFactoryDataList = new ObjectFactoryDataList();
     }
     if (data.SecurityData == null || (flags & ResetFlags.Security) == ResetFlags.Security)
     {
         data.SecurityData = new SecurityData();
     }
     if (data.SecurityData.SecurityExceptionDataList == null)
     {
         data.SecurityData.SecurityExceptionDataList = new SecurityExceptionDataList();
     }
     if (data.CatchAllEndpoint == null)
     {
         data.CatchAllEndpoint = new EndpointData();
     }
     //+ rule
     //LoadAccessRuleData(data, webDomainElement.AccessRules);
     //+ component
     LoadComponentData(data, webDomainElement.Components, webDomainElement.BasedOn);
     //+ factory
     LoadFactoryData(data, webDomainElement.Factories);
     //+ processor
     LoadProcessorData(data, webDomainElement.Processors);
     //+ handler
     LoadEndpointData(data, webDomainElement.Endpoints);
     //+ favicon
     FaviconMode faviconMode = ProcessingSection.GetConfigSection().WebDomain.FaviconMode;
     switch (faviconMode)
     {
         case FaviconMode.PassThrough:
             data.EndpointDataList.Add(EndpointData.Create(SelectorType.EndsWith, "/Favicon.ico", "{ForcePassThrough}"));
             PassThroughHttpHandler.ForceUse = true;
             break;
         case FaviconMode.Exclusion:
             data.EndpointDataList.Add(EndpointData.Create(SelectorType.EndsWith, "/Favicon.ico", "{Exclusion}"));
             break;
     }
     data.EndpointDataList.Add(EndpointData.Create(SelectorType.Contains, "/WebResource.axd?d=", "{Exclusion}"));
     //+ security
     LoadSecurityData(data, webDomainElement.Security);
     //+
     webDomainDataList.Add(data);
 }