Esempio n. 1
0
        public object BuildInput(Queue <string> tokens, ICommandCreator creator)
        {
            var model      = creator.CreateModel(_inputType);
            var responding = new List <ITokenHandler>();

            while (tokens.Any())
            {
                var handler = _handlers.FirstOrDefault(h => h.Handle(model, tokens));
                if (handler == null)
                {
                    throw new InvalidUsageException("Unknown argument or flag for value " + tokens.Peek());
                }
                responding.Add(handler);
            }

            if (!IsValidUsage(responding))
            {
                throw new InvalidUsageException();
            }

            return(model);
        }
 public static Task InsertAsync <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] ignoreFields)
 {
     return(creator.CreateInsert(tableName, value, queryOptions, ignoreFields).ExecuteNonQueryAsync());
 }
 public static void Insert <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] ignoreFields)
 {
     creator.CreateInsert(tableName, value, queryOptions, ignoreFields).ExecuteNonQuery();
 }
 public static IWrappedCommand CreateProcedureSimple(this ICommandCreator creator, QueryOptions queryOptions, string name, params DbParameter[] parameters)
 {
     return(creator.Set(x => x.CommandCompilator.CompileProcedureSimple(name).Create(x, queryOptions, parameters)));
 }
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, string commandText, params object[] parameters)
 {
     return(creator.CreateSimple(null, commandText, parameters));
 }
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, QueryOptions queryOptions, SimpleCommand precompiledCommand, params object[] parameters)
 {
     return(creator.Set(x => precompiledCommand.Create(x, queryOptions, parameters)));
 }
 public static Task MergeAsync <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] keyFields)
 {
     return(creator.CreateMerge(tableName, value, queryOptions, keyFields).ExecuteNonQueryAsync());
 }
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, QueryOptions queryOptions, string commandText, params object[] parameters)
 {
     return(creator.Set(x => x.CommandCompilator.CompileSimple(commandText).Create(x, queryOptions, parameters)));
 }
 public static IWrappedCommand CreateInsertWithOutput <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] outputFields)
 {
     return(creator.CreateInsertWithOutput(tableName, value, queryOptions, null, outputFields));
 }
Esempio n. 10
0
 public CommandFactory(ICommandCreator creator)
 {
     _commandCreator = creator;
 }
Esempio n. 11
0
 public static IWrappedCommand CreateInsert <T>(this ICommandCreator creator, string tableName, T value, params string[] ignoreFields)
 {
     return(creator.CreateInsert(tableName, value, null, ignoreFields));
 }
Esempio n. 12
0
 public CommandFactory()
 {
     _commandCreator = new ActivatorCommandCreator();
 }
Esempio n. 13
0
 public CommandFactory(ICommandCreator creator)
 {
     _commandCreator = creator;
 }
Esempio n. 14
0
 public CommandFactory()
 {
     _commandCreator = new ActivatorCommandCreator();
 }
Esempio n. 15
0
 public static void Delete <T>(this ICommandCreator creator, string tableName, T value, params string[] keyFields)
 {
     creator.CreateDelete(tableName, value, keyFields).ExecuteNonQuery();
 }
Esempio n. 16
0
 public static IWrappedCommand CreateInsertWithOutput <T>(this ICommandCreator creator, string tableName, T value, IList <string> ignoreFields, params string[] outputFields)
 {
     return(creator.CreateInsertWithOutput(tableName, value, null, ignoreFields, outputFields));
 }
Esempio n. 17
0
 public static Task DeleteAsync <T>(this ICommandCreator creator, string tableName, T value, params string[] keyFields)
 {
     return(creator.CreateDelete(tableName, value, keyFields).ExecuteNonQueryAsync());
 }
Esempio n. 18
0
 public static IWrappedCommand CreateInsertWithOutput <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, IList <string> ignoreFields, params string[] outputFields)
 {
     return(creator.Set(x => x.CommandCompilator.CompileInsertWithOutput <T>(tableName, FieldSettings.FromType <T>(FromTypeOption.Default), ignoreFields, outputFields).Create(x, value, queryOptions)));
 }
Esempio n. 19
0
 public static void Merge <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] keyFields)
 {
     creator.CreateMerge(tableName, value, queryOptions, keyFields).ExecuteNonQuery();
 }
Esempio n. 20
0
 public static IWrappedCommand CreateMerge <T>(this ICommandCreator creator, string tableName, T value, params string[] keyFields)
 {
     return(creator.CreateMerge(tableName, value, null, keyFields));
 }
Esempio n. 21
0
 public static IWrappedCommand CreateProcedureSimple(this ICommandCreator creator, string name, params DbParameter[] parameters)
 {
     return(creator.CreateProcedureSimple(null, name, parameters));
 }
Esempio n. 22
0
 public static IWrappedCommand CreateMerge <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] keyFields)
 {
     return(creator.Set(x => x.CommandCompilator.CompileMerge <T>(tableName, keyFields).Create(x, value, queryOptions)));
 }
Esempio n. 23
0
 public static IWrappedCommand CreateMapped <T>(this ICommandCreator creator, MappedCommand <T> precompiledCommand, T value, QueryOptions queryOptions = null)
 {
     return(creator.Set(x => precompiledCommand.Create(x, value, queryOptions)));
 }
Esempio n. 24
0
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, SimpleCommand precompiledCommand, params object[] parameters)
 {
     return(creator.CreateSimple(null, precompiledCommand, parameters));
 }
Esempio n. 25
0
 public DbCommand Get(ICommandCreator cmd)
 {
     return(cmd.Get(Type, Db, CmdWrapper));
 }
Esempio n. 26
0
 // combining Create and Execute
 public static T[] GetTable <T>(this ICommandCreator creator, string tableName) where T : new()
 {
     return(creator.CreateSimple($"select * from {tableName}").ExecuteQuery <T>().ToArray());
 }