Exemplo n.º 1
0
            // Where registryPath like "Software\\DTN\\IQFeed\\Startup"
            public static MyRegistryKey OpenSubKey(string registryPath, bool createIfNotExist = false)
            {
                string filename = string.Format("REGISTRY.LocalMachine.{0}.json", registryPath.Replace('\\', '.'));
                string json     = GFile.ReadTextFile(Folders.misc_path(filename), createIfNotExist);

                if (json == null)
                {
                    return(null);
                }
                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);

                return(new MyRegistryKey(dict));
            }
Exemplo n.º 2
0
        private Settings()
        {
            //var friendlyName = System.AppDomain.CurrentDomain.FriendlyName;
            string exeFilename      = GFile.GetExecutableFilename();
            string settingsFilename = string.Format(settings_filename_template, exeFilename);
            //string file = object_of_type_in_application_assembly.GetType().Assembly.Location;
            //string app = System.IO.Path.GetFileNameWithoutExtension(file);

            //var processname = System.Diagnostics.Process.GetCurrentProcess().ProcessName;       // filename without extension ("dotnet")
            //var filename = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;  // full path and filename ("/usr/local/share/dotnet/dotnet")
            //System.IO.Path.GetFileName();
            //System.IO.Path.GetFileNameWithoutExtension();
            //System.Diagnostics.Process.GetCurrentProcess().ProcessName;
            //System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;


            //string dir = AppDomain.CurrentDomain.BaseDirectory;
            string dir = GFile.GetExecutablePath();

            try
            {
                Console.WriteLine("\nSETTINGS: Looking for '{0}' in directory: {1}", settingsFilename, dir);
                m_settingsPathname = Path.Combine(dir, settingsFilename);
                m_settings         = ReadKeyValueFile(m_settingsPathname);
                if (m_settings.Count == 0)
                {
                    Console.WriteLine("\nSETTINGS: Empty settings file or settings file not found.");
                }
                else
                {
                    if (this["SECURITY_FILENAME"] != null)
                    {
                        m_security = new ApiSecurity(this["SECURITY_FILENAME"]);
                    }

                    /*foreach (var exch in m_security.ApiKeys.Keys)
                     * {
                     *  var c = m_security.ApiKeys[exch];
                     *  //Console.WriteLine("{0} '{1}' '{2}'", exch, c.ApiKey, c.ApiSecret);
                     * }
                     *
                     * ApiCredentials creds;
                     * creds = m_security.ApiKeys["BINANCE"]*/
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("\nSETTINGS: Error occurred attempting to load settings file: {0}", ex.Message);
            }
        }
        public static ExchangeSymbolsMap ReadFromFile(string pathname)
        {
            var results = new ExchangeSymbolsMap();
            var lines   = GFile.ReadTextFileLines(pathname);

            foreach (var line in lines)
            {
                var    symbols = line.Split(',').ToList();
                string exch    = symbols[0];                // exchange name is first element
                symbols.RemoveAt(0);                        // exchange symbols are all the remaining elements
                results[exch] = symbols;
            }
            return(results);
        }
Exemplo n.º 4
0
        // Read the ApiKey/ApiSecret credentials from the 'pathname' file
        public void ReadCredentials()
        {
            string json = GFile.ReadTextFile(Filename);

            ApiKeys.Clear();
            if (json == null)
            {
                return;
            }
            var res = JsonConvert.DeserializeObject <Dictionary <string, string[]> >(json);

            foreach (var exch in res.Keys)
            {
                var li = res[exch];
                ApiKeys.Add(exch, li[0], li[1]);
            }
        }