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


C# XmlUrlResolver.GetEntity方法代码示例

本文整理汇总了C#中System.Xml.XmlUrlResolver.GetEntity方法的典型用法代码示例。如果您正苦于以下问题:C# XmlUrlResolver.GetEntity方法的具体用法?C# XmlUrlResolver.GetEntity怎么用?C# XmlUrlResolver.GetEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlUrlResolver的用法示例。


在下文中一共展示了XmlUrlResolver.GetEntity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEntity

 public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
 {
     string name = absoluteUri.AbsoluteUri.Split(new char[] { '/' }).Last<string>();
     byte[] stream = _schemas[name];
     if (stream != null)
     {
         return new MemoryStream(stream);;
     }
     XmlUrlResolver resolver = new XmlUrlResolver();
     return resolver.GetEntity(absoluteUri, role, ofObjectToReturn);
 }
开发者ID:rretamal,项目名称:Hexa.Core,代码行数:11,代码来源:Resolver.cs

示例2: Form1

        public Form1()
        {
            InitializeComponent();
            XmlUrlResolver resolver = new XmlUrlResolver();
            Uri myUri = new Uri("http://dgcsc.org/goldprices.xml");
            Stream s = (Stream)resolver.GetEntity(myUri, null, typeof(Stream));
            // Construct a reader using the Stream object.
            XmlTextReader xmlTextReader = new XmlTextReader(s);

            XmlDataDocument xdoc1 = new XmlDataDocument();
            xdoc1.DataSet.ReadXml(xmlTextReader, XmlReadMode.Auto);

            DataSet ds = xdoc1.DataSet;
            //DataTable dt = ds;
            dataGridView1.DataSource = ds.Tables[1];
        }
开发者ID:phi0975490801,项目名称:Developer-Demo,代码行数:16,代码来源:Form1.cs

示例3: GetEntity

        public override object GetEntity(Uri absoluteUri, string role,
            Type ofObjectToReturn)
        {
            Object entityObj = null;
            String strURI = absoluteUri.AbsoluteUri;
            System.IO.MemoryStream msStream = null;

            switch (strURI.ToLower())
            {
                case "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd":
                    msStream = new MemoryStream(ResourceDTD.xhtml1_transitional);
                    break;
                case "http://www.w3.org/tr/xhtml1/dtd/xhtml1.dcl":
                    msStream = new MemoryStream(ResourceDTD.xhtml1);
                    break;
                case "http://www.w3.org/tr/xhtml1/dtd/xhtml-lat1.ent":
                    msStream = new MemoryStream(ResourceDTD.xhtml_lat1);
                    break;
                case "http://www.w3.org/tr/xhtml1/dtd/xhtml-special.ent":
                    msStream = new MemoryStream(ResourceDTD.xhtml_special);
                    break;
                case "http://www.w3.org/tr/xhtml1/dtd/xhtml-symbol.ent":
                    msStream = new MemoryStream(ResourceDTD.xhtml_symbol);
                    break;
                case "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd":
                    msStream = new MemoryStream(ResourceDTD.xhtml1_strict);
                    break;
                case "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd":
                    msStream = new MemoryStream(ResourceDTD.xhtml1_frameset);
                    break;
                case "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd":
                    msStream = new MemoryStream(ResourceDTD.xhtml11);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlstyle-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_inlstyle_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-framework-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_framework_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-datatypes-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_datatypes_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-qname-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_qname_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-events-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_events_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-attribs-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_attribs_1);
                    break;
                case "http://www.w3.org/tr/xhtml11/dtd/xhtml11-model-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml11_model_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-charent-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_charent_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-lat1.ent":
                    msStream = new MemoryStream(ResourceDTD.xhtml_lat11);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-symbol.ent":
                    msStream = new MemoryStream(ResourceDTD.xhtml_symbol11);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-special.ent":
                    msStream = new MemoryStream(ResourceDTD.xhtml_special11);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-text-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_text_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlstruct-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_inlstruct_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlphras-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_inlphras_1);
                    break;
                case "http://www.w3.org/tr/ruby/xhtml-ruby-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_ruby_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-blkstruct-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_blkstruct_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-blkphras-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_blkphras_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-hypertext-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_hypertext_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-list-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_list_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-edit-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_edit_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-bdo-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_bdo_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-pres-1.mod":
                    msStream = new MemoryStream(ResourceDTD.xhtml_pres_1);
                    break;
                case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlpres-1.mod":
//.........这里部分代码省略.........
开发者ID:bpaciao,项目名称:pagereleaser,代码行数:101,代码来源:XHTMLResolver.cs

示例4: CompileProlog

		private void CompileProlog ()
		{
			Prolog p = module.Prolog;

			// resolve external modules
			// FIXME: check if external queries are allowed by default.
			// FIXME: check recursion
			XmlUrlResolver res = new XmlUrlResolver ();
			foreach (ModuleImport modimp in p.ModuleImports) {
				foreach (string uri in modimp.Locations) {
					Stream s = res.GetEntity (res.ResolveUri (null, uri), null, typeof (Stream)) as Stream;
					XQueryLibraryModule ext = Mono.Xml.XQuery.Parser.Parser.Parse (new StreamReader (s)) as XQueryLibraryModule;
					if (ext == null)
						throw new XmlQueryCompileException (String.Format ("External module {0} is resolved as a main module, while it should be a library module."));
					XQueryStaticContext sctx = new XQueryASTCompiler (ext, options, compileContext, evidence, commandImpl).Compile ();
					libModuleContexts.Add (sctx);
				}
			}

			// resolve and compile in-scope schemas
			foreach (SchemaImport xsimp in p.SchemaImports) {
				foreach (string uri in xsimp.Locations) {
					XmlSchema schema = inScopeSchemas.Add (xsimp.Namespace, uri);
					compileContext.InEffectSchemas.Add (schema);
				}
			}
			inScopeSchemas.Compile ();

			CheckReferences ();

			ResolveVariableReferences ();

			// compile FunctionDeclaration into XQueryFunction
			foreach (FunctionDeclaration func in p.Functions.Values) {
				XQueryFunction cfunc = CompileFunction (func);
				localFunctions.Add (cfunc);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:38,代码来源:XQueryASTCompiler.cs

示例5: ReadFile

 public static string ReadFile(string path, bool skipdeclaration){
     var res = new XmlUrlResolver();
     var uri = res.ResolveUri(null, path);
     var s = (Stream) res.GetEntity(uri, "standard", typeof (Stream));
     try{
         var sw = new StringWriter();
         var w = XmlWriter.Create(sw);
         var r = XmlReader.Create(s);
         if (skipdeclaration){
             r.Read();
             if (!(r.NodeType == XmlNodeType.XmlDeclaration)) w.WriteNode(r, false);
             else r.Read();
         }
         while (!r.EOF) w.WriteNode(r, false);
         w.Flush();
         return sw.ToString();
     }
     finally{
         s.Close();
     }
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:21,代码来源:XmlUtil.cs

示例6: ResolveSchemaLocation

 private Stream ResolveSchemaLocation(XmlSchema enclosingSchema, string location, out string fullPath) {
     Stream stream;
     fullPath = null;
     try {
         XmlResolver resolver = new XmlUrlResolver();
         Uri ruri = resolver.ResolveUri((enclosingSchema.BaseUri != null && enclosingSchema.BaseUri != String.Empty) ? resolver.ResolveUri(null, enclosingSchema.BaseUri) : null, location);
         stream = (Stream)resolver.GetEntity(ruri, null, null);
         fullPath = ruri.ToString();
     }
     catch {
         return null;
     }
     return stream;
 }
开发者ID:ArildF,项目名称:masters,代码行数:14,代码来源:xmlschema.cs


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