protected override object Instantiate()
        {
            Type systemType = (Type)
                              Model.ExtendedProperties[PrevalenceFacility.SystemTypePropertyKey];
            String dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, (String)
                                      Model.ExtendedProperties[PrevalenceFacility.StorageDirPropertyKey]);
            bool autoVersionMigration = (bool)
                                        Model.ExtendedProperties[PrevalenceFacility.AutoMigrationPropertyKey];
            bool resetStorage = (bool)
                                Model.ExtendedProperties[PrevalenceFacility.ResetStoragePropertyKey];
            float snapshotPeriod = (float)Model.ExtendedProperties[PrevalenceFacility.SnapshotPeriodPropertyKey];

            if (resetStorage)
            {
                DeleteStorageDir(dir);
            }

            PrevalenceEngine engine = PrevalenceActivator.CreateEngine(
                systemType,
                dir,
                autoVersionMigration);

            if (snapshotPeriod > 0)
            {
                CreateSnapshotTaker(engine, snapshotPeriod);
            }

            return(engine);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            PrevalenceEngine engine = PrevalenceActivator.CreateTransparentEngine(typeof(ObjectModel.Company), Path.Combine(Path.GetTempPath(), "CompanySystem"));

            ObjectModel.Company company = engine.PrevalentSystem as ObjectModel.Company;

            // adding a new department is easy...
            ObjectModel.Department sales = new ObjectModel.Department("Sales");
            company.AddDepartment(sales);

            // adding a user is easy too, you only have
            // to remember to put the right department
            // reference...
            ObjectModel.Employee employee = new ObjectModel.Employee("John Salesman");
            employee.Department = new ObjectModel.Department(sales.ID);
            company.AddEmployee(employee);

            DisplayObjects(company);

            // updating an employee...
            ObjectModel.Employee updEmployee = new ObjectModel.Employee(employee.ID);
            updEmployee.Name = "Rodrigo B. de Oliveira";
            company.UpdateEmployee(updEmployee);

            DisplayObjects(company);

            company.RemoveEmployee(employee.ID);

            DisplayObjects(company);
        }
Beispiel #3
0
        public Application()
        {
            string prevalenceBase = Path.Combine(Environment.CurrentDirectory, "data");

            _engine = PrevalenceActivator.CreateTransparentEngine(typeof(ToDoList), prevalenceBase);
            _system = _engine.PrevalentSystem as ToDoList;
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            string prevalenceBase = Path.Combine(Environment.CurrentDirectory, "data");

            ClearPrevalenceBase(prevalenceBase);
            PrevalenceEngine engine = PrevalenceActivator.CreateEngine(typeof(Library), prevalenceBase);

            Library library = engine.PrevalentSystem as Library;

            Console.Write("Loading titles.xml... ");
            XmlDocument data = new XmlDocument();

            data.Load("titles.xml");
            Console.WriteLine("done!");

            foreach (XmlElement title in data.SelectNodes("//title"))
            {
                library.AddTitle(new Title(title.GetAttribute("name"), title.GetAttribute("summary")));
            }

            Console.Write("Taking snapshot... ");
            engine.TakeSnapshot();
            Console.WriteLine("done!");

            Console.WriteLine("Version 1.0 data successfully set up!");
        }
        protected void Application_Start(Object sender, EventArgs e)
        {
            string datapath = ConfigurationSettings.AppSettings["DataPath"];
            long   counter  = Convert.ToInt64(ConfigurationSettings.AppSettings["DataSnapshot"]);
            long   delay    = 0;

            engine = PrevalenceActivator.CreateEngine(typeof(PetStore), datapath);
            timer  = new Timer(new TimerCallback(TakeSnapshot), null, delay, counter);
        }
        public void SetUp()
        {
            // O primeiro passo � limpar qualquer resqu�cio de
            // testes anteriores para come�ar com uma "base" limpa
            ClearPrevalenceBase();

            _engine = PrevalenceActivator.CreateEngine(typeof(TaskManagementSystem), PrevalenceBase);
            _system = _engine.PrevalentSystem as TaskManagementSystem;
        }
Beispiel #7
0
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            _engine = PrevalenceActivator.CreateEngine(typeof(TaskManagementSystem), PrevalenceBase);
            _system = _engine.PrevalentSystem as TaskManagementSystem;

            RefreshProjectView();

            _status.Text = PrevalenceBase;
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            string           prevalenceBase = Path.Combine(Environment.CurrentDirectory, "data");
            PrevalenceEngine engine         = PrevalenceActivator.CreateEngine(typeof(LibrarySystem), prevalenceBase);

            LibrarySystem library = engine.PrevalentSystem as LibrarySystem;
            IList         titles  = library.GetTitles();

            XmlDocument data = new XmlDocument();

            data.Load("titles.xml");

            XmlNodeList expectedTitles = data.SelectNodes("//title");

            AssertEquals("titles.Count", expectedTitles.Count, titles.Count);

            foreach (XmlElement expected in expectedTitles)
            {
                Title title = FindByName(titles, expected.GetAttribute("name") + "*");
                AssertTitle(expected, title);
            }
        }
Beispiel #9
0
        public static void Main(string[] args)
        {
            //ChannelServices.RegisterChannel(new TcpChannel(8080));
            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();

            props["port"] = 8080;
            ChannelServices.RegisterChannel(new TcpChannel(props, null, provider));


            PrevalenceEngine engine = PrevalenceActivator.CreateTransparentEngine(typeof(AddressBook), Path.Combine(Environment.CurrentDirectory, "data"));
            AddressBook      book   = engine.PrevalentSystem as AddressBook;

            // Let's take a complete snapshot of the system
            // each 30 seconds...
            SnapshotTaker st = new SnapshotTaker(engine, 30000);

            ObjRef reference = RemotingServices.Marshal(book, "AddressBook", typeof(AddressBook));

            Console.WriteLine("server running... press <ENTER> to finish");
            Console.ReadLine();

            RemotingServices.Unmarshal(reference);
        }
Beispiel #10
0
        private void SetUpEngine(System.Collections.Hashtable engines, System.Xml.XmlElement item)
        {
            string     id                   = GetRequiredAttribute(item, "id");
            string     type                 = GetRequiredAttribute(item, "type");
            string     prevalenceBase       = GetOptionalPrevalenceBase(item, id);
            bool       autoVersionMigration = bool.Parse(GetOptionalAttribute(item, "autoVersionMigration", "false"));
            EngineType engineType           = (EngineType)EngineType.Parse(typeof(EngineType),
                                                                           GetOptionalAttribute(item, "engineType", "Normal"));

            System.Type systemType = System.Type.GetType(type);
            if (null == systemType)
            {
                TypeNotFoundError(type, item);
            }

            try
            {
                switch (engineType)
                {
                case EngineType.Transparent:
                    engines[id] = PrevalenceActivator.CreateTransparentEngine(systemType, prevalenceBase, autoVersionMigration);
                    break;

                case EngineType.Normal:
                    engines[id] = PrevalenceActivator.CreateEngine(systemType, prevalenceBase, autoVersionMigration, null);
                    break;

                default:
                    throw new PrevalenceException(prevalenceBase, "Invalid value for engineType attribute. Please specify one of [Normal, Transparent].");
                }
            }
            catch (System.Exception x)
            {
                SetUpError(x, item);
            }
        }
Beispiel #11
0
 private void SetupEngine()
 {
     engine = PrevalenceActivator.CreateTransparentEngine(typeof(CacheSystem), dataDir);
     system = engine.PrevalentSystem as CacheSystem;
     taker  = new SnapshotTaker(engine, TimeSpan.FromMinutes(5), CleanUpAllFilesPolicy.Default);
 }
 static PersistenceEngine()
 {
     Engine = PrevalenceActivator.CreateEngine(typeof(PersistenceSet), Path.Combine(Environment.CurrentDirectory, "Data"));
     new SnapshotTaker(Engine, TimeSpan.FromMinutes(1), CleanUpAllFilesPolicy.Default);
 }
Beispiel #13
0
 protected virtual PrevalenceEngine CreateEngine()
 {
     return(PrevalenceActivator.CreateEngine(PrevalentSystemType, PrevalenceBase));
 }
 protected void Application_Start(object sender, EventArgs args)
 {
     _engine = PrevalenceActivator.CreateTransparentEngine(typeof(UserLoginSystem), PrevalenceBase);
 }
 protected override PrevalenceEngine CreateEngine()
 {
     return(PrevalenceActivator.CreateEngine(PrevalentSystemType, PrevalenceBase, true));
 }