Class IntentFile
- Namespace
- IntentSharp.Catalog
- Assembly
- IntentSharp.Catalog.dll
Reads intent file text into definitions and writes definitions as intent file text, with the same reader and the same checks as the catalogs. Use it to exchange definitions with another program or service, or to check a file in a build step.
var read = IntentFile.Read(text, "Orders.ClassifyUrgency.intent.yaml");
foreach (var problem in read.Problems) Console.WriteLine(problem);
var json = IntentFile.Write(read.Definitions[0]); // reads back to an equal definition
var again = IntentFile.Read(json, "Orders.ClassifyUrgency.intent.json");
public static class IntentFile
- Inheritance
-
objectIntentFile
- Inherited Members
-
object.Equals(object)object.Equals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()object.ReferenceEquals(object, object)object.ToString()
Methods
- Read(string, string)
Reads JSON or YAML intent file text: one definition object or a list of them (YAML may also hold several documents). The format follows the extension of
path:.jsonis JSON (comments and trailing commas allowed),.yamland.ymlare YAML. Content never throws: unknown properties, wrong types, invalid rules and duplicate names are returned as problems with the line, and a definition with any problem is left out while the others still load. Each definition's Source ispath.
- Write(IntentDefinition)
Writes
definitionas JSON intent file text, indented. Every property is written, unset ones left out; Source and SourceSequence are not file properties and are not written. A valid definition reads back with Read(string, string) to one equal to it in every file property. The definition is not checked here: Read(string, string) reports what is wrong with it.
- Write(IEnumerable<IntentDefinition>)
Writes
definitionsas one JSON intent file, indented: a list of definition objects, in order. Each is written as Write(IntentDefinition) writes it.