GitSharp.Core.Transport.OpenSshConfig.refresh C# (CSharp) Method

refresh() private method

private refresh ( ) : Host>.Dictionary
return Host>.Dictionary
        private Dictionary<string, Host> refresh()
        {
            lock(locker)
            {
                long mtime = configFile.LastWriteTime.ToBinary();
                if (mtime != lastModified)
                {
                    try
                    {
                        FileStream s = new FileStream(configFile.FullName, System.IO.FileMode.Open, FileAccess.Read);
                        try
                        {
                            hosts = parse(s);
                        }
                        finally
                        {
                            s.Close();
                        }
                    }
                    catch (FileNotFoundException)
                    {
                        hosts = new Dictionary<string, Host>();
                    }
                    catch (IOException)
                    {
                        hosts = new Dictionary<string, Host>();
                    }
                    lastModified = mtime;
                }
                return hosts;
            }
        }

Usage Example

コード例 #1
0
ファイル: OpenSshConfig.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// Obtain the user's configuration data.
        /// <para/>
        /// The configuration file is always returned to the caller, even if no file
        /// exists in the user's home directory at the time the call was made. Lookup
        /// requests are cached and are automatically updated if the user modifies
        /// the configuration file since the last time it was cached.
        /// </summary>
        /// <returns>a caching reader of the user's configuration file.</returns>
        public static OpenSshConfig get()
        {
            DirectoryInfo home = FS.userHome() ?? new DirectoryInfo(Path.GetFullPath("."));

            FileInfo config = PathUtil.CombineFilePath(home, ".ssh" + Path.DirectorySeparatorChar + "config");
            var osc = new OpenSshConfig(home, config);
            osc.refresh();
            return osc;
        }
All Usage Examples Of GitSharp.Core.Transport.OpenSshConfig::refresh