Esempio n. 1
0
        public static TopResponse GetTopResponse(this NameValueCollection parameters, Type type, ITopCache cache = null)
        {
            if (type == null)
            {
                throw new TopException(1, "method is null");
            }

            var req = Activator.CreateInstance(type);
            TopResponse rsp = null;

            if (req is IParamsValidate)
            {
                (req as IParamsValidate).Validate(parameters);
            }
            if (cache != null && req is ICacheRequest)
            {
                string key = (req as ICacheRequest).GetKey(parameters);
                rsp = cache.Read(key);
            }
            if (rsp == null && req is IParamsRequest)
            {
                rsp = (req as IParamsRequest).GetResponse(parameters);
            }

            return rsp;
        }
Esempio n. 2
0
        public static TopResponse GetTopResponse(this IParamsRequest req, NameValueCollection parameters, ITopCache cache = null)
        {
            TopResponse rsp = null;

            if (req is IParamsValidate)
            {
                (req as IParamsValidate).Validate(parameters);
            }
            if (cache != null && req is ICacheRequest)
            {
                string key = (req as ICacheRequest).GetKey(parameters);
                rsp = cache.Read(key);
            }
            if (rsp == null)
            {
                rsp = req.GetResponse(parameters);
            }

            return rsp;
        }