Пример #1
0
 // Token: 0x060021D0 RID: 8656 RVA: 0x000A9550 File Offset: 0x000A7750
 internal ParserContext(ParserContext parserContext)
 {
     this._xmlLang        = parserContext.XmlLang;
     this._xmlSpace       = parserContext.XmlSpace;
     this._xamlTypeMapper = parserContext.XamlTypeMapper;
     this._mapTable       = parserContext.MapTable;
     this._baseUri        = parserContext.BaseUri;
     this._masterBracketCharacterCache = parserContext.MasterBracketCharacterCache;
     this._rootElement = parserContext._rootElement;
     if (parserContext._nameScopeStack != null)
     {
         this._nameScopeStack = (Stack)parserContext._nameScopeStack.Clone();
     }
     else
     {
         this._nameScopeStack = null;
     }
     this._skipJournaledProperties = parserContext._skipJournaledProperties;
     this._xmlnsDictionary         = null;
     if (parserContext._xmlnsDictionary != null && parserContext._xmlnsDictionary.Count > 0)
     {
         this._xmlnsDictionary = new XmlnsDictionary();
         XmlnsDictionary xmlnsDictionary = parserContext.XmlnsDictionary;
         if (xmlnsDictionary != null)
         {
             foreach (object obj in xmlnsDictionary.Keys)
             {
                 string prefix = (string)obj;
                 this._xmlnsDictionary[prefix] = xmlnsDictionary[prefix];
             }
         }
     }
 }
Пример #2
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Windows.Markup.XmlnsDictionary" /> class by using the specified dictionary as a copy source.</summary>
 /// <param name="xmlnsDictionary">The dictionary on which to base the new <see cref="T:System.Windows.Markup.XmlnsDictionary" />.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="xmlnsDictionary" /> is <see langword="null" />.</exception>
 // Token: 0x060023D8 RID: 9176 RVA: 0x000AEE98 File Offset: 0x000AD098
 public XmlnsDictionary(XmlnsDictionary xmlnsDictionary)
 {
     if (xmlnsDictionary == null)
     {
         throw new ArgumentNullException("xmlnsDictionary");
     }
     if (xmlnsDictionary != null && xmlnsDictionary.Count > 0)
     {
         this._lastDecl = xmlnsDictionary._lastDecl;
         if (this._nsDeclarations == null)
         {
             this._nsDeclarations = new XmlnsDictionary.NamespaceDeclaration[this._lastDecl + 1];
         }
         this._countDecl = 0;
         for (int i = 0; i <= this._lastDecl; i++)
         {
             if (xmlnsDictionary._nsDeclarations[i].Uri != null)
             {
                 this._countDecl++;
             }
             this._nsDeclarations[i].Prefix     = xmlnsDictionary._nsDeclarations[i].Prefix;
             this._nsDeclarations[i].Uri        = xmlnsDictionary._nsDeclarations[i].Uri;
             this._nsDeclarations[i].ScopeCount = xmlnsDictionary._nsDeclarations[i].ScopeCount;
         }
         return;
     }
     this.Initialize();
 }
Пример #3
0
        public static void SetXmlnsDictionary(DependencyObject dependencyObject, XmlnsDictionary value)
        {
            if (dependencyObject == null)
            {
                throw new ArgumentNullException();
            }

            dependencyObject.SetValue(XmlnsDictionaryProperty, value);
        }
 /// <summary>Sets the value of the <see cref="P:System.Windows.Markup.XmlAttributeProperties.XmlnsDictionary" /> attached property of the specified <see cref="T:System.Windows.DependencyObject" />.</summary>
 /// <param name="dependencyObject">The object on which to set the <see cref="P:System.Windows.Markup.XmlAttributeProperties.XmlnsDictionary" /> attached property.</param>
 /// <param name="value">The <see langword="xmlns" /> dictionary in string form.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="dependencyObject" /> is <see langword="null" />.</exception>
 // Token: 0x060023C5 RID: 9157 RVA: 0x000AEA4F File Offset: 0x000ACC4F
 public static void SetXmlnsDictionary(DependencyObject dependencyObject, XmlnsDictionary value)
 {
     if (dependencyObject == null)
     {
         throw new ArgumentNullException("dependencyObject");
     }
     if (!dependencyObject.IsSealed)
     {
         dependencyObject.SetValue(XmlAttributeProperties.XmlnsDictionaryProperty, value);
     }
 }
Пример #5
0
        private object LoadAsync(XmlReader reader, ParserContext parserContext)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (parserContext == null)
            {
                parserContext = new ParserContext();
            }

            _xmlReader = reader;
            object rootObject = null;

            if (parserContext.BaseUri == null ||
                String.IsNullOrEmpty(parserContext.BaseUri.ToString()))
            {
                if (reader.BaseURI == null ||
                    String.IsNullOrEmpty(reader.BaseURI.ToString()))
                {
                    parserContext.BaseUri = BaseUriHelper.PackAppBaseUri;
                }
                else
                {
                    parserContext.BaseUri = new Uri(reader.BaseURI);
                }
            }
            _baseUri = parserContext.BaseUri;
            System.Xaml.XamlXmlReaderSettings settings = new System.Xaml.XamlXmlReaderSettings();
            settings.IgnoreUidsOnPropertyElements = true;
            settings.BaseUri         = parserContext.BaseUri;
            settings.ProvideLineInfo = true;
            XamlSchemaContext schemaContext = parserContext.XamlTypeMapper != null ?
                                              parserContext.XamlTypeMapper.SchemaContext : GetWpfSchemaContext();

            try
            {
                _textReader = new System.Xaml.XamlXmlReader(reader, schemaContext, settings);

                _stack = new XamlContextStack <WpfXamlFrame>(() => new WpfXamlFrame());

                System.Xaml.XamlObjectWriterSettings objectSettings = XamlReader.CreateObjectWriterSettings();
                objectSettings.AfterBeginInitHandler = delegate(object sender, System.Xaml.XamlObjectEventArgs args)
                {
                    if (rootObject == null)
                    {
                        rootObject      = args.Instance;
                        _styleConnector = rootObject as IStyleConnector;
                    }

                    UIElement uiElement = args.Instance as UIElement;
                    if (uiElement != null)
                    {
                        uiElement.SetPersistId(_persistId++);
                    }

                    DependencyObject dObject = args.Instance as DependencyObject;
                    if (dObject != null && _stack.CurrentFrame.XmlnsDictionary != null)
                    {
                        XmlnsDictionary dictionary = _stack.CurrentFrame.XmlnsDictionary;
                        dictionary.Seal();

                        XmlAttributeProperties.SetXmlnsDictionary(dObject, dictionary);
                    }
                };

                _objectWriter            = new System.Xaml.XamlObjectWriter(_textReader.SchemaContext, objectSettings);
                _parseCancelled          = false;
                _skipJournaledProperties = parserContext.SkipJournaledProperties;

                XamlMember synchronousModeProperty   = _textReader.SchemaContext.GetXamlDirective("http://schemas.microsoft.com/winfx/2006/xaml", "SynchronousMode");
                XamlMember synchronousRecordProperty = _textReader.SchemaContext.GetXamlDirective("http://schemas.microsoft.com/winfx/2006/xaml", "AsyncRecords");

                System.Xaml.XamlReader xamlReader = _textReader;

                IXamlLineInfo         xamlLineInfo         = xamlReader as IXamlLineInfo;
                IXamlLineInfoConsumer xamlLineInfoConsumer = _objectWriter as IXamlLineInfoConsumer;
                bool shouldPassLineNumberInfo = false;
                if ((xamlLineInfo != null && xamlLineInfo.HasLineInfo) &&
                    (xamlLineInfoConsumer != null && xamlLineInfoConsumer.ShouldProvideLineInfo))
                {
                    shouldPassLineNumberInfo = true;
                }

                bool async = false;
                bool lastPropWasSyncMode    = false;
                bool lastPropWasSyncRecords = false;

                while (!_textReader.IsEof)
                {
                    WpfXamlLoader.TransformNodes(xamlReader, _objectWriter, true /*onlyLoadOneNode*/, _skipJournaledProperties, shouldPassLineNumberInfo, xamlLineInfo, xamlLineInfoConsumer, _stack, _styleConnector);

                    if (xamlReader.NodeType == System.Xaml.XamlNodeType.StartMember)
                    {
                        if (xamlReader.Member == synchronousModeProperty)
                        {
                            lastPropWasSyncMode = true;
                        }
                        else if (xamlReader.Member == synchronousRecordProperty)
                        {
                            lastPropWasSyncRecords = true;
                        }
                    }
                    else if (xamlReader.NodeType == System.Xaml.XamlNodeType.Value)
                    {
                        if (lastPropWasSyncMode == true)
                        {
                            if (xamlReader.Value as String == "Async")
                            {
                                async = true;
                            }
                        }
                        else if (lastPropWasSyncRecords == true)
                        {
                            if (xamlReader.Value is int)
                            {
                                _maxAsynxRecords = (int)xamlReader.Value;
                            }
                            else if (xamlReader.Value is String)
                            {
                                _maxAsynxRecords = Int32.Parse(xamlReader.Value as String, TypeConverterHelper.InvariantEnglishUS);
                            }
                        }
                    }
                    else if (xamlReader.NodeType == System.Xaml.XamlNodeType.EndMember)
                    {
                        lastPropWasSyncMode    = false;
                        lastPropWasSyncRecords = false;
                    }

                    if (async && rootObject != null)
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                // Don't wrap critical exceptions or already-wrapped exceptions.
                if (MS.Internal.CriticalExceptions.IsCriticalException(e) || !ShouldReWrapException(e, parserContext.BaseUri))
                {
                    throw;
                }
                RewrapException(e, parserContext.BaseUri);
            }

            if (!_textReader.IsEof)
            {
                Post();
                //ThreadStart threadStart = new ThreadStart(ReadXamlAsync);
                //Thread thread = new Thread(threadStart);
                //thread.Start();
            }
            else
            {
                TreeBuildComplete();
            }

            if (rootObject is DependencyObject)
            {
                if (parserContext.BaseUri != null && !String.IsNullOrEmpty(parserContext.BaseUri.ToString()))
                {
                    (rootObject as DependencyObject).SetValue(BaseUriHelper.BaseUriProperty, parserContext.BaseUri);
                }
                //else
                //    (rootObject as DependencyObject).SetValue(BaseUriHelper.BaseUriProperty, BaseUriHelper.PackAppBaseUri);
                WpfXamlLoader.EnsureXmlNamespaceMaps(rootObject, schemaContext);
            }

            Application app = rootObject as Application;

            if (app != null)
            {
                app.ApplicationMarkupBaseUri = GetBaseUri(settings.BaseUri);
            }

            return(rootObject);
        }
        private static object Load(System.Xaml.XamlReader xamlReader, IXamlObjectWriterFactory writerFactory,
                                   bool skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
        {
            XamlObjectWriter xamlWriter           = null;
            XamlContextStack <WpfXamlFrame> stack = new XamlContextStack <WpfXamlFrame>(() => new WpfXamlFrame());
            int persistId = 1;

            settings.AfterBeginInitHandler = delegate(object sender, System.Xaml.XamlObjectEventArgs args)
            {
                if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordXamlBaml | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose))
                {
                    IXamlLineInfo ixli = xamlReader as IXamlLineInfo;

                    int lineNumber   = -1;
                    int linePosition = -1;

                    if (ixli != null && ixli.HasLineInfo)
                    {
                        lineNumber   = ixli.LineNumber;
                        linePosition = ixli.LinePosition;
                    }

                    EventTrace.EventProvider.TraceEvent(
                        EventTrace.Event.WClientParseXamlBamlInfo,
                        EventTrace.Keyword.KeywordXamlBaml | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose,
                        args.Instance == null ? 0 : PerfService.GetPerfElementID(args.Instance),
                        lineNumber,
                        linePosition);
                }

                UIElement uiElement = args.Instance as UIElement;
                if (uiElement != null)
                {
                    uiElement.SetPersistId(persistId++);
                }

                XamlSourceInfoHelper.SetXamlSourceInfo(args.Instance, args, baseUri);

                DependencyObject dObject = args.Instance as DependencyObject;
                if (dObject != null && stack.CurrentFrame.XmlnsDictionary != null)
                {
                    XmlnsDictionary dictionary = stack.CurrentFrame.XmlnsDictionary;
                    dictionary.Seal();

                    XmlAttributeProperties.SetXmlnsDictionary(dObject, dictionary);
                }

                stack.CurrentFrame.Instance = args.Instance;
            };
            if (writerFactory != null)
            {
                xamlWriter = writerFactory.GetXamlObjectWriter(settings);
            }
            else
            {
                xamlWriter = new System.Xaml.XamlObjectWriter(xamlReader.SchemaContext, settings);
            }

            IXamlLineInfo xamlLineInfo = null;

            try
            {
                //Handle Line Numbers
                xamlLineInfo = xamlReader as IXamlLineInfo;
                IXamlLineInfoConsumer xamlLineInfoConsumer = xamlWriter as IXamlLineInfoConsumer;
                bool shouldPassLineNumberInfo = false;
                if ((xamlLineInfo != null && xamlLineInfo.HasLineInfo) &&
                    (xamlLineInfoConsumer != null && xamlLineInfoConsumer.ShouldProvideLineInfo))
                {
                    shouldPassLineNumberInfo = true;
                }

                IStyleConnector styleConnector = rootObject as IStyleConnector;
                TransformNodes(xamlReader, xamlWriter,
                               false /*onlyLoadOneNode*/,
                               skipJournaledProperties,
                               shouldPassLineNumberInfo, xamlLineInfo, xamlLineInfoConsumer,
                               stack, styleConnector);
                xamlWriter.Close();
                return(xamlWriter.Result);
            }
            catch (Exception e)
            {
                // Don't wrap critical exceptions or already-wrapped exceptions.
                if (MS.Internal.CriticalExceptions.IsCriticalException(e) || !XamlReader.ShouldReWrapException(e, baseUri))
                {
                    throw;
                }
                XamlReader.RewrapException(e, xamlLineInfo, baseUri);
                return(null);    // this should never be executed
            }
        }
Пример #7
0
 /// <summary>
 /// Create an instance of the BamlReader on the passed stream using
 /// the passed ParserContext.
 /// </summary>summary>
 public BamlReader(Stream bamlStream)
 {
     _parserContext = new ParserContext();
     _parserContext.XamlTypeMapper = XmlParserDefaults.DefaultMapper;
     _bamlRecordReader = new BamlRecordReader(bamlStream, _parserContext, false);
     _readState = ReadState.Initial;
     _bamlNodeType = BamlNodeType.None;
     _prefixDictionary = new XmlnsDictionary();
     _value = string.Empty;
     _assemblyName = string.Empty;
     _prefix = string.Empty;
     _xmlNamespace = string.Empty;
     _clrNamespace = string.Empty;
     _name = string.Empty;
     _localName = string.Empty;
     _ownerTypeName = string.Empty;
     _properties = new ArrayList();
     _haveUnprocessedRecord = false;
     _deferableContentBlockDepth = -1;
     _nodeStack = new Stack();
     _reverseXmlnsTable = new Dictionary<String, List<String>>();
 }
        // Token: 0x0600238A RID: 9098 RVA: 0x000AD808 File Offset: 0x000ABA08
        private object LoadAsync(XmlReader reader, ParserContext parserContext)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (parserContext == null)
            {
                parserContext = new ParserContext();
            }
            this._xmlReader = reader;
            object rootObject = null;

            if (parserContext.BaseUri == null || string.IsNullOrEmpty(parserContext.BaseUri.ToString()))
            {
                if (reader.BaseURI == null || string.IsNullOrEmpty(reader.BaseURI.ToString()))
                {
                    parserContext.BaseUri = BaseUriHelper.PackAppBaseUri;
                }
                else
                {
                    parserContext.BaseUri = new Uri(reader.BaseURI);
                }
            }
            this._baseUri = parserContext.BaseUri;
            XamlXmlReaderSettings xamlXmlReaderSettings = new XamlXmlReaderSettings();

            xamlXmlReaderSettings.IgnoreUidsOnPropertyElements = true;
            xamlXmlReaderSettings.BaseUri         = parserContext.BaseUri;
            xamlXmlReaderSettings.ProvideLineInfo = true;
            XamlSchemaContext schemaContext = (parserContext.XamlTypeMapper != null) ? parserContext.XamlTypeMapper.SchemaContext : XamlReader.GetWpfSchemaContext();

            try
            {
                this._textReader = new XamlXmlReader(reader, schemaContext, xamlXmlReaderSettings);
                this._stack      = new XamlContextStack <WpfXamlFrame>(() => new WpfXamlFrame());
                XamlObjectWriterSettings xamlObjectWriterSettings = XamlReader.CreateObjectWriterSettings();
                xamlObjectWriterSettings.AfterBeginInitHandler = delegate(object sender, XamlObjectEventArgs args)
                {
                    if (rootObject == null)
                    {
                        rootObject           = args.Instance;
                        this._styleConnector = (rootObject as IStyleConnector);
                    }
                    UIElement uielement = args.Instance as UIElement;
                    if (uielement != null)
                    {
                        UIElement uielement2 = uielement;
                        XamlReader < > 4__this = this;
                        int persistId = this._persistId;
                        < > 4__this._persistId = persistId + 1;
                        uielement2.SetPersistId(persistId);
                    }
                    DependencyObject dependencyObject = args.Instance as DependencyObject;
                    if (dependencyObject != null && this._stack.CurrentFrame.XmlnsDictionary != null)
                    {
                        XmlnsDictionary xmlnsDictionary = this._stack.CurrentFrame.XmlnsDictionary;
                        xmlnsDictionary.Seal();
                        XmlAttributeProperties.SetXmlnsDictionary(dependencyObject, xmlnsDictionary);
                    }
                };
 public static void SetXmlnsDictionary(System.Windows.DependencyObject dependencyObject, XmlnsDictionary value)
 {
 }
Пример #10
0
 public XmlnsDictionary(XmlnsDictionary dict)
 {
 }
Пример #11
0
		public XmlnsDictionary (XmlnsDictionary dict)
		{
		}
 public static void SetXmlnsDictionary(System.Windows.DependencyObject dependencyObject, XmlnsDictionary value)
 {
 }
Пример #13
0
        // Add an XML namespace dictionary entry to the current object in the
        // context stack.
        // NOTE:  Setting Xmlns information on a delay created type is not currently 
        //        supported.  The type must have already been instantiated in order to
        //        set the dictionary property on it.  See Windows bug 1068961. 
        protected void SetXmlnsOnCurrentObject(BamlXmlnsPropertyRecord xmlnsRecord) 
        {
            DependencyObject e = CurrentContext.ObjectData as DependencyObject; 

            // For cases where we have object factories, we may not have a valid DependencyObject at
            // this point, so don't try to set the xmlns dictionary.
            if (e != null) 
            {
                XmlnsDictionary elemDict = XmlAttributeProperties.GetXmlnsDictionary(e); 
 
                if (null != elemDict)
                { 
                    elemDict.Unseal();
                    elemDict[xmlnsRecord.Prefix] = xmlnsRecord.XmlNamespace;
                    elemDict.Seal();
                } 
                else
                { 
                    elemDict = new XmlnsDictionary(); 
                    elemDict[xmlnsRecord.Prefix] = xmlnsRecord.XmlNamespace;
                    elemDict.Seal(); 
                    XmlAttributeProperties.SetXmlnsDictionary(e, elemDict);
                }
            }
        } 
        public static void SetXmlnsDictionary(DependencyObject dependencyObject, XmlnsDictionary value)
        {
            if (dependencyObject == null)
                throw new ArgumentNullException ();

            dependencyObject.SetValue (XmlnsDictionaryProperty, value);
        }
Пример #15
0
        // Token: 0x0600226A RID: 8810 RVA: 0x000AAE10 File Offset: 0x000A9010
        private static object Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
        {
            XamlContextStack <WpfXamlFrame> stack = new XamlContextStack <WpfXamlFrame>(() => new WpfXamlFrame());
            int persistId = 1;

            settings.AfterBeginInitHandler = delegate(object sender, XamlObjectEventArgs args)
            {
                if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose))
                {
                    IXamlLineInfo xamlLineInfo2 = xamlReader as IXamlLineInfo;
                    int           num           = -1;
                    int           num2          = -1;
                    if (xamlLineInfo2 != null && xamlLineInfo2.HasLineInfo)
                    {
                        num  = xamlLineInfo2.LineNumber;
                        num2 = xamlLineInfo2.LinePosition;
                    }
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientParseXamlBamlInfo, EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordXamlBaml, EventTrace.Level.Verbose, new object[]
                    {
                        (args.Instance == null) ? 0L : PerfService.GetPerfElementID(args.Instance),
                        num,
                        num2
                    });
                }
                UIElement uielement = args.Instance as UIElement;
                if (uielement != null)
                {
                    UIElement uielement2 = uielement;
                    int       persistId  = persistId;
                    persistId++;
                    uielement2.SetPersistId(persistId);
                }
                XamlSourceInfoHelper.SetXamlSourceInfo(args.Instance, args, baseUri);
                DependencyObject dependencyObject = args.Instance as DependencyObject;
                if (dependencyObject != null && stack.CurrentFrame.XmlnsDictionary != null)
                {
                    XmlnsDictionary xmlnsDictionary = stack.CurrentFrame.XmlnsDictionary;
                    xmlnsDictionary.Seal();
                    XmlAttributeProperties.SetXmlnsDictionary(dependencyObject, xmlnsDictionary);
                }
                stack.CurrentFrame.Instance = args.Instance;
            };
            XamlObjectWriter xamlObjectWriter;

            if (writerFactory != null)
            {
                xamlObjectWriter = writerFactory.GetXamlObjectWriter(settings);
            }
            else
            {
                xamlObjectWriter = new XamlObjectWriter(xamlReader.SchemaContext, settings);
            }
            IXamlLineInfo xamlLineInfo = null;
            object        result;

            try
            {
                xamlLineInfo = (xamlReader as IXamlLineInfo);
                IXamlLineInfoConsumer xamlLineInfoConsumer = xamlObjectWriter;
                bool shouldPassLineNumberInfo = false;
                if (xamlLineInfo != null && xamlLineInfo.HasLineInfo && xamlLineInfoConsumer != null && xamlLineInfoConsumer.ShouldProvideLineInfo)
                {
                    shouldPassLineNumberInfo = true;
                }
                IStyleConnector styleConnector = rootObject as IStyleConnector;
                WpfXamlLoader.TransformNodes(xamlReader, xamlObjectWriter, false, skipJournaledProperties, shouldPassLineNumberInfo, xamlLineInfo, xamlLineInfoConsumer, stack, styleConnector);
                xamlObjectWriter.Close();
                result = xamlObjectWriter.Result;
            }
            catch (Exception ex)
            {
                if (CriticalExceptions.IsCriticalException(ex) || !XamlReader.ShouldReWrapException(ex, baseUri))
                {
                    throw;
                }
                XamlReader.RewrapException(ex, xamlLineInfo, baseUri);
                result = null;
            }
            return(result);
        }