/// <summary> /// Initialize the pipeline /// </summary> public void Initialize() { Data = new Dictionary <string, object>(); Components.Sort((a, b) => a.ExecutionOrder.CompareTo(b.ExecutionOrder)); foreach (IPipelineComponent pc in Components) { pc.Init(this); } Triggers.Sort((a, b) => a.InitOrder.CompareTo(b.InitOrder)); foreach (IPipelineTrigger pt in Triggers) { pt.Init(this); } State = PipelineStates.Initialized; }
public void Execute() { DateTime start = DateTime.Now; // Basic Execution Pattern try { // Iterate through states and components and execute the appropriate components for (int stateNumeral = (int)State + 1; stateNumeral <= (int)PipelineStates.Processed; stateNumeral++) { foreach (IPipelineComponent pc in Components) switch (State) { case PipelineStates.Initialized: // Pipeline is initialized, so we want to load the MIF file if (pc.ComponentType == PipelineComponentType.Loader) { pc.Execute(); System.Diagnostics.Trace.WriteLine(string.Format("{0} files not loaded", InputFiles.Count), "warn"); } break; case PipelineStates.SourceLoaded: if (pc.ComponentType == PipelineComponentType.Compiler) pc.Execute(); break; case PipelineStates.Compiled: if (pc.ComponentType == PipelineComponentType.Renderer) pc.Execute(); break; } // Change state State = (PipelineStates)stateNumeral; // Clean long gcOptimization = System.GC.GetTotalMemory(false); System.GC.Collect(); System.Diagnostics.Trace.WriteLine(string.Format("Cleaned {0:##,###,###} bytes wasted memory", gcOptimization - System.GC.GetTotalMemory(true)), "debug"); } } catch (Exception e) { PipelineStates oldState = State; State = PipelineStates.Error; #if DEBUG System.Diagnostics.Trace.WriteLine(e.ToString(), "fatal"); #else System.Diagnostics.Trace.WriteLine(e.Message, "fatal"); #endif throw new PipelineExecutionException(this, oldState, this.Data, e); } finally { TimeSpan fts = DateTime.Now.Subtract(start); System.Diagnostics.Trace.Write(string.Format("Pipeline took {0} to finish execution", fts.ToString()), "information"); } }
/// <summary> /// Initialize the pipeline /// </summary> public void Initialize() { Data = new Dictionary<string, object>(); Components.Sort((a, b) => a.ExecutionOrder.CompareTo(b.ExecutionOrder)); foreach (IPipelineComponent pc in Components) pc.Init(this); Triggers.Sort((a, b) => a.InitOrder.CompareTo(b.InitOrder)); foreach (IPipelineTrigger pt in Triggers) pt.Init(this); State = PipelineStates.Initialized; }
public void Execute() { DateTime start = DateTime.Now; // Basic Execution Pattern try { // Iterate through states and components and execute the appropriate components for (int stateNumeral = (int)State + 1; stateNumeral <= (int)PipelineStates.Processed; stateNumeral++) { foreach (IPipelineComponent pc in Components) { switch (State) { case PipelineStates.Initialized: // Pipeline is initialized, so we want to load the MIF file if (pc.ComponentType == PipelineComponentType.Loader) { pc.Execute(); System.Diagnostics.Trace.WriteLine(string.Format("{0} files not loaded", InputFiles.Count), "warn"); } break; case PipelineStates.SourceLoaded: if (pc.ComponentType == PipelineComponentType.Compiler) { pc.Execute(); } break; case PipelineStates.Compiled: if (pc.ComponentType == PipelineComponentType.Renderer) { pc.Execute(); } break; } } // Change state State = (PipelineStates)stateNumeral; // Clean long gcOptimization = System.GC.GetTotalMemory(false); System.GC.Collect(); System.Diagnostics.Trace.WriteLine(string.Format("Cleaned {0:##,###,###} bytes wasted memory", gcOptimization - System.GC.GetTotalMemory(true)), "debug"); } } catch (Exception e) { PipelineStates oldState = State; State = PipelineStates.Error; #if DEBUG System.Diagnostics.Trace.WriteLine(e.ToString(), "fatal"); #else System.Diagnostics.Trace.WriteLine(e.Message, "fatal"); #endif throw new PipelineExecutionException(this, oldState, this.Data, e); } finally { TimeSpan fts = DateTime.Now.Subtract(start); System.Diagnostics.Trace.Write(string.Format("Pipeline took {0} to finish execution", fts.ToString()), "information"); } }