Esempio n. 1
0
        public Template(SorentoLib.Session Session, string Filename)
        {
            this._session = Session;
            this._content = new List<System.String> ();
            this._blocks = new List<SorentoLib.Render.Block> ();

            this._filename = Filename;

            if (SorentoLib.Render.Template.ExpIsRoot.Match (this._filename).Success)
            {
                this._path = SorentoLib.Services.Config.Get<string> (Enums.ConfigKey.path_content);
            }
            else
            {
                this._path = SorentoLib.Services.Config.Get<string> (Enums.ConfigKey.path_content) + "/" + System.IO.Path.GetDirectoryName (Session.Request.Environment.RequestUri) + "/";
            }

            if (this._filename == string.Empty)
            {
                this._path = SorentoLib.Services.Config.Get<string> (Enums.ConfigKey.path_content) + System.IO.Path.GetDirectoryName (Session.Request.Environment.RequestUri) +"/";
                this._filename = System.IO.Path.GetFileName (Session.Request.Environment.RequestUri);

                if (this._filename == string.Empty)
                {
                    this._filename = "index";
                }
            }

            this._filename = this._path + this._filename;

            if (System.IO.Path.GetExtension (this._filename) != ".stpl")
            {
                this._filename += ".stpl";
            }

            if (File.Exists (this._filename))
            {
                if (SorentoLib.Services.Cache.Enabled)
                {
                    if (SorentoLib.Services.Cache.Exists (this._filename))
                    {
                        this._content = SorentoLib.Services.Cache.Get (this._filename);
                    }
                    else
                    {
                        this._content = SorentoLib.Services.Cache.Add (this._filename);
                    }
                }
                else
                {
                    this._content = SorentoLib.Render.Template.Read (this._filename);
                }
            }
            else
            {
            //				SorentoLib.Services.Events.InvokeTemplateRenderFailed(this._session, this);
            //				SorentoLib.Services.Logging.LogWarning("Template was not found : "+ this._filename);

            //				throw new Exceptions.RenderException (string.Format ())
                throw new Exception (string.Format (Strings.Exception.RenderTemplateLoad, this._filename));
            }
        }
Esempio n. 2
0
 public Template(SorentoLib.Session Session, List<string> Content)
 {
     this._session = Session;
     this._content = Content;
     this._blocks = new List<SorentoLib.Render.Block> ();
 }