Пример #1
0
 public static DeliveryRuleAction ToDeliveryRuleAction(this PSDeliveryRuleAction psDeliveryRuleAction)
 {
     if (psDeliveryRuleAction is PSDeliveryRuleCacheExpirationAction psDeliveryRuleCacheExpirationAction)
     {
         return(new DeliveryRuleCacheExpirationAction
         {
             Parameters = new CacheExpirationActionParameters
             {
                 CacheBehavior = psDeliveryRuleCacheExpirationAction.Parameters.CacheBehavior,
                 CacheDuration = psDeliveryRuleCacheExpirationAction.Parameters.CacheDuration
             }
         });
     }
     else if (psDeliveryRuleAction is PSDeliveryRuleHeaderAction psDeliveryRuleHeaderAction)
     {
         if (psDeliveryRuleHeaderAction.HeaderActionType == "ModifyRequestHeader")
         {
             return(new DeliveryRuleRequestHeaderAction
             {
                 Parameters = new HeaderActionParameters
                 {
                     HeaderAction = psDeliveryRuleHeaderAction.Action,
                     HeaderName = psDeliveryRuleHeaderAction.HeaderName,
                     Value = psDeliveryRuleHeaderAction.Value
                 }
             });
         }
         else if (psDeliveryRuleHeaderAction.HeaderActionType == "ModifyResponseHeader")
         {
             return(new DeliveryRuleRequestHeaderAction
             {
                 Parameters = new HeaderActionParameters
                 {
                     HeaderAction = psDeliveryRuleHeaderAction.Action,
                     HeaderName = psDeliveryRuleHeaderAction.HeaderName,
                     Value = psDeliveryRuleHeaderAction.Value
                 }
             });
         }
     }
     else if (psDeliveryRuleAction is PSDeliveryRuleUrlRedirectAction psDeliveryRuleUrlRedirectAction)
     {
         return(new UrlRedirectAction
         {
             Parameters = new UrlRedirectActionParameters
             {
                 RedirectType = psDeliveryRuleUrlRedirectAction.RedirectType,
                 DestinationProtocol = psDeliveryRuleUrlRedirectAction.DestinationProtocol,
                 CustomPath = psDeliveryRuleUrlRedirectAction.CustomPath,
                 CustomHostname = psDeliveryRuleUrlRedirectAction.CustomHostname,
                 CustomQueryString = psDeliveryRuleUrlRedirectAction.CustomQueryString,
                 CustomFragment = psDeliveryRuleUrlRedirectAction.CustomFragment
             }
         });
     }
     return(new DeliveryRuleAction());
 }
Пример #2
0
        public static DeliveryRuleAction ToDeliveryRuleAction(this PSDeliveryRuleAction psDeliveryRuleAction)
        {
            var psDeliveryRuleCacheExpirationAction = psDeliveryRuleAction as PSDeliveryRuleCacheExpirationAction;

            if (psDeliveryRuleCacheExpirationAction != null)
            {
                return(new DeliveryRuleCacheExpirationAction
                {
                    Parameters = new CacheExpirationActionParameters
                    {
                        CacheBehavior = psDeliveryRuleCacheExpirationAction.Parameters.CacheBehavior,
                        CacheDuration = psDeliveryRuleCacheExpirationAction.Parameters.CacheDuration
                    }
                });
            }
            return(new DeliveryRuleAction());
        }
Пример #3
0
        public override void ExecuteCmdlet()
        {
            PSDeliveryRuleAction deliveryRuleAction;

            if (ParameterSetName == CacheExpirationActionParameterSet)
            {
                deliveryRuleAction = new PSDeliveryRuleCacheExpirationAction
                {
                    Parameters = new PSCacheExpirationActionParameters
                    {
                        CacheBehavior = CacheBehavior,
                        CacheDuration = CacheDuration
                    }
                };
            }
            else if (ParameterSetName == HeaderActionParameterSet)
            {
                deliveryRuleAction = new PSDeliveryRuleHeaderAction
                {
                    HeaderActionType = HeaderActionType,
                    Action           = Action,
                    HeaderName       = HeaderName,
                    Value            = Value
                };
            }
            else if (ParameterSetName == UrlRedirectActionParameterSet)
            {
                deliveryRuleAction = new PSDeliveryRuleUrlRedirectAction
                {
                    RedirectType        = RedirectType,
                    DestinationProtocol = DestinationProtocol,
                    CustomPath          = CustomPath,
                    CustomHostname      = CustomHostname,
                    CustomQueryString   = CustomQueryString,
                    CustomFragment      = CustomFragment
                };
            }
            else
            {
                deliveryRuleAction = new PSDeliveryRuleAction();
            }
            WriteObject(deliveryRuleAction);
        }
Пример #4
0
        public override void ExecuteCmdlet()
        {
            PSDeliveryRuleAction deliveryRuleAction;

            if (ParameterSetName == CacheExpirationActionParameterSet)
            {
                deliveryRuleAction = new PSDeliveryRuleCacheExpirationAction
                {
                    Parameters = new PSCacheExpirationActionParameters
                    {
                        CacheBehavior = CacheBehavior,
                        CacheDuration = CacheDuration
                    }
                };
            }
            else if (ParameterSetName == HeaderActionParameterSet)
            {
                deliveryRuleAction = new PSDeliveryRuleHeaderAction
                {
                    HeaderActionType = HeaderActionType,
                    Action           = Action,
                    HeaderName       = HeaderName,
                    Value            = Value
                };
            }
            else if (ParameterSetName == UrlRedirectActionParameterSet)
            {
                deliveryRuleAction = new PSDeliveryRuleUrlRedirectAction
                {
                    RedirectType        = RedirectType,
                    DestinationProtocol = DestinationProtocol,
                    CustomPath          = CustomPath,
                    CustomHostname      = CustomHostname,
                    CustomQueryString   = CustomQueryString,
                    CustomFragment      = CustomFragment
                };
            }
            else if (ParameterSetName == CacheKeyQueryStringActionParameterSet)
            {
                if ((QueryStringBehavior == "Exclude" || QueryStringBehavior == "Include") && QueryParameter == null)
                {
                    throw new PSArgumentException("QueryParameter cannot be empty when QueryStringBehavior is {0}", QueryStringBehavior);
                }
                else if (QueryStringBehavior == "ExcludeAll" || QueryStringBehavior == "IncludeAll")
                {
                    QueryParameter = null;
                }

                deliveryRuleAction = new PSDeliveryRuleCacheKeyQueryStringAction
                {
                    QueryStringBehavior = QueryStringBehavior,
                    QueryParameter      = QueryParameter == null? string.Empty : string.Join(",", QueryParameter)
                };
            }
            else if (ParameterSetName == UrlRewriteActionParameterSet)
            {
                deliveryRuleAction = new PSDeliveryRuleUrlRewriteAction
                {
                    SourcePattern = SourcePattern,
                    Destination   = Destination,
                    PreservePath  = PreservePath
                };
            }
            else
            {
                deliveryRuleAction = new PSDeliveryRuleAction();
            }
            WriteObject(deliveryRuleAction);
        }