Ejemplo n.º 1
0
        public void Bind(string key, SillyView view)
        {
            if (view == null ||
                view.Html == null)
            {
                TextNode errorNode = new TextNode("Error binding " + key + ": no view or HTML to bind");

                BindVals[key] = new SillyTextAttribute(key, errorNode);

                return;
            }

            BindVals[key] = new SillyWidgetAttribute(key, view.Html.Root);
        }
Ejemplo n.º 2
0
        public async Task <bool> BindAsync(string key, string bucket, string bucketKey, Amazon.RegionEndpoint endpoint)
        {
            SillyView s3View = new SillyView();

            bool loaded = await s3View.LoadS3Async(bucket, bucketKey, endpoint);

            if (loaded)
            {
                Bind(key, s3View);
            }
            else
            {
                Bind(key, "Silly view not found: " + key);
            }

            return(loaded);
        }
Ejemplo n.º 3
0
        public SillyView Load(string filepath)
        {
            if (filepath == null ||
                filepath.Length == 0)
            {
                throw new SillyException(SillyHttpStatusCode.NotFound, "Invalid view file specified, either NULL or empty");
            }

            if (!File.Exists(filepath))
            {
                throw new SillyException(SillyHttpStatusCode.NotFound, "View file '" + filepath + "' does not exist");
            }

            SillyView  view       = null;
            FileStream fileStream = new FileStream(filepath, FileMode.Open);

            using (StreamReader reader = new StreamReader(fileStream))
            {
                view = new SillyView();
                view.Load(reader);
            }

            return(view);
        }