protected NodeEndpoint(N Node, SystemUri Identifier, Type EndpointType, EndpointRole Role) { this.Node = Node; this.Identifier = Identifier; this.Role = Role; this.EndpointType = EndpointType; }
public static Option <string> get(SystemUri query) => Use(HttpBasicClient.Client(uri(query)), client => { var response = client.GetAsync(string.Empty).Result; var content = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode) { return(content); } throw new Exception(($"{response.StatusCode} {content}")); });
public Option <T> FindEntity <T>(SystemUri id) => from e in Lookup(ifNull(id, () => typeof(T).Uri())) from r in TryReconsitute <T>(e.Body) select r;
public Option <SystemUri> SaveEntity <T>(T Body, SystemUri id) => from j in TrySerialize(Body) from s in Persist(ifNull(id, () => typeof(T).Uri()), typeof(T).Uri(), j) select s;
Option <SystemUri> Persist(SystemUri id, SystemUri type, Json json) => from saved in id.ToLocalPath().TryWriteAllText(json) select id;
Option <JsonEntity> Lookup(SystemUri id) => from text in id.ToLocalPath().TryReadAllText() let json = Json.FromText(text) from recon in TryReconsitute <JsonEntity>(json) select recon;
protected CatalogSubject(SystemUri Uri, INodeCatalogSubject Parent = null) : this(new SystemResourceScheme(Uri.Scheme), Uri.Host, Uri.Path, Parent) { }
/// <summary> /// Converts the uri to a local file system path /// </summary> /// <param name="uri">The uri to convert</param> /// <returns></returns> public static FilePath ToLocalPath(this SystemUri uri) => string.Join(bslash(), uri.Path.Components());
/// <summary> /// Converts a text-based uri representation to a <see cref="SystemUri"/> representation /// </summary> /// <param name="uriText"></param> /// <returns></returns> public static SystemUri uri(string uriText) => SystemUri.Parse(uriText);