Documentation
Table of Contents

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
object
IntentFile
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: .json is JSON (comments and trailing commas allowed), .yaml and .yml are 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 is path.

Write(IntentDefinition)

Writes definition as 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 definitions as one JSON intent file, indented: a list of definition objects, in order. Each is written as Write(IntentDefinition) writes it.