public FilterNode(IIOFactory factory) { // Create in and outputs based on properties of the filter instance var dummyInstance = new TFilterInstance(); var filterInstanceType = typeof(TFilterInstance); var properties = filterInstanceType.GetProperties(); var fields = filterInstanceType.GetFields(); var fieldsAndProperties = fields.Concat <MemberInfo>(properties); FInputMembers = fieldsAndProperties.Where(p => p.GetCustomAttributes(typeof(InputAttribute), true).Any()).ToList(); FOutputMembers = fieldsAndProperties.Where(p => p.GetCustomAttributes(typeof(OutputAttribute), true).Any()).ToList(); foreach (var member in FInputMembers) { var attribute = GetIOAttribute <InputAttribute>(dummyInstance, member); var memberType = GetMemberType(member); var spreadType = typeof(IDiffSpread <>).MakeGenericType(memberType); var spread = factory.CreateIO(spreadType, attribute) as IDiffSpread; FInputs.Add(spread); } foreach (var member in FOutputMembers) { var attribute = GetIOAttribute <OutputAttribute>(dummyInstance, member); var memberType = GetMemberType(member); var spreadType = typeof(ISpread <>).MakeGenericType(memberType); var spread = factory.CreateIO(spreadType, attribute) as ISpread; FOutputs.Add(spread); } }
public GroupOutStream(IIOFactory factory, OutputAttribute attribute) { FFactory = factory; FOutputAttribute = attribute; //increment instance Counter and store it as pin offset FOffsetCounter = FInstanceCounter++; FCountSpread = factory.CreateIO <IDiffSpread <int> >( new ConfigAttribute(FOutputAttribute.Name + " Count") { DefaultValue = 2, MinValue = 2 } ); FCountSpread.Changed += HandleCountSpreadChanged; FCountSpread.Sync(); }
public DiffSpreadList(IIOFactory ioFactory, IOAttribute attribute) : base(0) { //store fields FIOFactory = ioFactory; FAttribute = attribute; //create config pin var att = new ConfigAttribute(FAttribute.Name + " Count"); att.DefaultValue = 2; //increment instance Counter and store it as pin offset FOffsetCounter = FInstanceCounter++; FCountSpread = ioFactory.CreateIO <IDiffSpread <int> >(att); FCountSpread.Changed += UpdatePins; }
public SpreadList(IIOFactory factory, IOAttribute attribute) : base(new SpreadListStream()) { //store fields FFactory = factory; FAttribute = attribute; //increment instance Counter and store it as pin offset FOffsetCounter = FInstanceCounter++; //create config pin FCountSpread = factory.CreateIO <IDiffSpread <int> >( new ConfigAttribute(FAttribute.Name + " Count") { DefaultValue = 2, MinValue = 2 } ); FCountSpread.Changed += HandleCountSpreadChanged; FCountSpread.Sync(); }
protected void TestInputPin <T>(T[] sampleData) { var pinName = string.Format("{0} Input", typeof(T)); var attribute = new InputAttribute(pinName); ISpread <T> spread = FFactory.CreateIO <ISpread <T> >(attribute); spread.Sync(); Assert.AreEqual(1, spread.SliceCount, "Initial slice count must be 1 of input spread."); TestSpread(spread, sampleData); ISpread <ISpread <T> > spreadedSpread = FFactory.CreateIO <ISpread <ISpread <T> > >(attribute); spreadedSpread.Sync(); Assert.True(spreadedSpread.SliceCount == 1); TestSpread(spreadedSpread, new ISpread <T>[] { new Spread <T>(sampleData.ToList()), new Spread <T>(sampleData.ToList()) }); }
public static IDiffSpread <T> CreateDiffSpread <T>(this IIOFactory factory, IOAttribute attribute, bool subscribe = true) { return((IDiffSpread <T>)factory.CreateIO(typeof(IDiffSpread <T>), attribute, subscribe)); }
public static Pin <T> CreatePin <T>(this IIOFactory factory, IOAttribute attribute, bool subscribe = true) { return((Pin <T>)factory.CreateIO(typeof(Pin <T>), attribute, subscribe)); }
public static T CreateIO <T>(this IIOFactory factory, IOAttribute attribute, bool subscribe = true) { return((T)factory.CreateIO(typeof(T), attribute, subscribe)); }
public static object CreateIO(this IIOFactory factory, Type type, IOAttribute attribute, bool subscribe = true) { var context = IOBuildContext.Create(type, attribute, subscribe); return(factory.CreateIO(context)); }