예제 #1
0
        internal void ApplyTo(DependencyObject o, DependencyPropertyValuePrecedences precedence)
        {
            if (o == null)
            {
                this.Log().Warn("Style.ApplyTo - Applied to null object - Skipping");
                return;
            }

            using (DependencyObjectExtensions.OverrideLocalPrecedence(o, precedence))
            {
                var flattenedSetters = CreateSetterMap();
#if !HAS_EXPENSIVE_TRYFINALLY
                try
#endif
                {
                    ResourceResolver.PushNewScope(_xamlScope);
                    foreach (var pair in flattenedSetters)
                    {
                        pair.Value(o);
                    }

                    // Check tree for resource binding values, since some Setters may have set ThemeResource-backed values
                    (o as IDependencyObjectStoreProvider) !.Store.UpdateResourceBindings(isThemeChangedUpdate: false);
                }
#if !HAS_EXPENSIVE_TRYFINALLY
                finally
#endif
                {
                    ResourceResolver.PopScope();
                }
            }
        }
예제 #2
0
파일: Style.cs 프로젝트: yan2oo7/uno
        internal void ApplyTo(DependencyObject o, DependencyPropertyValuePrecedences precedence)
        {
            if (o == null)
            {
                this.Log().Warn("Style.ApplyTo - Applied to null object - Skipping");
                return;
            }

            using (DependencyObjectExtensions.OverrideLocalPrecedence(o, precedence))
            {
                var flattenedSetters = CreateSetterMap();
#if !HAS_EXPENSIVE_TRYFINALLY
                try
#endif
                {
                    ResourceResolver.PushNewScope(_xamlScope);
                    foreach (var pair in flattenedSetters)
                    {
                        pair.Value(o);
                    }
                }
#if !HAS_EXPENSIVE_TRYFINALLY
                finally
#endif
                {
                    ResourceResolver.PopScope();
                }
            }
        }
예제 #3
0
파일: Style.cs 프로젝트: propellingbits/Uno
        public void ApplyTo(DependencyObject o)
        {
            if (o == null)
            {
                this.Log().Warn("Style.ApplyTo - Applied to null object - Skipping");
                return;
            }

            using (DependencyObjectExtensions.OverrideLocalPrecedence(o, Precedence))
            {
                var flattenedSetters = CreateSetterMap();

                foreach (var pair in flattenedSetters)
                {
                    pair.Value(o);
                }
            }
        }
예제 #4
0
파일: Style.cs 프로젝트: Robert-Louis/Uno
        internal void ApplyTo(DependencyObject o, DependencyPropertyValuePrecedences precedence)
        {
            if (o == null)
            {
                this.Log().Warn("Style.ApplyTo - Applied to null object - Skipping");
                return;
            }

            var localPrecedenceDisposable = DependencyObjectExtensions.OverrideLocalPrecedence(o, precedence);

            var flattenedSetters = CreateSetterMap();

#if !HAS_EXPENSIVE_TRYFINALLY
            try
#endif
            {
                ResourceResolver.PushNewScope(_xamlScope);

                // This block is a manual enumeration to avoid the foreach pattern
                // See https://github.com/dotnet/runtime/issues/56309 for details
                var settersEnumerator = flattenedSetters.GetEnumerator();
                while (settersEnumerator.MoveNext())
                {
                    settersEnumerator.Current.Value(o);
                }

                // Check tree for resource binding values, since some Setters may have set ThemeResource-backed values
                (o as IDependencyObjectStoreProvider) !.Store.UpdateResourceBindings(isThemeChangedUpdate: false);
            }
#if !HAS_EXPENSIVE_TRYFINALLY
            finally
#endif
            {
                ResourceResolver.PopScope();
                localPrecedenceDisposable?.Dispose();
            }
        }