当前位置: 首页>>代码示例>>C#>>正文


C# Markup.ParserContext类代码示例

本文整理汇总了C#中System.Windows.Markup.ParserContext的典型用法代码示例。如果您正苦于以下问题:C# ParserContext类的具体用法?C# ParserContext怎么用?C# ParserContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParserContext类属于System.Windows.Markup命名空间,在下文中一共展示了ParserContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

 private static object Load(Stream stream)
 {
     var pc = new ParserContext();
     MethodInfo loadBamlMethod = typeof (XamlReader).GetMethod("LoadBaml",
         BindingFlags.NonPublic | BindingFlags.Static);
     return loadBamlMethod.Invoke(null, new object[] {stream, pc, null, false});
 }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:Resources.cs

示例2: BamlWriter

 /// <summary>
 /// Create a BamlWriter on the passed stream.  The stream must be writable.
 /// </summary>
 public BamlWriter(
     Stream stream)
 {
     if (null == stream)
     {
         throw new ArgumentNullException( "stream" );
     }
     if (!stream.CanWrite)
     {
         throw new ArgumentException(SR.Get(SRID.BamlWriterBadStream));
     }
     
     _parserContext = new ParserContext();
     if (null == _parserContext.XamlTypeMapper) 
     {
         _parserContext.XamlTypeMapper = new BamlWriterXamlTypeMapper(XmlParserDefaults.GetDefaultAssemblyNames(),
                                                                      XmlParserDefaults.GetDefaultNamespaceMaps());
     }
     _xamlTypeMapper = _parserContext.XamlTypeMapper;
     _bamlRecordWriter = new BamlRecordWriter(stream, _parserContext, true);
     _startDocumentWritten = false;
     _depth = 0;
     _closed = false;
     _nodeTypeStack = new ParserStack();
     _assemblies = new Hashtable(7);
    _extensionParser = new MarkupExtensionParser((IParserHelper)this, _parserContext);
    _markupExtensionNodes = new ArrayList();
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:31,代码来源:BamlWriter.cs

示例3: OnBoundDocumentChanged

        private static void OnBoundDocumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RichTextBox box = d as RichTextBox;

            if (box == null)
                return;

            RemoveEventHandler(box);

            string newXAML = GetBoundDocument(d);

            box.Document.Blocks.Clear();

            if (!string.IsNullOrEmpty(newXAML))
            {
                using (MemoryStream xamlMemoryStream = new MemoryStream(Encoding.ASCII.GetBytes(newXAML)))
                {
                    ParserContext parser = new ParserContext();
                    parser.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                    parser.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
                    FlowDocument doc = new FlowDocument();
                    Section section = XamlReader.Load(xamlMemoryStream, parser) as Section;

                    box.Document.Blocks.Add(section);

                }
            }

            AttachEventHandler(box);

        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:31,代码来源:RichTextboxAssistant.cs

示例4: LoadBaml

        public static object LoadBaml(Stream stream)
        {
            var presentationFrameworkAssembly = Assembly.GetAssembly(typeof(Button));

            if( Environment.Version.Major == 4)
            {
                var xamlAssembly = Assembly.Load("System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
                var readerType = presentationFrameworkAssembly.GetType("System.Windows.Baml2006.Baml2006Reader");
                var reader = Activator.CreateInstance(readerType, stream);
                var schemaContextProperty = readerType.GetProperty("SchemaContext");
                var schemaContext = schemaContextProperty.GetGetMethod().Invoke(reader, null);
                var writerType = xamlAssembly.GetType("System.Xaml.XamlObjectWriter");
                var writer = Activator.CreateInstance(writerType, schemaContext);
                var readerReadMethod = readerType.GetMethod("Read");
                var writerWriteMethod = writerType.GetMethod("WriteNode");
                while( (bool)readerReadMethod.Invoke(reader, null))
                {
                    writerWriteMethod.Invoke(writer, new[] {reader});
                }
                var writerResultProperty = writerType.GetProperty("Result");
                return writerResultProperty.GetGetMethod().Invoke(writer, null);
            }
            else
            {
                var pc = new ParserContext();
                var readerType = presentationFrameworkAssembly.GetType("System.Windows.Markup.XamlReader");
                var method = readerType.GetMethod("LoadBaml", BindingFlags.NonPublic | BindingFlags.Static);
                return method.Invoke(null, new object[] {stream, pc, null, false});
            }
        }
开发者ID:bdurrani,项目名称:WPF-Inspector,代码行数:30,代码来源:BamlLoader.cs

示例5: DeSerializeObjectTree

 public static object DeSerializeObjectTree(string xaml)
 {
     Stream stream = ConvertTextToStream(xaml);
     ParserContext parserContext = new ParserContext();
     parserContext.BaseUri = new Uri("pack://siteoforigin:,,,/");
     return XamlReader.Load(stream, parserContext);
 }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:7,代码来源:Util.cs

示例6: DeserializeFlowDocument

        // ---------------------------------------------------------------------
        //
        // Internal Methods
        //
        // ---------------------------------------------------------------------

        #region Internal Methods

        public static FlowDocument DeserializeFlowDocument(string strFlowDocumentXML)
        {
            Debug.WriteLine("DeserializeFlowDocument: " + strFlowDocumentXML);
            try
            {
                MemoryStream memoryStream = new MemoryStream(strFlowDocumentXML.Length);
                using (StreamWriter streamWriter = new StreamWriter(memoryStream))
                {
                    streamWriter.Write(strFlowDocumentXML);
                    streamWriter.Flush();

                    memoryStream.Seek(0, SeekOrigin.Begin);

                    ParserContext parserContext = new ParserContext();

                    parserContext.BaseUri = new Uri(System.Environment.CurrentDirectory + "/");

                    return XamlReader.Load(memoryStream, parserContext) as FlowDocument;
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(false, "Load flow document failed! :" +ex);
                //return new FlowDocument();
                throw ex;
            }
        }
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:35,代码来源:HtmlToXamlConverter.cs

示例7: BamlConverter

        // <summary>
        // Creates an object instance from a Baml stream and it's Uri 
        // </summary>
        internal static object BamlConverter(Stream stream, Uri baseUri, bool canUseTopLevelBrowser, bool sandboxExternalContent, bool allowAsync, bool isJournalNavigation, out XamlReader asyncObjectConverter) 
        { 
            asyncObjectConverter = null;
 
            // If this stream comes from outside the application throw
            //
            if (!BaseUriHelper.IsPackApplicationUri(baseUri))
            { 
                throw new InvalidOperationException(SR.Get(SRID.BamlIsNotSupportedOutsideOfApplicationResources));
            } 
 
            // If this stream comes from a content file also throw
            Uri partUri = PackUriHelper.GetPartUri(baseUri); 
            string partName, assemblyName, assemblyVersion, assemblyKey;
            BaseUriHelper.GetAssemblyNameAndPart(partUri, out partName, out assemblyName, out assemblyVersion, out assemblyKey);
            if (ContentFileHelper.IsContentFile(partName))
            { 
                throw new InvalidOperationException(SR.Get(SRID.BamlIsNotSupportedOutsideOfApplicationResources));
            } 
 
            ParserContext pc = new ParserContext();
 
            pc.BaseUri = baseUri;
            pc.SkipJournaledProperties = isJournalNavigation;

            return Application.LoadBamlStreamWithSyncInfo(stream, pc); 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:30,代码来源:AppModelKnownContentFactory.cs

示例8: LoadFromPng

        public static ResourceDictionary LoadFromPng( string FileName )
        {
            // read all file
            PngReader pngr = FileHelper.CreatePngReader(FileName);
            pngr.ReadSkippingAllRows();
            pngr.End();
            // we assume there can be at most one chunk of this type...
            PngChunk chunk = pngr.GetChunksList().GetById1(PngChunkSKIN.ID); // This would work even if not registered, but then PngChunk would be of type PngChunkUNKNOWN

            if (chunk != null) {
                // the following would fail if we had not register the chunk
                PngChunkSKIN chunkprop = (PngChunkSKIN)chunk;
                ParserContext pc = new ParserContext();
                pc.XamlTypeMapper = XamlTypeMapper.DefaultMapper;
              //  pc.XmlSpace

                //MimeObjectFactory s;

                var rd1 = (ResourceDictionary)XamlReader.Parse(chunkprop.Content);

              // Application.Current.Resources.MergedDictionaries.Add(rd1);

              //  var rd2 = (ResourceDictionary)XamlReader.Parse(chunkprop.Content);

              ////  Application.Current.Resources.MergedDictionaries.Add(rd2);

              //  if (rd1 == rd2) {
              //  }

                return rd1;
            } else {
                return null;
            }
        }
开发者ID:johnkramerr,项目名称:Sc2tvChatPub,代码行数:34,代码来源:PngSkin.cs

示例9: WpfContainer

        public WpfContainer()
        {
            Context = new ParserContext();
            Context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
            Context.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");

            XamlFile = null;
        }
开发者ID:DavidSeptimus,项目名称:PowerShell-DAVToolkit,代码行数:8,代码来源:WpfContainer.cs

示例10: XamlToObjectConverter

 static XamlToObjectConverter()
 {
     // Initialize the parser context, which provides xml namespace mappings used when
     // the loose XAML is loaded and converted into a .NET object.
     parserContext = new ParserContext();
     parserContext.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
     parserContext.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:8,代码来源:XamlToObjectConverter.cs

示例11: Parse

		public static FrameworkElement Parse(string xaml)
		{
			var context = new ParserContext();
			context.XmlnsDictionary.Add(string.Empty, "http://schemas.microsoft.com/winfx/2006/xaml/presentation");

			var element = (FrameworkElement)XamlReader.Parse(xaml, context);
			return element;
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:8,代码来源:XamlParser.cs

示例12: ParseXaml

        /// <summary>
        /// Parse a string to WPF object.
        /// </summary>
        /// <param name="str">string to be parsed</param>
        /// <returns>return an object</returns>
        public static object ParseXaml(string str)
        {
            MemoryStream ms = new MemoryStream(str.Length);
            StreamWriter sw = new StreamWriter(ms);
            sw.Write(str);
            sw.Flush();

            ms.Seek(0, SeekOrigin.Begin);

            ParserContext pc = new ParserContext();

            pc.BaseUri = new Uri(System.Environment.CurrentDirectory + "/");

            return XamlReader.Load(ms, pc);
        }
开发者ID:HETUAN,项目名称:PersonalInfoForWPF,代码行数:20,代码来源:XAMLHelper.cs

示例13: EnumComboBox

        /// <summary>
        /// Creates a new instance.
        /// </summary>
        public EnumComboBox()
        {
            var context = new ParserContext();

            context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
            context.XmlnsDictionary.Add("lex", "http://wpflocalizeextension.codeplex.com");

            var xaml = "<DataTemplate><TextBlock><lex:EnumRun EnumValue=\"{Binding}\"";
            xaml += " PrependType=\"{Binding PrependType, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=lex:EnumComboBox}}\"";
            xaml += " Separator=\"{Binding Separator, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=lex:EnumComboBox}}\"";
            xaml += " Prefix=\"{Binding Prefix, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=lex:EnumComboBox}}\"";
            xaml += " /></TextBlock></DataTemplate>";

            ItemTemplate = (DataTemplate)XamlReader.Parse(xaml, context);
        }
开发者ID:SeriousM,项目名称:WPFLocalizationExtension,代码行数:18,代码来源:EnumComboBox.cs

示例14: ParseDocument

		public static FlexDocument ParseDocument(string configFilePath)
		{
			//try
			//{
			var parserContext = new ParserContext();
			var configFileStream = new FileStream(configFilePath, FileMode.Open);
			var configObject = XamlReader.Load(configFileStream, parserContext);
			var chartConfigObject = (FlexDocument)configObject;
			return chartConfigObject;
			//}
			//catch// (Exception ex)
			//{
			//	throw;// ex;// new Exception("Parser fail");
			//} 
		}
开发者ID:JackWangCUMT,项目名称:FlexCharts,代码行数:15,代码来源:FlexDocumentReader.cs

示例15: GetTemplate

        public static ControlTemplate GetTemplate()
        {
            if (m_TemplateCache == null)
            {
                //m_TemplateCache = new ControlTemplate();

                //m_TemplateCache.VisualTree = new System.Windows.FrameworkElementFactory(typeof(TextErrorTemplateVisualtree));
                MemoryStream sr = new MemoryStream(Encoding.ASCII.GetBytes(c_TemplateXaml));
                ParserContext pc = new ParserContext();
                pc.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                pc.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
                m_TemplateCache = (ControlTemplate)XamlReader.Load(sr, pc);
            }
            return m_TemplateCache;
        }
开发者ID:yuxin80,项目名称:QuantConnectDataConverter,代码行数:15,代码来源:TextErrorTemplate.cs


注:本文中的System.Windows.Markup.ParserContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。