Microsoft.Azure.Commands.Resources.GetAzureProviderOperationCommand.GetResourceProviderFullName C# (CSharp) Method

GetResourceProviderFullName() private static method

Extracts the resource provider's full name - i.e portion of the non-wildcard prefix before the '/' Returns null if the nonWildCardPrefix does not contain a '/'
private static GetResourceProviderFullName ( string nonWildCardPrefix ) : string
nonWildCardPrefix string
return string
        private static string GetResourceProviderFullName(string nonWildCardPrefix)
        {
            int index = nonWildCardPrefix.IndexOf(Separator.ToString(), 0);
            return index > 0 ? nonWildCardPrefix.Substring(0, index) : string.Empty;
        }

Usage Example

        /// <summary>
        /// Get a list of Provider operations in the case that the Actionstring input contains a wildcard
        /// </summary>
        private List <PSResourceProviderOperation> ProcessProviderOperationsWithWildCard(string actionString)
        {
            // Filter the list of all operation names to what matches the wildcard
            WildcardPattern wildcard = new WildcardPattern(actionString, WildcardOptions.IgnoreCase | WildcardOptions.Compiled);

            List <ProviderOperationsMetadata> providers = new List <ProviderOperationsMetadata>();

            string nonWildCardPrefix = GetAzureProviderOperationCommand.GetNonWildcardPrefix(actionString);

            if (string.IsNullOrWhiteSpace(nonWildCardPrefix))
            {
                // 'Get-AzureRmProviderOperation *' or 'Get-AzureRmProviderOperation */virtualmachines/*'
                // get operations for all providers
                providers.AddRange(this.ResourcesClient.ListProviderOperationsMetadata());
            }
            else
            {
                // Some string exists before the wild card character - potentially the full name of the provider.
                string providerFullName = GetAzureProviderOperationCommand.GetResourceProviderFullName(nonWildCardPrefix);
                if (!string.IsNullOrWhiteSpace(providerFullName))
                {
                    // we have the full name of the provider. 'Get-AzureRmProviderOperation Microsoft.Sql/servers/*'
                    // only query for that provider
                    providers.Add(this.ResourcesClient.GetProviderOperationsMetadata(providerFullName));
                }
                else
                {
                    // We have only a partial name of the provider, say Microsoft.*/* or Microsoft.*/*/read.
                    // query for all providers and then do prefix match on the operations
                    providers.AddRange(this.ResourcesClient.ListProviderOperationsMetadata());
                }
            }

            return(providers.SelectMany(p => GetPSOperationsFromProviderOperationsMetadata(p)).Where(operation => wildcard.IsMatch(operation.Operation)).ToList());
        }
All Usage Examples Of Microsoft.Azure.Commands.Resources.GetAzureProviderOperationCommand::GetResourceProviderFullName