using System; using System.Collections.Generic; using System.Text; using System.Reflection; using Integrator.Framework.ServiceManagerModel; namespace Integrator.Framework.ServiceManagerModel { public enum StatusEnum { Ready, Started, Stopped, Pause, Done } public class Operation { private Parameter[] input = null; private Parameter output = null; private FastInvoker fastInvoker = null; private StatusEnum state = StatusEnum.Ready; private Operation() { } private Operation(FastInvoker fastInvoker) { this.fastInvoker = fastInvoker; } public static Operation CreateOperation(Object hostObject, String methodName) { if (hostObject == null) { throw new ArgumentNullException("Invalid Host Object"); } if (methodName == string.Empty) { throw new ArgumentNullException("Invalid Method Name"); } FastInvoker invoker = new FastInvoker(hostObject, methodName); return new Operation(invoker); } public void SetInput(Parameter param, int index) { if (index < 0 || index > input.Length - 1) { throw new IndexOutOfRangeException("Index out of range."); } this.input[index] = param; } public Parameter GetInput(int index) { if (index < 0 || index > input.Length - 1) { throw new IndexOutOfRangeException("Index out of range."); } return this.input[index]; } public Parameter [] Input { get { return this.input; } set { this.input = value; } } public Parameter Output { get { return this.output; } set { this.output = value; } } public void Run() { object returnObject = this.fastInvoker.Call(this.GetRawParameters()); if (this.output != null) { this.output.ActualData = returnObject; } } public StatusEnum State { get { return this.state; } set { this.state = value; } } public string Name { get { return this.fastInvoker.theMethodInfo.Name; } } private object[] GetRawParameters() { object[] rawParameters = new object[this.Input.Length]; for (int index = 0; index < this.Input.Length; index++) { rawParameters[index] = this.Input[index].ActualData; } return rawParameters; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)