public IEnumerable<ProcessorArgument> GetBoundToArguments(ProcessorArgument argument) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); IEnumerable<ProcessorArgument> arguments = this.GetBindingsForArgumentOrNull(argument); return arguments ?? Processor.EmptyProcessorArgumentArray; }
internal BindArgumentsEventArgs(ProcessorArgument outArgument, ProcessorArgument inArgument) { Debug.Assert(outArgument != null, "The 'outArgument' parameter should not be null."); Debug.Assert(inArgument != null, "The 'inArgument' parameter should not be null."); this.OutArgument = outArgument; this.InArgument = inArgument; }
public IEnumerable <ProcessorArgument> GetBoundToArguments(ProcessorArgument argument) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); IEnumerable <ProcessorArgument> arguments = this.GetBindingsForArgumentOrNull(argument); return(arguments ?? Processor.EmptyProcessorArgumentArray); }
private void OnBindingArguments(ProcessorArgument outArgument, ProcessorArgument inArgument) { EventHandler handler = this.BindingArguments; if (handler != null) { handler(this, new BindArgumentsEventArgs(outArgument, inArgument)); } }
private static void RemoveArgumentFromBinding(ProcessorArgument argument, List <ProcessorArgument> argumentBindings) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); if (argumentBindings != null && argumentBindings.Contains(argument)) { argumentBindings.Remove(argument); } }
public void ContainingCollection_Should_Be_Non_Null_After_Adding_To_A_ProcessorArgumentCollection() { ProcessorArgument arg = new ProcessorArgument("AName", typeof(int)); MockNonGenericProcessor processor = new MockNonGenericProcessor(); processor.SetInputArguments(arg); ProcessorArgumentCollection collection = processor.InArguments; Assert.AreSame(collection, arg.ContainingCollection, "ProcessorArgument.ContainingColelction should be non-null after being added to the ProcessorArgumentCollection."); }
protected override void OnBindArguments(ProcessorArgument outArgument, ProcessorArgument inArgument) { if (this.OnBindArgumentsCalled != null) { this.OnBindArgumentsCalled(outArgument, inArgument); } base.OnBindArguments(outArgument, inArgument); }
/// <summary> /// Retrieves information about the output values for the given processor. /// </summary> /// <param name="processorIndex">The 0-based index of the processor in this context.</param> /// <param name="outArgumentIndex">The 0-based index of the output argument for this processor.</param> /// <param name="outArgument">Out parameter to receive the <see cref="ProcessorArgument"/> for this output argument.</param> /// <param name="inArguments">Out parameter to receive the collection of input value <see cref="ProcessorArgument"/>s.</param> /// <returns>An array of offsets in the input value pool for each of the input values.</returns> public int[] GetOutputValueInfo(int processorIndex, int outArgumentIndex, out ProcessorArgument outArgument, out ProcessorArgument[] inArguments) { Debug.Assert(processorIndex >= 0 && processorIndex < this.ProcessorValueInfos.Length, "processorIndex out of bounds"); OutputValueInfo info = this.ProcessorValueInfos[processorIndex].OutputValueInfos[outArgumentIndex]; outArgument = info.OutArgument; inArguments = info.InArguments; return info.InputValueIndices; }
private static void RemoveArgumentFromBinding(ProcessorArgument argument, List<ProcessorArgument> argumentBindings) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); if (argumentBindings != null && argumentBindings.Contains(argument)) { argumentBindings.Remove(argument); } }
/// <summary> /// Returns the collection of <see cref="ProcessorArgument"/> instances bound to <paramref name="argument"/>. /// </summary> /// <remarks> /// This method can be used for both input and output arguments. /// </remarks> /// <param name="argument">The <see cref="ProcessorArgument"/> whose bindings are required.</param> /// <returns>The collection of <see cref="ProcessorArgument"/>s bound to <paramref name="argument"/></returns> public IEnumerable <ProcessorArgument> GetBoundToArguments(ProcessorArgument argument) { if (argument == null) { throw new ArgumentNullException("argument"); } return(this.bindings.GetBoundToArguments(argument)); }
private static void AddArgumentToBinding(ProcessorArgument argument, List <ProcessorArgument> argumentBindings) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); Debug.Assert(argumentBindings != null, "The 'argumentBindings' parameter should not be null."); if (!argumentBindings.Contains(argument)) { argumentBindings.Add(argument); } }
private static void AddArgumentToBinding(ProcessorArgument argument, List<ProcessorArgument> argumentBindings) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); Debug.Assert(argumentBindings != null, "The 'argumentBindings' parameter should not be null."); if (!argumentBindings.Contains(argument)) { argumentBindings.Add(argument); } }
public void Index_Returns_Null_For_Non_Existing_Arguments() { ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string)); ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int)); MockNonGenericProcessor processor1 = new MockNonGenericProcessor(); processor1.SetInputArguments(arg1, arg2); ProcessorArgument processor1Arg = processor1.InArguments["SomeOtherName"]; Assert.IsNull(processor1Arg, "ProcessorArgumentCollection.Index should have returned null because there is no argument with that name."); }
public void Index_Is_Case_Sensitive() { ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string)); ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int)); MockNonGenericProcessor processor1 = new MockNonGenericProcessor(); processor1.SetInputArguments(arg1, arg2); ProcessorArgument processor1Arg = processor1.InArguments["Aname"]; Assert.IsNull(processor1Arg, "ProcessorArgumentCollection.Index should have returned null because the names differed by case."); }
/// <summary> /// Retrieves information about the output values for the given processor. /// </summary> /// <param name="processorIndex">The 0-based index of the processor in this context.</param> /// <param name="outArgumentIndex">The 0-based index of the output argument for this processor.</param> /// <param name="outArgument">Out parameter to receive the <see cref="ProcessorArgument"/> for this output argument.</param> /// <param name="inArguments">Out parameter to receive the collection of input value <see cref="ProcessorArgument"/>s.</param> /// <returns>An array of offsets in the input value pool for each of the input values.</returns> public int[] GetOutputValueInfo(int processorIndex, int outArgumentIndex, out ProcessorArgument outArgument, out ProcessorArgument[] inArguments) { Debug.Assert(processorIndex >= 0 && processorIndex < this.ProcessorValueInfos.Length, "processorIndex out of bounds"); OutputValueInfo info = this.ProcessorValueInfos[processorIndex].OutputValueInfos[outArgumentIndex]; outArgument = info.OutArgument; inArguments = info.InArguments; return(info.InputValueIndices); }
private int SlotOffSetOfInArgument(ProcessorArgument inArgument) { int processorIndex = this.Pipeline.Processors.IndexOf(inArgument.ContainingCollection.Processor); Debug.Assert(processorIndex >= 0, "Processor does not belong to the current pipeline"); Debug.Assert(inArgument != null, "inArgument cannot be null"); Debug.Assert(inArgument.Index.HasValue, "inArgument must have valid index"); return(this.ProcessorValueInfos[processorIndex].InputValueOffset + inArgument.Index.Value); }
public void Index_Returns_Argument() { ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string)); ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int)); MockNonGenericProcessor processor1 = new MockNonGenericProcessor(); processor1.SetInputArguments(arg1, arg2); ProcessorArgument processor1Arg = processor1.InArguments["AName"]; Assert.AreSame(arg1, processor1Arg, "ProcessorArgumentCollection.Index should have returned the same instance."); }
private int InputValueOffset(ProcessorArgument inArgument) { Debug.Assert(inArgument != null, "inArgument cannot be null"); Debug.Assert(inArgument.Index.HasValue, "inArgument must have an index value"); int processorIndex = this.IndexOfProcessor(inArgument.ContainingCollection.Processor); int inputValueOffset; this.ContextInfo.GetInputValueInfo(processorIndex, out inputValueOffset); return(inputValueOffset + inArgument.Index.Value); }
/// <summary> /// Binds the given input <paramref name="argument"/> to the given <see cref="Pipeline"/> input argument. /// </summary> /// <remarks> /// This binding means the <see cref="Processor"/> containing <paramref name="argument"/> will receive /// the corresponding input value directly from the <see cref="Pipeline"/> instance when execution begins. /// </remarks> /// <param name="pipelineInputArgumentIndex">The relative zero-based index of the <see cref="Pipeline"/>'s /// input <see cref="ProcessorArgument"/>. That index must match the order of the <see cref="Pipeline"/>'s /// <see cref="InArguments"/> collection.</param> /// <param name="argument">The input <see cref="ProcessorArgument"/> to bind to that <see cref="Pipeline"/> argument.</param> public void BindArgumentToPipelineInput(int pipelineInputArgumentIndex, ProcessorArgument argument) { ProcessorArgumentCollection pipelineInputs = this.Processors[0].OutArguments; if (pipelineInputArgumentIndex < 0 || pipelineInputArgumentIndex >= pipelineInputs.Count) { throw new ArgumentOutOfRangeException("pipelineInputArgumentIndex"); } this.BindArguments(pipelineInputs[pipelineInputArgumentIndex], argument); }
/// <summary> /// Binds the given output <paramref name="argument"/> to the given <see cref="Pipeline"/> output argument. /// </summary> /// <remarks> /// This binding means the <see cref="Processor"/> containing <paramref name="argument"/> will provide /// the corresponding output value directly to the <see cref="Pipeline"/> instance's output values /// when execution begins. /// </remarks> /// <param name="argument">The <see cref="ProcessorArgument"/> to bind to the <see cref="Pipeline"/> argument.</param> /// <param name="pipelineOutputArgumentIndex">The relative zero-based index of the respective output argument /// in the <see cref="Pipeline"/>'s <see cref="OutArgument"/> collection.</param> public void BindArgumentToPipelineOutput(ProcessorArgument argument, int pipelineOutputArgumentIndex) { ProcessorArgumentCollection pipelineInputs = this.Processors[this.Processors.Count - 1].InArguments; if (pipelineOutputArgumentIndex < 0 || pipelineOutputArgumentIndex >= pipelineInputs.Count) { throw new ArgumentOutOfRangeException("pipelineOutputArgumentIndex"); } this.BindArguments(argument, pipelineInputs[pipelineOutputArgumentIndex]); }
public void Copy_Honors_Cloneable_Properties() { Uri uri = new Uri("http://localhost"); MockCloneableProperty cloneable = new MockCloneableProperty { Id = 5, Name = "SomeName" }; ProcessorArgument arg = new ProcessorArgument("AName", typeof(string), uri, cloneable); ProcessorArgument argCopy = arg.Copy(); Assert.AreEqual(2, argCopy.Properties.Count, "The copied ProcessorArgument should have the same properties as the original ProcessorArgument."); Assert.AreSame(uri, argCopy.Properties.Find<Uri>(), "The copied ProcessorArgument should have the same property instance as the original ProcessorArgument."); Assert.AreNotSame(cloneable, argCopy.Properties.Find<MockCloneableProperty>(), "The copied ProcessorArgument should have a new property instance."); }
public void UnbindArguments(ProcessorArgument outArgument, ProcessorArgument inArgument) { Debug.Assert(outArgument != null, "The 'outArgument' parameter should not be null."); Debug.Assert(inArgument != null, "The 'inArgument' parameter should not be null."); this.ValidateBinding(outArgument, inArgument); List<ProcessorArgument> outArgumentBindings = this.GetBindingsForArgumentOrNull(outArgument); RemoveArgumentFromBinding(inArgument, outArgumentBindings); List<ProcessorArgument> inArgumentBindings = this.GetBindingsForArgumentOrNull(inArgument); RemoveArgumentFromBinding(outArgument, inArgumentBindings); }
private List <ProcessorArgument> GetBindingsForArgumentOrNull(ProcessorArgument argument) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); List <ProcessorArgument> argumentBindings; if (!this.bindings.TryGetValue(argument, out argumentBindings)) { return(null); } return(argumentBindings); }
private void EnsureValidInArgument(ProcessorArgument inArgument) { if (inArgument == null) { throw new ArgumentNullException("inArgument"); } if (!inArgument.Index.HasValue || this.Pipeline.Processors.IndexOf(inArgument.ContainingCollection.Processor) < 0) { throw new ArgumentException(SR.ArgumentDoesNotBelongToProcessorInCurrentPipeline, "inArgument"); } }
public void ProcessorArgumentCollection_Cannot_Be_Created_With_The_Same_Argument_Twice() { ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string)); MockNonGenericProcessor processor1 = new MockNonGenericProcessor(); processor1.SetInputArguments(arg1, arg1); ExceptionAssert.ThrowsInvalidOperation( "Creating the argument collection with the same argument used twice should throw", () => { ProcessorArgumentCollection processor1InArguments = processor1.InArguments; }); }
private List <ProcessorArgument> GetBindingsForArgument(ProcessorArgument argument) { Debug.Assert(argument != null, "The 'argument' parameter should not be null."); List <ProcessorArgument> argumentBindings = this.GetBindingsForArgumentOrNull(argument); if (argumentBindings == null) { argumentBindings = new List <ProcessorArgument>(); this.bindings.Add(argument, argumentBindings); } return(argumentBindings); }
public void UnbindArguments(ProcessorArgument outArgument, ProcessorArgument inArgument) { Debug.Assert(outArgument != null, "The 'outArgument' parameter should not be null."); Debug.Assert(inArgument != null, "The 'inArgument' parameter should not be null."); this.ValidateBinding(outArgument, inArgument); List <ProcessorArgument> outArgumentBindings = this.GetBindingsForArgumentOrNull(outArgument); RemoveArgumentFromBinding(inArgument, outArgumentBindings); List <ProcessorArgument> inArgumentBindings = this.GetBindingsForArgumentOrNull(inArgument); RemoveArgumentFromBinding(outArgument, inArgumentBindings); }
public void Copy_Creates_New_ProcessorArgument_Not_Attached_To_Any_Collection() { ProcessorArgument arg = new ProcessorArgument("AName", typeof(string)); MockNonGenericProcessor processor1 = new MockNonGenericProcessor(); processor1.SetInputArguments(arg); ProcessorArgumentCollection processor1InArguments = processor1.InArguments; ProcessorArgument argCopy = arg.Copy(); Assert.IsNotNull(argCopy, "ProcessorArgument.Copy should not have returned null."); Assert.AreNotSame(arg, argCopy, "ProcessorArgument.Copy should have returned a new instance of ProcessorArgument."); Assert.IsNotNull(arg.ContainingCollection, "The original ProcessorArgument should have had a containing collection."); Assert.IsNull(argCopy.ContainingCollection, "The copied ProcessorArgument should not belong to any containing collection."); Assert.IsNotNull(arg.Index, "The original processor argument should have an index since it belongs to a collection."); Assert.IsNull(argCopy.Index, "The copied processor argument should not have an index since it does not belong to any containing collection."); }
public void Copy_Creates_New_ProcessorArgument_With_Same_Name_Type_And_Properties() { ProcessorArgument arg = new ProcessorArgument("AName", typeof(string), 5); ProcessorArgument argCopy = arg.Copy(); Assert.IsNotNull(argCopy, "ProcessorArgument.Copy should not have returned null."); Assert.AreNotSame(arg, argCopy, "ProcessorArgument.Copy should have returned a new instance of ProcessorArgument."); Assert.AreEqual("AName", argCopy.Name, "The copied ProcessorArgument should have the same name as the original ProcessorArgument."); Assert.AreEqual("AName", arg.Name, "The original ProcessorArgument's name should not have changed."); Assert.AreEqual(typeof(string), argCopy.ArgumentType, "The copied ProcessorArgument should have the same type as the original ProcessorArgument."); Assert.AreEqual(typeof(string), arg.ArgumentType, "The original ProcessorArgument's type should not have changed."); Assert.AreEqual(1, argCopy.Properties.Count, "The copied ProcessorArgument should have the same properties as the original ProcessorArgument."); Assert.AreEqual(5, argCopy.Properties.Find<int>(), "The copied ProcessorArgument should have the same properties as the original ProcessorArgument."); Assert.AreEqual(1, arg.Properties.Count, "The original ProcessorArgument's properties should not have changed."); Assert.AreEqual(5, arg.Properties.Find<int>(), "The original ProcessorArgument's properties should have changed."); }
/// <summary> /// Removes the binding between <paramref name="outArgument"/> and <paramref name="inArgument"/>. /// </summary> /// <param name="outArgument">The output <see cref="ProcessorArgument"/>.</param> /// <param name="inArgument">The input <see cref="ProcessorArgument"/></param> public void UnbindArguments(ProcessorArgument outArgument, ProcessorArgument inArgument) { if (outArgument == null) { throw new ArgumentNullException("outArgument"); } if (inArgument == null) { throw new ArgumentNullException("inArgument"); } if (this.IsInitialized) { throw new InvalidOperationException(SR.ArgumentsCannotBeUnboundAfterInitialization); } this.bindings.UnbindArguments(outArgument, inArgument); }
internal IEnumerable <ProcessorArgument> BuildInputArgumentCollection() { MethodInfo localExecuteMethod = this.ExecuteMethod; if (localExecuteMethod == null) { return(Enumerable.Empty <ProcessorArgument>()); } ParameterInfo[] parameterInfos = localExecuteMethod.GetParameters(); ProcessorArgument[] arguments = new ProcessorArgument[parameterInfos.Length]; for (int i = 0; i < parameterInfos.Length; ++i) { ParameterInfo parameter = parameterInfos[i]; ProcessorArgument pad = new ProcessorArgument(parameter.Name, parameter.ParameterType); arguments[i] = pad; } return(arguments); }
private OutputValueInfo[] CreateOutputValueInfos(Processor processor) { int numberOfOutArgs = processor.OutArguments.Count; OutputValueInfo[] result = new OutputValueInfo[numberOfOutArgs]; for (int outArgIndex = 0; outArgIndex < numberOfOutArgs; ++outArgIndex) { ProcessorArgument outArg = processor.OutArguments[outArgIndex]; ProcessorArgument[] inArgs = this.Pipeline.GetBoundToArguments(processor.OutArguments[outArgIndex]).ToArray(); int[] inputValueIndices = new int[inArgs.Length]; for (int inArgIndex = 0; inArgIndex < inArgs.Length; ++inArgIndex) { int slotOffset = this.SlotOffSetOfInArgument(inArgs[inArgIndex]); inputValueIndices[inArgIndex] = slotOffset; } result[outArgIndex] = new OutputValueInfo(outArg, inputValueIndices, inArgs); } return(result); }
/// <summary> /// Binds the given output <paramref name="argument"/> to the given <see cref="Pipeline"/> output argument. /// </summary> /// <remarks> /// This binding means the <see cref="Processor"/> containing <paramref name="argument"/> will provide /// the corresponding output value directly to the <see cref="Pipeline"/> instance's output values /// when execution begins. /// </remarks> /// <param name="argument">The <see cref="ProcessorArgument"/> to bind to the <see cref="Pipeline"/> argument.</param> /// <param name="pipelineOutputArgumentName">The <see cref="ProcessorArgument.Name"/> of the <see cref="Pipeline"/> argument.</param> public void BindArgumentToPipelineOutput(ProcessorArgument argument, string pipelineOutputArgumentName) { if (string.IsNullOrWhiteSpace(pipelineOutputArgumentName)) { throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, SR.ParameterCannotBeNullEmptyStringOrWhitespace, "pipelineOutputArgumentName"), "pipelineOutputArgumentName"); } ProcessorArgument pipelineOutput = this.Processors[this.Processors.Count - 1].InArguments[pipelineOutputArgumentName]; if (pipelineOutput == null) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.PipelineDoesNotHaveGivenOutputArgument, pipelineOutputArgumentName)); } this.BindArguments(argument, pipelineOutput); }
private void EnsureValidName(string argumentName) { Debug.Assert(argumentName != null, "The 'name' parameter should not be null."); if (string.IsNullOrWhiteSpace(argumentName)) { throw new InvalidOperationException( SR.ProcessorArgumentNameCannotBeEmptyStringOrWhitespace); } if (this.ContainingCollection != null) { ProcessorArgument argument = this.ContainingCollection[argumentName]; if (argument != null && argument != this) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ProcessorArgumentWithSameName, argumentName, argument.Index)); } } }
private void ValidateBinding(ProcessorArgument outArgument, ProcessorArgument inArgument) { Debug.Assert(outArgument != null, "The 'outArgument' parameter should not be null."); Debug.Assert(inArgument != null, "The 'inArgument' parameter should not be null."); if (inArgument.ContainingCollection == null) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceNotInProcessorArgumentCollection, inArgument.Name, inArgument.ArgumentType.FullName)); } if (outArgument.ContainingCollection == null) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceNotInProcessorArgumentCollection, outArgument.Name, outArgument.ArgumentType.FullName)); } if (outArgument.ContainingCollection.Direction != ProcessorArgumentDirection.Out) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceNotOutputArgument, outArgument.Name, outArgument.ArgumentType.FullName)); } if (inArgument.ContainingCollection.Direction != ProcessorArgumentDirection.In) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceNotInputArgument, inArgument.Name, inArgument.ArgumentType.FullName)); } if (!inArgument.ArgumentType.IsAssignableFrom(outArgument.ArgumentType)) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceNotAssignable, outArgument.Name, outArgument.ArgumentType.FullName, inArgument.Name, inArgument.ArgumentType.FullName)); } Processor inProcessor = inArgument.ContainingCollection.Processor; Processor outProcessor = outArgument.ContainingCollection.Processor; if (inProcessor == outProcessor) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceBelongToSameProcessor, outArgument.Name, outArgument.ArgumentType.FullName, inArgument.Name, inArgument.ArgumentType.FullName)); } int outProcessorIndex = -1; int inProcessorIndex = -1; for (int i = 0; i < this.processors.Count; i++) { if (this.processors[i] == outProcessor) { outProcessorIndex = i; } else if (this.processors[i] == inProcessor) { inProcessorIndex = i; } if (inProcessorIndex > -1 && outProcessorIndex > -1) { break; } } if (outProcessorIndex == -1) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceProcessorNotInPipeline, outArgument.Name, outArgument.ArgumentType.FullName)); } if (inProcessorIndex == -1) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceProcessorNotInPipeline, inArgument.Name, inArgument.ArgumentType.FullName)); } if (outProcessorIndex >= inProcessorIndex) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, SR.ArgumentBindingInvalidSinceProcessorOrderIsWrong, outArgument.Name, outArgument.ArgumentType.FullName, inArgument.Name, inArgument.ArgumentType.FullName)); } }
public void ProcessorArgumentCollection_Cannot_Have_Two_Arguments_With_The_Same_Name() { ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string)); ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int)); MockNonGenericProcessor processor1 = new MockNonGenericProcessor(); processor1.SetInputArguments(arg1, arg2); ProcessorArgumentCollection processor1InArguments = processor1.InArguments; ExceptionAssert.ThrowsInvalidOperation( "Setting the argument name to something already in the argument collection should throw", () => { arg2.Name = "AName"; }); }
/// <summary> /// Writes the given data value into memory for the specified input <see cref="ProcessorArgument"/>. /// </summary> /// <remarks> /// This value can be retrieved by using <see cref="ReadInput"/>. /// </remarks> /// <param name="inArgument">The input <see cref="ProcessorArgument"/> whose value is being written.</param> /// <param name="value">The value to write. It may be <c>null</c>.</param> public void WriteInput(ProcessorArgument inArgument, object value) { this.EnsureValidInArgument(inArgument); this.OnWriteInput(/*outArgument*/ null, inArgument, value); }
public void Properties_Should_Never_Be_Null() { ProcessorArgument arg = new ProcessorArgument("AName", typeof(int)); Assert.IsNotNull(arg.Properties, "ProcessorArgument.Properties should never be null."); }
public void ProcessorArgumentCollection_With_A_Null_ProcessorArgument_Throws() { MockNonGenericProcessor processor = new MockNonGenericProcessor(); ProcessorArgument arg1 = new ProcessorArgument("arg1", typeof(string), "someProperty"); ProcessorArgument arg2 = null; ProcessorArgument arg3 = new ProcessorArgument("arg3", typeof(int)); processor.SetInputArguments(arg1, arg2, arg3); ExceptionAssert.ThrowsArgumentNull( "ProcessorArgumentCollection should have thrown since a null ProcessorArgument was provided.", string.Empty, () => { ProcessorArgumentCollection arguments = processor.InArguments; }); }
/// <summary> /// Virtual method called when <see cref="BindArguments"/> has been called to bind two <see cref="ProcessorArguments"/>. /// </summary> /// <param name="outArgument">The output <see cref="ProcessorArgument"/>.</param> /// <param name="inArgument">The input <see cref="ProcessorArgument"/>.</param> protected virtual void OnBindArguments(ProcessorArgument outArgument, ProcessorArgument inArgument) { }
public void ContainingCollection_Should_Be_Null_After_Construction() { ProcessorArgument arg = new ProcessorArgument("AName", typeof(int)); Assert.IsNull(arg.ContainingCollection, "ProcessorArgument.ContainingCollection should be null after construction."); }
/// <summary> /// Returns the collection of <see cref="ProcessorArgument"/> instances bound to <paramref name="argument"/>. /// </summary> /// <remarks> /// This method can be used for both input and output arguments. /// </remarks> /// <param name="argument">The <see cref="ProcessorArgument"/> whose bindings are required.</param> /// <returns>The collection of <see cref="ProcessorArgument"/>s bound to <paramref name="argument"/></returns> public IEnumerable<ProcessorArgument> GetBoundToArguments(ProcessorArgument argument) { if (argument == null) { throw new ArgumentNullException("argument"); } return this.bindings.GetBoundToArguments(argument); }
/// <summary> /// Virtual method called when a value is written for the given input <see cref="ProcessorArgument"/>. /// </summary> /// <remarks> /// The base class implementation writes this value into an internal memory structure. Subclasses /// overriding this method may use alternate storage, alter the value, etc. Subclasses that wish /// to share the base implementation for storage must call the base method to write the value. /// </remarks> /// <param name="outArgument">The output <see cref="ProcessorArgument"/> whose value is being written. /// This argument will be <c>null</c> in situations where that output <see cref="ProcessorArgument"/> /// is not available.</param> /// <param name="inArgument">The input <see cref="ProcessorArgument"/> to which the value belongs.</param> /// <param name="value">The value to write. It may be <c>null</c>.</param> protected virtual void OnWriteInput(ProcessorArgument outArgument, ProcessorArgument inArgument, object value) { int inputValueOffset = this.InputValueOffset(inArgument); this.InputValues[inputValueOffset] = value; }
internal IEnumerable <ProcessorArgument> BuildOutputArgumentCollection() { ProcessorArgument arg = new ProcessorArgument(this.processorType.Name + "Result", this.OutputArgumentType); return(new ProcessorArgument[] { arg }); }
public object ReadInput(ProcessorArgument inArgument) { this.EnsureValidInArgument(inArgument); object[] value = this.OnReadAllInputs(inArgument.ContainingCollection.Processor); return(value[inArgument.Index.Value]); }
public OutputValueInfo(ProcessorArgument outArgument, int[] inputValueIndices, ProcessorArgument[] inArguments) { this.OutArgument = outArgument; this.InputValueIndices = inputValueIndices; this.InArguments = inArguments; }
public void ProcessorArgument_Type_Can_Be_Generic() { ProcessorArgument arg = new ProcessorArgument("AName", typeof(List<int>)); Assert.AreEqual(typeof(List<int>), arg.ArgumentType, "ProcessorArgument.Type should be a generic list of integers."); }
public void GetBoundToArguments_Never_Returns_Null() { MockNonGenericProcessor p1 = new MockNonGenericProcessor(); p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string))); ProcessorArgument arg2 = new ProcessorArgument("arg1", typeof(string)); ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1); PipelineBindingCollection bindings = new PipelineBindingCollection(collection); IEnumerable<ProcessorArgument> boundArguments = bindings.GetBoundToArguments(p1.OutArguments[0]); Assert.IsNotNull(boundArguments, "ProcessorBindingCollection.GetBoundArguments should never return null."); Assert.AreEqual(0, boundArguments.Count(), "ProcessorBindingCollection.GetBoundArguments should have returned an empty collection."); boundArguments = bindings.GetBoundToArguments(arg2); Assert.IsNotNull(boundArguments, "ProcessorBindingCollection.GetBoundArguments should never return null."); Assert.AreEqual(0, boundArguments.Count(), "ProcessorBindingCollection.GetBoundArguments should have returned an empty collection."); }
public void ProcessorArgumentCollection_Can_Have_Two_Arguments_With_The_Same_Name_Different_Case() { ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string)); ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int)); MockNonGenericProcessor processor1 = new MockNonGenericProcessor(); processor1.SetInputArguments(arg1, arg2); ProcessorArgumentCollection processor1InArguments = processor1.InArguments; arg2.Name = "aname"; }
private void OnBoundArguments(ProcessorArgument outArgument, ProcessorArgument inArgument) { EventHandler handler = this.BoundArguments; if (handler != null) { handler(this, new BindArgumentsEventArgs(outArgument, inArgument)); } }
public void Index_Should_Be_Non_Null_After_Adding_To_A_ProcessorArgumentCollection() { ProcessorArgument arg = new ProcessorArgument("AName", typeof(int)); MockNonGenericProcessor processor = new MockNonGenericProcessor(); processor.SetInputArguments(arg); ProcessorArgumentCollection collection = processor.InArguments; Assert.AreEqual(0, arg.Index, "ProcessorArgument.Index should be 0 after being added to the ProcessorArgumentCollection."); }