Beispiel #1
0
        public DEServer(string configurationFile, IEnumerable <string> properties)
            : base(new ServiceContainer(), "Main")
        {
            if (Current != null)
            {
                throw new InvalidOperationException("Only one instance per process is allowed.");
            }
            Current = this;

            // register resolver
            this.resolveEventHandler = (sender, e) => ResolveAssembly(e.Name, e.RequestingAssembly);
            AddAssemblyPath(".");
            AddAssemblyPath(Path.GetDirectoryName(GetType().Assembly.Location));
            AppDomain.CurrentDomain.AssemblyResolve += resolveEventHandler;

            // register session list
            this.eventSessions = new DEList <EventSession>(this, "tw_eventsessions", "Event sessions");

            // create configurations service
            this.configuration = new DEConfigurationService(this, configurationFile, ConvertProperties(properties));
            this.dumpFiles     = new DEList <DumpFileInfo>(this, "tw_dumpfiles", "Dumps");

            PublishItem(dumpFiles);
            PublishItem(new DEConfigItemPublicAction("dump")
            {
                DisplayName = "Dump"
            });
        } // ctor
Beispiel #2
0
        public void LoadAssemblies()
        {
            var service = new SimpleServiceProvider();
            var cs      = new DEConfigurationService(service, @"..\..\Files\01_Main.xml", new DE.Stuff.PropertyDictionary());

            service.Add(typeof(IDEConfigurationService), cs);

            cs.UpdateSchema(Assembly.LoadFile(Path.GetFullPath(@"..\..\..\Server\bin\Debug\DEServer.exe")));

            var n = cs[DEConfigurationConstants.MainNamespace + "configLogItem"];

            Assert.IsNotNull(n);
            Assert.AreEqual("configLogItem", n.Name.LocalName);
            Assert.AreEqual(typeof(DEConfigLogItem), n.ClassType);

            foreach (var c in n.GetAttributes())
            {
                Console.WriteLine($"Attribute[{c.IsPrimaryKey}]: {c.Name.LocalName} : {c.TypeName} [{c.Type}]");
            }

            var a2 = n.GetAttributes().FirstOrDefault(c => c.Name == "script");

            Assert.IsNotNull(a2);
            Assert.IsTrue(a2.IsList);

            foreach (var c in n.GetElements())
            {
                Console.WriteLine($"Element: {c.Name.LocalName}");
            }

            var n2 = n.GetElements().FirstOrDefault(c => c.Name == DEConfigurationConstants.MainNamespace + "log");

            Assert.IsNotNull(n2);
            Assert.IsNull(n2.ClassType);
            Assert.IsNotNull(n2.Documentation);

            var a1 = n2.GetAttributes().FirstOrDefault(c => c.Name == "min");

            Assert.IsNotNull(a1);
            Assert.AreEqual(typeof(uint), a1.Type);
            Assert.AreEqual("3670016", a1.DefaultValue);
        }
Beispiel #3
0
        public void MergeConfigurations()
        {
            var service = new SimpleServiceProvider();
            var cs      = new DEConfigurationService(service, @"..\..\Files\01_Main.xml", new DE.Stuff.PropertyDictionary());

            service.Add(typeof(IDEConfigurationService), cs);
            cs.UpdateSchema(Assembly.LoadFile(Path.GetFullPath(@"..\..\..\Server\bin\Debug\DEServer.exe")));

            var x = cs.ParseConfiguration();

            Console.WriteLine(x.ToString());

            // tests

            var p = x.Element(DEConfigurationConstants.xnServer)?.Attribute("logpath")?.Value;

            Assert.IsTrue(Path.IsPathRooted(p));

            var c1 = x.Elements(DEConfigurationConstants.MainNamespace + "configLogItem").First();

            Assert.IsNotNull(c1);
            Assert.AreEqual("test 1", c1.Attribute("displayname")?.Value);
            Assert.AreEqual("neu", c1.Attribute("icon")?.Value);

            var l1 = c1.Element(DEConfigurationConstants.xnLog);

            Assert.IsNotNull(l1);
            Assert.AreEqual("4096", l1.Attribute("min")?.Value);
            Assert.AreEqual("8128", l1.Attribute("max")?.Value);

            var c2 = x.Elements(DEConfigurationConstants.MainNamespace + "configLogItem").Skip(1).First();

            Assert.IsNotNull(c2);
            Assert.AreEqual("test 2", c2.Attribute("displayname")?.Value);
            Assert.AreEqual("script1 script2 script3", c2.Attribute("script")?.Value);
            var l2 = c2.Element(DEConfigurationConstants.xnLog);

            Assert.IsNotNull(l2);
            Assert.AreEqual("4096", l2.Attribute("min")?.Value);
            Assert.AreEqual("8128", l2.Attribute("max")?.Value);
        }
Beispiel #4
0
        }         // proc InitConfiguration

        private void DoneConfiguration()
        {
            configuration = null;
        }         // proc DoneConfiguration