RankSystem.RankConfigFile.Read C# (CSharp) Method

Read() public static method

public static Read ( Stream stream ) : RankConfigFile
stream Stream
return RankConfigFile
        public static RankConfigFile Read(Stream stream)
        {
            using (var sr = new StreamReader(stream))
            {
                var cf = JsonConvert.DeserializeObject<RankConfigFile>(sr.ReadToEnd());
                if (ConfigRead != null)
                    ConfigRead(cf);
                return cf;
            }
        }

Same methods

RankConfigFile::Read ( string path ) : RankConfigFile

Usage Example

 private static void SetupConfig()
 {
     try
     {
         if (File.Exists(RankConfigPath))
         {
             RankConfig = RankConfigFile.Read(RankConfigPath);
             // Add all the missing config properties in the json file
         }
         RankConfig.Write(RankConfigPath);
     }
     catch (Exception ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Error in config file");
         Console.ForegroundColor = ConsoleColor.Gray;
         Log.Error("Config Exception");
         Log.Error(ex.ToString());
     }
 }
RankConfigFile