public ObjectWriterContext(XamlSchemaContext schemaContext,
                                   XamlObjectWriterSettings settings, XAML3.INameScope rootNameScope, XamlRuntime runtime)
            : base(schemaContext)
        {
            _stack = new XamlContextStack <ObjectWriterFrame>(() => new ObjectWriterFrame());

            XAML3.INameScopeDictionary rootNameScopeDictionary = null;
            if (rootNameScope == null)
            {
#if TARGETTING35SP1
                rootNameScopeDictionary = new NameScopeDictionary(new NameScope());
#else
                rootNameScopeDictionary = new NameScope();
#endif
            }
            else
            {
                rootNameScopeDictionary = rootNameScope as XAML3.INameScopeDictionary;

                if (rootNameScopeDictionary == null)
                {
                    rootNameScopeDictionary = new NameScopeDictionary(rootNameScope);
                }
            }
            _stack.CurrentFrame.NameScopeDictionary = rootNameScopeDictionary;
            _stack.PushScope();  // put a blank sentinal frame on the stack.
            if (settings != null)
            {
                _settings = settings.StripDelegates();
            }
            _runtime    = runtime;
            _savedDepth = 0;
        }
Esempio n. 2
0
 public XamlContextStack(XamlContextStack <T> source, bool copy)
 {
     this._depth            = -1;
     this._currentFrame     = default(T);
     this._recycledFrame    = default(T);
     this._creationDelegate = source._creationDelegate;
     this._depth            = source.Depth;
     if (!copy)
     {
         this._currentFrame = source.CurrentFrame;
     }
     else
     {
         T currentFrame = source.CurrentFrame;
         T local2       = default(T);
         while (currentFrame != null)
         {
             T local3 = (T)currentFrame.Clone();
             if (this._currentFrame == null)
             {
                 this._currentFrame = local3;
             }
             if (local2 != null)
             {
                 local2.Previous = local3;
             }
             local2       = local3;
             currentFrame = (T)currentFrame.Previous;
         }
     }
 }
Esempio n. 3
0
 public XamlContextStack(XamlContextStack <T> source, bool copy)
 {
     _creationDelegate = source._creationDelegate;
     _depth            = source.Depth;
     if (!copy)
     {
         _currentFrame = source.CurrentFrame;
     }
     else
     {
         T iteratorFrame       = source.CurrentFrame;
         T lastFrameInNewStack = null;
         while (iteratorFrame != null)
         {
             T newFrame = (T)iteratorFrame.Clone();
             if (_currentFrame == null)
             {
                 _currentFrame = newFrame;
             }
             if (lastFrameInNewStack != null)
             {
                 lastFrameInNewStack.Previous = newFrame;
             }
             lastFrameInNewStack = newFrame;
             iteratorFrame       = (T)iteratorFrame.Previous;
         }
     }
 }
 public XamlParserContext(XamlSchemaContext schemaContext, Assembly localAssembly)
     : base(schemaContext)
 {
     _stack = new XamlContextStack <XamlParserFrame>(() => new XamlParserFrame());
     _prescopeNamespaces = new Dictionary <string, string>();
     base._localAssembly = localAssembly;
 }
Esempio n. 5
0
        // Token: 0x06007DED RID: 32237 RVA: 0x00234CE0 File Offset: 0x00232EE0
        public XamlContextStack(XamlContextStack <T> source, bool copy)
        {
            this._creationDelegate = source._creationDelegate;
            this._depth            = source.Depth;
            if (!copy)
            {
                this._currentFrame = source.CurrentFrame;
                return;
            }
            T t  = source.CurrentFrame;
            T t2 = default(T);

            while (t != null)
            {
                T t3 = (T)((object)t.Clone());
                if (this._currentFrame == null)
                {
                    this._currentFrame = t3;
                }
                if (t2 != null)
                {
                    t2.Previous = t3;
                }
                t2 = t3;
                t  = (T)((object)t.Previous);
            }
        }
        public ObjectWriterContext(XamlSchemaContext schemaContext, XamlObjectWriterSettings settings, INameScope rootNameScope, XamlRuntime runtime) : base(schemaContext)
        {
            this._stack = new XamlContextStack <ObjectWriterFrame>(() => new ObjectWriterFrame());
            INameScopeDictionary dictionary = null;

            if (rootNameScope == null)
            {
                dictionary = new NameScope();
            }
            else
            {
                dictionary = rootNameScope as INameScopeDictionary;
                if (dictionary == null)
                {
                    dictionary = new NameScopeDictionary(rootNameScope);
                }
            }
            this._stack.CurrentFrame.NameScopeDictionary = dictionary;
            this._stack.PushScope();
            if (settings != null)
            {
                this._settings = settings.StripDelegates();
            }
            this._runtime    = runtime;
            this._savedDepth = 0;
        }
        public ObjectWriterContext(XamlSavedContext savedContext,
                                   XamlObjectWriterSettings settings, XAML3.INameScope rootNameScope, XamlRuntime runtime)
            : base(savedContext.SchemaContext)
        {
            _stack = new XamlContextStack <ObjectWriterFrame>(savedContext.Stack, false);
            if (settings != null)
            {
                _settings = settings.StripDelegates();
            }
            _runtime = runtime;
            BaseUri  = savedContext.BaseUri;
            // If the bottom of the stack is a (no XamlType) Value (reparse) then back-up onto it.
            // Otherwise add a blank frame to isolate template use from the saved context.
            switch (savedContext.SaveContextType)
            {
            case SavedContextType.Template:
                // Templates always need a root namescope, to isolate them from the rest of the doc
                XAML3.INameScopeDictionary rootNameScopeDictionary = null;
                if (rootNameScope == null)
                {
#if TARGETTING35SP1
                    rootNameScopeDictionary = new NameScopeDictionary(new NameScope());
#else
                    rootNameScopeDictionary = new NameScope();
#endif
                }
                else
                {
                    rootNameScopeDictionary = rootNameScope as XAML3.INameScopeDictionary;

                    if (rootNameScopeDictionary == null)
                    {
                        rootNameScopeDictionary = new NameScopeDictionary(rootNameScope);
                    }
                }

                // Push an extra frame to ensure that the template NameScope is
                // not part of the saved context.  Otherwise, the namescope
                // will hold things alive as long as the template is alive
                _stack.PushScope();
                _savedDepth = _stack.Depth;
                _stack.CurrentFrame.NameScopeDictionary = rootNameScopeDictionary;
                _stack.PushScope();
                break;

            case SavedContextType.ReparseValue:
            case SavedContextType.ReparseMarkupExtension:
                Debug.Assert(rootNameScope == null, "Cannot pass a new namescope in to a reparse context");
                _savedDepth = _stack.Depth - 1;
                break;
            }
        }
        public XamlSavedContext GetSavedContext(SavedContextType savedContextType)
        {
            // Ensure that we have a root namescope before cloning the stack
            ObjectWriterFrame topFrame = GetTopFrame();

            if (topFrame.NameScopeDictionary == null)
            {
                topFrame.NameScopeDictionary = LookupNameScopeDictionary(topFrame);
            }

            // Clone the stack
            var newStack = new XamlContextStack <ObjectWriterFrame>(_stack, true);
            XamlSavedContext savedContext = new XamlSavedContext(savedContextType, this, newStack);

            return(savedContext);
        }
        public ObjectWriterContext(XamlSavedContext savedContext, XamlObjectWriterSettings settings, INameScope rootNameScope, XamlRuntime runtime) : base(savedContext.SchemaContext)
        {
            INameScopeDictionary dictionary;

            this._stack = new XamlContextStack <ObjectWriterFrame>(savedContext.Stack, false);
            if (settings != null)
            {
                this._settings = settings.StripDelegates();
            }
            this._runtime = runtime;
            this.BaseUri  = savedContext.BaseUri;
            switch (savedContext.SaveContextType)
            {
            case SavedContextType.Template:
                dictionary = null;
                if (rootNameScope != null)
                {
                    dictionary = rootNameScope as INameScopeDictionary;
                    if (dictionary == null)
                    {
                        dictionary = new NameScopeDictionary(rootNameScope);
                    }
                    break;
                }
                dictionary = new NameScope();
                break;

            case SavedContextType.ReparseValue:
            case SavedContextType.ReparseMarkupExtension:
                this._savedDepth = this._stack.Depth - 1;
                return;

            default:
                return;
            }
            this._stack.PushScope();
            this._savedDepth = this._stack.Depth;
            this._stack.CurrentFrame.NameScopeDictionary = dictionary;
            this._stack.PushScope();
        }