public static ILexicalContextmenu Create(this ILexical lexical) { Validate.NotNull(lexical, nameof(lexical)); return(lexical.Match() .Case((IReferencer r) => CreateForReferencer(r)) .Case((IVerbal v) => CreateForVerbal(v)) .Result()); }
private static IEnumerable <JProperty> GetStructuralProperties(ILexical element) => from result in element.Match() .Case((Phrase p) => new JProperty("words", p.Words.ToJArray())) .Case((Clause c) => new JProperty("phrases", c.Phrases.ToJArray())) select result;
/// <summary> /// Creates a Newtonsoft.Linq.JObject representation of the lexical. /// </summary> /// <param name="lexical">The source entity.</param> /// <returns>A Newtonsoft.Linq.JObject representation of the lexical.</returns> public static JObject ToJObject(this ILexical lexical) => lexical.Match() .Case((IEntity e) => e.ToJObject()) .Case((IVerbal v) => v.ToJObject()) .Case((IAdverbial a) => a.ToJObject()) .Result(new JObject(GetRoleIndependentProperties(lexical)));