public List <PSActivityWindow> ProcessListFilterActivityWindows(ActivityWindowFilterOptions filterOptions)
        {
            List <PSActivityWindow> runs = new List <PSActivityWindow>();

            ActivityWindowListResponse response;

            if (string.IsNullOrWhiteSpace(filterOptions.PipelineName) &&
                !string.IsNullOrWhiteSpace(filterOptions.DatasetName) &&
                string.IsNullOrWhiteSpace(filterOptions.ActivityName))
            {
                ActivityWindowsByDatasetListParameters byDatasetListParameters =
                    this.GenerateListParameters <ActivityWindowsByDatasetListParameters>(filterOptions);
                response = this.ListByDatasetActivityWindows(filterOptions.NextLink, byDatasetListParameters);
            }
            else if (string.IsNullOrWhiteSpace(filterOptions.DatasetName) &&
                     !string.IsNullOrWhiteSpace(filterOptions.PipelineName) &&
                     string.IsNullOrWhiteSpace(filterOptions.ActivityName))
            {
                ActivityWindowsByPipelineListParameters byPipelineListParameters =
                    this.GenerateListParameters <ActivityWindowsByPipelineListParameters>(filterOptions);
                response = this.ListByPipelineActivityWindows(filterOptions.NextLink, byPipelineListParameters);
            }
            else if (string.IsNullOrWhiteSpace(filterOptions.DatasetName) &&
                     !string.IsNullOrWhiteSpace(filterOptions.PipelineName) &&
                     !string.IsNullOrWhiteSpace(filterOptions.ActivityName))
            {
                ActivityWindowsByActivityListParameters byActivityListParameters =
                    this.GenerateListParameters <ActivityWindowsByActivityListParameters>(filterOptions);
                response = this.ListByActivityActivityWindows(filterOptions.NextLink, byActivityListParameters);
            }
            else if (string.IsNullOrWhiteSpace(filterOptions.DatasetName) &&
                     string.IsNullOrWhiteSpace(filterOptions.PipelineName) &&
                     string.IsNullOrWhiteSpace(filterOptions.ActivityName))
            {
                ActivityWindowsByDataFactoryListParameters byDataFactoryListParameters =
                    this.GenerateListParameters <ActivityWindowsByDataFactoryListParameters>(filterOptions);
                response = this.ListByDataFactoryActivityWindows(filterOptions.NextLink, byDataFactoryListParameters);
            }
            else
            {
                throw new PSArgumentException(
                          "An incorrect combination of arguments was passed. One of the following combinations of arguments must be provided:\n" +
                          "1) List activity windows by data factory: '-ResourceGroupName' and '-DataFactoryName'.\n" +
                          "2) List activity windows by pipeline: '-ResourceGroupName' and '-DataFactoryName' and '-PipelineName'.\n" +
                          "3) List activity windows by pipeline activity: '-ResourceGroupName' and '-DataFactoryName' and '-PipelineName' and '-ActivityName'.\n" +
                          "4) List activity windows by dataset: '-ResourceGroupName' and '-DataFactoryName' and '-DatasetName'.\n");
            }

            filterOptions.NextLink = response != null ? response.NextLink : null;

            if (response != null && response.ActivityWindowListResponseValue.ActivityWindows != null)
            {
                runs.AddRange(response.ActivityWindowListResponseValue.ActivityWindows.Select(activityWindow => new PSActivityWindow(activityWindow)));
            }

            return(runs);
        }
        public override void ExecuteCmdlet()
        {
            if (this.ParameterSetName == ByFactoryObject)
            {
                if (this.DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                this.DataFactoryName   = DataFactory.DataFactoryName;
                this.ResourceGroupName = DataFactory.ResourceGroupName;
            }

            ActivityWindowFilterOptions filterOptions = new ActivityWindowFilterOptions()
            {
                ResourceGroupName = this.ResourceGroupName,
                DataFactoryName   = this.DataFactoryName,
                ActivityName      = this.ActivityName,
                DatasetName       = this.DatasetName,
                PipelineName      = this.PipelineName,
                Filter            = Filter,
                OrderBy           = this.OrderBy,
                RunEnd            = this.RunEnd,
                RunStart          = this.RunStart,
                Top            = this.Top,
                WindowEnd      = this.WindowEnd,
                WindowStart    = this.WindowStart,
                WindowState    = this.WindowState,
                WindowSubstate = this.WindowSubstate
            };

            try
            {
                do
                {
                    List <PSActivityWindow> activityWindows = DataFactoryClient.ProcessListFilterActivityWindows(filterOptions);
                    WriteObject(activityWindows, true);
                } while (filterOptions.NextLink.IsNextPageLink());
            }
            catch (PSArgumentException e)
            {
                WriteWarning(e.Message);
            }
        }
        private T GenerateListParameters <T>(ActivityWindowFilterOptions filterOptions)
            where T : ActivityWindowsListParameters, new()
        {
            T listParameters = new T();

            Type typeOfT    = typeof(T);
            Type filterType = typeof(ActivityWindowFilterOptions);

            foreach (PropertyInfo pi in filterType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                object filterValue = filterType.GetProperty(pi.Name).GetValue(filterOptions, null);

                PropertyInfo propertyInfo = typeOfT.GetProperty(pi.Name);
                if (propertyInfo != null)
                {
                    typeOfT.GetProperty(pi.Name).SetValue(listParameters, filterValue);
                }
            }

            return(listParameters);
        }
        public override void ExecuteCmdlet()
        {
            if (this.ParameterSetName == ByFactoryObject)
            {
                if (this.DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                this.DataFactoryName = DataFactory.DataFactoryName;
                this.ResourceGroupName = DataFactory.ResourceGroupName;
            }

            ActivityWindowFilterOptions filterOptions = new ActivityWindowFilterOptions()
            {
                ResourceGroupName = this.ResourceGroupName,
                DataFactoryName = this.DataFactoryName,
                ActivityName = this.ActivityName,
                DatasetName = this.DatasetName,
                PipelineName = this.PipelineName,
                Filter = Filter,
                OrderBy = this.OrderBy,
                RunEnd = this.RunEnd,
                RunStart = this.RunStart,
                Top = this.Top,
                WindowEnd = this.WindowEnd,
                WindowStart = this.WindowStart,
                WindowState = this.WindowState,
                WindowSubstate = this.WindowSubstate
            };

            try
            {
                do
                {
                    List<PSActivityWindow> activityWindows = DataFactoryClient.ProcessListFilterActivityWindows(filterOptions);
                    WriteObject(activityWindows, true);
                } while (filterOptions.NextLink.IsNextPageLink());
            }
            catch (PSArgumentException e)
            {
                WriteWarning(e.Message);
            }
        }