Пример #1
0
        private static void TestXmlDatabase()
        {
            XmlDatabase db = new XmlDatabase(@"C:\tmp");
              db.OutputIndent = true;

              Cat origin = new Cat() { Name = "Garfield", Legs = 4 };
              db.Save<Cat>(origin);

              db.Save<Cat>(origin.Id, origin);
              db.Delete<Cat>(origin.Id);
        }
Пример #2
0
        private static Form GetMain()
        {
            //var database = new BinaryDatabase<List<Node>>("nodes.binary");
            var database          = new XmlDatabase <List <Node> >("nodes.xml");
            var nodeRepository    = new NodeRepository(database);
            var dataDecoder       = new DataDecoder();
            var connectionChecker = new ConnectionChecker(dataDecoder);
            var frmMain           = new frmMain(nodeRepository, connectionChecker);

            return(frmMain);
        }
Пример #3
0
        public void TestMethod1()
        {
            XmlDatabase db = new XmlDatabase();
            StringReader sr = new StringReader(@"<?xml version=""1.0"" encoding=""utf-8"" ?>
            <JinxBotDatabase Provider=""JinxBot.Plugins.Data.Xml.XmlDatabase, JinxBot.Plugins.Data.Xml, Version=1.0.0.0""
                 Version=""1.0"">
            <Roles>
            <Role Name=""O"" Description=""Owner"">
            <Overrides>
                <Override Name=""B"" />
            </Overrides>
            </Role>
            <Role Name=""B"" Description=""Autoban"" />
            </Roles>

            <Users>
            <User Name=""MyndFyre"" Gateway=""USEast"" LastSeen=""Never"">
            <Roles>
                <Add Role=""O"" />
            </Roles>
            </User>
            <User Name=""brew"" Gateway=""USEast"" LastSeen=""Never"">
            <Roles>
                <Add Role=""B"" />
            </Roles>
            </User>
            </Users>

            <Metas>
            <Meta InputString=""*joe*"" Match="".*joe.*"">
            <Roles>
                <Add Role=""B"" />
            </Roles>
            </Meta>
            </Metas>
            </JinxBotDatabase>");
            db.Load(sr);
            Assert.IsTrue(db.IsRoleOverridden("B", new string[] { "B", "O" }));
            Assert.IsFalse(db.IsRoleOverridden("O", new string[] { "B", "O" }));

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            db.Save(sw);
            Debug.WriteLine(sb.ToString(), "Database Persisted");
            db.Load(new StringReader(sb.ToString()));
            sb = new StringBuilder();
            sw = new StringWriter(sb);
            db.Save(sw);
            Debug.WriteLine(sb.ToString());
        }
Пример #4
0
        private static void TestXmlDatabase()
        {
            XmlDatabase db = new XmlDatabase(@"C:\tmp");

            db.OutputIndent = true;

            Cat origin = new Cat()
            {
                Name = "Garfield", Legs = 4
            };

            db.Save <Cat>(origin);

            db.Save <Cat>(origin.Id, origin);
            db.Delete <Cat>(origin.Id);
        }
Пример #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Logger.Debug("OnStartUp");

            InitializeComponent();
            base.OnStartup(e);

            Application.Current.DispatcherUnhandledException += OnUnhandledException;

            // Load theme
            try
            {
                WpfHelper.LoadTheme(Configuration.CurrentTheme);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Failed to load theme {0}, {1}",
                                              Configuration.CurrentTheme, ex.Message), "Astounding Dock",
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Set default resources. Even if the theme fails to load, with these set the application should run fine.
            if (!this.Resources.Contains("WindowBackgroundBrush"))
            {
                this.Resources.Add("WindowBackgroundBrush", new SolidColorBrush(Colors.Gray));
            }
            if (!this.Resources.Contains("TextBrush"))
            {
                this.Resources.Add("TextBrush", new SolidColorBrush(Colors.Black));
            }

            // Register services
            RegisterServices();

            // Load xml file
            XmlDatabase database = new XmlDatabase(Configuration.DatabaseFile);

            Application.Current.Exit += OnApplicationExit;

            // Opened the main window.
            MainViewModel viewModel = new MainViewModel(database);

            ServiceManager.GetService <IViewService>().OpenWindow(viewModel);
        }
Пример #6
0
        //private static void TestJsonDatabase()
        //{
        //    JsonDatabase db = new JsonDatabase(@"C:\tmp");
        //    db.OutputIndent = true;

        //    Cat origin = new Cat() { Name = "Garfield", Legs = 4 };
        //    db.Save<Cat>(origin);

        //    db.Save<Cat>(origin.Id, origin);
        //    db.Delete<Cat>(origin.Id);
        //}

        private static void TestXmlDatabase()
        {
            XmlDatabase db = new XmlDatabase(@"C:\tmp");

            db.OutputIndent = true;

            Cat origin = new Cat()
            {
                Name = "Garfield", Legs = 4
            };

            db.Save <Cat>(origin);

            db.Save <Cat>(origin.Id, origin);

            IEnumerable <Cat> founds = db.FindAll <Cat>();

            Cat found = db.FindOneById <Cat>(origin.Id);


            db.Delete <Cat>(origin.Id);
        }
Пример #7
0
        public MainViewModel(XmlDatabase database)
        {
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }

            _database = database;
            Tabs      = new ObservableCollection <TabViewModel>();
            TabsView  = (ListCollectionView)CollectionViewSource.GetDefaultView(Tabs);
            TabsView.SortDescriptions.Add(new SortDescription("TabOrder", ListSortDirection.Ascending));

            // Loading applications asynchronously using reactive extensions to reduce initial startup time.

            // TODO: Does this actually speed things up or is it loading all the sections before add doing
            // the subscribe??
            _database.LoadTabs().OrderBy(x => x.TabOrder).ToObservable().Subscribe(tabModel =>
            {
                TabViewModel tabViewModel = new TabViewModel(tabModel);
                Tabs.Add(tabViewModel);
                Configuration.AvailableTabs.Add(tabViewModel.Title);
            },
                                                                                   () => // OnComplete
            {
                FixTabOrdering();

                Tabs.CollectionChanged += OnTabsChanged;

                // Expand the default tab when the application starts up.
                ExpandedTab = Tabs.SingleOrDefault(obj => obj.Title == Configuration.DefaultTab) ?? Tabs.FirstOrDefault();
            });

            Messenger.Default.Register <ApplicationMessage>(this, OnApplicationMessage);
            Messenger.Default.Register <TabMessage>(this, OnTabMessage);
            Messenger.Default.Register <TabToMainMessage>(this, OnTabToMainMessage);
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlagRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public FlagRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <FlagEntity>(fileName);
 }
Пример #9
0
 public XmlChatDatabase(string filePath)
 {
     _xmlDatabase = new XmlDatabase(filePath);
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FactionRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public FactionRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <FactionEntity>(fileName);
 }
Пример #11
0
 public static void Load()
 {
     db = new XmlDatabase(DatabaseLocation, new string[] { SyncTag }, null);
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public ResourceRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <ResourceEntity>(fileName);
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HoldingRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public HoldingRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <HoldingEntity>(fileName);
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BorderRepository"/> class.
 /// </summary>
 public BorderRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <BorderEntity>(fileName);
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public UnitRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <UnitEntity>(fileName);
 }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CultureRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public CultureRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <CultureEntity>(fileName);
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProvinceRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public ProvinceRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <ProvinceEntity>(fileName);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProfileEventRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public ProfileEventRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <ProfileEventEntity>(fileName);
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BiomeRepository"/> class.
 /// </summary>
 /// <param name="fileName">File name.</param>
 public BiomeRepository(string fileName)
 {
     xmlDatabase = new XmlDatabase <BiomeEntity>(fileName);
 }