public Module_Answer_AddServer(Module_Answer parent) { mainPageLocation = new Configurable() { Name = "WebPagePath", ReadableName = "Path to webpage for Adding new entries to DB", Parent = parent }; port = new Configurable() { Name = "webPort", ReadableName = "Web-server Port", DefaultValue = "80", Parent = parent }; parent.Configurables.Add(mainPageLocation); parent.Configurables.Add(port); mainPage = Accessories.ReadFileToString(mainPageLocation.Value); try { http = new HttpListener(); http.Prefixes.Add("http://*:" + port.Value + "/"); http.Start(); } catch (Exception e) { InformationCollector.Error(http, e.Message); } thread = new Thread(Listen); thread.Start(); dbPath = parent.db_filename.Value; }
private void Awake() { Application.targetFrameRate = 60; _config = Configurable.Instance; _playerController = FindObjectOfType <PlayerController>(); _uiController = FindObjectOfType <UiController>(); _enemiesController = FindObjectOfType <EnemiesController>(); _enemiesController.Init(); MakeBlockOnBorders(); _playerController.Init(); _uiController.Init(_playerController.GetHp()); for (int i = 0; i < 3; i++) { _uiController.SetCurrency((ECurrencyType)i, _config.GetCurrency((ECurrencyType)i)); } SetupAchievementItems(); _playerController.EvnPlayerHpChange += OnPlayerHpChange; _playerController.EvnPlayerDefeated += OnPlayerDefeated; _enemiesController.EvnAsteroidTerminated += OnAsteroidTerminated; _uiController.EvnAchievementDone += OnAchievementDone; }
public void ReadWriteModifyEnum() { var config = Configurable.CreateConfig("ReadWriteModifyEnum").Clear(); var accessor1 = config.ReadValue(new[] { ABC.A, ABC.B, ABC.C }, "EnumArr"); var accessor2 = config.ReadValue(ABC.B, "Enum"); { var actual1 = config.ToString(); var expected1 = @"EnumArr=A B C Enum=B" + Global.NL; Assert.AreEqual(expected1, actual1); } { accessor1.Value[1] = ABC.C; accessor2.Value = ABC.C; accessor1.Commentary = "it is array"; accessor2.Commentary = "it is single value"; var actual2 = config.ToString(); var expected2 = @"EnumArr=A C C\\it is array Enum=C\\it is single value" + Global.NL; Assert.AreEqual(expected2, actual2); } }
//private Constants programConst = new Constants(); public MainWindow() { InitializeComponent(); //tabControl1.SelectedIndexChanged += new EventHandler(); System.Console.WriteLine("Window is loaded"); System.Console.WriteLine(Constants.READY); DBConn connection = new DBConn(); String configDBSource = ConfigurationManager.AppSettings["dbSource"]; dbh = connection.getDBConn(configDBSource); dbh.Open(); // load the system configuration config = new Configurable(dbh); InitializeFormElements(); loadQueues(); //loadImage(); toggleControlsOnOff(false); initializeToolTips(); //TODO: set thresholds. Graph view of each the queues. Green means queue is normal , yellow close to reach peak level, red something is wrong //https://stackoverflow.com/questions/33525881/draw-a-graph-in-windows-forms-application-from-a-datatable-in-a-data-access-clas //dbh.Close(); }
public void ReadArray() { var stream = "Arr=1 2 3".GetBytes(Encoding.UTF8).ToMemoryStream(); var config = Configurable.CreateConfig(stream); Assert.AreEqual(new[] { 1, 2, 3 }, config.ReadValue(new int[0], "Arr").Value); }
static MockConfigurableDetector() { _supportedFormats = new CodecID[] { }; Configurable = new Configurable <ConfigurationKey>(); Configurable.Add(ConfigurationKey.Key1, 123); }
public void OpenAlreadyOpenedAsReadOnlyConfigAsReadWrite() { Configurable.CreateConfig("OpenAlreadyOpenedAsReadOnlyConfigAsReadWrite", "Access", ConfigAccess.READ_ONLY); Configurable.CreateConfig("OpenAlreadyOpenedAsReadOnlyConfigAsReadWrite", "Access", ConfigAccess.READ_ONLY); Assert.Throws <InvalidOperationException>(() => Configurable.CreateConfig("OpenAlreadyOpenedAsReadOnlyConfigAsReadWrite", "Access", ConfigAccess.READ_WRITE)); }
public void ReadAndEraseCommentary() { var config = Configurable.CreateConfig("ReadAndEraseCommentary", "SomeDir").Clear(); config.ReadValue((byte)3, "SomeUInt8").SetComment("Hi!"); config.ReadValue(new int[] { 1, 2, 3 }, "SomeInt32Arr"); var accessor = config.ReadValue("Hello", "SomeString").SetComment("Hello!"); var actual1 = config.ToString(); var expected1 = @"SomeUInt8=3\\Hi! SomeInt32Arr=1 2 3 SomeString=#'Hello'\\Hello!" + Global.NL; Assert.AreEqual(expected1, actual1); Assert.AreEqual("Hello!", accessor.Commentary); accessor.SetComment(null); var actual2 = config.ToString(); var expected2 = @"SomeUInt8=3\\Hi! SomeInt32Arr=1 2 3 SomeString=#'Hello'" + Global.NL; Assert.AreEqual(expected2, actual2); Assert.AreEqual(null, accessor.Commentary); }
public void WriteNullableValueTypes() { var config = Configurable.CreateConfig("WriteNullableValueTypes").Clear(); Assert.Throws <NotSupportedException>(() => config.ReadValue <int?>(null, "SomeInt32")); Assert.Throws <NotSupportedException>(() => config.ReadValue(new double?[] { null, -1, 2, 2.345, null }, "SomeDoubleArr")); }
public void CreateTwoFieldsWithSameName() { var config = Configurable.CreateConfig("CreateTwoFieldsWithSameName").Clear(); config.ReadValue("ABC", "SomeValue"); Assert.Throws <InvalidOperationException>(() => config.ReadValue(123, "SomeValue")); }
public NalUnitStreamParser(INalUnitParser nalUnitParser, IH264State state) { _nalUnitParser = nalUnitParser; _state = state; _nalUnitStartByteLongLengthPrefix = new bool[256]; _nalUnitStartByteShortLengthPrefix = new bool[256]; for (int nalRefIdc = 0; nalRefIdc <= 3; nalRefIdc++) { int nonIdrPictureSliceIndex = (nalRefIdc << 5) | (int)NalUnitType.CodedSliceOfANonIdrPicture; _nalUnitStartByteLongLengthPrefix[nonIdrPictureSliceIndex] = true; } for (int nalRefIdc = 1; nalRefIdc <= 3; nalRefIdc++) { int nalRefIdcBits = (nalRefIdc << 5); _nalUnitStartByteLongLengthPrefix[nalRefIdcBits | (int)NalUnitType.CodedSliceOfAnIdrPicture] = true; _nalUnitStartByteShortLengthPrefix[nalRefIdcBits | (int)NalUnitType.SequenceParameterSet] = true; _nalUnitStartByteShortLengthPrefix[nalRefIdcBits | (int)NalUnitType.PictureParameterSet] = true; } Configurable <H264Detector.ConfigurationKey> configurable = H264Detector.Configurable; _minSliceNalUnitLength = (uint)configurable[H264Detector.ConfigurationKey.MinSliceNalUnitLength]; _maxSliceNalUnitLength = (uint)configurable[H264Detector.ConfigurationKey.MaxSliceNalUnitLength]; }
public static Configurable getInstance(Class targetClass, Map props, string compName) { PropertySheet propSheetInstanceFromClass = ConfigurationManager.getPropSheetInstanceFromClass(targetClass, props, compName, new ConfigurationManager()); Configurable owner = propSheetInstanceFromClass.getOwner(); return((Configurable)targetClass.cast(owner)); }
public void WriteFlatStructObjectsToSubsections() { var config = Configurable.CreateConfig("WriteFlatStructObjectsToSubsections").Clear(); config.ReadObjectFrom(new V2(7, 8), "ROOT.SECTION", "Object4"); config.ReadObjectFrom(new V2(3, 4), "ROOT", "Object2"); config.ReadObjectFrom(new V2(1, 2), null, "Object1"); config.ReadObjectFrom(new V2(5, 6), "ROOT", "Object3"); var actual = config.ToString(); var expected = @"[Object1] X=1 Y=2 [ROOT] [ROOT.Object2] X=3 Y=4 [ROOT.Object3] X=5 Y=6 [ROOT.SECTION] [ROOT.SECTION.Object4] X=7 Y=8" + Global.NL; Assert.AreEqual(expected, actual); }
public void WriteValueAfterFileReleased() { var config = Configurable.CreateConfig("WriteValueAfterFileReleased").Clear(); Configurable.ReleaseFile(config.SourceInfo.FilePath); Assert.Throws <ObjectDisposedException>(() => config.ReadValue("1", "Key1")); }
/// <summary> /// Defines the configuration items to create. /// </summary> /// <param name="configFolder">Folder storing the configuration.</param> public virtual IUpdatableConfigurable[] MakeConfigurations(string configFolder) { // You can add any Configurable here. return(new IUpdatableConfigurable[] { Configurable <Config> .FromFile(Path.Combine(configFolder, "Config.json"), "Default Config") }); }
public void ReleaseFile() { var config = Configurable.CreateConfig("ReleaseFile").Clear(); Assert.Throws <IOException>(() => new FileStream(config.SourceInfo.FilePath, FileMode.Open)); Configurable.ReleaseFile(config.SourceInfo.FilePath); Assert.DoesNotThrow(() => new FileStream(config.SourceInfo.FilePath, FileMode.Open)); }
public void TestAddAndGet() { Configurable <MockConfigurableDetector.ConfigurationKey> configurable = new Configurable <MockConfigurableDetector.ConfigurationKey>(); configurable.Add(MockConfigurableDetector.ConfigurationKey.Key1, 123); Assert.That((int)configurable.Configuration.Count, Is.EqualTo(1)); Assert.That((int)configurable[MockConfigurableDetector.ConfigurationKey.Key1], Is.EqualTo(123)); }
public static string getColor(ConfigurationManager ConfigurationManager, string componentName) { string result; try { Configurable configurable = ConfigurationManager.lookup(componentName); Class @class = java.lang.Object.instancehelper_getClass(configurable); if (java.lang.String.instancehelper_indexOf(@class.getName(), ".recognizer") > 1) { result = "cyan"; } else { if (java.lang.String.instancehelper_indexOf(@class.getName(), ".tools") > 1) { return("darkcyan"); } if (java.lang.String.instancehelper_indexOf(@class.getName(), ".decoder") > 1) { return("green"); } if (java.lang.String.instancehelper_indexOf(@class.getName(), ".frontend") > 1) { return("orange"); } if (java.lang.String.instancehelper_indexOf(@class.getName(), ".acoustic") > 1) { return("turquoise"); } if (java.lang.String.instancehelper_indexOf(@class.getName(), ".linguist") > 1) { return("lightblue"); } if (java.lang.String.instancehelper_indexOf(@class.getName(), ".instrumentation") > 1) { return("lightgrey"); } if (java.lang.String.instancehelper_indexOf(@class.getName(), ".util") > 1) { return("lightgrey"); } goto IL_10B; } } catch (PropertyException) { goto IL_110; } return(result); IL_10B: return("darkgrey"); IL_110: return("black"); }
public void TestGetValueForNonExistingKey() { Configurable <MockConfigurableDetector.ConfigurationKey> configurable = new Configurable <MockConfigurableDetector.ConfigurationKey>(); configurable.Add(MockConfigurableDetector.ConfigurationKey.Key1, 123); Assert.That((int)configurable.Configuration.Count, Is.EqualTo(1)); Assert.That((int)configurable[MockConfigurableDetector.ConfigurationKey.Key2], Is.EqualTo(123)); }
static AsfDetector() { _supportedFormats = new[] { CodecID.Asf }; Configurable = new Configurable <ConfigurationKey>(); Configurable.Add(ConfigurationKey.AsfObjectMaxUnparsedByteCount, (uint)65536); Configurable.Add(ConfigurationKey.AttributeMaxStringLength, (uint)100000); }
public void WriteValueAfterClose() { var config = Configurable.CreateConfig("ReadValue_WriteValueAfterClose").Clear(); config.Close(); var value = config.ReadValue("1", "Key1"); Assert.AreEqual("1", value.Value); }
public void ReadConfigFromStream() { var configData = @"SomeInt32 =10 SomeDouble =1.5" + Global.NL; var stream = Encoding.UTF8.GetBytes(configData).ToMemoryStream(); var config = Configurable.CreateConfig(stream); Assert.AreEqual(10, config.ReadValue(999, "SomeInt32").Value); Assert.AreEqual(1.5, config.ReadValue(999D, "SomeDouble").Value); }
public override void SetupConfig() { phrasePath = new Configurable() { Name = "dbpath", ReadableName = "Path to Database", Parent = this }; Configurables.Add(phrasePath); }
public override void SetupConfig() { db_filename = new Configurable() { Name = "dbpath", ReadableName = "Path to Database", Parent = this }; Configurables.Add(db_filename); }
public void ModifyValue() { var config = Configurable.CreateConfig("ModifyValue", "").Clear(); config.ReadValue(10, "SomeInt32"); var accessor = config.ReadValue("Hello ", "SomeString"); config.ReadValue(3, "SomeByte"); accessor.Value = $"Hello {Global.Random.NextENWord()}"; }
static QtDetector() { _supportedFormats = new[] { CodecID.QuickTime, CodecID.Itu3Gpp }; Configurable = new Configurable <ConfigurationKey>(); Configurable.Add(ConfigurationKey.QtAtomMaxUnparsedBytes, (uint)65536); Configurable.Add(ConfigurationKey.FileTypeMaxUnparsedBytes, (uint)1000); Configurable.Add(ConfigurationKey.MediaDateMaxUnparsedBytes, (uint)64); Configurable.Add(ConfigurationKey.ReferenceMovieDataReferenceMaxUrlLength, (uint)1000); }
public void ModifyAfterClose() { var config = Configurable.CreateConfig("ModifyAfterClose").Clear(); config.Close(); var value = config.ReadValue("1", "Key1"); value.Value = "2"; Assert.AreEqual("2", value.Value); }
static Mpeg2VideoDetector() { Configurable = new Configurable <ConfigurationKey>(); Configurable.Add(ConfigurationKey.MaxVideoHeaderCount, (uint)100000); Configurable.Add(ConfigurationKey.MinVideoHeaderCount, (uint)2); Configurable.Add(ConfigurationKey.UserDataMaxLength, (uint)4096); Configurable.Add(ConfigurationKey.SliceMaxLength, (uint)0x20000); Configurable.Add(ConfigurationKey.ParserMaxZeroByteStuffingLength, (uint)32); Configurable.Add(ConfigurationKey.MaximumSliceNumberIncrement, (uint)2); Configurable.Add(ConfigurationKey.PictureHeaderMaxLengthOfExtraInformation, (uint)1000); }
public void ModifyArrayValue() { var config = Configurable.CreateConfig("ModifyArrayValue").Clear(); var accessor = config.ReadValue(new[] { 10, 20, 55 }, "SomeInt32Array"); var expected = Global.Random.NextUnique(0, 1000, 10).ToArray(); accessor.Value = expected; var actual = accessor.Value; Assert.AreEqual(expected, actual); }
static Mpeg2SystemDetector() { Configurable = new Configurable <ConfigurationKey>(); Configurable.Add(ConfigurationKey.MaxSystemHeaderCount, (uint)150000); Configurable.Add(ConfigurationKey.MinSystemHeaderCount, (uint)2); Configurable.Add(ConfigurationKey.PesPacketMaxUnknownByteCount, (uint)1000); Configurable.Add(ConfigurationKey.PictureHeaderMaxLengthOfExtraInformation, (uint)1000); Configurable.Add(ConfigurationKey.ExtraByteCountAllowedBetweenHeaders, (uint)0); Configurable.Add(ConfigurationKey.UseSystemClockReferenceValidation, true); Configurable.Add(ConfigurationKey.MaxTimeGapSeconds, 1.0); Configurable.Add(ConfigurationKey.MaxZeroByteStuffingLength, (uint)32); }
public void ConfigurationUpdate(Configurable config) { if(config is DeviceSettings) { DeviceSettings settings = (DeviceSettings)config; OutputSettings devSettings; devSettings.MaxBrightness = settings.maxBrightness; devSettings.redBias = settings.redBias; devSettings.greenBias = settings.greenBias; devSettings.blueBias = settings.blueBias; devSettings.whiteBalanceMin = Convert.ToUInt16((Math.Abs(settings.redBias) + Math.Abs(settings.greenBias) + Math.Abs(settings.blueBias) / 3)); AllDeviceSettings[settings.id] = devSettings; } }
/// <summary> /// Update Extensions when new Configuration is available /// </summary> /// <param name="config"></param> public void ConfigurationUpdate(Configurable config) { if(config is DeviceSettings && Extensions != null) { bool wasRunning = running; if(wasRunning) { Stop(); } DeviceSettings settings = (DeviceSettings)config; if(Extensions.ActiveDriver != null) { Extensions.ActiveDriver.stepSleep = settings.stepSleep; Extensions.ActiveDriver.weighted = settings.weightingEnabled; } if(Extensions.ActiveGrabber != null) { Extensions.ActiveGrabber.captureThrottle = settings.captureThrottle; Extensions.ActiveGrabber.x = settings.boundX; Extensions.ActiveGrabber.y = settings.boundY; Extensions.ActiveGrabber.width = settings.boundWidth; Extensions.ActiveGrabber.height = settings.boundHeight; } foreach(var process in Extensions.ActiveProcessors) { if(settings.id == process.devId) { process.SetArea(settings.x - settings.boundX, settings.y - settings.boundY, settings.width, settings.height); } } if(wasRunning) { Start(); } } }
/// <summary> /// Update UI to match with new config announced /// </summary> /// <param name="config"></param> public void ConfigurationUpdate(Configurable config) { if(config is DeviceSettings && window != null) {//settings changed DeviceSettings settings = (DeviceSettings)config; window.SetCaptureThrottleValue(settings.captureThrottle); window.SetBrightnessValue(Convert.ToInt32(settings.maxBrightness * 100)); ResendManualColor(settings.id); } }
/// <summary> /// Route the ConfigurationUpdate to the correct ExtensionInstance /// </summary> /// <param name="config"></param> public void ConfigurationUpdate(Configurable config) { foreach(ExtensionInstance Instance in Instances.Values) { Instance.ConfigurationUpdate(config); } }
/// <summary> /// Handle a ConfigurationUpdate /// </summary> /// <param name="config"></param> public void ConfigurationUpdate(Configurable config) { if(NewConfigUpdateAvail != null) { NewConfigUpdateAvail(config); } }