Microsoft.Azure.Commands.DataFactories.DataFactoryClient.FilterPSDataFactories C# (CSharp) Method

FilterPSDataFactories() public method

public FilterPSDataFactories ( DataFactoryFilterOptions filterOptions ) : List
filterOptions DataFactoryFilterOptions
return List
        public virtual List<PSDataFactory> FilterPSDataFactories(DataFactoryFilterOptions filterOptions)
        {
            if (filterOptions == null)
            {
                throw new ArgumentNullException("filterOptions");
            }

            // ToDo: make ResourceGroupName optional
            if (string.IsNullOrWhiteSpace(filterOptions.ResourceGroupName))
            {
                throw new ArgumentException(Resources.ResourceGroupNameCannotBeEmpty);
            }

            List<PSDataFactory> dataFactories = new List<PSDataFactory>();

            if (!string.IsNullOrWhiteSpace(filterOptions.Name))
            {
                dataFactories.Add(GetDataFactory(filterOptions.ResourceGroupName, filterOptions.Name));
            }
            else
            {
                dataFactories.AddRange(ListDataFactories(filterOptions));
            }

            return dataFactories;
        }

Usage Example

        public override void ExecuteCmdlet()
        {
            // ValidationNotNullOrEmpty doesn't handle whitespaces well
            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new PSArgumentNullException("Name");
            }

            DataFactoryFilterOptions filterOptions = new DataFactoryFilterOptions()
            {
                Name = Name,
                ResourceGroupName = ResourceGroupName
            };

            if (Name != null)
            {
                List <PSDataFactory> dataFactories = DataFactoryClient.FilterPSDataFactories(filterOptions);
                if (dataFactories != null && dataFactories.Any())
                {
                    WriteObject(dataFactories.First());
                }
                return;
            }

            //List data factories until all pages are fetched
            do
            {
                WriteObject(DataFactoryClient.FilterPSDataFactories(filterOptions), true);
            } while (filterOptions.NextLink.IsNextPageLink());
        }
All Usage Examples Of Microsoft.Azure.Commands.DataFactories.DataFactoryClient::FilterPSDataFactories