/// <summary> /// Builds a collection of annotations. /// </summary> /// <param name="sut">The Subject Under Test.</param> /// <returns>The collection of annotations.</returns> private IReadOnlyCollection <ITerm> BuildAnnos(ITermFactory sut) { var annos = new ITerm[] { sut.String("Annotation") }; return(annos); }
private IStringTerm Concat(ITermFactory factory, IListTerm <IStringTerm> strs) { var sb = new StringBuilder(strs.Sum(s => s.Value.Length)); foreach (var s in strs) { sb.Append(s.Value); } return(factory.String(sb.ToString())); }
/// <summary> /// Builds a new string term. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="value">The value of the term.</param> /// <returns>The string term.</returns> public static IStringTerm String(this ITermFactory termFactory, string value) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } #endregion return(termFactory.String(value, Enumerable.Empty <ITerm>())); }
/// <summary> /// Builds a new integer term. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="value">The value of the term.</param> /// <returns>The built term.</returns> public static IIntTerm Int(this ITermFactory termFactory, int value) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } #endregion return(termFactory.Int(value, Enumerable.Empty <ITerm>())); }
/// <summary> /// Creates a reader for this format. /// </summary> /// <param name="termFactory">The term factory to use.</param> /// <returns>The created <see cref="ATermReader"/>.</returns> public ATermReader CreateReader(ITermFactory termFactory) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } #endregion return(new ATermReader(termFactory)); }
/// <summary> /// Initializes a new instance of the <see cref="AstBuilder"/> class. /// </summary> public AstBuilder(ITermFactory termFactory) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } #endregion this.termFactory = termFactory; }
/// <summary> /// Initializes a new instance of the <see cref="ListTerm{T}"/> class. /// </summary> /// <param name="factory">The factory that created this term.</param> /// <param name="elements">The elements.</param> /// <param name="annotations">The annotations of the term.</param> public ListTerm(ITermFactory factory, IReadOnlyList <T> elements, IReadOnlyCollection <ITerm> annotations) : base(factory, annotations) { #region Contract if (elements == null) { throw new ArgumentNullException(nameof(elements)); } #endregion this.Elements = elements; }
/// <summary> /// Initializes a new instance of the <see cref="StringTerm"/> class. /// </summary> /// <param name="factory">The factory that created this term.</param> /// <param name="value">The value.</param> /// <param name="annotations">The annotations of the term.</param> public StringTerm(ITermFactory factory, string value, IReadOnlyCollection <ITerm> annotations) : base(factory, annotations) { #region Contract if (value == null) { throw new ArgumentNullException(nameof(value)); } #endregion this.Value = value; }
/// <summary> /// Initializes a new instance of the <see cref="TypeATerm"/> class. /// </summary> /// <param name="factory">The factory that created this term.</param> /// <param name="name">The name.</param> /// <param name="annotations">The annotations of the term.</param> public TypeATerm(ITermFactory factory, IStringTerm name, IReadOnlyCollection <ITerm> annotations) : base(factory, annotations) { #region Contract if (name == null) { throw new ArgumentNullException(nameof(name)); } #endregion this.Name = name; this.subterms = new SubtermCollection(this); }
/// <summary> /// Initializes a new instance of the <see cref="ATermReader"/> class. /// </summary> /// <param name="termFactory">The term factory to use.</param> /// <param name="culture">The culture of the reader.</param> internal ATermReader(ITermFactory termFactory, CultureInfo culture) : base(termFactory, culture) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } if (culture == null) { throw new ArgumentNullException(nameof(culture)); } #endregion }
/// <summary> /// Creates a new term of the specified type, with the specified subterms and annotations. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="subterms">The subterms.</param> /// <returns>The created term.</returns> public static T Create <T>(this ITermFactory termFactory, IEnumerable <ITerm> subterms) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } if (subterms == null) { throw new ArgumentNullException(nameof(subterms)); } #endregion return(termFactory.Create <T>(subterms, Enumerable.Empty <ITerm>())); }
/// <summary> /// Initializes a new instance of the <see cref="TermTextReader"/> class. /// </summary> /// <param name="termFactory">The term factory to use.</param> /// <param name="culture">The culture of the reader.</param> protected TermTextReader(ITermFactory termFactory, CultureInfo culture) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } if (culture == null) { throw new ArgumentNullException(nameof(culture)); } #endregion this.TermFactory = termFactory; this.Culture = culture; }
/// <summary> /// Initializes a new instance of the <see cref="Term"/> class. /// </summary> /// <param name="termFactory">The term factory that created this term.</param> /// <param name="annotations">The annotations of the term.</param> protected Term(ITermFactory termFactory, IReadOnlyCollection <ITerm> annotations) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(annotations)); } if (annotations == null) { throw new ArgumentNullException(nameof(annotations)); } #endregion this.Factory = termFactory; this.Annotations = annotations; }
/// <summary> /// Builds a new list term. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="terms">The terms in the list.</param> /// <returns>The list term.</returns> public static IListTerm <T> List <T>(this ITermFactory termFactory, IEnumerable <T> terms) where T : class, ITerm { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } if (terms == null) { throw new ArgumentNullException(nameof(terms)); } #endregion return(termFactory.List(terms, Enumerable.Empty <ITerm>())); }
/// <summary> /// Initializes a new instance of the <see cref="ModuleATerm"/> class. /// </summary> /// <param name="factory">The factory that created this term.</param> /// <param name="name">The name.</param> /// <param name="definitions">The definitions.</param> /// <param name="annotations">The annotations of the term.</param> public ModuleATerm(ITermFactory factory, IStringTerm name, IListTerm <IEntityTerm> definitions, IReadOnlyCollection <ITerm> annotations) : base(factory, annotations) { #region Contract if (name == null) { throw new ArgumentNullException(nameof(name)); } if (definitions == null) { throw new ArgumentNullException(nameof(definitions)); } #endregion this.Name = name; this.Definitions = definitions; this.subterms = new SubtermCollection(this); }
/// <summary> /// Initializes a new instance of the <see cref="EntityATerm"/> class. /// </summary> /// <param name="factory">The factory that created this term.</param> /// <param name="name">The name.</param> /// <param name="properties">The properties.</param> /// <param name="annotations">The annotations of the term.</param> public EntityATerm(ITermFactory factory, IStringTerm name, IListTerm <IPropertyTerm> properties, IReadOnlyCollection <ITerm> annotations) : base(factory, annotations) { #region Contract if (name == null) { throw new ArgumentNullException(nameof(name)); } if (properties == null) { throw new ArgumentNullException(nameof(properties)); } #endregion this.Name = name; this.Properties = properties; this.subterms = new SubtermCollection(this); }
/// <summary> /// Creates a new term of the specified type, with the specified subterms and annotations. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="subterms">The subterms.</param> /// <param name="annotations">The annotations.</param> /// <returns>The created term.</returns> public static T Create <T>(this ITermFactory termFactory, IEnumerable <ITerm> subterms, IEnumerable <ITerm> annotations) { #region Contract if (termFactory == null) { throw new ArgumentNullException(nameof(termFactory)); } if (subterms == null) { throw new ArgumentNullException(nameof(subterms)); } if (annotations == null) { throw new ArgumentNullException(nameof(annotations)); } #endregion return((T)termFactory.Create(typeof(T), subterms, annotations)); }
/// <summary> /// Initializes a new instance of the <see cref="ATermReader"/> class. /// </summary> /// <param name="termFactory">The term factory to use.</param> internal ATermReader(ITermFactory termFactory) : this(termFactory, TermTextReader.DefaultCulture) { // Nothing to do. }
/// <summary> /// Builds a new list term. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="terms">The terms in the list.</param> /// <returns>The list term.</returns> public static IListTerm <T> List <T>(this ITermFactory termFactory, params T[] terms) where T : class, ITerm => termFactory.List((IEnumerable <T>)terms);
/// <summary> /// Creates a new term of the specified type, with the specified subterms and annotations. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="type">The type of term.</param> /// <param name="subterms">The subterms.</param> /// <returns>The created term.</returns> public static ITerm Create(this ITermFactory termFactory, Type type, params ITerm[] subterms) => termFactory.Create(type, (IEnumerable <ITerm>)subterms);
private IListTerm <T> Concat <T>(ITermFactory factory, IListTerm <T> list1, IListTerm <T> list2) where T : class, ITerm { return(factory.List(list1.Concat(list2))); }
private IListTerm <T> Flatten <T>(ITermFactory factory, IListTerm <IListTerm <T> > list) where T : class, ITerm { return(factory.List(list.SelectMany(t => t))); }
private IListTerm <U> Map <T, U>(ITermFactory factory, IListTerm <T> list, Func <T, U> f) where T : class, ITerm where U : class, ITerm { return(factory.List(list.Select(t => f(t)))); }
/// <summary> /// Initializes a new instance of the <see cref="IntTerm"/> class. /// </summary> /// <param name="factory">The factory that created this term.</param> /// <param name="value">The value.</param> /// <param name="annotations">The annotations of the term.</param> public IntTerm(ITermFactory factory, int value, IReadOnlyCollection <ITerm> annotations) : base(factory, annotations) { this.Value = value; }
public CodeGenerator(ITermFactory factory) { this.Factory = factory; }
/// <summary> /// Creates a new term of the specified type, with the specified subterms and annotations. /// </summary> /// <param name="termFactory">The term factory.</param> /// <param name="subterms">The subterms.</param> /// <returns>The created term.</returns> public static T Create <T>(this ITermFactory termFactory, params ITerm[] subterms) => termFactory.Create <T>((IEnumerable <ITerm>)subterms);
/// <inheritdoc /> ITermReader ITermFormat.CreateReader(ITermFactory termFactory) => this.CreateReader(termFactory);