ReadData() public method

Reads data in INI format from a stream.
/// Thrown if is null. ///
public ReadData ( StreamReader reader ) : IniData
reader System.IO.StreamReader Reader stream.
return Fusion.Core.IniParser.Model.IniData
Exemplo n.º 1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="bindings"></param>
		/// <param name="path"></param>
		public static void LoadFromStream	( IEnumerable<GameModule.ModuleBinding> bindings, Stream stream )
		{
			try {
		
				var iniData = new IniData();
				var parser = new StreamIniDataParser();

				parser.Parser.Configuration.CommentString	=	"# ";

				using ( var sw = new StreamReader(stream) ) {
					iniData	= parser.ReadData( sw );
				}
			

				//	read data :
				foreach ( var section in iniData.Sections ) {

					var bind	=	bindings
								.Where( b => b.NiceName == section.SectionName )
								.SingleOrDefault();

					if (bind==null) {
						Log.Warning("Module {0} does not exist. Section ignored.", section.SectionName );
					}

					bind.Module.SetConfiguration( section.Keys );
				}

			} catch (IniParser.Exceptions.ParsingException e) {
				Log.Warning("INI parser error: {0}", e.Message);
			}
		}
Exemplo n.º 2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="options"></param>
		public static void Build ( BuildOptions options )
		{
			Log.Message("");
			Log.Message("-------- Build started : {0} --------", options.InputDirectory );

			options.CheckOptionsAndMakeDirs();

			Log.Message("Reading '.content'...");
			//
			//	Parse INI file :
			//
			var ip = new StreamIniDataParser();
			ip.Parser.Configuration.AllowDuplicateSections	=	true;
			ip.Parser.Configuration.AllowDuplicateKeys		=	true;
			ip.Parser.Configuration.CommentString			=	"#";
			ip.Parser.Configuration.OverrideDuplicateKeys	=	true;
			ip.Parser.Configuration.KeyValueAssigmentChar	=	'=';
			ip.Parser.Configuration.AllowKeysWithoutValues	=	true;

			var iniData = ip.ReadData( new StreamReader( options.ContentIniFile ) );


			//
			//	Setup builder :
			//	
			var bindings = AssetProcessorBinding.GatherAssetProcessors();

			Log.Message("Asset processors:");
			foreach ( var bind in bindings ) {
				Log.Message("  {0,-20} - {1}", bind.Name, bind.Type.Name );
			}
			Log.Message("");

			var builder = new Builder( bindings );

			var result  = builder.Build( options, iniData );

			Log.Message("-------- {5} total, {0} succeeded, {1} failed, {2} up-to-date, {3} ignored, {4} skipped --------", 
				result.Succeded,
				result.Failed,
				result.UpToDate,
				result.Ignored,
				result.Skipped,
				result.Total );

			Log.Message("");

			if (result.Failed>0) {
				throw new BuildException("Build errors");
			}
		}