public bool CanCreate(PluginInterfaces.V2.IOBuildContext context) { if (context.DataType == null) { return(false); } if (context.DataType.IsGenericType && context.IOType.IsGenericType) { if ((context.DataType.GetGenericTypeDefinition() == typeof(DX11Resource <>) && context.IOType.GetGenericTypeDefinition() == typeof(IInStream <>) && context.Direction == PinDirection.Input) || (context.DataType.GetGenericTypeDefinition() == typeof(DX11Resource <>) && context.IOType.GetGenericTypeDefinition() == typeof(IOutStream <>) && context.Direction == PinDirection.Output)) { return(true); } } return(false); }
public PluginInterfaces.V2.IIOContainer CreateIOContainer(PluginInterfaces.V2.IIOFactory factory, PluginInterfaces.V2.IOBuildContext context) { if (context.Direction == PinDirection.Input) { var t = context.DataType; var attribute = context.IOAttribute; var container = factory.CreateIOContainer(context.ReplaceIOType(typeof(INodeIn))); Type restype = t.GetGenericArguments()[0]; Type fulltype = typeof(DX11Resource <>).MakeGenericType(restype); var stream = Activator.CreateInstance(typeof(DX11ResourceInputStream <,>).MakeGenericType(fulltype, restype), container.RawIOObject) as IInStream; IPluginIO io = container.GetPluginIO(); ResourceListener rl = new ResourceListener(io); this.pinconnections.Add(rl.pin, rl); return(IOContainer.Create(context, stream, container)); } if (context.Direction == PinDirection.Output) { var t = context.DataType; var attribute = context.IOAttribute; var container = factory.CreateIOContainer(context.ReplaceIOType(typeof(INodeOut))); Type restype = t.GetGenericArguments()[0]; Type fulltype = typeof(DX11Resource <>).MakeGenericType(restype); var stream = Activator.CreateInstance(typeof(DX11ResourceOutputStream <,>).MakeGenericType(fulltype, restype), container.RawIOObject, false) as IOutStream; return(IOContainer.Create(context, stream, container)); } return(null); }
public PluginInterfaces.V2.IIOContainer CreateIOContainer(PluginInterfaces.V2.IIOFactory factory, PluginInterfaces.V2.IOBuildContext context) { if (context.Direction == PinDirection.Input) { var t = context.DataType; var attribute = context.IOAttribute; var container = factory.CreateIOContainer(context.ReplaceIOType(typeof(INodeIn))); Type restype = t.GetGenericArguments()[0]; Type fulltype = typeof(DX11Resource <>).MakeGenericType(restype); var stream = Activator.CreateInstance(typeof(DX11ResourceInputStream <,>).MakeGenericType(fulltype, restype), container.RawIOObject) as IInStream; IPluginIO io = container.GetPluginIO(); ResourceListener rl = new ResourceListener(io, stream); this.pinconnections.Add(rl.Pin, rl); return(IOContainer.Create(context, stream, container)); } if (context.Direction == PinDirection.Output) { var t = context.DataType; var attribute = context.IOAttribute; var container = factory.CreateIOContainer(context.ReplaceIOType(typeof(INodeOut))); Type restype = t.GetGenericArguments()[0]; Type fulltype = typeof(DX11Resource <>).MakeGenericType(restype); //Check if resource type should only be a single output bool shouldBeSingle = restype.GetCustomAttributes(typeof(SingleOutputAttribute), true).Length > 0; var stream = Activator.CreateInstance(typeof(DX11ResourceOutputStream <,>).MakeGenericType(fulltype, restype), container.RawIOObject, shouldBeSingle) as IOutStream; return(IOContainer.Create(context, stream, container)); } return(null); }