コード例 #1
0
        public static void AddViewData(object model, IController controller, int depth = 0)
        {
            if (depth > 3)
            {
                return;
            }

            // Step 1. Get the model
            if (model == null)
            {
                return;
            }

            // Step 2. Get the model type
            Type modelType = model.GetType();

            // Step 3. Get the IAddView Attributes
            List <IAddViewData> addViewDataList = AttributeHelper.GetAddViewDataList(modelType);

            // Step 4. Call IAddViewData.Add
            foreach (IAddViewData addViewData in addViewDataList)
            {
                addViewData.Add(model, controller);
            }

            /////////////////////////////////////////////////////

            List <IExecuteValue> executeValueList = AttributeHelper.GetAttributeList <IExecuteValue>(modelType).FindAll(x => x.Global && !string.IsNullOrEmpty(x.Key));

            foreach (IExecuteValue item in executeValueList)
            {
                ((ControllerBase)controller).ViewData[item.Key] = item.Execute(null, model, controller);
            }
        }
コード例 #2
0
        public static bool UpdateCacheItem(object item, object message)
        {
            if (item == null)
            {
                return(false);
            }

            // Step 1. Get CacheAttributes
            List <CacheAttribute> cacheAttributeList = AttributeHelper.GetAttributeList <CacheAttribute>(item.GetType());

            // Step 2. Execute CacheAttributes
            bool result = false;

            foreach (CacheAttribute cacheAttribute in cacheAttributeList)
            {
                // Step 1. Get cache Key
                string cacheKey = cacheAttribute.GetCacheKey(item);

                // Step 2.
                result = result | cacheAttribute.UpdateItem(item);
            }

            return(result);
        }
コード例 #3
0
        public static bool AddCacheItem <T>(T item, object message) where T : class, IId
        {
            if (item == null)
            {
                return(false);
            }

            // Step 1. Get CacheAttributes
            List <CacheAttribute> cacheAttributeList = AttributeHelper.GetAttributeList <CacheAttribute>(item.GetType());

            // Step 2. Execute CacheAttributes
            bool result = false;

            foreach (CacheAttribute cacheAttribute in cacheAttributeList)
            {
                // Step 1. Get cache Key
                string cacheKey = cacheAttribute.GetCacheKey(item);

                // Step 2.
                result = result | cacheAttribute.AddItem <T>(item);
            }

            return(result);
        }