Ejemplo n.º 1
0
        /**
         *
         */
        internal StyleTable CreateProtoChainRoot(bool registerClone = true)
        {
            StyleTable root = new StyleTable();

            // If there's a defaultFactory for this style sheet,
            // then add the object it produces to the root.
            if (null != Set1)
            {
                root = root.CloneAndOverrideWith(Set1.Produce());
            }

            // If there's a factory for this style sheet,
            // then add the object it produces to the root.
            if (null != Set2)
            {
                root = root.CloneAndOverrideWith(Set2.Produce());
            }

            if (registerClone)
            {
                _clones.Add(root);
            }

            return(root);
        }
Ejemplo n.º 2
0
// ReSharper restore UnassignedField.Global
#endif

        ///<summary>
        ///</summary>
        ///<param name="chain">Replikativni Dictionary</param>
        ///<param name="target"></param>
        ///<returns></returns>
        internal virtual StyleTable AddStyleToProtoChain(StyleTable chain, object target /*, object filterMap*/)
        {
            //Debug.Log("AddStyleToProtoChain: chain: " + chain + "; target: " + target);

            bool nodeAddedToChain = false;

            //var originalChain = chain;

            //if (filterMap)
            //{
            //    chain = {};
            //}

#if DEBUG
            if (!string.IsNullOrEmpty(DebugId))
            {
                Debug.Log(DebugId + " 0. " + chain);
            }
#endif

            // If there's a defaultFactory for this style sheet,
            // then add the object it produces to the chain.
            if (null != Set1)
            {
                chain            = chain.CloneAndOverrideWith(Set1.Produce());
                nodeAddedToChain = true;
            }

#if DEBUG
            if (!string.IsNullOrEmpty(DebugId))
            {
                Debug.Log(DebugId + " 1. " + chain);
            }
#endif

            // If there's a factory for this style sheet,
            // then add the object it produces to the chain.
            if (null != Set2)
            {
                chain            = chain.CloneAndOverrideWith(Set2.Produce());
                nodeAddedToChain = true;
            }

#if DEBUG
            if (!string.IsNullOrEmpty(DebugId))
            {
                Debug.Log(DebugId + " 2. " + chain);
            }
#endif

            //Debug.Log("-- chain: " + chain);

            // If someone has called setStyle() on this StyleDeclaration,
            // then some of the values returned from the factory are
            // out-of-date. Overwrite them with the up-to-date values.
            if (null != _overrides)
            {
                // Before we add our overrides to the object at the head of
                // the chain, make sure that we added an object at the head
                // of the chain.
                if (null == Set1 && null == Set2)
                {
                    chain            = (StyleTable)chain.Clone();
                    nodeAddedToChain = true;
                }

                foreach (string p in _overrides.Keys)
                {
                    if (!UNDEFINED.Equals(_overrides[p]))
                    {
                        chain[p] = _overrides[p];
                    }

                    /*if (UNDEFINED.Equals(_overrides[p]))
                     *      chain.Remove(p);
                     * else
                     *      chain[p] = _overrides[p];*/
                }
            }

#if DEBUG
            if (!string.IsNullOrEmpty(DebugId))
            {
                Debug.Log(DebugId + " 3. " + chain);
            }
#endif

            #region _complex

            ////if (filterMap)
            ////{
            //    if (nodeAddedToChain)
            //    {
            //        //Debug.Log("nodeAddedToChain");
            //        //var filteredChain = new Dictionary<string, object>();
            //        //for (string i in chain)
            //        //{
            //        //    if (filterMap[i] != null)
            //        //    {
            //        //        filteredChain[filterMap[i]] = chain[i];
            //        //    }
            //        //}

            //        //var f = new StyleTableValuesFactory(originalChain);

            //        chain = (StyleTable) originalChain.Clone();

            //        //chain = originalChain;

            //        //chain = filteredChain;
            //        //chain = f.Produce();

            //        //chain[FILTERMAP_PROP] = filterMap;
            //    }
            //    else
            //    {
            //        chain = originalChain;
            //    }
            ////}

            #endregion

            if (nodeAddedToChain)
            {
                _clones.Add(chain);
            }

            return(chain);
        }