//- ~AdjustMatchType -//
 internal static EndpointData AdjustMatchType(String matchText)
 {
     EndpointData element = null;
     if (matchText.StartsWith("wdp^", StringComparison.OrdinalIgnoreCase) && matchText.EndsWith("$", StringComparison.OrdinalIgnoreCase))
     {
         element = new EndpointData();
         element.Selector = SelectorType.WebDomainPathEquals;
         element.Text = matchText.Substring(3, matchText.Length - 4);
     }
     if (matchText.StartsWith("p^", StringComparison.OrdinalIgnoreCase) && matchText.EndsWith("$", StringComparison.OrdinalIgnoreCase))
     {
         element = new EndpointData();
         element.Selector = SelectorType.PathEquals;
         element.Text = matchText.Substring(2, matchText.Length - 3);
     }
     if (matchText.StartsWith("^", StringComparison.OrdinalIgnoreCase) && matchText.EndsWith("$", StringComparison.OrdinalIgnoreCase))
     {
         element = new EndpointData();
         element.Selector = SelectorType.Equals;
         element.Text = matchText.Substring(1, matchText.Length - 2);
     }
     if (matchText.StartsWith("wdp^", StringComparison.OrdinalIgnoreCase))
     {
         element = new EndpointData();
         element.Selector = SelectorType.WebDomainPathStartsWith;
         element.Text = matchText.Substring(4, matchText.Length - 4);
     }
     if (matchText.StartsWith("p^", StringComparison.OrdinalIgnoreCase))
     {
         element = new EndpointData();
         element.Selector = SelectorType.PathStartsWith;
         element.Text = matchText.Substring(2, matchText.Length - 2);
     }
     if (matchText.EndsWith("$", StringComparison.OrdinalIgnoreCase))
     {
         element = new EndpointData();
         element.Selector = SelectorType.EndsWith;
         element.Text = matchText.Substring(0, matchText.Length - 1);
     }
     if (matchText.StartsWith("^", StringComparison.OrdinalIgnoreCase))
     {
         element = new EndpointData();
         element.Selector = SelectorType.StartsWith;
         element.Text = matchText.Substring(1, matchText.Length - 1);
     }
     //+
     return element;
 }
 //- ~AttemptHttpHandlerCreate-//
 internal IHttpHandler AttemptHttpHandlerCreate(EndpointData endpoint, String type)
 {
     IHttpHandler hh = CreateHttpHandler(type);
     if (hh == null)
     {
         if (WebProcessingReportController.Reporter.Initialized)
         {
             var map = new Map();
             map.Add("Section", "Handler Creation");
             map.Add("Message", "Could not create handler.  Either the type name is incorrect or the required handler factory was not installed correctly.");
             map.Add("Handler Name", endpoint.Type);
             map.Add("Handler Match Type", endpoint.Selector.ToString());
             map.Add("Handler Match Text", endpoint.Text);
             //+
             WebProcessingReportController.Reporter.AddMap(map);
         }
     }
     else
     {
         //+ initialize
         IHasParameterMap iHasParameterMap;
         if ((iHasParameterMap = hh as IHasParameterMap) != null)
         {
             if ((endpoint.ParameterMap == null || endpoint.ParameterMap.Count == 0) && !String.IsNullOrEmpty(iHasParameterMap.DefaultParameter) && !String.IsNullOrEmpty(endpoint.ParameterValue))
             {
                 if (iHasParameterMap.ParameterMap == null)
                 {
                     iHasParameterMap.ParameterMap = new Map();
                 }
                 iHasParameterMap.ParameterMap[iHasParameterMap.DefaultParameter] = endpoint.ParameterValue;
             }
             else
             {
                 iHasParameterMap.ParameterMap = endpoint.ParameterMap;
                 if (iHasParameterMap.ParameterMap == null)
                 {
                     iHasParameterMap.ParameterMap = new Map();
                 }
             }
         }
     }
     //+
     return hh;
 }
 //+
 //- @OnSelectionProcessorExecute -//
 public override IHttpHandler Execute(params Object[] parameterArray)
 {
     WebDomainData data = NalariumContext.Current.WebDomain.Configuration;
     DefaultType type = data.DefaultType;
     switch (type)
     {
         case DefaultType.Page:
         case DefaultType.Sequence:
             return new PageEndpointHttpHandler(type == DefaultType.Sequence);
             //+
         case DefaultType.Handler:
             var parameter = HttpData.GetScopedItem<String>(DefaultPageInitProcessor.Info.Scope, DefaultPageInitProcessor.Info.DefaultParameter);
             EndpointData endpointData;
             Map parameterMap = data.ParameterDataList.GetMapForCategory(String.Empty);
             if (!String.IsNullOrEmpty(data.CustomParameter))
             {
                 parameterMap.Add(String.Empty, parameter);
                 endpointData = new EndpointData
                                {
                                    Type = data.CustomParameter,
                                    ParameterMap = parameterMap
                                };
             }
             else
             {
                 endpointData = new EndpointData
                                {
                                    Type = parameter,
                                    ParameterMap = data.ParameterDataList.GetMapForCategory(String.Empty)
                                };
             }
             String typeName = endpointData.Type;
             if (!typeName.Contains(","))
             {
                 typeName = "{" + typeName + "}";
             }
             return new HttpHandlerSelector().AttemptHttpHandlerCreate(endpointData, typeName);
             //+
         case DefaultType.Mvc:
             return CreateMvcHandler();
     }
     //+
     return null;
 }
 //- ~AttemptHttpHandlerCreate-//
 internal IHttpHandler AttemptHttpHandlerCreate(EndpointData endpoint)
 {
     return AttemptHttpHandlerCreate(endpoint, endpoint.Type);
 }
 //- $ProcessPotentialSubEndpoint -//
 private EndpointData ProcessPotentialSubEndpoint(EndpointData endpoint)
 {
     EndpointDataList list = endpoint.SubEndpointDataList;
     foreach (EndpointData data in list)
     {
         switch (data.Selector)
         {
             case SelectorType.UserAgent:
                 if (Http.UserAgent.Contains(data.Text) || (data.Text.Equals("{blank}") && Http.UserAgent.Length == 0))
                 {
                     return data;
                 }
                 break;
             case SelectorType.Referrer:
                 if (Http.Referrer.Contains(data.Text) || (data.Text.Equals("{blank}") && Http.Referrer.Length == 0))
                 {
                     return data;
                 }
                 break;
             case SelectorType.IPAddress:
                 if (IPAddressMatcher.Match(data.Text) || (data.Text.Equals("{blank}") && Http.IPAddress.Length == 0))
                 {
                     return data;
                 }
                 break;
         }
     }
     //+
     return null;
 }
 //- ~MatchHttpHandler -//
 internal EndpointData MatchHttpHandler(EndpointData endpoint, Boolean withoutSlash, out IHttpHandler handler)
 {
     String text = endpoint.Text;
     if (withoutSlash)
     {
         text = endpoint.TextWithoutSlash;
     }
     if (PathMatcher.Match(endpoint.Selector, text))
     {
         if (endpoint.SubEndpointDataList != null && endpoint.SubEndpointDataList.Count > 0)
         {
             EndpointData newEndpoint = ProcessPotentialSubEndpoint(endpoint);
             if (newEndpoint != null)
             {
                 endpoint = newEndpoint;
             }
         }
         handler = AttemptHttpHandlerCreate(endpoint);
     }
     else
     {
         handler = new DummyHttpHandler();
     }
     //+
     return endpoint;
 }
Exemple #7
0
 //- #AddEndpoint -//
 protected void AddEndpoint(EndpointData endpointData)
 {
     endpointData.Source = Key;
     _endpointDataList.Add(endpointData);
 }
 //- ~LoadEndpointData -//
 internal static void LoadEndpointData(WebDomainData data, EndpointCollection collection)
 {
     List<EndpointElement> elementList = collection.ToList();
     var matchTextList = new List<String>();
     var referenceKeyList = new List<String>();
     if (collection.Count(p => p.Text == "*") > 1)
     {
         throw new ConfigurationErrorsException(ResourceAccessor.GetString("WebDomain_DuplicateCatchAll"));
     }
     foreach (EndpointElement element in elementList)
     {
         if (element.Disabled)
         {
             continue;
         }
         String matchText = element.Text;
         Boolean requireSlash = element.RequireSlash;
         String withoutSlash = EndpointData.GetTextWithoutSlash(matchText);
         SelectorType matchType = element.Selector;
         String originalMatchText = matchText;
         EndpointData newElement = AdjustMatchType(element.Text);
         if (newElement != null)
         {
             matchText = newElement.Text;
             matchType = newElement.Selector;
         }
         matchTextList.Add(matchText);
         if (element.Text == "*")
         {
             data.CatchAllEndpoint = new EndpointData
                                     {
                                         AccessRuleGroup = element.AccessRuleGroup,
                                         OriginalMatchText = originalMatchText,
                                         Text = matchText,
                                         TextWithoutSlash = withoutSlash,
                                         Selector = matchType,
                                         Type = element.Type,
                                         ParameterValue = element.Parameter,
                                         ParameterMap = element.GetParameterMap(),
                                         Source = Info.System
                                     };
         }
         else
         {
             var endpointData = new EndpointData
                                {
                                    AccessRuleGroup = element.AccessRuleGroup,
                                    OriginalMatchText = originalMatchText,
                                    Text = matchText,
                                    TextWithoutSlash = withoutSlash,
                                    Selector = matchType,
                                    Type = element.Type,
                                    RequireSlash = element.RequireSlash,
                                    ParameterValue = element.Parameter,
                                    ParameterMap = element.GetParameterMap(),
                                    Source = Info.System
                                };
             endpointData.SubEndpointDataList = new EndpointDataList();
             foreach (EndpointElement subElement in element.SubEndpoints)
             {
                 String subWithoutSlash = EndpointData.GetTextWithoutSlash(matchText);
                 endpointData.SubEndpointDataList.Add(new EndpointData
                                                      {
                                                          Text = subElement.Text,
                                                          TextWithoutSlash = subWithoutSlash,
                                                          Selector = subElement.Selector,
                                                          Type = subElement.Type,
                                                          ParameterValue = subElement.Parameter,
                                                          ParameterMap = subElement.GetParameterMap(),
                                                          Source = Info.System
                                                      });
             }
             data.EndpointDataList.Add(endpointData);
         }
     }
     EndpointDataList handlerList = data.EndpointDataList.Clone();
     data.EndpointDataList = new EndpointDataList();
     handlerList.Where(p => p.Selector == SelectorType.PathEquals).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     handlerList.Where(p => p.Selector == SelectorType.EndsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     handlerList.Where(p => p.Selector == SelectorType.WebDomainPathStartsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     handlerList.Where(p => p.Selector == SelectorType.WebDomainPathEquals).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     handlerList.Where(p => p.Selector == SelectorType.PathStartsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     handlerList.Where(p => p.Selector == SelectorType.StartsWith).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     handlerList.Where(p => p.Selector == SelectorType.PathContains).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     handlerList.Where(p => p.Selector == SelectorType.Contains).OrderByDescending(p => p.Text.Length).ToList().ForEach(p => data.EndpointDataList.Add(p));
     //+
     data.EndpointDataList.OriginalCount = data.EndpointDataList.Count;
 }
Exemple #9
0
 private static EndpointData TryCreateAndInit(HttpHandlerSelector router, EndpointData endpoint, Boolean withoutSlash, out IHttpHandler hh)
 {
     return router.MatchHttpHandler(endpoint, withoutSlash, out hh);
 }
Exemple #10
0
 //- $TryCreateAndInit -//
 private static EndpointData TryCreateAndInit(HttpHandlerSelector router, EndpointData endpoint, out IHttpHandler hh)
 {
     return TryCreateAndInit(router, endpoint, false, out hh);
 }
Exemple #11
0
 //+
 //- @Clone -//
 public EndpointData Clone()
 {
     var newMap = new Map(ParameterMap);
     var newData = new EndpointData
                   {
                       OriginalMatchText = OriginalMatchText,
                       Text = Text,
                       TextWithoutSlash = TextWithoutSlash,
                       Selector = Selector,
                       Type = Type,
                       ParameterValue = ParameterValue,
                       ParameterMap = newMap,
                       RequireSlash = RequireSlash,
                       SubEndpointDataList = SubEndpointDataList != null ? SubEndpointDataList.Clone() : new EndpointDataList(),
                       Source = Source
                   };
     //+
     return this;
 }