コード例 #1
0
ファイル: Freezable.cs プロジェクト: JianwenSun/cc
        //
        // helper function to add a singleton handler.  The passed in handler parameter
        // will be stored as the singleton handler.
        //
        private void AddSingletonHandler(EventHandler handler)
        {
            Debug.Assert(!Freezable_UsingHandlerList && !Freezable_UsingSingletonHandler);
            Debug.Assert(handler != null);

            if (HasContextInformation)
            {
                HandlerContextStorage hps = new HandlerContextStorage();

                hps._contextStorage = _contextStorage;
                hps._handlerStorage = handler;

                _contextStorage = hps;
            }
            else
            {
                _contextStorage = handler;
            }

            Freezable_UsingSingletonHandler = true;
        }
コード例 #2
0
ファイル: Freezable.cs プロジェクト: JianwenSun/cc
        /// <summary>
        /// Helper function to add a singleton context to the Freezable's storage
        /// <param name="context">The DependencyObject to add that references this Freezable.</param>
        /// <param name="property">The property of the DependencyObject this object maps to or null if none.</param>
        /// </summary>
        private void AddSingletonContext(DependencyObject context, DependencyProperty property)
        {
            Debug.Assert(!Freezable_UsingSingletonContext && !Freezable_UsingContextList);
            Debug.Assert(context != null);

            if (HasHandlers)
            {
                HandlerContextStorage hps = new HandlerContextStorage();

                hps._handlerStorage = _contextStorage;
                hps._contextStorage = context;

                _contextStorage = hps;
            }
            else
            {
                _contextStorage = context;
            }

            // set the singleton context property
            _property = property;

            Freezable_UsingSingletonContext = true;
        }