示例#1
0
        internal static bool MatchesCSSType(Type clientType, string cssType)
        {
            //StyleManager styleManager = StyleManager.Instance;
            //bool qualified = styleManager.QualifiedTypeSelectors;
            OrderedObject <bool> typeHierarchy = TypeHierarchyHelper.GetTypeHierarchy(clientType);

            return(typeHierarchy.KeyExists(cssType));
        }
示例#2
0
        public static Type TYPE_TO_MONITOR;         // = typeof(ImageButtonSkin);

// ReSharper restore MemberCanBePrivate.Global
// ReSharper restore FieldCanBeMadeReadOnly.Global
// ReSharper restore UnassignedField.Global
// ReSharper restore InconsistentNaming
// ReSharper restore UnusedMember.Global
#endif

        /**
         *
         *  Implements the getClassStyleDeclarations() logic
         *  for Component and TextBase.
         *  The 'object' parameter will be one or the other.
         */
        internal static List <StyleDeclaration> GetClassStyleDeclarations(IStyleClient client)
        {
            /*if (client.GetType().FullName == "Assets.eDriven.Skins.ImageButtonSkin")
             *      Debug.Log("GetMatchingStyleDeclarations for: " + client);*/

            StyleManager styleManager = StyleManager.Instance;
            //bool qualified = true;
            string className = client.GetType().FullName;
            //IStyleClient advancedObject = client as IStyleClient;
            OrderedObject <bool> typeHierarchy = TypeHierarchyHelper.GetTypeHierarchy(client.GetType());            //, qualified);
            List <string>        types         = typeHierarchy.Keys;
            int typeCount = types.Count;

            //Debug.Log("typeCount for " + client + ": " + typeHierarchy);

            List <StyleDeclaration> classDecls = null;

            /*if (styleManager.TypeSelectorCache.ContainsKey(className))
             *      classDecls = styleManager.TypeSelectorCache[className];*/
            /*if (null != classDecls)
             *      return classDecls;*/

            classDecls = new List <StyleDeclaration>();

            // Loop over the type hierarhcy starting at the base type and work
            // down the chain of subclasses.
            for (int i = typeCount - 1; i >= 0; i--)
            {
                string type = types[i];                 //.toString(); && TODO??

                //Debug.Log("Getting decls for " + type);
                List <StyleDeclaration> decls = styleManager.GetStyleDeclarations(type);
                if (null != decls)
                {
                    //Debug.Log("  ->" + decls.Count);
                    var matchingDecls = MatchStyleDeclarations(decls, client);
                    if (null != matchingDecls)
                    {
                        classDecls.AddRange(matchingDecls);
                    }
                }
            }

            #region Monitor

//#if DEBUG
//            if (null != TYPE_TO_MONITOR)
//            {
//                if (client.GetType() == TYPE_TO_MONITOR)
//                    Debug.Log(string.Format(@"### {0} classDecls ###
//{1}", TYPE_TO_MONITOR, ListUtil<StyleDeclaration>.Format(classDecls)));
//            }
//#endif

            #endregion

            classDecls = SortOnSpecificity(classDecls);             //classDecls.Sort(SpecificitySort); // = SortOnSpecificity(classDecls);

            #region Monitor

//#if DEBUG
//            if (null != TYPE_TO_MONITOR)
//            {
//                if (client.GetType() == TYPE_TO_MONITOR)
//                    Debug.Log(string.Format(@"### {0} classDecls 2 ###
//{1}", TYPE_TO_MONITOR, ListUtil<StyleDeclaration>.Format(classDecls)));
//            }
//#endif

            #endregion

            #region Always advanced - NO caching!

/*if (styleManager.HasAdvancedSelectors()/* && advancedObject != null#1#)
 *                      {
 *                              // Advanced selectors may result in more than one match per type so
 *                              // we sort based on specificity, but we preserve the declaration
 *                              // order for equal selectors.
 *                              classDecls = SortOnSpecificity(classDecls);
 *                      }
 *                      else
 *                      {
 *                              // Cache the simple type declarations for this class
 *                              styleManager.TypeSelectorCache[className] = classDecls;
 *                      }*/

            #endregion


            return(classDecls);
        }