public static T NewTick <T>( DateTime dateTime, DateTime exchangeDateTime, byte providerId, int instrumentId, double price, double size) where T : Tick { FastConstructorHandler handler = null; if (typeof(T) == typeof(Tick)) { handler = TickConstructor; } if (typeof(T) == typeof(Ask)) { handler = AskConstructor; } if (typeof(T) == typeof(Bid)) { handler = BidConstructor; } if (typeof(T) == typeof(Trade)) { handler = TradeConstructor; } if (DoubleSize) { return((T)handler?.Invoke(dateTime, exchangeDateTime, providerId, instrumentId, price, size)); } return((T)handler?.Invoke(dateTime, exchangeDateTime, providerId, instrumentId, price, (int)size)); }
/// <summary> /// Initializes a new instance of the <see cref="ais.tool.ReflectionAccessor"/> class. /// </summary> /// <param name='constructorInfo'> /// Constructor info. only create method usable /// </param> public ReflectionAccessor(ConstructorInfo constructorInfo) { string name = constructorInfo.DeclaringType.FullName + ".ctor(" + constructorInfo.GetParameters().Length + ")"; if (cacheHandlers.Contains(name)) constructorHandler = (FastConstructorHandler)cacheHandlers[name]; else { constructorHandler = GetConstructorInvoker(constructorInfo); cacheHandlers[name] = constructorHandler; } }
public static object Inject(this FastConstructorHandler constructor, IServiceProvider provider, params Type[] ctrParamTypes) { return(constructor(ctrParamTypes.Select(t => provider.GetService(t)).ToArray())); }
public DIFastConstructor(FastConstructorHandler handler, params Type[] paramTypes) { _ctrHandler = handler; _ctrParamTypes = paramTypes; }