예제 #1
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(Component.For <CampfireApiLoggingInterceptor>().ImplementedBy <CampfireApiLoggingInterceptor>());
     container.Register(Component.For <ICampfireApi>().ImplementedBy <CampfireApi>().Interceptors <CampfireApiLoggingInterceptor>());
     container.Register(AllTypes.FromThisAssembly().Pick().WithServiceAllInterfaces());
 }
예제 #2
0
 public static void RegisterAllFromAssemblies(string a)
 {
     IoC.Container.Register(AllTypes.FromAssemblyNamed(a).Pick()
                            .WithService.DefaultInterface()
                            .Configure(c => c.LifeStyle.PerWebRequest));
 }
예제 #3
0
 public object Any(AllTypes request)
 {
     return(request);
 }
예제 #4
0
 public void GetDefaults(DeltinScript deltinScript)
 {
     AllTypes.AddRange(CodeType.DefaultTypes);
     AllTypes.Add(new Pathfinder.PathmapClass(deltinScript));
     AllTypes.Add(new Pathfinder.PathResolveClass());
 }
예제 #5
0
 public T GetCodeType <T>() where T : CodeType => (T)AllTypes.FirstOrDefault(type => type.GetType() == typeof(T));
예제 #6
0
 /// <summary>
 /// Create a new AllTypes object.
 /// </summary>
 /// <param name="c1_int">Initial value of C1_int.</param>
 /// <param name="c2_int">Initial value of C2_int.</param>
 /// <param name="c3_smallint">Initial value of C3_smallint.</param>
 /// <param name="c4_tinyint">Initial value of C4_tinyint.</param>
 /// <param name="c5_bit">Initial value of C5_bit.</param>
 /// <param name="c6_datetime">Initial value of C6_datetime.</param>
 /// <param name="c7_smalldatetime">Initial value of C7_smalldatetime.</param>
 /// <param name="c8_decimal28_4">Initial value of C8_decimal28_4.</param>
 /// <param name="c9_numeric28_4">Initial value of C9_numeric28_4.</param>
 /// <param name="c10_real">Initial value of C10_real.</param>
 /// <param name="c11_float">Initial value of C11_float.</param>
 /// <param name="c12_money">Initial value of C12_money.</param>
 /// <param name="c13_smallmoney">Initial value of C13_smallmoney.</param>
 /// <param name="c23_uniqueidentifier">Initial value of C23_uniqueidentifier.</param>
 /// <param name="c24_bigint">Initial value of C24_bigint.</param>
 public static AllTypes CreateAllTypes(int c1_int, int c2_int, short c3_smallint, byte c4_tinyint, bool c5_bit, global::System.DateTime c6_datetime, global::System.DateTime c7_smalldatetime, decimal c8_decimal28_4, decimal c9_numeric28_4, float c10_real, double c11_float, decimal c12_money, decimal c13_smallmoney, global::System.Guid c23_uniqueidentifier, long c24_bigint)
 {
     AllTypes allTypes = new AllTypes();
     allTypes.C1_int = c1_int;
     allTypes.C2_int = c2_int;
     allTypes.C3_smallint = c3_smallint;
     allTypes.C4_tinyint = c4_tinyint;
     allTypes.C5_bit = c5_bit;
     allTypes.C6_datetime = c6_datetime;
     allTypes.C7_smalldatetime = c7_smalldatetime;
     allTypes.C8_decimal28_4 = c8_decimal28_4;
     allTypes.C9_numeric28_4 = c9_numeric28_4;
     allTypes.C10_real = c10_real;
     allTypes.C11_float = c11_float;
     allTypes.C12_money = c12_money;
     allTypes.C13_smallmoney = c13_smallmoney;
     allTypes.C23_uniqueidentifier = c23_uniqueidentifier;
     allTypes.C24_bigint = c24_bigint;
     return allTypes;
 }
        public void Can_Create_and_put_empty_AllTypes()
        {
            var db = CreatePocoDynamo();
            db.RegisterTable<AllTypes>();
            db.InitSchema();

            var dto = new AllTypes { Id = 1 };

            db.PutItem(dto);

            var row = db.GetItem<AllTypes>(1);

            Assert.That(dto, Is.EqualTo(row));
        }
예제 #8
0
 private static IEnumerable <Type> AllPublicTypes() => AllTypes.From(AssemblyUnderTest).Where(t => t.GetTypeInfo().IsPublic);
예제 #9
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(AllTypes.FromThisAssembly().Where(type => type.GetInterfaces().Length > 0).WithService.AllInterfaces());
     container.Register(Component.For <UnicastBus>().UsingFactoryMethod(kernel => InternalBusCreator.CreateBus()));
 }
예제 #10
0
            public void UpdatePutBinaryPrimitiveValueWithFixedContentLength()
            {
                TypedCustomDataContext<AllTypes>.ClearValues();
                TypedCustomDataContext<AllTypes>.PreserveChanges = true;
                EventHandler handler = new EventHandler((sender, e) =>
                {
                    var context = (TypedCustomDataContext<AllTypes>)sender;
                    var theValue = new AllTypes();

                    theValue.ID = 1;
                    theValue.BinaryType = new byte[] { 1, 2, 3, 4 };

                    context.SetValues(new object[] { theValue });
                });

                TypedCustomDataContext<AllTypes>.ValuesRequested += handler;
                try
                {
                    string payLoad = "12345";
                    UpdateTests.DoPrimitiveValueUpdates(payLoad, "/Values(1)/BinaryType/$value",
                        new string[] { String.Format("{0}[text()='Foo']", 
                                        JsonValidator.ValueString)
                                 },
                       typeof(TypedCustomDataContext<AllTypes>), UnitTestsUtil.MimeApplicationOctetStream, 5);
                }
                finally
                {
                    TypedCustomDataContext<AllTypes>.ValuesRequested -= handler;
                }

                TypedCustomDataContext<AllTypes>.PreserveChanges = false;
            }
예제 #11
0
 private static void RegisterControllers(IWindsorContainer container)
 {
     container.Register(AllTypes.FromAssembly(Assembly.GetExecutingAssembly())
                        .BasedOn <Controller>()
                        .Configure(c => c.LifeStyle.Transient.Named(c.Implementation.Name.ToLower())));
 }
 public T GetInitializer <T>() where T : ICodeTypeInitializer => (T)AllTypes.First(type => type.GetType() == typeof(T));
 public CodeType GetInstanceFromInitializer <T>() where T : ICodeTypeInitializer => AllTypes.First(type => type.GetType() == typeof(T)).GetInstance();
 public T GetInstance <T>() where T : CodeType => (T)AllTypes.First(type => type.BuiltInTypeMatches(typeof(T))).GetInstance();
 private static void RegisterPlugin(IWindsorContainer container, System.Reflection.Assembly plugin)
 {
     container.Register(AllTypes.FromAssembly(plugin).Where(t => _pluginTypes.Any(pt => pt.IsAssignableFrom(t))).WithServiceSelect((t, _) => t.GetInterfaces().Intersect(_pluginTypes)));
 }
예제 #16
0
파일: Intelli.cs 프로젝트: BoltBait/CodeLab
 internal static bool IsEnum(string enumName)
 {
     return(enumName != null && (UserDefinedTypes.TryGetValue(enumName, out Type type) || AllTypes.TryGetValue(enumName, out type)) &&
            type.IsEnum && Enum.GetValues(type).Length > 0);
 }
예제 #17
0
 /// <summary>
 /// Create a new AllTypes object.
 /// </summary>
 /// <param name="c1_int">Initial value of c1_int.</param>
 /// <param name="c2_int">Initial value of c2_int.</param>
 /// <param name="c3_smallint">Initial value of c3_smallint.</param>
 /// <param name="c4_tinyint">Initial value of c4_tinyint.</param>
 /// <param name="c5_bit">Initial value of c5_bit.</param>
 /// <param name="c6_datetime">Initial value of c6_datetime.</param>
 /// <param name="c7_smalldatetime">Initial value of c7_smalldatetime.</param>
 /// <param name="c8_decimal_28_4_">Initial value of c8_decimal_28_4_.</param>
 /// <param name="c9_numeric_28_4_">Initial value of c9_numeric_28_4_.</param>
 /// <param name="c10_real">Initial value of c10_real.</param>
 /// <param name="c11_float">Initial value of c11_float.</param>
 /// <param name="c12_money">Initial value of c12_money.</param>
 /// <param name="c13_smallmoney">Initial value of c13_smallmoney.</param>
 /// <param name="c14_varchar_512_">Initial value of c14_varchar_512_.</param>
 /// <param name="c15_char_512_">Initial value of c15_char_512_.</param>
 /// <param name="c16_text">Initial value of c16_text.</param>
 /// <param name="c17_binary_512_">Initial value of c17_binary_512_.</param>
 /// <param name="c18_varbinary_512_">Initial value of c18_varbinary_512_.</param>
 /// <param name="c19_image">Initial value of c19_image.</param>
 /// <param name="c20_nvarchar_512_">Initial value of c20_nvarchar_512_.</param>
 /// <param name="c21_nchar_512_">Initial value of c21_nchar_512_.</param>
 /// <param name="c22_ntext">Initial value of c22_ntext.</param>
 /// <param name="c23_uniqueidentifier">Initial value of c23_uniqueidentifier.</param>
 /// <param name="c24_bigint">Initial value of c24_bigint.</param>
 public static AllTypes CreateAllTypes(
             int c1_int, 
             int c2_int, 
             short c3_smallint, 
             byte c4_tinyint, 
             bool c5_bit, 
             global::System.DateTimeOffset c6_datetime, 
             global::System.DateTimeOffset c7_smalldatetime, 
             decimal c8_decimal_28_4_, 
             decimal c9_numeric_28_4_, 
             float c10_real, 
             double c11_float, 
             decimal c12_money, 
             decimal c13_smallmoney, 
             string c14_varchar_512_, 
             string c15_char_512_, 
             string c16_text, 
             byte[] c17_binary_512_, 
             byte[] c18_varbinary_512_, 
             byte[] c19_image, 
             string c20_nvarchar_512_, 
             string c21_nchar_512_, 
             string c22_ntext, 
             global::System.Guid c23_uniqueidentifier, 
             long c24_bigint)
 {
     AllTypes allTypes = new AllTypes();
     allTypes.c1_int = c1_int;
     allTypes.c2_int = c2_int;
     allTypes.c3_smallint = c3_smallint;
     allTypes.c4_tinyint = c4_tinyint;
     allTypes.c5_bit = c5_bit;
     allTypes.c6_datetime = c6_datetime;
     allTypes.c7_smalldatetime = c7_smalldatetime;
     allTypes.c8_decimal_28_4_ = c8_decimal_28_4_;
     allTypes.c9_numeric_28_4_ = c9_numeric_28_4_;
     allTypes.c10_real = c10_real;
     allTypes.c11_float = c11_float;
     allTypes.c12_money = c12_money;
     allTypes.c13_smallmoney = c13_smallmoney;
     allTypes.c14_varchar_512_ = c14_varchar_512_;
     allTypes.c15_char_512_ = c15_char_512_;
     allTypes.c16_text = c16_text;
     allTypes.c17_binary_512_ = c17_binary_512_;
     allTypes.c18_varbinary_512_ = c18_varbinary_512_;
     allTypes.c19_image = c19_image;
     allTypes.c20_nvarchar_512_ = c20_nvarchar_512_;
     allTypes.c21_nchar_512_ = c21_nchar_512_;
     allTypes.c22_ntext = c22_ntext;
     allTypes.c23_uniqueidentifier = c23_uniqueidentifier;
     allTypes.c24_bigint = c24_bigint;
     return allTypes;
 }
예제 #18
0
파일: Intelli.cs 프로젝트: BoltBait/CodeLab
        internal static bool TryGetEnumNames(string enumName, out string[] names)
        {
            if (enumName == null || !(UserDefinedTypes.TryGetValue(enumName, out Type type) || AllTypes.TryGetValue(enumName, out type)) || !type.IsEnum)
            {
                names = null;
                return(false);
            }

            names = Enum.GetNames(type).Select(name => type.Name + "." + name).ToArray();
            return(true);
        }
예제 #19
0
        public void TestAllTypes()
        {
            CassandraSharpConfig cassandraSharpConfig = new CassandraSharpConfig();
            ClusterManager.Configure(cassandraSharpConfig);

            ClusterConfig clusterConfig = new ClusterConfig
                {
                        Endpoints = new EndpointsConfig
                            {
                                    Servers = new[] {"localhost"}
                            }
                };

            using (ICluster cluster = ClusterManager.GetCluster(clusterConfig))
            {
                const string createFoo = "CREATE KEYSPACE Tests WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}";
                Console.WriteLine("============================================================");
                Console.WriteLine(createFoo);
                Console.WriteLine("============================================================");

                var resCount = cluster.ExecuteNonQuery(createFoo);
                resCount.Wait();
                Console.WriteLine();
                Console.WriteLine();

                // http://www.datastax.com/docs/1.1/references/cql/cql_data_types
                const string createBar = @"CREATE TABLE Tests.AllTypes (cAscii ascii,
                                                                            cBigint bigint,
                                                                            cBlob blob,
                                                                            cBoolean boolean,
                                                                            cDecimal decimal,
                                                                            cDouble double,
                                                                            cFloat float,
                                                                            cInet inet,
                                                                            cInt int,
                                                                            cText text,
                                                                            cTimestamp timestamp,
                                                                            cTimeuuid timeuuid,
                                                                            cUuid uuid,
                                                                            cVarchar varchar,
                                                                            cVarint varint,
                                                          PRIMARY KEY (cInt))";
                Console.WriteLine("============================================================");
                Console.WriteLine(createBar);
                Console.WriteLine("============================================================");
                resCount = cluster.ExecuteNonQuery(createBar);
                resCount.Wait();
                Console.WriteLine();
                Console.WriteLine();

                const string insertBatch = @"insert into Tests.AllTypes (cAscii, cBigint, cBlob, cBoolean, cDouble, cFloat,
                                                                         cInet, cInt, cText, cTimestamp, cTimeuuid, cUuid, cVarchar)
                                             values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                var prepared = cluster.Prepare(insertBatch);

                var allTypesInsert = new AllTypes
                    {
                            CAscii = "ascii",
                            CBigint = 0x0102030405060708,
                            CBlob = new byte[] {0x1, 0x02, 0x03, 0x04, 0x05},
                            CBoolean = true,
                            CDouble = 1234.5678,
                            CFloat = 234.567f,
                            CInet = new IPAddress(new byte[] {0x01, 0x02, 0x03, 0x04}),
                            CInt = 42,
                            CText = "text",
                            CTimestamp = new DateTime(2013, 1, 16, 14, 20, 0),
                            CTimeuuid = TimedUuid.GenerateTimeBasedGuid(DateTime.Now),
                            CUuid = Guid.NewGuid(),
                            CVarchar = "varchar"
                    };

                prepared.ExecuteNonQuery(allTypesInsert).Wait();

                const string selectAll = "select * from Tests.AllTypes";
                AllTypes allTypesSelect = cluster.Execute<AllTypes>(selectAll).Result.Single();

                const string dropFoo = "drop keyspace Tests";
                resCount = cluster.ExecuteNonQuery(dropFoo);
                resCount.Wait();

                Assert.AreEqual(allTypesInsert.CAscii, allTypesSelect.CAscii);
                Assert.AreEqual(allTypesInsert.CBigint, allTypesSelect.CBigint);
                Assert.AreEqual(allTypesInsert.CBlob, allTypesSelect.CBlob);
                Assert.AreEqual(allTypesInsert.CBoolean, allTypesSelect.CBoolean);
                Assert.AreEqual(allTypesInsert.CDouble, allTypesSelect.CDouble);
                Assert.AreEqual(allTypesInsert.CFloat, allTypesSelect.CFloat);
                Assert.AreEqual(allTypesInsert.CInet, allTypesSelect.CInet);
                Assert.AreEqual(allTypesInsert.CInt, allTypesSelect.CInt);
                Assert.AreEqual(allTypesInsert.CText, allTypesSelect.CText);
                Assert.AreEqual(allTypesInsert.CTimestamp, allTypesSelect.CTimestamp);
                Assert.AreEqual(allTypesInsert.CTimeuuid, allTypesSelect.CTimeuuid);
                Assert.AreEqual(allTypesInsert.CUuid, allTypesSelect.CUuid);
                Assert.AreEqual(allTypesInsert.CVarchar, allTypesSelect.CVarchar);
            }

            ClusterManager.Shutdown();
        }
예제 #20
0
 private static BasedOnDescriptor FindControllers()
 {
     return(AllTypes.FromThisAssembly()
            .BasedOn <IController>()
            .If(t => t.Name.EndsWith("Controller")));
 }
예제 #21
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(AllTypes.FromThisAssembly().BasedOn <ApiController>().LifestyleScoped());
 }
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(AllTypes.FromThisAssembly().InSameNamespaceAs <ProductsController>()
                        .LifestyleTransient());
 }
예제 #23
0
 public CodeType GetCodeType(string name) => AllTypes.FirstOrDefault(type => type.Name == name);
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(AllTypes.FromAssemblyContaining <AlbumManager>()
                        .Where(t => !t.IsAbstract && !t.IsInterface)
                        .WithService.FirstInterface());
 }
예제 #25
0
 public T GetInstance <T>() where T : CodeType => (T)AllTypes.First(type => type.GetType() == typeof(T));
예제 #26
0
 public void Install(IWindsorContainer container, IConfigurationStore store)
 {
     container.Register(AllTypes.FromThisAssembly().BasedOn <IProvideDataFor>().WithServiceBase());
 }
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Component
                               .For <IReservationRepository>()
                               .ImplementedBy <AzureReservationRepository>());

            container.Register(AllTypes.FromAssemblyContaining <ReservationContext>()
                               .Where(t => t.Name.EndsWith("Context") && typeof(IRequiresInitialization).IsAssignableFrom(t))
                               .WithService.Select((type, baseTypes) => new[] { type, typeof(IRequiresInitialization) }));

            container.Register(Component
                               .For <IChannel>()
                               .ImplementedBy <AzureChannel>());
            container.Register(Component
                               .For <CapacityGuard>()
                               .ServiceOverrides(new { capacityContainer = "capacityContainer" }));
            container.Register(Component
                               .For <IMonthViewWriter>()
                               .ImplementedBy <AzureMonthViewStore>()
                               .ServiceOverrides(new { viewContainer = "viewContainer" }));

            container.Register(Component
                               .For <CloudQueue>()
                               .UsingFactoryMethod(k =>
            {
                var queueName = "messagequeue";
                var client    = k.Resolve <CloudQueueClient>();
                var queue     = client.GetQueueReference(queueName);
                queue.CreateIfNotExist();
                return(queue);
            }));
            container.Register(Component
                               .For <CloudBlobContainer>()
                               .UsingFactoryMethod(k =>
            {
                var c = k.Resolve <CloudBlobClient>().GetContainerReference("capacity");
                c.CreateIfNotExist();
                return(c);
            })
                               .Named("capacityContainer"));
            container.Register(Component
                               .For <CloudBlobContainer>()
                               .UsingFactoryMethod(k =>
            {
                var c = k.Resolve <CloudBlobClient>().GetContainerReference("view");
                c.CreateIfNotExist();
                return(c);
            })
                               .Named("viewContainer"));
            container.Register(Component
                               .For <CloudQueueClient>()
                               .UsingFactoryMethod(k => k.Resolve <CloudStorageAccount>().CreateCloudQueueClient()));
            container.Register(Component
                               .For <CloudBlobClient>()
                               .UsingFactoryMethod(k => k.Resolve <CloudStorageAccount>().CreateCloudBlobClient()));
            container.Register(Component
                               .For <CloudStorageAccount>()
                               .UsingFactoryMethod(() => CloudStorageAccount.FromConfigurationSetting("DataConnectionString")));

            foreach (var i in container.ResolveAll <IRequiresInitialization>())
            {
                i.Initialize();
            }
        }
예제 #28
0
        public void TestAllTypes()
        {
            CassandraSharpConfig cassandraSharpConfig = new CassandraSharpConfig();

            ClusterManager.Configure(cassandraSharpConfig);

            ClusterConfig clusterConfig = new ClusterConfig
            {
                Endpoints = new EndpointsConfig
                {
                    Servers = new[] { "localhost" }
                }
            };

            using (ICluster cluster = ClusterManager.GetCluster(clusterConfig))
            {
                ICqlCommand cmd = cluster.CreateCommand().FromOrdinal().ToPoco().Build();

                const string dropFoo = "drop keyspace Tests";

                try
                {
                    cmd.Execute(dropFoo).AsFuture().Wait();
                }
                catch
                {
                }

                const string createFoo = "CREATE KEYSPACE Tests WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}";
                Console.WriteLine("============================================================");
                Console.WriteLine(createFoo);
                Console.WriteLine("============================================================");

                cmd.Execute(createFoo).AsFuture().Wait();
                Console.WriteLine();
                Console.WriteLine();

                // http://www.datastax.com/docs/1.1/references/cql/cql_data_types
                const string createBar = @"CREATE TABLE Tests.AllTypes (cAscii ascii, 
                                                                            cBigint bigint,
                                                                            cBlob blob,
                                                                            cBoolean boolean,
                                                                            cDecimal decimal,
                                                                            cDouble double,
                                                                            cFloat float,
                                                                            cInet inet,
                                                                            cInt int,
                                                                            cText text,
                                                                            cTimestamp timestamp,
                                                                            cTimeuuid timeuuid,
                                                                            cUuid uuid,
                                                                            cVarchar varchar,
                                                                            cVarint varint,
                                                                            cList list<int>,
                                                                            cSet set<int>,
                                                                            cMap map<text, int>,
                                                          PRIMARY KEY (cInt))";
                Console.WriteLine("============================================================");
                Console.WriteLine(createBar);
                Console.WriteLine("============================================================");
                cmd.Execute(createBar).AsFuture().Wait();
                Console.WriteLine();
                Console.WriteLine();

                const string insertBatch = @"insert into Tests.AllTypes (cAscii, cBigint, cBlob, cBoolean, cDouble, cFloat,
                                                                         cInet, cInt, cText, cTimestamp, cTimeuuid, cUuid, cVarchar, cList, cSet, cMap)
                                             values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                var          prepared    = cmd.Prepare(insertBatch);

                var allTypesInsert = new AllTypes
                {
                    CAscii     = new string('x', 8000),
                    CBigint    = 0x0102030405060708,
                    CBlob      = Enumerable.Repeat((byte)42, 7142).ToArray(),
                    CBoolean   = true,
                    CDouble    = 1234.5678,
                    CFloat     = 234.567f,
                    CInet      = new IPAddress(new byte[] { 0x01, 0x02, 0x03, 0x04 }),
                    CInt       = 42,
                    CText      = new string('x', 3000),
                    CTimestamp = new DateTime(2013, 1, 16, 14, 20, 0),
                    CTimeuuid  = TimedUuid.GenerateTimeBasedGuid(DateTime.Now),
                    CUuid      = Guid.NewGuid(),
                    CVarchar   = new string('x', 5000),
                    CList      = new List <int> {
                        1, 2, 3
                    },
                    CSet = new HashSet <int> {
                        1, 2, 3
                    },
                    CMap = new Dictionary <string, int> {
                        { "one", 1 }, { "two", 2 }, { "three", 3 }
                    },
                };

                var param = new object[]
                {
                    allTypesInsert.CAscii,
                    allTypesInsert.CBigint,
                    allTypesInsert.CBlob,
                    allTypesInsert.CBoolean,
                    allTypesInsert.CDouble,
                    allTypesInsert.CFloat,
                    allTypesInsert.CInet,
                    allTypesInsert.CInt,
                    allTypesInsert.CText,
                    allTypesInsert.CTimestamp,
                    allTypesInsert.CTimeuuid,
                    allTypesInsert.CUuid,
                    allTypesInsert.CVarchar,
                    allTypesInsert.CList,
                    allTypesInsert.CSet,
                    allTypesInsert.CMap,
                };

                prepared.Execute(param).AsFuture().Wait();

                const string selectAll =
                    "select cAscii, cBigint, cBlob, cBoolean, cDouble, cFloat, cInet, cInt, cText, cTimestamp, cTimeuuid, cUuid, cVarchar, cList, cSet, cMap from Tests.AllTypes";
                AllTypes allTypesSelect = cmd.Execute <AllTypes>(selectAll).AsFuture().Result.Single();

                cmd.Execute(dropFoo).AsFuture().Wait();

                Assert.AreEqual(allTypesInsert.CAscii, allTypesSelect.CAscii);
                Assert.AreEqual(allTypesInsert.CBigint, allTypesSelect.CBigint);
                Assert.AreEqual(allTypesInsert.CBlob, allTypesSelect.CBlob);
                Assert.AreEqual(allTypesInsert.CBoolean, allTypesSelect.CBoolean);
                Assert.AreEqual(allTypesInsert.CDouble, allTypesSelect.CDouble);
                Assert.AreEqual(allTypesInsert.CFloat, allTypesSelect.CFloat);
                Assert.AreEqual(allTypesInsert.CInet, allTypesSelect.CInet);
                Assert.AreEqual(allTypesInsert.CInt, allTypesSelect.CInt);
                Assert.AreEqual(allTypesInsert.CText, allTypesSelect.CText);
                Assert.AreEqual(allTypesInsert.CTimestamp, allTypesSelect.CTimestamp);
                Assert.AreEqual(allTypesInsert.CTimeuuid, allTypesSelect.CTimeuuid);
                Assert.AreEqual(allTypesInsert.CUuid, allTypesSelect.CUuid);
                Assert.AreEqual(allTypesInsert.CVarchar, allTypesSelect.CVarchar);
                Assert.AreEqual(allTypesInsert.CList, allTypesSelect.CList);
                Assert.AreEqual(allTypesInsert.CSet, allTypesSelect.CSet);
                Assert.AreEqual(allTypesInsert.CMap, allTypesSelect.CMap);
            }

            ClusterManager.Shutdown();
        }
예제 #29
0
        public void DynamicTypes()
        {
            AllTypes types = new AllTypes();

            // boolean
            types.AnyProperty = false;
            Assert.False((bool)types.AnyProperty);

            // string
            types.AnyProperty = "String";
            Assert.Equal("String", types.AnyProperty);

            // number
            types.AnyProperty = 12;
            Assert.Equal((double)12, types.AnyProperty);

            // date
            types.AnyProperty = UnixEpoch.AddSeconds(1234);
            Assert.Equal(UnixEpoch.AddSeconds(1234), types.AnyProperty);

            // json (notice that when deserialized, it is deserialized as a map).
            types.AnyProperty = new JObject(new JProperty("Goo",
                                                          new JArray(
                                                              "Hello",
                                                              new JObject(new JProperty("World", 123))
                                                              )
                                                          ));
            var @object     = (IDictionary <string, object>)types.AnyProperty;
            var array       = (object[])@object["Goo"];
            var innerObject = (IDictionary <string, object>)array[1];

            Assert.Equal((double)123, innerObject["World"]);

            // array
            types.AnyProperty = new[] { "Hello", "World" };
            Assert.Equal("Hello", ((object[])types.AnyProperty)[0]);
            Assert.Equal("World", ((object[])types.AnyProperty)[1]);

            // array of any
            types.AnyArrayProperty = new object[] { "Hybrid", new Number(12), 123, false };
            Assert.Equal((double)123, types.AnyArrayProperty[2]);

            // map
            IDictionary <string, object> map = new Dictionary <string, object>();

            map["MapKey"]     = "MapValue";
            types.AnyProperty = map;
            Assert.Equal("MapValue", ((IDictionary <string, object>)types.AnyProperty)["MapKey"]);

            // map of any
            map["Goo"]           = 19289812;
            types.AnyMapProperty = map;
            Assert.Equal((double)19289812, types.AnyMapProperty["Goo"]);

            // classes
            Multiply mult = new Multiply(new Number(10), new Number(20));

            types.AnyProperty = mult;
            Assert.Same(types.AnyProperty, mult);
            Assert.IsType <Multiply>(types.AnyProperty);
            Assert.Equal((double)200, ((Multiply)types.AnyProperty).Value);
        }
예제 #30
0
 private BasedOnDescriptor FindControllers()
 {
     return(AllTypes.FromAssemblyContaining <TicketsController>()
            .BasedOn <IController>()
            .If(t => t.Name.EndsWith("Controller")));
 }
예제 #31
0
 private BasedOnDescriptor FindRepositorios()
 {
     return(AllTypes.FromThisAssembly()
            .BasedOn(typeof(IRepositorio <>)).WithService.Base());
 }
예제 #32
0
        public void RequestQueryParserReproTests()
        {
            using (TestWebRequest request = TestWebRequest.CreateForInProcess())
            {
                request.DataServiceType = typeof(TypedCustomDataContext<AllTypes>);
                string[] filters = new string[]
                {
                    // Protocol: Can't compare decimal value to literal greater than maxint
                    "DecimalType eq 100000000000000000000000M",

                    // Protocol: Can't use large Decimal in filter expression
                    "79228162514264337593543950335M gt 0",

                    // Protocol: Filter does not match large float values
                    "DoubleType eq 3.4E%2B38",

                   //(double)(3.4E+38f) will be 3.3999999521443642E+38

                    // Protocol: filter can't compare two byte properties
                    "ByteType eq ByteType",
                    "NullableByteType eq NullableByteType",
                    "ByteType eq (1 add 1 sub 2)",

                    // Protocol: contains in filter expression can not find single extended char
                    "null ne StringType and contains(StringType,'\x00A9 \x0040')",
                    "null ne StringType and contains(StringType,'\x00A9')"
                };

                TypedCustomDataContext<AllTypes>.ClearValues();
                TypedCustomDataContext<AllTypes>.ValuesRequested += (sender, y) =>
                {
                    AllTypes[] values = new AllTypes[]
                    {
                        new AllTypes() { ID = 1, DecimalType = 100000000000000000000000m },
                        new AllTypes() { ID = 2, DoubleType = 3.4E+38 },
                        new AllTypes() { ID = 3, StringType = "\x00A9 \x0040" },
                    };
                    TypedCustomDataContext<AllTypes> c = (TypedCustomDataContext<AllTypes>)sender;
                    c.SetValues(values);
                };

                foreach (string filter in filters)
                {
                    request.RequestUriString = "/Values?$format=atom&$filter=" + filter;
                    Trace.WriteLine("Sending request for " + request.RequestUriString);
                    Exception exception = TestUtil.RunCatching(request.SendRequest);
                    TestUtil.AssertExceptionExpected(exception, false);
                    XmlDocument document = request.GetResponseStreamAsXmlDocument();
                    TestUtil.AssertSelectNodes(document, "/atom:feed/atom:entry");
                }
            }
        }
예제 #33
0
        public void Registreting_by_namespace_no_subnamespaces()
        {
            Kernel.Register(AllTypes.FromThisAssembly().Where(Component.IsInNamespace("RootNamespace")));

            Assert.AreEqual(1, ComponentsCount());
        }
예제 #34
0
        /// <summary>
        /// Registers all plugins in an assembly.
        /// </summary>
        public static void RegisterPluginsFromAssembly(this IWindsorContainer container, Assembly assembly)
        {
            var pluginAttributes = new[] { typeof(NodeProcessorAttribute), typeof(TypedMarkupParserImplAttribute), typeof(UntypedMarkupParserImplAttribute) };

            container.Register(AllTypes.FromAssembly(assembly).Where(type => type.GetCustomAttributes(true).Any(a => pluginAttributes.Contains(a.GetType()))).LifestyleCustom <TrulyTransientLifestyle>());
        }
예제 #35
0
 /// <summary>
 /// There are no comments for AllTypes in the schema.
 /// </summary>
 public void AddToAllTypes(AllTypes allTypes)
 {
     base.AddObject("AllTypes", allTypes);
 }
예제 #36
0
 /// <summary>
 /// Registers all controls in an assembly.
 /// </summary>
 public static void RegisterControlsFromAssembly(this IWindsorContainer container, Assembly assembly)
 {
     container.Register(AllTypes.FromAssembly(assembly).BasedOn <IControl>().WithServiceSelf().LifestyleCustom <TrulyTransientLifestyle>());
 }
예제 #37
0
        public void TestAllTypes()
        {
            CassandraSharpConfig cassandraSharpConfig = new CassandraSharpConfig();
            ClusterManager.Configure(cassandraSharpConfig);

            ClusterConfig clusterConfig = new ClusterConfig
                {
                        Endpoints = new EndpointsConfig
                            {
                                    Servers = new[] {"localhost"}
                            }
                };

            using (ICluster cluster = ClusterManager.GetCluster(clusterConfig))
            {
                ICqlCommand cmd = cluster.CreateCommand().FromOrdinal().ToPoco().Build();

                const string dropFoo = "drop keyspace Tests";

                try
                {
                    cmd.Execute(dropFoo).AsFuture().Wait();
                }
                catch
                {
                }

                const string createFoo = "CREATE KEYSPACE Tests WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}";
                Console.WriteLine("============================================================");
                Console.WriteLine(createFoo);
                Console.WriteLine("============================================================");

                cmd.Execute(createFoo).AsFuture().Wait();
                Console.WriteLine();
                Console.WriteLine();

                // http://www.datastax.com/docs/1.1/references/cql/cql_data_types
                const string createBar = @"CREATE TABLE Tests.AllTypes (cAscii ascii, 
                                                                            cBigint bigint,
                                                                            cBlob blob,
                                                                            cBoolean boolean,
                                                                            cDecimal decimal,
                                                                            cDouble double,
                                                                            cFloat float,
                                                                            cInet inet,
                                                                            cInt int,
                                                                            cText text,
                                                                            cTimestamp timestamp,
                                                                            cTimeuuid timeuuid,
                                                                            cUuid uuid,
                                                                            cVarchar varchar,
                                                                            cVarint varint,
                                                                            cList list<int>,
                                                                            cSet set<int>,
                                                                            cMap map<text, int>,
                                                          PRIMARY KEY (cInt))";
                Console.WriteLine("============================================================");
                Console.WriteLine(createBar);
                Console.WriteLine("============================================================");
                cmd.Execute(createBar).AsFuture().Wait();
                Console.WriteLine();
                Console.WriteLine();

                const string insertBatch = @"insert into Tests.AllTypes (cAscii, cBigint, cBlob, cBoolean, cDouble, cFloat,
                                                                         cInet, cInt, cText, cTimestamp, cTimeuuid, cUuid, cVarchar, cList, cSet, cMap)
                                             values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                var prepared = cmd.Prepare(insertBatch);

                var allTypesInsert = new AllTypes
                    {
                            CAscii = new string('x', 8000),
                            CBigint = 0x0102030405060708,
                            CBlob = Enumerable.Repeat((byte) 42, 7142).ToArray(),
                            CBoolean = true,
                            CDouble = 1234.5678,
                            CFloat = 234.567f,
                            CInet = new IPAddress(new byte[] {0x01, 0x02, 0x03, 0x04}),
                            CInt = 42,
                            CText = new string('x', 3000),
                            CTimestamp = new DateTime(2013, 1, 16, 14, 20, 0),
                            CTimeuuid = TimedUuid.GenerateTimeBasedGuid(DateTime.Now),
                            CUuid = Guid.NewGuid(),
                            CVarchar = new string('x', 5000),
                            CList = new List<int> {1, 2, 3},
                            CSet = new HashSet<int> {1, 2, 3},
                            CMap = new Dictionary<string, int> {{"one", 1}, {"two", 2}, {"three", 3}},
                    };

                var param = new object[]
                    {
                            allTypesInsert.CAscii,
                            allTypesInsert.CBigint,
                            allTypesInsert.CBlob,
                            allTypesInsert.CBoolean,
                            allTypesInsert.CDouble,
                            allTypesInsert.CFloat,
                            allTypesInsert.CInet,
                            allTypesInsert.CInt,
                            allTypesInsert.CText,
                            allTypesInsert.CTimestamp,
                            allTypesInsert.CTimeuuid,
                            allTypesInsert.CUuid,
                            allTypesInsert.CVarchar,
                            allTypesInsert.CList,
                            allTypesInsert.CSet,
                            allTypesInsert.CMap,
                    };

                prepared.Execute(param).AsFuture().Wait();

                const string selectAll =
                        "select cAscii, cBigint, cBlob, cBoolean, cDouble, cFloat, cInet, cInt, cText, cTimestamp, cTimeuuid, cUuid, cVarchar, cList, cSet, cMap from Tests.AllTypes";
                AllTypes allTypesSelect = cmd.Execute<AllTypes>(selectAll).AsFuture().Result.Single();

                cmd.Execute(dropFoo).AsFuture().Wait();

                Assert.AreEqual(allTypesInsert.CAscii, allTypesSelect.CAscii);
                Assert.AreEqual(allTypesInsert.CBigint, allTypesSelect.CBigint);
                Assert.AreEqual(allTypesInsert.CBlob, allTypesSelect.CBlob);
                Assert.AreEqual(allTypesInsert.CBoolean, allTypesSelect.CBoolean);
                Assert.AreEqual(allTypesInsert.CDouble, allTypesSelect.CDouble);
                Assert.AreEqual(allTypesInsert.CFloat, allTypesSelect.CFloat);
                Assert.AreEqual(allTypesInsert.CInet, allTypesSelect.CInet);
                Assert.AreEqual(allTypesInsert.CInt, allTypesSelect.CInt);
                Assert.AreEqual(allTypesInsert.CText, allTypesSelect.CText);
                Assert.AreEqual(allTypesInsert.CTimestamp, allTypesSelect.CTimestamp);
                Assert.AreEqual(allTypesInsert.CTimeuuid, allTypesSelect.CTimeuuid);
                Assert.AreEqual(allTypesInsert.CUuid, allTypesSelect.CUuid);
                Assert.AreEqual(allTypesInsert.CVarchar, allTypesSelect.CVarchar);
                Assert.AreEqual(allTypesInsert.CList, allTypesSelect.CList);
                Assert.AreEqual(allTypesInsert.CSet, allTypesSelect.CSet);
                Assert.AreEqual(allTypesInsert.CMap, allTypesSelect.CMap);
            }

            ClusterManager.Shutdown();
        }
예제 #38
0
 public object Any(AllTypes request) => request;
예제 #39
0
            public void AllTypesTest()
            {
                Dictionary<Type, PropertyInfo> typeToPropertyMap = new Dictionary<Type, PropertyInfo>();
                // build a dictionary for the type to properties
                foreach (PropertyInfo property in typeof(AllTypes).GetProperties(BindingFlags.Public | BindingFlags.Instance))
                {
                    if (property.Name == "ID")
                    {
                        continue;
                    }

                    typeToPropertyMap.Add(property.PropertyType, property);
                }

                int maxSampleValue = 0;
                Dictionary<Type, TypeData> typeToDataMap = new Dictionary<Type, TypeData>();
                foreach (TypeData typeData in TypeData.Values)
                {
                    // Ignore the invalid types
                    if (!typeToPropertyMap.ContainsKey(typeData.ClrType))
                    {
                        continue;
                    }

                    typeToDataMap.Add(typeData.ClrType, typeData);
                    if (maxSampleValue < typeData.SampleValues.Length)
                    {
                        maxSampleValue = typeData.SampleValues.Length;
                    }
                }

                IEdmEntityType entityType = null;
                for (int i = 0; i < maxSampleValue; i++)
                {
                    // Get the metadata for the type
                    if (i == 0)
                    {
                        var model = UnitTestsUtil.LoadMetadataFromDataServiceType(typeof(TypedCustomAllTypesDataContext), null);
                        entityType = model.FindType(typeof(AllTypes).FullName) as IEdmEntityType;
                    }

                    object entityInstance = typeof(AllTypes).GetConstructor(System.Type.EmptyTypes).Invoke(null);
                    PopulateResource(entityType, typeToDataMap, entityInstance, i);

                    InsertEntityAndCompareValues(entityType, entityInstance);
                }

                // create entity with all default values
                AllTypes emptyAllTypes = new AllTypes();
                emptyAllTypes.ID = 1;
                InsertEntityAndCompareValues(entityType, emptyAllTypes);
            }
        public void Can_Create_and_put_populated_AllTypes()
        {
            var db = CreatePocoDynamo();
            db.RegisterTable<AllTypes>();
            db.InitSchema();

            var dto = new AllTypes
            {
                Id = 1,
                NullableId = 2,
                Byte = 3,
                Short = 4,
                Int = 5,
                Long = 6,
                UShort = 7,
                UInt = 8,
                ULong = 9,
                Float = 1.1f,
                Double = 2.2,
                Decimal = 3.3M,
                String = "String",
                DateTime = new DateTime(2001, 01, 01),
                TimeSpan = new TimeSpan(1, 1, 1, 1, 1),
                DateTimeOffset = new DateTimeOffset(new DateTime(2001, 01, 01)),
                Guid = new Guid("DC8837C3-84FB-401B-AB59-CE799FF99142"),
                Char = 'A',
                NullableDateTime = new DateTime(2001, 01, 01),
                NullableTimeSpan = new TimeSpan(1, 1, 1, 1, 1),
                StringList = new[] { "A", "B", "C" }.ToList(),
                StringArray = new[] { "D", "E", "F" },
                StringMap = new Dictionary<string, string>
                {
                    {"A","1"},
                    {"B","2"},
                    {"C","3"},
                },
                IntStringMap = new Dictionary<int, string>
                {
                    { 1, "A" },
                    { 2, "B" },
                    { 3, "C" },
                },
                SubType = new SubType
                {
                    Id = 1,
                    Name = "Name"
                }
            };

            db.PutItem(dto);

            var row = db.GetItem<AllTypes>(1);

            Assert.That(dto, Is.EqualTo(row));
        }