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)); }
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; }
public TreePathStreamedBlob(TreeID rootTreeID, CanonicalBlobPath path, IStreamedBlob blob) : this(new TreeBlobPath(rootTreeID, path), blob) { }
public TreeBlobPath(TreeID rootTreeID, CanonicalBlobPath path) { this.RootTreeID = rootTreeID; this.Path = path; }
public RenderBlobResult(RenderingSystemContext renderer, CanonicalBlobPath path) { this.renderer = renderer; this.path = path; }
public MaybeTreeBlobPath(Maybe<TreeID> rootTreeID, CanonicalBlobPath path) { this.RootTreeID = rootTreeID; this.Path = path; }
public MaybeTreeBlobPath(Maybe <TreeID> rootTreeID, CanonicalBlobPath path) { this.RootTreeID = rootTreeID; this.Path = path; }
public CanonicalBlobIDPath(CanonicalBlobPath path, BlobID blobID) { this.Path = path; this.BlobID = blobID; }