Exemple #1
0
        public ClientCredentials GetDefaultCredentials([NotNull] string configName = ConfigurationNames.Default)
        {
            if (configName == null)
            {
                throw new ArgumentNullException(nameof(configName));
            }

            var storesReader  = new ConfigStoresReader(_systemEnvironment, configName);
            var defaultClient = storesReader.GetDefaultClient();

            return(defaultClient == null ? null : storesReader.GetClientCredentials(defaultClient.Id));
        }
Exemple #2
0
        protected EryphClientConfiguration ToOutput(ClientData clientData, string configurationName)
        {
            var reader = new ConfigStoresReader(new PowershellEnvironment(SessionState), configurationName);

            return(new EryphClientConfiguration
            {
                Id = clientData.Id,
                Name = clientData.Name,
                Configuration = configurationName,
                IsDefault = clientData.Id == reader.GetDefaultClient()?.Id
            });
        }
Exemple #3
0
        protected override void ProcessRecord()
        {
            var configurationNames = new List <string>
            {
                ConfigurationNames.Default, ConfigurationNames.Local, ConfigurationNames.Zero
            };

            if (Configuration != null)
            {
                configurationNames.Clear();
                configurationNames.Add(Configuration);
            }

            foreach (var configurationName in configurationNames)
            {
                var storesReader  = new ConfigStoresReader(new PowershellEnvironment(SessionState), configurationName);
                var defaultClient = storesReader.GetDefaultClient();

                EryphClientConfiguration Output(ClientData d) => ToOutput(d, configurationName);

                if (Default == true)
                {
                    if (defaultClient != null)
                    {
                        WriteObject(defaultClient);
                    }
                    return;
                }

                if (Id == null)
                {
                    WriteObject(storesReader.GetClients().Select(Output), true);
                }
                else
                {
                    WriteObject(Id.Select(x => storesReader.GetClientById(x)).Where(x => x != null)
                                .Select(Output), true);
                }
            }
        }