• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Markup.ParserContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CreateTemplate

            private static DataTemplate CreateTemplate(Type viewModelType, Type viewType)
            {
                var xaml = $"<DataTemplate DataType=\"{{x:Type vm:{viewModelType.Name}}}\"><v:{viewType.Name} /></DataTemplate>";

                var context = new ParserContext();

                context.XamlTypeMapper = new XamlTypeMapper(new string[0]);
                context.XamlTypeMapper.AddMappingProcessingInstruction("vm", viewModelType.Namespace, viewModelType.Assembly.FullName);
                context.XamlTypeMapper.AddMappingProcessingInstruction("v", viewType.Namespace, viewType.Assembly.FullName);

                context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                context.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
                context.XmlnsDictionary.Add("vm", "vm");
                context.XmlnsDictionary.Add("v", "v");

                var template = (DataTemplate)XamlReader.Parse(xaml, context);
                return template;
            }
开发者ID:distantcam,项目名称:ServiceInsight2,代码行数:18,代码来源:ViewModelTemplateSelector.cs


示例17: CreateTemplate

        private DataTemplate CreateTemplate()
        {
            const string xamlTemplate = "<DataTemplate x:Name=\"Tpl\">" +
                                        "   <TextBox Background=\"{{Binding Background, ElementName=Txt}}\"" +
                                        "            Text=\"{{Binding Value}}\" />" +
                                        "</DataTemplate>";
            var xaml = string.Format(xamlTemplate);

            var context = new ParserContext();

            var type = typeof(DataTemplateSampleView);
            context.XamlTypeMapper = new XamlTypeMapper(new string[0]);
            context.XamlTypeMapper.AddMappingProcessingInstruction("v", type.Namespace, type.Assembly.FullName);

            context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
            context.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
            context.XmlnsDictionary.Add("v", "v");

            var template = (DataTemplate) XamlReader.Parse(xaml, context);
            return template;
        }
开发者ID:MaxGaranin,项目名称:WpfSamples,代码行数:21,代码来源:DataTemplateSampleView.xaml.cs


示例18: Run

        public override void Run()
        {
            String xamlFile = null;

              using (var writer = new System.IO.StringWriter()) {
            using (var ofd = new System.Windows.Forms.OpenFileDialog() {
                 Filter = "XAML File|*.xaml"
               }) {
              if (ofd.ShowDialog() != DialogResult.OK)
            return;
              xamlFile = ofd.FileName;
            }
              }
              var xamlStr = System.IO.File.ReadAllText(xamlFile);
              var pc = new ParserContext();
              //
              pc.XamlTypeMapper = new XamlTypeMapper(new string[] {  });
              //
              pc.XamlTypeMapper.AddMappingProcessingInstruction("ad", "AvalonDock", "AvalonDock");
              pc.XamlTypeMapper.AddMappingProcessingInstruction("adRes", "AvalonDock.Properties", "AvalonDock");
              pc.XamlTypeMapper.AddMappingProcessingInstruction("sys", "System", "mscorlib");
              pc.XamlTypeMapper.AddMappingProcessingInstruction("th", "ThemeTool","AnotherThemeTool");
              //
              pc.XmlnsDictionary.Add("ad", "ad");
              pc.XmlnsDictionary.Add("adRes", "adRes");
              pc.XmlnsDictionary.Add("sys", "sys");
              pc.XmlnsDictionary.Add("th", "th");
              Assembly.LoadWithPartialName("AnotherThemeTool");
            //      pc.BaseUri = new Uri(@"clr-namespace:AnotherThemeTool",UriKind.RelativeOrAbsolute);
              var rd = (ResourceDictionary)XamlReader.Parse(xamlStr);
              //
              AvalonDock.ThemeFactory.ResetTheme();
            //      System.Windows.Application.Current.Resources.MergedDictionaries.Add(
            //        new ResourceDictionary{Source=new Uri(@"/AvalonDock;component/themes/generic.xaml",UriKind.RelativeOrAbsolute)}
            //       );
              System.Windows.Application.Current.Resources.MergedDictionaries.Add(rd);
        }
开发者ID:tfwio,项目名称:sd-ext,代码行数:37,代码来源:LoadXamlTheme.cs


示例19: CreateContentTemplate

        private static DataTemplate CreateContentTemplate()
        {
            const string xaml =
                "<DataTemplate><Border b:TabContent.InternalTabControl=\"{Binding RelativeSource={RelativeSource AncestorType=TabControl}}\" /></DataTemplate>";

            var context = new ParserContext();

            context.XamlTypeMapper = new XamlTypeMapper(new string[0]);
            context.XamlTypeMapper.AddMappingProcessingInstruction("b", typeof (TabContent).Namespace,
                typeof (TabContent).Assembly.FullName);

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

            var template = (DataTemplate) XamlReader.Parse(xaml, context);
            return template;
        }
开发者ID:MozzieMD,项目名称:Popcorn,代码行数:17,代码来源:TabContent.cs


示例20: LoadAsync

		public object LoadAsync (Stream stream, ParserContext context)
		{
			if (stream == null || context == null)
				throw new ArgumentNullException ();
			throw new NotImplementedException ();
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:6,代码来源:XamlReader.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Media.ArcSegment类代码示例发布时间:2022-05-26
下一篇:
C# Interop.WindowInteropHelper类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap