コード例 #1
0
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (typeof(string) == destinationType)
            {
                return(((TreeBlobPath)value).ToString());
            }
            else if (typeof(Errorable <TreeBlobPath>) == destinationType)
            {
                string strValue = value as string;
                if (strValue == null)
                {
                    return((Errorable <TreeBlobPath>)null);
                }

                try
                {
                    // {TreeID}:{CanonicalBlobPath}
                    int colon = strValue.IndexOf(':');
                    if (colon < 0)
                    {
                        return((Errorable <TreeBlobPath>) new TreeID.ParseError("Could not find first ':' char of TreeBlobPath"));
                    }

                    var eroot = TreeID.TryParse(strValue.Substring(0, colon));
                    if (eroot.HasErrors)
                    {
                        return((Errorable <TreeBlobPath>)eroot.Errors);
                    }

                    // TODO: TryParse on CanonicalBlobPath...
                    CanonicalBlobPath path = (CanonicalBlobPath)('/' + strValue.Substring(colon + 1));

                    return((Errorable <TreeBlobPath>) new TreeBlobPath(eroot.Value, path));
                }
                catch (ErrorBase err)
                {
                    return((Errorable <TreeBlobPath>)err);
                }
                catch (Exception ex)
                {
                    return((Errorable <TreeBlobPath>) new InputError(ex.Message));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
コード例 #2
0
        public async Task<Errorable<HtmlFragment>> RenderBlobAsync(CanonicalBlobPath path)
        {
            var mroot = await GetRoot();
            // The most popular error message will be...
            if (!mroot.HasValue) return new ConsistencyError("Either the site is not published or we have no frame of reference on which ");

            // Create a TreeBlobPath to root the blob path in the current root TreeID:
            var tbpath = new TreeBlobPath(mroot.Value, path);

            // Try getting the blob by its path:
            var eblob = await SystemContext.tpsbrepo.GetBlobByTreePath(tbpath);
            if (eblob.HasErrors) return eblob.Errors;
            var blob = eblob.Value.StreamedBlob;

            // Render the blob:
            var efragment = await Engine.RenderBlob(new TreePathStreamedBlob(tbpath, blob));
            if (efragment.HasErrors) return efragment.Errors;

            // Return its output:
            return efragment.Value;
        }
コード例 #3
0
 public TreePathStreamedBlob(TreeID rootTreeID, CanonicalBlobPath path, IStreamedBlob blob)
     : this(new TreeBlobPath(rootTreeID, path), blob)
 {
 }
コード例 #4
0
 public TreeBlobPath(TreeID rootTreeID, CanonicalBlobPath path)
 {
     this.RootTreeID = rootTreeID;
     this.Path = path;
 }
コード例 #5
0
 public RenderBlobResult(RenderingSystemContext renderer, CanonicalBlobPath path)
 {
     this.renderer = renderer;
     this.path = path;
 }
コード例 #6
0
 public MaybeTreeBlobPath(Maybe<TreeID> rootTreeID, CanonicalBlobPath path)
 {
     this.RootTreeID = rootTreeID;
     this.Path = path;
 }
コード例 #7
0
 public MaybeTreeBlobPath(Maybe <TreeID> rootTreeID, CanonicalBlobPath path)
 {
     this.RootTreeID = rootTreeID;
     this.Path       = path;
 }
コード例 #8
0
 public TreeBlobPath(TreeID rootTreeID, CanonicalBlobPath path)
 {
     this.RootTreeID = rootTreeID;
     this.Path       = path;
 }
コード例 #9
0
 public CanonicalBlobIDPath(CanonicalBlobPath path, BlobID blobID)
 {
     this.Path = path;
     this.BlobID = blobID;
 }
コード例 #10
0
 public CanonicalBlobIDPath(CanonicalBlobPath path, BlobID blobID)
 {
     this.Path   = path;
     this.BlobID = blobID;
 }
コード例 #11
0
 public TreePathStreamedBlob(TreeID rootTreeID, CanonicalBlobPath path, IStreamedBlob blob)
     : this(new TreeBlobPath(rootTreeID, path), blob)
 {
 }