Ejemplo n.º 1
0
        public void ReloadConfig()
        {
            ParentConfig?.ReloadConfig();
            Config?.ReadConfigFile();

            ConfigLocation          = ShouldGetFromConfig(ConfigLocationKey) ? Config.GetString(ConfigLocationKey, "") : ParentConfig.ConfigLocation;
            DisableConfigValidation = ShouldGetFromConfig(DisableConfigValidationKey) ? Config.GetBool(DisableConfigValidationKey, false) : ParentConfig.DisableConfigValidation;
            ShareNonConfigs         = ShouldGetFromConfig(ShareNonConfigsKey) ? Config.GetBool(ShareNonConfigsKey, true) : ParentConfig.ShareNonConfigs;
            NoLog             = ShouldGetFromConfig(NoLogKey) ? Config.GetBool(NoLogKey, false) : ParentConfig.NoLog;
            DebugLog          = ShouldGetFromConfig(DebugLogKey) ? Config.GetBool(DebugLogKey, true) : ParentConfig.DebugLog;
            DebugLogBlacklist = ShouldGetFromConfig(DebugLogBlacklistKey) ? Config.GetStringList(DebugLogBlacklistKey, new string[] { "ProcessFile" }) : ParentConfig.DebugLogBlacklist;
            DebugLogWhitelist = ShouldGetFromConfig(DebugLogWhitelistKey) ? Config.GetStringList(DebugLogWhitelistKey, new string[0]) : ParentConfig.DebugLogWhitelist;
            UseNewInputSystem = ShouldGetFromConfig(UseNewInputSystemKey) ? Config.GetBool(UseNewInputSystemKey, true) : ParentConfig.UseNewInputSystem;
            Port = ShouldGetFromConfig(PortKey) ? Config.GetUInt(PortKey, 7777) : ParentConfig.Port;
            CopyFromFolderOnReload        = ShouldGetFromConfig(CopyFromFolderOnReloadKey) ? Config.GetString(CopyFromFolderOnReloadKey, "") : ParentConfig.CopyFromFolderOnReload;
            FilesToCopyFromFolder         = ShouldGetFromConfig(FilesToCopyFromFolderKey) ? Config.GetStringList(FilesToCopyFromFolderKey, new string[0]) : ParentConfig.FilesToCopyFromFolder;
            FolderCopyRoundQueue          = ShouldGetFromConfig(FolderCopyRoundQueueKey) ? Config.GetStringList(FolderCopyRoundQueueKey, new string[0]) : ParentConfig.FolderCopyRoundQueue;
            RandomizeFolderCopyRoundQueue = ShouldGetFromConfig(RandomizeFolderCopyRoundQueueKey) ? Config.GetBool(RandomizeFolderCopyRoundQueueKey, false) : ParentConfig.RandomizeFolderCopyRoundQueue;
            LogModActionsToOwnFile        = ShouldGetFromConfig(LogModActionsToOwnFileKey) ? Config.GetBool(LogModActionsToOwnFileKey, false) : ParentConfig.LogModActionsToOwnFile;
            ManualStart              = ShouldGetFromConfig(ManualStartKey) ? Config.GetBool(ManualStartKey, false) : ParentConfig.ManualStart;
            MaxMemory                = ShouldGetFromConfig(MaxMemoryKey) ? Config.GetFloat(MaxMemoryKey, 2048) : ParentConfig.MaxMemory;
            RestartLowMemory         = ShouldGetFromConfig(RestartLowMemoryKey) ? Config.GetFloat(RestartLowMemoryKey, 400) : ParentConfig.RestartLowMemory;
            RestartLowMemoryRoundEnd = ShouldGetFromConfig(RestartLowMemoryRoundEndKey) ? Config.GetFloat(RestartLowMemoryRoundEndKey, 450) : ParentConfig.RestartLowMemoryRoundEnd;
            MaxPlayers               = ShouldGetFromConfig(MaxPlayersKey) ? Config.GetInt(MaxPlayersKey, 20) : ParentConfig.MaxPlayers;
            RandomInputColors        = ShouldGetFromConfig(RandomInputColorsKey) ? Config.GetBool(RandomInputColorsKey, false) : ParentConfig.RandomInputColors;
            RestartEveryNumRounds    = ShouldGetFromConfig(RestartEveryNumRoundsKey) ? Config.GetInt(RestartEveryNumRoundsKey, -1) : ParentConfig.RestartEveryNumRounds;
            ServerRestartTimeout     = ShouldGetFromConfig(ServerRestartTimeoutKey) ? Config.GetFloat(ServerRestartTimeoutKey, 10) : ParentConfig.ServerRestartTimeout;
            ServerStopTimeout        = ShouldGetFromConfig(ServerStopTimeoutKey) ? Config.GetFloat(ServerStopTimeoutKey, 10) : ParentConfig.ServerStopTimeout;
            ServersFolder            = ShouldGetFromConfig(ServersFolderKey) ? Config.GetString(ServersFolderKey, "servers") : ParentConfig.ServersFolder;
            ShutdownWhenEmptyFor     = ShouldGetFromConfig(ShutdownWhenEmptyForKey) ? Config.GetInt(ShutdownWhenEmptyForKey, -1) : ParentConfig.ShutdownWhenEmptyFor;
            StartConfigOnFull        = ShouldGetFromConfig(StartConfigOnFullKey) ? Config.GetString(StartConfigOnFullKey, "") : ParentConfig.StartConfigOnFull;
        }
Ejemplo n.º 2
0
 private static void Initialize()
 {
     ParentServerConfig = new ParentConfig(2);
     ServerConfig       = new NetConfig();
     ServerConfig.SetMaxBackLogConnections(MAXIMUM_BACKLOG);
     ServerConfig.SetMaxConnections(MAXIMUM_CONNECTIONS);
     ServerConfig.SetMaxMessageSize(MESSAGE_SIZE);
     ServerConfig.SetBufferSize(BUFFER_SIZE);
     ServerConfig.SetHeaderSize(HEADER_SIZE);
     ServerConfig.SetEnableKeepAlive(false);
     ServerConfig.SetPort(1660);
     ParentServer = new Parent(ParentServerConfig, ServerConfig);
     ParentServer.OnParentCreatedEvent     += ParentServer_OnParentCreatedEvent;
     ParentServer.OnParentClosedEvent      += ParentServer_OnParentClosedEvent;
     ParentServer.OnExceptionEvent         += ParentServer_OnExceptionEvent;
     ParentServer.OnChildCreateEvent       += ParentServer_OnChildCreateEvent;
     ParentServer.OnChildConnectEvent      += ParentServer_OnChildConnectEvent;
     ParentServer.OnChildAuthenticateEvent += ParentServer_OnChildAuthenticateEvent;
     ParentServer.OnChildSendEvent         += ParentServer_OnChildSendEvent;
     ParentServer.OnChildReceiveEvent      += ParentServer_OnChildReceiveEvent;
     ParentServer.OnChildDisconnectEvent   += ParentServer_OnChildDisconnectEvent;
     ParentServer.OnChildDestroyEvent      += ParentServer_OnChildDestroyEvent;
     Input  = new InputQueue(ParentServer);
     Output = new OutputQueue();
     Output.OnFrameEvent += Output_OnFrameEvent;
     ParentServer.StartParent();
     PacketHandler = new PacketHandler(Input, Output, MainLogger);
     ConnectPipeline();
     Pipeline.SendMessage(new IViewNet.Common.Models.Packet(1111, "SetDetectionType", new byte[1024 * 19]));
     Console.ReadKey();
 }
Ejemplo n.º 3
0
        internal /*public*/ void FixupInheritance(IndividualDeviceConfig referrer, XmlNode configNode)
        {
            if (_fixup == FixupState.FixedUp)
            {
                return;
            }

            if (_fixup == FixupState.FixingUp)
            {
                Debug.Assert(referrer != null);

                // Circular reference
                throw new Exception(SR.GetString(SR.MobileControlsSectionHandler_CircularReference,
                                                 referrer.Name));
            }

            _fixup = FixupState.FixingUp;

            if (ParentConfigName != null)
            {
                Debug.Assert(ParentConfigName != String.Empty && ParentConfig == null);

                ParentConfig = _controlsConfig.GetDeviceConfig(ParentConfigName);

                if (ParentConfig == null)
                {
                    throw new ConfigurationException(
                              SR.GetString(SR.MobileControlsSectionHandler_DeviceConfigNotFound,
                                           ParentConfigName),
                              configNode);
                }

                // Make sure parent is fixed up.

                ParentConfig.FixupInheritance(this, configNode);

                if (PageAdapterType == null)
                {
                    PageAdapterType = ParentConfig.PageAdapterType;
                }

                if (DeviceQualifiesPredicate == null)
                {
                    DeviceQualifiesPredicate = ParentConfig.DeviceQualifiesPredicate;
                }

                Debug.Assert(PageAdapterType != null);
                Debug.Assert(DeviceQualifiesPredicate != null);

                // Reset this since we don't need it any longer.
                ParentConfigName = null;
            }

            _fixup = FixupState.FixedUp;
        }
Ejemplo n.º 4
0
        public void CheckJoinTables()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var potatoFields = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("FoobarId", null),
                new FieldConfig("Type", null)
            };
            var foobarRelationship = new ParentConfig ("Foobar", null, null);
            var tables = new List<OracularTable>
            {
                new OracularTable("Foobar", null, null, justAnId),
                new OracularTable("Potato", null, new List<ParentConfig>{foobarRelationship}, potatoFields)
            };
            var specs = new List<OracularSpec>();
            var config = new OracularConfig (tables, specs);
            var checker = new RefChecker (config);

            var fingerlingPotatoes = new BinaryOperation("=",
                new Reference(new [] { "Potato", "Type" }),
                new StringLiteral("Fingerling")
            );

            var call = new MacroExpansion(
                new Reference(new [] { "ANY" }),
                new AstNode[] {
                    new Reference(new [] { "Potato" }),
                    fingerlingPotatoes
                }
            );

            var initial = new []{ "Foobar" };

            var result = call.Walk (checker, initial);

            Assert.AreEqual (2, result.Length);
            Assert.Contains ("Foobar", result);
            Assert.Contains ("Potato", result);
        }
Ejemplo n.º 5
0
        public void ExpectNestedSpecToRefcheck()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var potatoFields = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("FoobarId", null)
            };
            var foobarRelationship = new ParentConfig ("Foobar", null, null);
            var tables = new List<OracularTable>
            {
                new OracularTable("Foobar", null, null, justAnId),
                new OracularTable("Potato", null, new List<ParentConfig>{foobarRelationship}, potatoFields)
            };
            var specs = new List<OracularSpec>();
            var config = new OracularConfig (tables, specs);
            var checker = new RefChecker (config);

            var fingerlingPotatoes = new MacroExpansion(
                new Reference(new [] { "isFingerling" }),
                new [] { new Reference(new [] { "Potato" }) }
            );

            var call = new MacroExpansion(
                new Reference(new [] { "ANY" }),
                new AstNode[] {
                    new Reference(new [] { "Potato" }),
                    fingerlingPotatoes
                }
            );

            var initial = new []{ "Foobar" };

            var ex = Assert.Throws<RefCheckException> (() => call.Walk (checker, initial));

            Assert.That (REFERENCE_RE.IsMatch (ex.Message));
        }