protected override void OnStart()
        {
            database = new FileSystemDatabase(dbPath);
            database.Start();

            SetBlockDatabase(database);

            // Read all the registered block servers that were last persisted and
            // populate the manager with them,
            string f = Path.Combine(basePath, RegisteredBlockServers);
            if (File.Exists(f)) {
                using (StreamReader rin = new StreamReader(f)) {
                    string line;
                    while ((line = rin.ReadLine()) != null) {
                        int p = line.IndexOf(",");
                        long guid = Int64.Parse(line.Substring(0, p));
                        IServiceAddress addr = ServiceAddresses.ParseString(line.Substring(p + 1));
                        AddRegisteredBlockServer(guid, addr);
                    }
                }
            }

            // Read all the registered root servers that were last persisted and
            // populate the manager with them,
            f = Path.Combine(basePath, RegisteredRootServers);
            if (File.Exists(f)) {
                using (StreamReader rin = new StreamReader(f)) {
                    string line;
                    while ((line = rin.ReadLine()) != null) {
                        IServiceAddress addr = ServiceAddresses.ParseString(line);
                        AddRegisteredRootServer(addr);
                    }
                }
            }
        }
 public void TearDown()
 {
     _database             = null;
     _hostService          = null;
     _tripService          = null;
     _newsletterService    = null;
     _newsletterController = null;
 }
 public void TearDown()
 {
     _database = null;
     _hostService = null;
     _tripService = null;
     _newsletterService = null;
     _newsletterController = null;
 }
 public void Initialize()
 {
     fileLoader        = Substitute.For <ILoader>();
     instructionParser = Substitute.For <IInstructionParser>();
     queryParser       = Substitute.For <IQueryParser>();
     databaseEngine    = Substitute.For <IDatabaseEngine>();
     database          = new FileSystemDatabase(fileLoader, instructionParser, queryParser, databaseEngine);
 }
        protected override void OnStop()
        {
            if (database != null) {
                database.Stop();
                database = null;
            }

            base.OnStop();
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing) {
                database.Stop();
                database = null;
            }

            base.Dispose(disposing);
        }
 public void SetUp()
 {
     _database             = new FileSystemDatabase();
     _hostService          = new HostService(_database);
     _tripService          = new TripService(_database);
     _newsletterService    = new NewsletterService(_database);
     _newsletterController = new NewsletterController(_newsletterService,
                                                      _hostService,
                                                      _tripService);
 }
 public void SetUp()
 {
     _database = new FileSystemDatabase();
     _hostService = new HostService(_database);
     _tripService = new TripService(_database);
     _newsletterService = new NewsletterService(_database);
     _newsletterController = new NewsletterController(_newsletterService, 
                                                      _hostService, 
                                                      _tripService);
 }
Beispiel #9
0
        static void Main(string[] args)
        {
            var db = new FileSystemDatabase();

            db.Reset();

            var evtStream            = new FileSystemEventStream(db);
            var projectionRepository = new FileSystemProjectionRepository();
            var evtBus = new FileSystemEventBus(projectionRepository, evtStream);

            var zId         = Guid.NewGuid();
            var zombieBirth = new ZombieBirth(evtBus);

            zombieBirth.Execute(zId, "cfvghjk");

            var zWalk = new ZombieHiking(db, evtBus);

            zWalk.Execute(zId, 97);

            zWalk = new ZombieHiking(db, evtBus);
            zWalk.Execute(zId, 1);

            zWalk = new ZombieHiking(db, evtBus);
            zWalk.Execute(zId, 20);

            zWalk = new ZombieHiking(db, evtBus);
            zWalk.Execute(zId, 9);

            zWalk = new ZombieHiking(db, evtBus);
            zWalk.Execute(zId, 7);

            var zId2 = Guid.NewGuid();

            zombieBirth = new ZombieBirth(evtBus);
            zombieBirth.Execute(zId2, "Alexandre");



            var query = new GetAllZombiesQuery(projectionRepository);

            foreach (var z in query.Execute())
            {
                Console.WriteLine($"{z.Id} {z.Name} {z.LimbNumber}");
            }
        }
        protected override void OnStart()
        {
            localDb = new FileSystemDatabase(dbpath);
            localDb.Start();

            SetBlockDatabase(localDb);

            // Read the unique id value,
            string f = Path.Combine(basePath, ManagerProperties);
            if (File.Exists(f)) {
                StreamReader reader = new StreamReader(f);
                string line;
                while ((line = reader.ReadLine()) != null) {
                    if (line.StartsWith("id=")) {
                        int uniqueId = Int32.Parse(line.Substring(3));
                        UniqueManagerId = uniqueId;
                    }
                }
                reader.Close();
            }

            // Read all the registered block servers that were last persisted and
            // populate the manager with them,
            f = Path.Combine(basePath, RegisteredBlockServers);
            if (File.Exists(f)) {
                StreamReader reader = new StreamReader(f);
                string line;
                while ((line = reader.ReadLine()) != null) {
                    int p = line.IndexOf(",");
                    long guid = Int64.Parse(line.Substring(0, p));
                    IServiceAddress addr = ServiceAddresses.ParseString(line.Substring(p + 1));
                    AddRegisteredBlockService(guid, addr);
                }
                reader.Close();
            }

            // Read all the registered root servers that were last persisted and
            // populate the manager with them,
            f = Path.Combine(basePath, RegisteredRootServers);
            if (File.Exists(f)) {
                StreamReader reader = new StreamReader(f);
                string line;
                while ((line = reader.ReadLine()) != null) {
                    IServiceAddress addr = ServiceAddresses.ParseString(line);
                    AddRegisteredRootService(addr);
                }
                reader.Close();
            }

            // Read all the registered manager servers that were last persisted and
            // populate the manager with them,
            f = Path.Combine(basePath, RegisteredManagerServers);
            if (File.Exists(f)) {
                StreamReader reader = new StreamReader(f);
                string line;
                while ((line = reader.ReadLine()) != null) {
                    IServiceAddress addr = ServiceAddresses.ParseString(line);
                    AddRegisteredManagerService(addr);
                }
                reader.Close();
            }

            // Perform the initialization procedure (contacts the other managers and
            // syncs data).
            base.OnStart();
        }
Beispiel #11
0
        protected override void OnStart()
        {
            localDb = new FileSystemDatabase(dbpath);
            localDb.Start();

            SetBlockDatabase(localDb);

            // Read the unique id value,
            string f = Path.Combine(basePath, ManagerProperties);

            if (File.Exists(f))
            {
                StreamReader reader = new StreamReader(f);
                string       line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("id="))
                    {
                        int uniqueId = Int32.Parse(line.Substring(3));
                        UniqueManagerId = uniqueId;
                    }
                }
                reader.Close();
            }

            // Read all the registered block servers that were last persisted and
            // populate the manager with them,
            f = Path.Combine(basePath, RegisteredBlockServers);
            if (File.Exists(f))
            {
                StreamReader reader = new StreamReader(f);
                string       line;
                while ((line = reader.ReadLine()) != null)
                {
                    int             p    = line.IndexOf(",");
                    long            guid = Int64.Parse(line.Substring(0, p));
                    IServiceAddress addr = ServiceAddresses.ParseString(line.Substring(p + 1));
                    AddRegisteredBlockService(guid, addr);
                }
                reader.Close();
            }

            // Read all the registered root servers that were last persisted and
            // populate the manager with them,
            f = Path.Combine(basePath, RegisteredRootServers);
            if (File.Exists(f))
            {
                StreamReader reader = new StreamReader(f);
                string       line;
                while ((line = reader.ReadLine()) != null)
                {
                    IServiceAddress addr = ServiceAddresses.ParseString(line);
                    AddRegisteredRootService(addr);
                }
                reader.Close();
            }

            // Read all the registered manager servers that were last persisted and
            // populate the manager with them,
            f = Path.Combine(basePath, RegisteredManagerServers);
            if (File.Exists(f))
            {
                StreamReader reader = new StreamReader(f);
                string       line;
                while ((line = reader.ReadLine()) != null)
                {
                    IServiceAddress addr = ServiceAddresses.ParseString(line);
                    AddRegisteredManagerService(addr);
                }
                reader.Close();
            }

            // Perform the initialization procedure (contacts the other managers and
            // syncs data).
            base.OnStart();
        }