コード例 #1
0
 public IStringTerm Generate(IModuleTerm module)
 {
     return(Concat(Factory, Flatten(Factory, Factory.List(
                                        Factory.List(Factory.String(
                                                         "using System;" + Environment.NewLine +
                                                         Environment.NewLine +
                                                         "namespace Entities" + Environment.NewLine +
                                                         "{" + Environment.NewLine)),
                                        Map(Factory, module.Definitions, Generate),
                                        Factory.List(Factory.String(
                                                         "}" + Environment.NewLine)))
                                    )));
 }
コード例 #2
0
        /// <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>()));
        }
コード例 #3
0
 private IListTerm <T> Flatten <T>(ITermFactory factory, IListTerm <IListTerm <T> > list)
     where T : class, ITerm
 {
     return(factory.List(list.SelectMany(t => t)));
 }
コード例 #4
0
 private IListTerm <T> Concat <T>(ITermFactory factory, IListTerm <T> list1, IListTerm <T> list2)
     where T : class, ITerm
 {
     return(factory.List(list1.Concat(list2)));
 }
コード例 #5
0
 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))));
 }
コード例 #6
0
 /// <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);