Ejemplo n.º 1
0
        /// <summary>
        /// Returns all the default properties that don't have any dependency from other default properties.
        /// The first time they are fetched from DB, the other ones from in-memory cache.
        /// </summary>
        /// <returns>an empty map if any error occurred; the default basic properties otherwise,
        /// where the keys are the properties names and the values are the actual possible values of that basic property</returns>
        public static IDictionary <string, List <string> > GetBasicProperties(this IPropertiesRepository repo)
        {
            if (s_basicProps == null)
            {
                //init default properties if needed:
                ICollection <DefaultProperty> defProperties = repo.GetDefaultProperties();

                s_basicProps = DefaultProperty.FilterBasicProperties(defProperties);
            }
            return(s_basicProps);
        }
Ejemplo n.º 2
0
        private static bool LoadDefaultProperties(this IPropertiesRepository repo)
        {
            //check whether the lists have been already retrieved
            if (s_osTypes != null)
            {
                return(true);
            }

            //get the list of default values:
            ICollection <DefaultProperty> defaultProps = repo.GetDefaultProperties();

            if (defaultProps == null)
            {
                log.ErrorFormat("Cannot retrieve default properties");
                return(false);
            }

            //fill all the list with the proper values:
            foreach (DefaultProperty defProp in defaultProps)
            {
                switch (defProp.Name)
                {
                case DefaultProperty.Architecture:
                    s_architectures = defProp.PossibleValues;
                    break;

                case DefaultProperty.Browser:
                    s_browsers = defProp.PossibleValues;
                    break;

                case DefaultProperty.OS:
                    s_osTypes = defProp.PossibleValues;
                    break;

                case DefaultProperty.WindowsVersion:
                    s_windowsVersions = defProp.PossibleValues;
                    break;

                case DefaultProperty.Language:
                    s_languages = defProp.PossibleValues;
                    break;
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////


        #region Get Methods
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Returns all the default properties that can be associated to a snippet.
        /// The first time they are fetched from DB, the other ones from in-memory cache.
        /// </summary>
        /// <returns>an empty map if any error occurred; the default properties otherwise,
        /// where the keys are the properties names and the values are the actual possible values of that property</returns>
        public static Dictionary <string, List <string> > GetDefaultPropertiesValues(this IPropertiesRepository repo)
        {
            if (repo == null)
            {
                return(new Dictionary <string, List <string> >());
            }
            if (s_defPropertyValues == null)
            {
                //init default properties if needed:
                ICollection <DefaultProperty> defProperties = repo.GetDefaultProperties();

                //fill all the list with the proper values:
                s_defPropertyValues = new Dictionary <string, List <string> >();
                foreach (DefaultProperty defProp in defProperties)
                {
                    s_defPropertyValues.Add(defProp.Name, defProp.PossibleValues);
                }
            }
            return(s_defPropertyValues);
        }