Example #1
0
        public void Usage()
        {
            ObjectContainer db4oContainer = (ObjectContainer)Container["db4o.container"];

            Assert.IsNotNull(db4oContainer);

            Guid id = Guid.NewGuid();

            try
            {
                db4oContainer.Set(new Beer(id));
            }
            catch
            {
                db4oContainer.Rollback();
            }
            finally
            {
                db4oContainer.Commit();
            }

            ObjectSet results = db4oContainer.Get(typeof(Beer));

            Assert.AreEqual(1, results.Size());
            Beer loaded = (Beer)results.Next();

            Assert.AreEqual(id, loaded.Id);

            db4oContainer.Delete(loaded);
            db4oContainer.Commit();

            results = db4oContainer.Get(typeof(Beer));
            Assert.AreEqual(0, results.Size());
        }
Example #2
0
        public static async Task <bool> InsertData(Complain data)
        {
            try
            {
                /*
                 * // Retrieve the storage account from the connection string.
                 * var storageAccount = CloudStorageAccount.Parse(
                 * ConfigurationManager.AppSettings["StorageConnectionString"]);
                 *
                 * // Create the table client.
                 * CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
                 *
                 * // Retrieve a reference to the table.
                 * CloudTable table = tableClient.GetTableReference("laporan");
                 *
                 * // Create the table if it doesn't exist.
                 * table.CreateIfNotExists();
                 * // Create the TableOperation object that inserts the customer entity.
                 * TableOperation insertOperation = TableOperation.Insert(data);
                 *
                 * // Execute the insert operation.
                 * table.Execute(insertOperation);*/
                var db = ObjectContainer.Get <RedisDB>();
                data.Id = db.GetId <Complain>();
                var res = await db.InsertDoc <Complain>("complain", data);

                return(res);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.StackTrace + " : " + ex.Message);
                return(false);
            }
        }
Example #3
0
        public void MigrateDown()
        {
            var migrator = ObjectContainer.Get <BasicManifestMigrator>();
            var version  = migrator.MigrateTo(0);

            Console.WriteLine("Migrated to {0}", version);
        }
Example #4
0
 public TicketServiceController()
 {
     db = ObjectContainer.Get <RedisDB>();
     if (readyTickets == null)
     {
         readyTickets = new ConcurrentQueue <Ticket>();
         var datas = from c in db.GetAllData <Ticket>()
                     where c.Status == TicketStatus.Ready
                     select c;
         foreach (var item in datas)
         {
             readyTickets.Enqueue(item);
         }
     }
     if (activeTickets == null)
     {
         activeTickets = new ConcurrentDictionary <long, Ticket>();
         var datas = from c in db.GetAllData <Ticket>()
                     where c.Status == TicketStatus.Active
                     select c;
         foreach (var item in datas)
         {
             activeTickets.TryAdd(item.UserId, item);
         }
     }
 }
Example #5
0
        public static void Main(string[] args)
        {
            ObjectContainer.Init(new GenerateRegistry());
            var executor = ObjectContainer.Get <ICommandExecutor>();
            var result   = executor.Execute(args.Length == 0 ? "unknown" : args[0]);

            Console.WriteLine(result);
        }
Example #6
0
        public void MigrateTo()
        {
            const long to       = 42;
            var        migrator = ObjectContainer.Get <BasicManifestMigrator>();
            var        version  = migrator.MigrateTo(to);

            Console.WriteLine("Migrated to {0}", version);
        }
Example #7
0
 internal ISQLQuery CreateSQLQuery(string queryString)
 {
     if (Session != null)
     {
         return(ObjectContainer.Get <ISQLQuery>(Session.CreateSQLQuery(queryString)));
     }
     else
     {
         return(ObjectContainer.Get <ISQLQuery>(StatelessSession.CreateSQLQuery(queryString)));
     }
 }
Example #8
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     Lifecycle.Current = new HttpContextLifecycle();
     ObjectContainer.Init(new BMRegistry());
     ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
     MappingConfiguration.Init(new BasicManifestMappingProfile());
     ObjectContainer.Get <IBasicManifestMigrator>().MigrateUp();
 }
        public void ConfigureContainer()
        {
            ApplicationConfiguration config = new ApplicationConfiguration();
            config.ContainerConfiguration.Items.Add(new ObjectContainerAdd() { KeyType = GetTypeFullname("IA"), ObjectType = GetTypeFullname("A") });
            config.ContainerConfiguration.Items.Add(new ObjectContainerAdd() { KeyType = GetTypeFullname("IB"), ObjectType = GetTypeFullname("B") });

            ObjectContainer container = new ObjectContainer();
            ConfigManager.ConfigureContainer(container, config);

            Assert.AreEqual(2, container.AllObjects.Length);
            IA a = container.Get<IA>();
            Assert.IsNotNull(a);
            Assert.AreSame(typeof(A), a.GetType());
        }
Example #10
0
        public void ConfigureContainer()
        {
            ApplicationConfiguration config = new ApplicationConfiguration();

            config.ContainerConfiguration.Items.Add(new ObjectContainerAdd()
            {
                KeyType = GetTypeFullname("IA"), ObjectType = GetTypeFullname("A")
            });
            config.ContainerConfiguration.Items.Add(new ObjectContainerAdd()
            {
                KeyType = GetTypeFullname("IB"), ObjectType = GetTypeFullname("B")
            });

            ObjectContainer container = new ObjectContainer();

            ConfigManager.ConfigureContainer(container, config);

            Assert.AreEqual(2, container.AllObjects.Length);
            IA a = container.Get <IA>();

            Assert.IsNotNull(a);
            Assert.AreSame(typeof(A), a.GetType());
        }
Example #11
0
 public UpdateHistoryController()
 {
     db = ObjectContainer.Get <RDSDatabase>();
 }
Example #12
0
 public PublicServiceLogic()
 {
     db = ObjectContainer.Get <RedisDB>();
 }
Example #13
0
 public void Setup()
 {
     Lifecycle.Current = new IntegrationTestLifecycle();
     _repo             = ObjectContainer.Get <BMRepo>();
     _unitOfWork       = ObjectContainer.Get <NHibernateUnitOfWork>();
 }
 protected override IUnitOfWork CreateUnitOfWork()
 {
     return(ObjectContainer.Get <IUnitOfWorkFactory>().StartSysCEFUnitOfWork());
 }
 public override object DoGet(string key)
 {
     return(Container.Get(key));
 }
 public FirmwareInfoController()
 {
     db = ObjectContainer.Get <RDSDatabase>();
 }
Example #17
0
 public EMoneyLogic()
 {
     db = ObjectContainer.Get <RedisDB>();
 }
 public DeviceController()
 {
     db = ObjectContainer.Get <RDSDatabase>();
 }
Example #19
0
 public UserServiceController()
 {
     db = ObjectContainer.Get <RedisDB>();
 }
Example #20
0
 public EmoneyServiceController()
 {
     db = ObjectContainer.Get <RedisDB>();
 }
Example #21
0
 public BackupInfoController()
 {
     db = ObjectContainer.Get <RDSDatabase>();
 }
Example #22
0
 public UserProfileLogic()
 {
     db = ObjectContainer.Get <RedisDB>();
 }
Example #23
0
        static ObjectManager()
        {
            objects = new ObjectContainer(new FileInfo("objects.config"));

            Database = (IDatabase)objects.Get("Database");
        }
Example #24
0
 public virtual ObjectSet FindAll()
 {
     return(_objContainer.Get(typeof(Beer)));
 }
Example #25
0
 public static T Get <T>(string objectId)
 {
     return((T)objects.Get(objectId));
 }