/// <summary> /// /{name}/1.jpg => {bin}/{name}/1.jpg /// /{name}/path1/1.jpg => {bin}/{name}/path1/1.jpg /// /{name}/path2/path1/1.jpg => {bin}/{name}/path1/path2/1.jpg /// </summary> public virtual string GetProxyFilePath(ProxyUri uri) { string convertedPath = uri.AbsolutePath.Replace("/", "\\").TrimStart('\\'); string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, convertedPath); return(filePath); }
public InfinityServerSite(ProxyUri uri, IOwinRequest request, IOwinResponse response) { this.Uri = uri; this.Request = request; this.Response = response; this.RequestOption = GetSourceRequestOption(); }
public InfinityServerHandler(IOwinContext context) { this._context = context; this._uri = new ProxyUri(context.Request); this._site = new InfinityServerSite(this._uri, this.Request, this.Response); this._mapping = this._site.MainMapping; }
public InfinityApiBase TryResolveApi(ProxyUri uri) { if (_apiDict.ContainsKey(uri.ApiName)) { return(_apiDict[uri.ApiName](this)); } return(null); }
protected InfinityServerModel GetProxyModel(ProxyUri uri) { string templateName = TryResolveTemplateName(uri); if (_modelTypeDict.ContainsKey(templateName)) { return(Activator.CreateInstance(_modelTypeDict[templateName], this) as InfinityServerModel); } return(new InfinityServerModel(this)); }
public string ParseHtml(ProxyUri uri) { InfinityServerModel model = GetProxyModel(uri); string templatePath = TryGetTemplatePath(uri); string layoutPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "Shared", "_Layout.cshtml"); var builder = new CodeBuilder <InfinityServerModel>(templatePath, model); builder.LoadLayout(layoutPath); string result = builder.Generate(); return(result); }
/// <summary> /// _index => {name}/_index.cshtml /// path1 => {name}/path1.cshtml /// path1/path2 => {name}/path1/path2.cshtml /// </summary> /// <param name="proxyPath"></param> /// <returns></returns> protected virtual string TryGetTemplatePath(ProxyUri uri) { string result = null; string templateName = TryResolveTemplateName(uri); if (!string.IsNullOrEmpty(templateName)) { string templateFileName = string.Format("{0}.cshtml", templateName); result = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", templateFileName); } return(result); }
public InfinityServerModel(InfinityServerSite site) { this._uri = site.Uri; this._site = site; }
public virtual bool HasTemplate(ProxyUri uri) { string templatePath = TryGetTemplatePath(uri); return(!string.IsNullOrEmpty(templatePath) && File.Exists(templatePath)); }
protected string TryResolveTemplateName(ProxyUri uri) { return(uri.TemplateName); }