12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using HTEXLib.Models.Inner;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Net;
- using System.Text;
- using System.Xml;
- namespace HTEXLib.COMM.Helpers
- {
- public class CustomXmlResolver : XmlResolver
- {
- public CustomXmlResolver() { }
- public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
- {
- MemoryStream entityStream = null;
- switch (absoluteUri.Scheme)
- {
- case "custom-scheme":
- string absoluteUriOriginalString = absoluteUri.OriginalString;
- string ctgXsltEntityName = absoluteUriOriginalString.Substring(absoluteUriOriginalString.IndexOf(":") + 1);
- string entityXslt = "";
- // TODO: Replace the following with your own code to load data for referenced entities.
- switch (ctgXsltEntityName)
- {
- case "tokens.xsl":
- //entityXslt= System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\tokens.xsl");
- entityXslt = Globals.tokens;
- break;
- case "glayout.xsl":
- //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\glayout.xsl");
- entityXslt = Globals.glayout;
- break;
- case "scripts.xsl":
- //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\scripts.xsl");
- entityXslt = Globals.scripts;
- break;
- case "tables.xsl":
- //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\tables.xsl");
- entityXslt = Globals.tables;
- break;
- case "entities.xsl":
- //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\entities.xsl");
- entityXslt = Globals.entities;
- break;
- case "cmarkup.xsl":
- //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\cmarkup.xsl");
- entityXslt = Globals.cmarkup;
- break;
- }
- UTF8Encoding utf8Encoding = new UTF8Encoding();
- byte[] entityBytes = utf8Encoding.GetBytes(entityXslt);
- entityStream = new MemoryStream(entityBytes);
- break;
- }
- return entityStream;
- }
- public override Uri ResolveUri(Uri baseUri, string relativeUri)
- {
- // You might want to resolve all reference URIs using a custom scheme.
- if (baseUri != null)
- return base.ResolveUri(baseUri, relativeUri);
- else
- return new Uri("custom-scheme:" + relativeUri);
- }
- }
- }
|