Example #1
0
 /// <summary>
 /// Create a new generic response.
 /// </summary>
 /// <param name="Request">The request leading to this result.</param>
 public ResponseBase(TRequest request) : base()
 {
     Request = request;
     if (request != null)
     {
         Duration  = ResponseTimestamp - request.RequestTimestamp;
         MessageId = request.MessageId;
         Name      = request.GetType().Name.Replace("Request", "");
     }
 }
Example #2
0
        public static Boolean RegisterRequestType <TRequest, TReply>()
            where TRequest : INetRequest <TRequest, TReply>, new()
            where TReply : INetRequestReply <TRequest, TReply>, new()
        {
            var   inst = new TRequest();
            Type  type = inst.GetType();
            Int32 hash = GetNetworkCoreHash(type);

            if (netRequests.ContainsKey(hash))
            {
                Log.Error("Tried to register a request type with a duplicate hash");
                return(false);
            }
            else
            {
                netRequests[hash] = new RequestPerformer <TRequest, TReply>(inst, new TReply());
                return(true);
            }
        }
Example #3
0
        IMapper <TViewModel, TRequest, TResponse> IMapperFactory.CreateMapper <TViewModel, TRequest, TResponse>()
        {
            Type[] typeList = GetTypesInNamespace(Assembly.GetExecutingAssembly(), "WeatherApp.ServiceLayerInteractions.Mappers");
            for (int i = 0; i < typeList.Length; i++)
            {
                if (typeof(IMapper <TViewModel, TRequest, TResponse>).IsAssignableFrom(typeList[i]))
                {
                    return(CreateMapper <TViewModel, TRequest, TResponse>(typeList[i]));
                }
            }
            TRequest   req = Activator.CreateInstance <TRequest>();
            TResponse  res = Activator.CreateInstance <TResponse>();
            TViewModel vm  = Activator.CreateInstance <TViewModel>();

            throw new Exception("mapper not found by MapperFactory for request type: " + req.GetType());
        }