Ejemplo n.º 1
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 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);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
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);
            }
        }
 static PersistenceEngine()
 {
     Engine = PrevalenceActivator.CreateEngine(typeof(PersistenceSet), Path.Combine(Environment.CurrentDirectory, "Data"));
     new SnapshotTaker(Engine, TimeSpan.FromMinutes(1), CleanUpAllFilesPolicy.Default);
 }
Ejemplo n.º 9
0
 protected virtual PrevalenceEngine CreateEngine()
 {
     return(PrevalenceActivator.CreateEngine(PrevalentSystemType, PrevalenceBase));
 }
 protected override PrevalenceEngine CreateEngine()
 {
     return(PrevalenceActivator.CreateEngine(PrevalentSystemType, PrevalenceBase, true));
 }