Exemplo n.º 1
0
        public static void Register(Incubator incubator)
        {
            MySqlSqlStringBuilder builder = new MySqlSqlStringBuilder();

            incubator.Set(typeof(SqlStringBuilder), builder);
            incubator.Set <SqlStringBuilder>(builder);
        }
Exemplo n.º 2
0
 public static void Register(Incubator incubator)
 {
     incubator.Set <IParameterBuilder>(() => new OracleParameterBuilder());
     incubator.Set <SqlStringBuilder>(() => new OracleSqlStringBuilder());
     incubator.Set <SchemaWriter>(() => new OracleSqlStringBuilder());
     incubator.Set <QuerySet>(() => new OracleQuerySet());
 }
Exemplo n.º 3
0
        public static void Register(Incubator incubator)
        {
            incubator.Set <SqlStringBuilder>(new OracleSqlStringBuilder());

            OracleSqlStringBuilder builder = new OracleSqlStringBuilder();

            incubator.Set <OracleSqlStringBuilder>(builder);
        }
Exemplo n.º 4
0
        public static void Register(Incubator incubator)
        {
            incubator.Set <SqlStringBuilder>(new SQLiteSqlStringBuilder());

            SQLiteSqlStringBuilder builder = new SQLiteSqlStringBuilder();

            incubator.Set <SQLiteSqlStringBuilder>(builder);
        }
Exemplo n.º 5
0
        public static void Register(Incubator incubator)
        {
            SQLiteConnectionStringResolver.Register();

            incubator.Set <IParameterBuilder>(() => new SQLiteParameterBuilder());
            incubator.Set <SqlStringBuilder>(() => new SQLiteSqlStringBuilder());
            incubator.Set <SchemaWriter>(() => new SQLiteSqlStringBuilder());
            incubator.Set <QuerySet>(() => new SQLiteQuerySet());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Registser the MS implementation of IParameterBuilder, SchemaWriter and QuerySet
        /// into the specified incubator
        /// </summary>
        /// <param name="incubator"></param>
        public static void Register(Incubator incubator)
        {
            MsSqlParameterBuilder b = new MsSqlParameterBuilder();

            incubator.Set <IParameterBuilder>(b);

            incubator.Set <SqlStringBuilder>(() => new SqlStringBuilder());
            incubator.Set <SchemaWriter>(() => new MsSqlSqlStringBuilder());
            incubator.Set <QuerySet>(() => new MsSqlQuerySet());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Registser the MS implementation of IParameterBuilder, SchemaWriter and QuerySet
        /// into the specified incubator
        /// </summary>
        /// <param name="incubator"></param>
        public static void Register(Incubator incubator)
        {
            InterSystemsParameterBuilder b = new InterSystemsParameterBuilder();

            incubator.Set <IParameterBuilder>(b);

            incubator.Set <SqlStringBuilder>(() => new InterSystemsSqlStringBuilder());
            incubator.Set <SchemaWriter>(() => new InterSystemsSqlStringBuilder());
            incubator.Set <QuerySet>(() => new InterSystemsQuerySet());
            incubator.Set <IDataTypeTranslator>(() => new InterSystemsDataTypeTranslator());
        }
Exemplo n.º 8
0
        /// <summary>
        /// Registser the MySql implementation of IParameterBuilder, SchemaWriter and QuerySet
        /// into the specified incubator
        /// </summary>
        /// <param name="incubator"></param>
        public static void Register(Incubator incubator)
        {
            MySqlParameterBuilder b = new MySqlParameterBuilder();

            incubator.Set <IParameterBuilder>(b);

            incubator.Set <SqlStringBuilder>(() => new MySqlSqlStringBuilder());
            incubator.Set <SchemaWriter>(() => new MySqlSqlStringBuilder());
            incubator.Set <QuerySet>(() => new MySqlQuerySet());
            incubator.Set <IDataTypeTranslator>(() => new MySqlDataTypeTranslator());
        }
Exemplo n.º 9
0
        public void ExecuteNamedParamsTest()
        {
            Incubator inc = new Incubator();

            inc.Set(new Echo());
            string         id      = "A Value";
            JsonRpcRequest request = new JsonRpcRequest();

            request.Incubator = inc;
            string value = "hello there ".RandomLetters(8);

            request.Params            = JToken.Parse("{{'value': '{0}'}}"._Format(value));
            request.RpcParams.By.Name = request.Params;
            request.Method            = "Send";
            request.Id = id;

            IHttpContext context = GetPostContextWithInput(request.ToJson());

            request           = (JsonRpcRequest)JsonRpcMessage.Parse(context);
            request.Incubator = inc;

            JsonRpcResponse response = request.Execute();

            Expect.IsTrue(response.GetType().Equals(typeof(JsonRpcResponse)));
            Expect.AreEqual(response.Result, value);
            Expect.IsNull(response.Error);
            Expect.AreEqual(request.Id, response.Id);
            Expect.AreEqual(id, response.Id);
        }
Exemplo n.º 10
0
 private void Register()
 {
     ServiceProvider = new Incubator();
     ServiceProvider.Set <DbProviderFactory>(OracleClientFactory.Instance);
     OracleRegistrar.Register(this);
     Infos.Add(new DatabaseInfo(this));
 }
Exemplo n.º 11
0
 private void Register()
 {
     ServiceProvider = new Incubator();
     ServiceProvider.Set <DbProviderFactory>(NpgsqlFactory.Instance);
     NpgsqlRegistrar.Register(this);
     Infos.Add(new DatabaseInfo(this));
 }
Exemplo n.º 12
0
        public void SecureExecutionRequest_ShouldExecute()
        {
            EnsureRepository();
            IHttpContext context = CreateFakeContext(MethodInfo.GetCurrentMethod().Name);

            string input      = "monkey";
            string jsonParams = ApiParameters.ParametersToJsonParamsArray(new object[] { input }).ToJson();

            Incubator testIncubator = new Incubator();

            testIncubator.Set <Echo>(new Echo());
            SecureExecutionRequest request = new SecureExecutionRequest(context, "Echo", "Send", jsonParams);

            request.ServiceProvider = testIncubator;

            AesKeyVectorPair kvp = new AesKeyVectorPair();

            // ensure the symettric key is set
            request.Session.SetSymmetricKey(kvp.Key, kvp.IV);
            //

            request.Execute();

            Expect.IsTrue(request.Result.GetType() == typeof(string)); // should be base64 cipher of json result

            string result = request.GetResultAs <string>();

            Expect.AreEqual(input, result);

            CleanUp();
        }
Exemplo n.º 13
0
 private void Register()
 {
     SelectStar      = true;
     ServiceProvider = new Incubator();
     ServiceProvider.Set <DbProviderFactory>(CacheFactory.Instance);
     CacheRegistrar.Register(this);
     Infos.Add(new DatabaseInfo(this));
 }
Exemplo n.º 14
0
        public static void IncubatorShouldTakeAFuncAndReturnResult2()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(() => { return(new Monkey()); });
            Primate m = i.Get <Primate>();

            Expect.IsTrue(m.GetType() == typeof(Monkey));
        }
        /// <summary>
        /// Instantiates a database uing the specified ConnectionStringSettings and DbProviderFactory
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="factory"></param>
        /// <returns></returns>
        public virtual Database GetDatabase(ConnectionStringSettings conn, DbProviderFactory factory)
        {
            Incubator serviceProvider = new Incubator();

            serviceProvider.Set <DbProviderFactory>(factory);
            Database database = new Database(serviceProvider, conn.ConnectionString, conn.Name);

            return(database);
        }
Exemplo n.º 16
0
        public static void IncubatorShouldTakeAFuncAndReturnByClassName()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(() => { return(new Monkey()); });
            object m = i.Get("Primate");

            Expect.IsTrue(m.GetType() == typeof(Monkey));
        }
Exemplo n.º 17
0
        public static void IncubatorShouldTakeAFuncAndPopOutSpecifiedType()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(() => new Monkey());
            object m = i.Get("Primate", out Type type);

            (type == typeof(Primate)).IsTrue();
        }
Exemplo n.º 18
0
        public static void IncubatorShouldGiveMeWhatISet2()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(new Monkey());
            Primate m = i.Get <Primate>();

            Expect.IsTrue(m.GetType() == typeof(Monkey));
        }
Exemplo n.º 19
0
        public static void IncubatorShouldTakeAFuncAndReturnResult()
        {
            Incubator      i = new Incubator();
            Func <Primate> f = () => new Monkey();

            i.Set(typeof(Primate), f);
            Primate m = i.Get <Primate>();

            (m.GetType() == typeof(Monkey)).IsTrue();
        }
Exemplo n.º 20
0
        public void GetShouldReturnSameInstanceThatWasSet()
        {
            Incubator inc  = new Incubator();
            TestBam   test = new TestBam();

            inc.Set(typeof(TestBam), test);
            TestBam check = (TestBam)inc.Get(typeof(TestBam), new object[] { });

            Expect.AreSame(test, check);
            Expect.IsTrue(test == check);
        }
            public TestExecutionRequest(string c, string m, string f)
                : base(c, m, f)
            {
                Incubator inc = new Incubator();

                inc.Set(new Echo());
                ServiceProvider = inc;
                Instance        = new Echo();
                MethodInfo      = typeof(Echo).GetMethod(m);
                Request         = Substitute.For <IRequest>();
                Request.Url.Returns(new Uri($"http://localhost/{c}/{m}.{f}"));
                Request.QueryString.Returns(new NameValueCollection());
            }
Exemplo n.º 22
0
        public void ExecuteParameterWithObjectParamters()
        {
            Incubator inc = new Incubator();

            inc.Set(new Echo());
            EchoData data = new EchoData();

            data.BoolProperty   = true;
            data.StringProperty = "dlhsddfflk";
            data.IntProperty    = 888;

            JsonRpcRequest  request  = JsonRpcRequest.Create <Echo>(inc, "TestObjectParameter", data, "some addditional stuff");
            JsonRpcResponse response = request.Execute();

            Expect.IsNotNull(response.Result);
            OutLine(response.Result.ToString(), ConsoleColor.Cyan);
        }
Exemplo n.º 23
0
        public void ShouldBeAbleToSwitchOutServiceProviderAndReExecute()
        {
            ExecutionRequest request = CreateExecutionRequest("/SwitchTest/Do.json");
            Incubator        bad     = new Incubator();

            request.ServiceProvider = bad;

            Expect.IsFalse(request.Execute());

            Incubator good = new Incubator();

            good.Set <SwitchTest>(new SwitchTest());
            request.ServiceProvider = good;

            Expect.IsTrue(request.Execute());
            Expect.AreEqual("Yay it worked", request.Result);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Instantiate a new SQLiteDatabase instance where the database
        /// file will be placed into the specified directoryPath using the
        /// specified connectionName as the file name
        /// </summary>
        /// <param name="directoryPath"></param>
        /// <param name="connectionName"></param>
        public SQLiteDatabase(string directoryPath, string connectionName)
            : base()
        {
            DirectoryInfo directory = new DirectoryInfo(directoryPath);

            if (!directory.Exists)
            {
                directory.Create();
            }
            ConnectionStringResolver = new SQLiteConnectionStringResolver
            {
                Directory = directory
            };

            ConnectionName  = connectionName;
            ServiceProvider = new Incubator();
            ServiceProvider.Set <DbProviderFactory>(SQLiteFactory.Instance);
            Register();
        }
Exemplo n.º 25
0
        public void ExecuteOrderedParamsTest()
        {
            Incubator inc = new Incubator();

            inc.Set(new Echo());
            string          value       = "hello there ".RandomLetters(8);
            object          id          = "some value";
            string          inputString = "{{'jsonrpc': '2.0', 'method': 'Send', 'id': '{0}', 'params': ['{1}']}}"._Format(id, value);
            IHttpContext    context     = GetPostContextWithInput(inputString);
            IJsonRpcRequest parsed      = JsonRpcMessage.Parse(context);
            JsonRpcRequest  request     = (JsonRpcRequest)parsed;

            request.Incubator = inc;
            JsonRpcResponse response = request.Execute();

            Expect.IsTrue(response.GetType().Equals(typeof(JsonRpcResponse)));
            Expect.AreEqual(value, response.Result);
            Expect.IsNull(response.Error);
            Expect.AreEqual(id, response.Id);
        }
Exemplo n.º 26
0
 public void AddCommoneService(Type type, Func <object> instanciator)
 {
     _commonServiceProvider.Set(type, instanciator);
     OnCommonServiceAdded(type, instanciator);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Register the instance of T.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="instance"></param>
 public static void Register <T>(T instance)
 {
     Initialize();
     Incubator.Set <T>(instance);
 }