private void Add <THandler, TCommand>(string contextName) { var handlerType = typeof(THandler); var commandType = typeof(TCommand); var interfaces = handlerType.GetInterfaces(); foreach (var interfaceType in interfaces) { if (!interfaceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(IRequestHandler <,>))) { continue; } var handlerCommandType = interfaceType.GetGenericArguments()[0]; if (handlerCommandType != commandType) { continue; } var handlerResponseType = interfaceType.GetGenericArguments()[1]; _types[contextName] = new DestinationTypes(handlerCommandType, handlerResponseType); } }
public Destination(DestinationTypes destinationType, params object[] args) { Type = destinationType; GoalEntityId = Int64.MinValue; switch (destinationType) { case DestinationTypes.BookMark: BookMarkId = (Int64)args[0]; if (args.Length > 1) { WarpToDistance = (int)args[1]; } else { WarpToDistance = 0; } break; case DestinationTypes.FleetMember: break; case DestinationTypes.SolarSystem: SolarSystemId = (int)args[0]; break; case DestinationTypes.Entity: EntityId = (Int64)args[0]; if (args.Length > 1) { Distance = (double)args[1]; } if (args.Length > 2) { UseGate = (bool)args[2]; } break; } }