Ejemplo n.º 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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 4
0
 public InfinityApiBase TryResolveApi(ProxyUri uri)
 {
     if (_apiDict.ContainsKey(uri.ApiName))
     {
         return(_apiDict[uri.ApiName](this));
     }
     return(null);
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 9
0
        public virtual bool HasTemplate(ProxyUri uri)
        {
            string templatePath = TryGetTemplatePath(uri);

            return(!string.IsNullOrEmpty(templatePath) && File.Exists(templatePath));
        }
Ejemplo n.º 10
0
 protected string TryResolveTemplateName(ProxyUri uri)
 {
     return(uri.TemplateName);
 }