Esempio n. 1
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);
        }
Esempio n. 2
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);
        }