public static void Main(string[] commandArgs) { try { var record = new Record(); record.Add(new Property("title", "My Title")); record.Add(new Property("header", "My Header")); var link = new Link(); link.Add(new Property("title", "My Title")); link.Add(new Property("href", "My #ref")); link.Add(new Property("header", "My Header")); link.Add(new Class("header")); link.Add(new Rel("header")); record.Add(link); var file = new ResourceRef(); file.Add(new Property("title", "My Title")); file.Add(new Property("href", "My #ref")); file.Add(new Property("header", "My Header")); file.Add(new Class("header")); file.Add(new Rel("header")); record.Add(file); record.Add(new Property("__meta", Value.CreateObject(new { Tables = new { Headers = new VName[] { "Id", "Name" } } }))); var p1 = record.GetProperty <VArray>("__meta.tables.headers"); record.SetProperty("__meta.tables.headers.id", new[] { 10 }); var p2 = record.GetProperty <VArray>("__meta.tables.headers.id"); var serializer = new MediaSerializer(MimeType.JsonSiren); var step1 = serializer.Serialize(record); var target = serializer.Deserialize(step1); var step2 = serializer.Serialize(record); Debug.WriteLine(Json.Beautify(step1)); Debug.WriteLine(Json.Beautify(step2)); } catch (Exception ex) { ex.Trace(); } }
} // SetSortOrder /// <summary> /// Adds a new link to the tblLink table. /// </summary> /// <param name="caption"> The new caption for the link.</param> /// <param name="url"> The new Url for the link.</param> /// <param name="showDisclaimer"> The new setting for the ShowDisclaimer.</param> private void AddLink(string caption, string url, bool showDisclaimer) { try { //1. Get the UserID. int intUserID = UserContext.UserID; //3. Add the new record. Link objLink = new Link(); objLink.Add(UserContext.UserData.OrgID, caption, url, showDisclaimer, intUserID); this.grdResults.EditItemIndex = -1; Response.Redirect("ModifyLinks.aspx"); } catch (ParameterException ex) { throw ex; } catch (UniqueViolationException ex) { this.lblMessage.Text = ex.Message; this.lblMessage.CssClass = "WarningMessage"; } catch (Exception ex) //Unexpected error. { throw ex; } } // AddLink
private static async Task WriteEntityAsync(IResponse res, IEntity entity, HttpStatusCode status = HttpStatusCode.OK) { var req = res.Context.Request; var accept = req.Headers[HeaderNames.Accept] ?? MimeTypeNames.JsonSiren; var contentType = MediaSerializer.ParseMediaType(accept); var hasSelf = ( from link in entity.OfType <Link>() from rel in link.OfType <Rel>() where rel.Name == Rel.Self.Name select link ).Any(); if (!hasSelf) { var link = new Link(); link.Href = req.RequestUri; link.Add(Rel.Self); entity.Add(link); } res.Status = status; res.Headers[HeaderNames.ContentType] = $"{contentType}; charset=UTF-8"; var serializer = new MediaSerializer(contentType); serializer.Serialize(entity, res.Body); await Task.Yield(); }
public virtual void Add(TLink link) { if (Link == null) { Link = link; } else { Link.Add(link); } }
public AdvanceArray(FuzzyData.FuzzyArray array) { // Initialize exists = false; classname = ""; // Check FuzzyData.FuzzyObject fob; foreach (object ob in array) { if ((fob = ob as FuzzyData.FuzzyObject) == null) { return; } else if (fob == FuzzyData.FuzzyNil.Instance) { continue; } else if (ClassName == "") { classname = fob.ClassName.Name; } else if (fob.ClassName.Name != ClassName) { return; } } exists = true; // Data int i = 0, j = 0; foreach (object ob in array) { base.Add(ob); fob = ob as FuzzyData.FuzzyObject; if (fob == FuzzyData.FuzzyNil.Instance) { continue; } else { Link.Add(i++, j); Data.Add(fob); } j++; } }
private void setEntry(string rel, Uri uri) { if (Link == null) { Link = new List <BundleLinkComponent>(); } var entry = Link.FirstOrDefault(e => rel.Equals(e.Relation, StringComparison.OrdinalIgnoreCase)); if (entry != null) { entry.Url = uri.ToString(); } else { Link.Add(new BundleLinkComponent() { Relation = rel, Url = uri.ToString() }); } }
public void Refresh() { int i = 0, j = 0; FuzzyData.FuzzyObject fob; link.Clear(); Data.Clear(); foreach (object ob in this) { fob = ob as FuzzyData.FuzzyObject; if (fob == FuzzyData.FuzzyNil.Instance) { continue; } else { Link.Add(i++, j); Data.Add(fob); } j++; } }
private void setLink(string rel, Uri uri) { if (Link == null) { Link = new List <LinkComponent>(); } var entry = Link.FirstOrDefault(e => rel.Equals(e.Relation, StringComparison.OrdinalIgnoreCase)); var uriString = uri.IsAbsoluteUri ? uri.AbsoluteUri : uri.OriginalString; if (entry != null) { entry.Url = uriString; } else { Link.Add(new LinkComponent() { Relation = rel, Url = uriString }); } }
private TextElement[] CreateText(string text) { var results = new List <TextElement>(); if (text.Length == 0) { return(new TextElement[0]); } var options = new[] { new CreateTextOption() { Pattern = inlineCodeMatcher, Evaluator = (match) => new InlineCode(match.Groups[1].Value) }, new CreateTextOption() { Pattern = formulaMatcher, Evaluator = (match) => new Formula(match.Groups[1].Value), }, new CreateTextOption() { Pattern = urlMatcher, Evaluator = (match) => { var link = new Link(); link.Target = match.Groups[2].Value; foreach (var item in CreateText(match.Groups[1].Value)) { link.Add(item); } return(link); }, }, new CreateTextOption() { Pattern = boldMatcher, Evaluator = (match) => { var bold = new Bold(); foreach (var item in CreateText(match.Groups[1].Value)) { bold.Add(item); } return(bold); }, }, new CreateTextOption() { Pattern = italicMatcher, Evaluator = (match) => { var bold = new Italic(); foreach (var item in CreateText(match.Groups[1].Value)) { bold.Add(item); } return(bold); }, }, }; for (int i = 0; i < options.Length; i++) { if (ProcessPattern(results, text, options[i].Pattern, options[i].Evaluator)) { return(results.ToArray()); } } return(new[] { new Run(text) }); }