Example #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));
 }
Example #10
0
 public CommandFactory(ICommandCreator creator)
 {
     _commandCreator = creator;
 }
 public static IWrappedCommand CreateInsert <T>(this ICommandCreator creator, string tableName, T value, params string[] ignoreFields)
 {
     return(creator.CreateInsert(tableName, value, null, ignoreFields));
 }
Example #12
0
 public CommandFactory()
 {
     _commandCreator = new ActivatorCommandCreator();
 }
Example #13
0
 public CommandFactory(ICommandCreator creator)
 {
     _commandCreator = creator;
 }
Example #14
0
 public CommandFactory()
 {
     _commandCreator = new ActivatorCommandCreator();
 }
 public static void Delete <T>(this ICommandCreator creator, string tableName, T value, params string[] keyFields)
 {
     creator.CreateDelete(tableName, value, keyFields).ExecuteNonQuery();
 }
 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));
 }
 public static Task DeleteAsync <T>(this ICommandCreator creator, string tableName, T value, params string[] keyFields)
 {
     return(creator.CreateDelete(tableName, value, keyFields).ExecuteNonQueryAsync());
 }
 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)));
 }
 public static void Merge <T>(this ICommandCreator creator, string tableName, T value, QueryOptions queryOptions, params string[] keyFields)
 {
     creator.CreateMerge(tableName, value, queryOptions, keyFields).ExecuteNonQuery();
 }
 public static IWrappedCommand CreateMerge <T>(this ICommandCreator creator, string tableName, T value, params string[] keyFields)
 {
     return(creator.CreateMerge(tableName, value, null, keyFields));
 }
 public static IWrappedCommand CreateProcedureSimple(this ICommandCreator creator, string name, params DbParameter[] parameters)
 {
     return(creator.CreateProcedureSimple(null, name, parameters));
 }
 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)));
 }
 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)));
 }
 public static IWrappedCommand CreateSimple(this ICommandCreator creator, SimpleCommand precompiledCommand, params object[] parameters)
 {
     return(creator.CreateSimple(null, precompiledCommand, parameters));
 }
Example #25
0
 public DbCommand Get(ICommandCreator cmd)
 {
     return(cmd.Get(Type, Db, CmdWrapper));
 }
 // 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());
 }