示例#1
0
        private void PopulateCacheWithDataTypePreValues()
        {
            var c  = System.Web.HttpContext.Current.Cache;
            var ds = new Umbraco.Core.Services.DataTypeService();

            foreach (var dtd in ds.GetAllDataTypeDefinitions())
            {
                c.Insert(dtd.Name, PreValues.GetPreValues(dtd.Id));
            }
        }
示例#2
0
        /// <summary>
        /// Get all the prevalues for a given data type.
        /// </summary>
        /// <param name="dataTypeName">The name of the data type.</param>
        /// <returns>A sorted list with the prevalues.</returns>
        public SortedList GetPreValues(string dataTypeName)
        {
            // Get a sorted list of all prevalues from the cache
            var        c           = System.Web.HttpContext.Current.Cache;
            SortedList statusTypes = c.Get(dataTypeName) as SortedList;

            if (statusTypes == null)
            {
                // Connect to Umbraco DataTypeService
                var ds = new Umbraco.Core.Services.DataTypeService();

                // Get the Definition Id
                int dataTypeDefinitionId = ds.GetAllDataTypeDefinitions().First(x => x.Name == dataTypeName).Id;

                // Get a sorted list of all prevalues and store it in the cache
                statusTypes = PreValues.GetPreValues(dataTypeDefinitionId);
                c.Insert(dataTypeName, statusTypes);
            }

            return(statusTypes);
        }