예제 #1
0
        /// <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);
        }
예제 #2
0
 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;
 }
예제 #4
0
 public InfinityApiBase TryResolveApi(ProxyUri uri)
 {
     if (_apiDict.ContainsKey(uri.ApiName))
     {
         return(_apiDict[uri.ApiName](this));
     }
     return(null);
 }
예제 #5
0
        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));
        }
예제 #6
0
        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);
        }
예제 #7
0
        /// <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;
 }
예제 #9
0
        public virtual bool HasTemplate(ProxyUri uri)
        {
            string templatePath = TryGetTemplatePath(uri);

            return(!string.IsNullOrEmpty(templatePath) && File.Exists(templatePath));
        }
예제 #10
0
 protected string TryResolveTemplateName(ProxyUri uri)
 {
     return(uri.TemplateName);
 }