示例#1
0
        internal ConfigConsole(ConsoleSettings settings)
        {
            m_settings = settings;

            this.CreateClients();

            TokenSettings tokenSettings = null;

            try
            {
                string dataPath =
                    Path.Combine(
                        Path.Combine(
                            Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                            "DirectProject"),
                        "TokenSettings.xml");

                if (File.Exists(dataPath))
                {
                    string tokenSettingsXml = File.ReadAllText(dataPath);
                    tokenSettings = tokenSettingsXml.FromXml <TokenSettings>();
                }
                else
                {
                    Property[] properties       = m_propertyClient.GetProperties(new[] { "TokenSettings" });
                    string     tokenSettingsXml = properties.SingleOrDefault().Value;
                    tokenSettings = tokenSettingsXml.FromXml <TokenSettings>();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            m_commands        = new Commands("ConfigConsole");
            m_commands.Error += PrintError;

            m_commands.Register(new AddressCommands(this, () => m_addressClient));
            m_commands.Register(new AnchorCommands(this, () => m_anchorClient));
            m_commands.Register(new CertificateCommands(this, () => m_certificateClient));
            if (tokenSettings != null)
            {
                m_commands.Register(new Pkcs11Commands(this, () => m_certificateClient, tokenSettings));
            }
            m_commands.Register(new DomainCommands(this, () => m_domainClient, () => m_addressClient));
            m_commands.Register(new DnsRecordCommands(this, () => m_dnsRecordClient));
            m_commands.Register(new PropertyCommands(this, () => m_propertyClient));
            m_commands.Register(new BlobCommands(this, () => m_blobClient));
            m_commands.Register(new SettingsCommands(this));
            m_commands.Register(new TestCommands(this));
            m_commands.Register(new BundleCommands(this, () => m_bundleClient));
            m_commands.Register(new MdnMonitorCommands(this, () => m_mdnMoniotrClient));
            m_commands.Register(new CertPolicyCommands(this, () => m_certPolicyClient));

            m_settings.HostAndPortChanged += HostAndPortChanged;
        }
示例#2
0
        static void Main(string[] args)
        {
            ConfigConsole console = new ConfigConsole(ConsoleSettings.Load());

            bool result = console.Run(args);

            if (!result && Environment.ExitCode == 0)
            {
                Environment.ExitCode = -1;
            }
        }
示例#3
0
        public static ConsoleSettings Load(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ConsoleSettings));

            using (Stream stream = File.OpenRead(path))
            {
                ConsoleSettings settings = (ConsoleSettings)serializer.Deserialize(stream);
                settings.Validate();
                return(settings);
            }
        }
示例#4
0
        internal ConfigConsole(ConsoleSettings settings)
        {
            m_settings = settings;

            this.CreateClients();

            TokenSettings tokenSettings = null;

            try
            {
                Property[] properties       = m_propertyClient.GetProperties(new[] { "TokenSettings" });
                string     tokenSettingsXml = properties.SingleOrDefault().Value;
                tokenSettings = tokenSettingsXml.FromXml <TokenSettings>();
            }
            catch (Exception)
            {
                //Acceptable to not have token settings.
            }

            m_commands        = new Commands("ConfigConsole");
            m_commands.Error += PrintError;

            m_commands.Register(new AddressCommands(this, () => m_addressClient));
            m_commands.Register(new AnchorCommands(this, () => m_anchorClient));
            m_commands.Register(new CertificateCommands(this, () => m_certificateClient));
            if (tokenSettings != null)
            {
                m_commands.Register(new Pkcs11Commands(this, () => m_certificateClient, tokenSettings));
            }
            m_commands.Register(new DomainCommands(this, () => m_domainClient, () => m_addressClient));
            m_commands.Register(new DnsRecordCommands(this, () => m_dnsRecordClient));
            m_commands.Register(new PropertyCommands(this, () => m_propertyClient));
            m_commands.Register(new BlobCommands(this, () => m_blobClient));
            m_commands.Register(new SettingsCommands(this));
            m_commands.Register(new TestCommands(this));
            m_commands.Register(new BundleCommands(this, () => m_bundleClient));
            m_commands.Register(new MdnMonitorCommands(this, () => m_mdnMoniotrClient));
            m_commands.Register(new CertPolicyCommands(this, () => m_certPolicyClient));

            m_settings.HostAndPortChanged += HostAndPortChanged;
        }
示例#5
0
        internal ConfigConsole(ConsoleSettings settings)
        {
            m_settings = settings;

            this.CreateClients();

            m_commands        = new Commands("ConfigConsole");
            m_commands.Error += PrintError;

            m_commands.Register(new AddressCommands(this, () => m_addressClient));
            m_commands.Register(new AnchorCommands(this, () => m_anchorClient));
            m_commands.Register(new CertificateCommands(this, () => m_certificateClient));
            m_commands.Register(new DomainCommands(this, () => m_domainClient, () => m_addressClient));
            m_commands.Register(new DnsRecordCommands(this, () => m_dnsRecordClient));
            m_commands.Register(new PropertyCommands(this, () => m_propertyClient));
            m_commands.Register(new BlobCommands(this, () => m_blobClient));
            m_commands.Register(new SettingsCommands(this));
            m_commands.Register(new TestCommands(this));
            m_commands.Register(new BundleCommands(this, () => m_bundleClient));

            m_settings.HostAndPortChanged += HostAndPortChanged;
        }