public static ItemQueryRedirect ToItemQueryRedirectAction(this ItemQueryRedirectItem itemQueryRedirectItem) { if (itemQueryRedirectItem == null) { return(null); } var itemQueryRedirectAction = new ItemQueryRedirect() { Name = itemQueryRedirectItem.Name, ItemQuery = itemQueryRedirectItem.ItemQuery.Value }; var baseAppendQueryString = itemQueryRedirectItem.BaseAppendQuerystringItem; GetBaseAppendQueryStringItem(baseAppendQueryString, itemQueryRedirectAction); var stopProcessingItem = itemQueryRedirectItem.BaseStopProcessingItem; GetStopProcessing(stopProcessingItem, itemQueryRedirectAction); var redirectTypeItem = itemQueryRedirectItem.BaseRedirectTypeItem; GetStatusCode(redirectTypeItem, itemQueryRedirectAction); var httpCacheabilityTypeItem = itemQueryRedirectItem.BaseCacheItem; GetCacheability(httpCacheabilityTypeItem, itemQueryRedirectAction); return(itemQueryRedirectAction); }
public static InboundRule ToInboundRule(this InboundRuleItem inboundRuleItem, string siteNameRestriction) { if (inboundRuleItem == null) { return(null); } var conditionItems = GetBaseConditionItems(inboundRuleItem); //var serverVariableItems = GetServerVariableItems(inboundRuleItem); //var requestHeaderItems = GetRequestHeaderItems(inboundRuleItem); var responseHeaderItems = GetResponseHeaderItems(inboundRuleItem); var inboundRule = new InboundRule { ItemId = inboundRuleItem.ID.Guid, Name = inboundRuleItem.Name }; SetBaseRule(inboundRuleItem.BaseRuleItem, inboundRule); if (string.IsNullOrEmpty(inboundRuleItem.BaseRuleItem.BaseMatchItem.MatchPatternItem.Pattern.Value)) { Log.Warn(logObject, inboundRuleItem.Database, "No pattern set on rule with ItemID: {0}", inboundRuleItem.ID); return(null); } if (inboundRuleItem.Action == null) { Log.Warn(logObject, inboundRuleItem.Database, "No action set on rule with ItemID: {0}", inboundRuleItem.ID); return(null); } var baseActionItem = inboundRuleItem.Action.TargetItem; IBaseAction baseAction = null; if (baseActionItem != null) { var baseActionItemTemplateId = baseActionItem.TemplateID.ToString(); if (baseActionItemTemplateId.Equals(RedirectItem.TemplateId, StringComparison.InvariantCultureIgnoreCase)) { baseAction = new RedirectItem(baseActionItem).ToRedirectAction(); } else if (baseActionItemTemplateId.Equals(RewriteItem.TemplateId, StringComparison.InvariantCultureIgnoreCase)) { baseAction = new RewriteItem(baseActionItem).ToRewriteAction(); } else if (baseActionItemTemplateId.Equals(AbortRequestItem.TemplateId, StringComparison.InvariantCultureIgnoreCase)) { baseAction = new AbortRequestItem(baseActionItem).ToAbortRequestAction(); } else if (baseActionItemTemplateId.Equals(CustomResponseItem.TemplateId, StringComparison.InvariantCultureIgnoreCase)) { baseAction = new CustomResponseItem(baseActionItem).ToCustomResponseAction(); } else if (baseActionItemTemplateId.Equals(ItemQueryRedirectItem.TemplateId)) { baseAction = new ItemQueryRedirectItem(baseActionItem).ToItemQueryRedirectAction(); } } inboundRule.Action = baseAction; if (conditionItems != null) { SetConditions(conditionItems, inboundRule); } //if (serverVariableItems != null) //{ // SetServerVariables(serverVariableItems, inboundRule); //} //if (requestHeaderItems != null) //{ // SetRequestHeaders(requestHeaderItems, inboundRule); //} if (responseHeaderItems != null) { SetResponseHeaders(responseHeaderItems, inboundRule); } inboundRule.SiteNameRestriction = siteNameRestriction; return(inboundRule); }