예제 #1
0
		public static bool ReadFile( string Filename, out EathenaConfigFile Configs ) {
			EathenaConfig Config = new EathenaConfig();
			string line = string.Empty;
			string[] Lines;

			Configs = new EathenaConfigFile();
			Configs.Filename = Filename;

			if( File.Exists( Filename ) == false )
				return false;

			Lines = File.ReadAllLines( Filename );
			for( int i = 0; i < Lines.Length; i++ ) {
				line = Lines[ i ].Trim();
				if( line.IsComment() == true || line.Length < 2 )
					continue;

				if( ExtractSetting( line, out Config ) == false )
					continue;

				Config.Comments = FetchComments( Lines, i - 1 );
				Config.Line = i;
				Configs.Add( Config );
			}

			return true;

		}
예제 #2
0
파일: Tools.cs 프로젝트: CairoLee/svn-dump
        public static void FillGrid(ref DataGridViewX GridView, EathenaConfigFile File, bool PrintComments)
        {
            GridView.Rows.Clear();
            int n = 0;

            for (int i = 0; i < File.Configs.Count; i++)
            {
                if (PrintComments == true)
                {
                    for (int c = 0; c < File.Configs[i].Comments.Length; c++)
                    {
                        n = GridView.Rows.Add();
                        GridView.Rows[n].Tag                        = i;    // save the "real" index
                        GridView.Rows[n].Cells[0].Value             = "// " + File.Configs[i].Comments[c];
                        GridView.Rows[n].Cells[0].ReadOnly          = true;
                        GridView.Rows[n].DefaultCellStyle.ForeColor = Color.DarkGreen;
                    }
                }

                n = GridView.Rows.Add();
                GridView.Rows[n].Tag                        = i; // save the "real" index
                GridView.Rows[n].Cells[0].Value             = File.Configs[i].Name;
                GridView.Rows[n].Cells[1].Value             = File.Configs[i].Value;
                GridView.Rows[n].DefaultCellStyle.ForeColor = Color.DarkBlue;
                GridView.Rows[n].DefaultCellStyle.Font      = new Font("Tahoma", 8.0f, FontStyle.Bold);

                GridView.Rows[n].Cells[0].ReadOnly = true;
            }
        }
예제 #3
0
        public static EathenaConfigFileCollection Load(string Name)
        {
            EathenaConfigFileCollection files  = new EathenaConfigFileCollection();
            EathenaConfigFile           config = new EathenaConfigFile();

            if (Directory.Exists(Name) == false)
            {
                if (ConfParser.ReadFile(Name, out config) == true)
                {
                    files.Add(Name.GetPathParts("conf"), config);
                }
                return(files);
            }

            string[] Files = Directory.GetFiles(Name, "*.conf");
            for (int i = 0; i < Files.Length; i++)
            {
                if (ConfParser.ReadFile(Files[i], out config) == true)
                {
                    files.Add(Files[i].GetPathParts("conf"), config);
                }
            }

            string[] Dirs = Directory.GetDirectories(Name);
            for (int i = 0; i < Dirs.Length; i++)
            {
                files.AddRange(ConfParser.Load(Dirs[i]));
            }

            return(files);
        }
예제 #4
0
		public static EathenaConfigFileCollection Load( string Name ) {
			EathenaConfigFileCollection files = new EathenaConfigFileCollection();
			EathenaConfigFile config = new EathenaConfigFile();
			if( Directory.Exists( Name ) == false ) {
				if( ConfParser.ReadFile( Name, out config ) == true )
					files.Add( Name.GetPathParts( "conf" ), config );
				return files;
			}

			string[] Files = Directory.GetFiles( Name, "*.conf" );
			for( int i = 0; i < Files.Length; i++ )
				if( ConfParser.ReadFile( Files[ i ], out config ) == true )
					files.Add( Files[ i ].GetPathParts( "conf" ), config );

			string[] Dirs = Directory.GetDirectories( Name );
			for( int i = 0; i < Dirs.Length; i++ )
				files.AddRange( ConfParser.Load( Dirs[ i ] ) );

			return files;
		}
예제 #5
0
        public static bool ReadFile(string Filename, out EathenaConfigFile Configs)
        {
            EathenaConfig Config = new EathenaConfig();
            string        line   = string.Empty;

            string[] Lines;

            Configs          = new EathenaConfigFile();
            Configs.Filename = Filename;

            if (File.Exists(Filename) == false)
            {
                return(false);
            }

            Lines = File.ReadAllLines(Filename);
            for (int i = 0; i < Lines.Length; i++)
            {
                line = Lines[i].Trim();
                if (line.IsComment() == true || line.Length < 2)
                {
                    continue;
                }

                if (ExtractSetting(line, out Config) == false)
                {
                    continue;
                }

                Config.Comments = FetchComments(Lines, i - 1);
                Config.Line     = i;
                Configs.Add(Config);
            }

            return(true);
        }
예제 #6
0
 public void Add(string Key, EathenaConfigFile File)
 {
     mFiles.Add(Key, File);
 }
예제 #7
0
 public void Add(EathenaConfigFile File)
 {
     mFiles.Add(File);
 }
예제 #8
0
		public void Add( string Key, EathenaConfigFile File ) {
			mFiles.Add( Key, File );
		}
예제 #9
0
		public void Add( EathenaConfigFile File ) {
			mFiles.Add( File );
		}