Exemplo 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);
        }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
 public static void Insert <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] ignoreFields)
 {
     creator.CreateInsert(tableName, value, queryOptions, ignoreFields).ExecuteNonQuery();
 }
Exemplo n.º 4
0
 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)));
 }
Exemplo n.º 5
0
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, string commandText, params object[] parameters)
 {
     return(creator.CreateSimple(null, commandText, parameters));
 }
Exemplo n.º 6
0
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, QueryOptions queryOptions, SimpleCommand precompiledCommand, params object[] parameters)
 {
     return(creator.Set(x => precompiledCommand.Create(x, queryOptions, parameters)));
 }
Exemplo n.º 7
0
 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());
 }
Exemplo n.º 8
0
 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)));
 }
Exemplo n.º 9
0
 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));
 }
Exemplo n.º 10
0
 public CommandFactory(ICommandCreator creator)
 {
     _commandCreator = creator;
 }
Exemplo 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));
 }
Exemplo n.º 12
0
 public CommandFactory()
 {
     _commandCreator = new ActivatorCommandCreator();
 }
Exemplo n.º 13
0
 public CommandFactory(ICommandCreator creator)
 {
     _commandCreator = creator;
 }
Exemplo n.º 14
0
 public CommandFactory()
 {
     _commandCreator = new ActivatorCommandCreator();
 }
Exemplo n.º 15
0
 public static void Delete <T>(this ICommandCreator creator, string tableName, T value, params string[] keyFields)
 {
     creator.CreateDelete(tableName, value, keyFields).ExecuteNonQuery();
 }
Exemplo 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));
 }
Exemplo 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());
 }
Exemplo 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)));
 }
Exemplo 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();
 }
Exemplo 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));
 }
Exemplo n.º 21
0
 public static IWrappedCommand CreateProcedureSimple(this ICommandCreator creator, string name, params DbParameter[] parameters)
 {
     return(creator.CreateProcedureSimple(null, name, parameters));
 }
Exemplo 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)));
 }
Exemplo 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)));
 }
Exemplo n.º 24
0
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, SimpleCommand precompiledCommand, params object[] parameters)
 {
     return(creator.CreateSimple(null, precompiledCommand, parameters));
 }
Exemplo n.º 25
0
 public DbCommand Get(ICommandCreator cmd)
 {
     return(cmd.Get(Type, Db, CmdWrapper));
 }
Exemplo 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());
 }