Ejemplo n.º 1
0
        public T GetModel <T>(params object[] modelId) where T : class, ICacheableModel
        {
            CleanReferences();
            var identifier = GetIdentifier(typeof(T), modelId);

            if (referenceList.ContainsKey(identifier))
            {
                T model = referenceList[identifier].Target as T;
                return(model);
            }
            return(null);
        }
Ejemplo n.º 2
0
        // Generate a unique ID of normalized key names + key values
        private string GetUniqueIdFromCommand(CommandHandlerContext filterContext)
        {
            Contract.Requires(filterContext != null);
            Contract.Requires(filterContext.Configuration != null);
            Contract.Requires(filterContext.Command != null);

            IModelFlattener       flattener        = filterContext.Configuration.Services.GetModelFlattener();
            ModelMetadataProvider metadataProvider = filterContext.Configuration.Services.GetModelMetadataProvider();
            ModelDictionary       parameters       = flattener.Flatten(filterContext.Command, filterContext.Command.GetType(), metadataProvider, string.Empty);
            IEnumerable <string>  keys             = SplitVaryByParam(this.VaryByParams);

            keys = (keys ?? parameters.Keys).OrderBy(key => key, StringComparer.Ordinal);

            return(CreateUniqueId(keys.Concat(keys.Select(key => parameters.ContainsKey(key) ? parameters[key] : null))));
        }