public void AddSwitch(Switches.Switch _switch) { var switchButton = new SwitchButton(_switch); SwitchButtons.Add(switchButton); SwitchesContainer.Children.Add(switchButton); switchButton.SetSize(IconSize); }
/// <summary> /// Initialisiert den Schalter. /// </summary> /// <param name="swi">der abzubildende Schalter</param> public Switch(Switches swi, DigitalIn aDigitalIn) { this.swi = swi; this.digitalIn = aDigitalIn; this.digitalIn.DigitalInChanged += new EventHandler(digitalInChanged); this.oldState = false; }
public void BranchpointRule_Unspecified() { var switches = new Switches(); var config = new Config(switches); Assert.IsNull(config.BranchpointRule); }
/// <summary> /// Initialisiert den Schalter. /// </summary> /// <param name="swi">der abzubildende Schalter</param> public Switch(DigitalIn digitalIn, Switches swi) { this.digitalIn = digitalIn; this.swi = swi; this.oldState = false; this.digitalIn.DigitalInChanged += new EventHandler(digitalIn_DigitalInChanged); }
public void CvsLogFileName_NotSpecified_DefaultValue() { var switches = new Switches(); var config = new Config(switches); Assert.AreEqual(Path.GetFullPath(@"DebugLogs\cvs.log"), config.CvsLogFileName); Assert.IsTrue(config.CreateCvsLog); }
/// <summary> /// Initializes a new instance of the <see cref="Switch" /> class. /// </summary> /// <param name="swi">The swi.</param> /// <param name="digitalIn">The digital in.</param> /// <exception cref="System.ArgumentNullException"></exception> public Switch(Switches swi, DigitalIn digitalIn) { if (digitalIn == null) throw new ArgumentNullException("digitalIn"); _switch = swi; _digitalIn = digitalIn; _digitalIn.DigitalInChanged += DigitalInChanged; _oldState = false; }
public void GitDir_NotEmpty_NoImportSpecified() { using (var temp = new TempDir()) { File.WriteAllText(temp.GetPath("file.txt"), "blah"); var switches = new Switches(); switches.Parse("--sandbox", Path.GetTempPath(), "--gitdir", temp.Path, "--noimport"); } }
public void CvsLogFileName_Specified_Exists() { using (var temp = new TempDir()) { var logFilename = temp.GetPath("blah.log"); File.WriteAllText(logFilename, "blah"); var switches = new Switches() { CvsLog = logFilename, }; var config = new Config(switches); Assert.AreEqual(logFilename, config.CvsLogFileName); Assert.IsFalse(config.CreateCvsLog); } }
public void ConfFile_VerifyNotCalledUntilAllSwitchesProcessed() { using (var temp = new TempDir()) { var confFileName = temp.GetPath("test.conf"); File.WriteAllText(confFileName, "noimport\r\n"); var sandbox = temp.GetPath("sandbox"); Directory.CreateDirectory(sandbox); // specify sandbox directory after the conf file has been processed var switches = new Switches(); switches.Parse("-C", confFileName, "--sandbox", sandbox); Assert.IsTrue(switches.NoImport); Assert.AreEqual(sandbox, switches.Sandbox); } }
public void Dispose() { if (IsDisposed) { return; } //Console.WriteLine("SuperGump Disposing: {0} (0x{1:X})", GetType(), Serial); //GC.SuppressFinalize(this); IsDisposed = true; IsOpen = Hidden = false; VitaNexCore.TryCatch(OnDispose); VitaNexCore.TryCatch(UnregisterInstance); VitaNexCore.TryCatch( () => { if (Linked != null) { Linked.ForEachReverse(Unlink); Linked.Free(true); } }); VitaNexCore.TryCatch( () => { if (Children != null) { Children.ForEachReverse(RemoveChild); Children.Free(true); } }); VitaNexCore.TryCatch( () => { if (InstancePoller != null) { InstancePoller.Dispose(); } }); VitaNexCore.TryCatch( () => { if (Entries != null) { Entries.ForEachReverse( e => { if (e is IDisposable) { VitaNexCore.TryCatch(((IDisposable)e).Dispose); } }); } }); VitaNexCore.TryCatch(OnDisposed); VitaNexCore.TryCatch( () => { if (Buttons != null) { Buttons.Clear(); } if (TileButtons != null) { TileButtons.Clear(); } if (Switches != null) { Switches.Clear(); } if (Radios != null) { Radios.Clear(); } if (TextInputs != null) { TextInputs.Clear(); } if (LimitedTextInputs != null) { LimitedTextInputs.Clear(); } if (Entries != null) { Entries.Free(true); } if (Layout != null) { Layout.Clear(); } }); NextButtonID = 1; NextSwitchID = 0; NextTextInputID = 0; OnActionSend = null; OnActionClose = null; OnActionHide = null; OnActionRefresh = null; OnActionDispose = null; OnActionClick = null; OnActionDoubleClick = null; LastButtonClicked = null; Buttons = null; ButtonHandler = null; TileButtons = null; TileButtonHandler = null; Switches = null; SwitchHandler = null; Radios = null; RadioHandler = null; TextInputs = null; TextInputHandler = null; LimitedTextInputs = null; LimitedTextInputHandler = null; Layout = null; Linked = null; Children = null; Parent = null; User = null; InstancePoller = null; }
public static async Task SellOnPercentOverTime() { var restClient = new RestClient(Switches.AlpacaAPIKey(), Switches.AlpacaSecretAPIKey(), Switches.AlpacaEndPoint()); if (File.Exists(Switches.stockDirectory + "Portfolio.csv")) { var allLines = File.ReadAllLines(Switches.stockDirectory + "Portfolio.csv"); for (int i = 1; i < allLines.Count(); i++) { string[] temp = allLines[i].Split(','); var p2 = await restClient.GetAssetAsync((temp[0])); var position = await restClient.GetPositionAsync(temp[0]); int numberOfShares = position.Quantity; int daysAlloted = DateTime.Today.Day - Convert.ToDateTime(temp[1]).Day; //set minimal required selling point double required = Convert.ToDouble(temp[3]); if (daysAlloted < 7 && daysAlloted > 0) { required *= (1 + 0.005 * daysAlloted); } else if (daysAlloted >= 7 && daysAlloted < 30) { required *= (1.03); } else if (daysAlloted > 31 && daysAlloted <= 60) { required *= (1.1); } else { required *= 1.18; } try { if ((double)position.AssetCurrentPrice > required) { var order = await restClient.PostOrderAsync(temp[0], numberOfShares, OrderSide.Sell, OrderType.Market, TimeInForce.Day); } } catch (Exception ex) { Console.WriteLine("could not sell because " + ex.ToString()); } } } }
/// <summary> /// Parses a switch. /// </summary> private void ParseSwitch(string SwitchID, ref int CmdLinePtr, ref int TemplPtr, bool xlatStrings) { string MethodName = "CommandLine.ParseSwitch"; LogWrite(MethodName + ": SwitchID = " + SwitchID); char SwitchType; int i = Template.ToUpper().IndexOf(SwitchID.ToUpper()); if (i > -1) { // The switch is expected. Set the template // pointer to point to the switch's type: TemplPtr = i + 2; // Determine the type of switch: if (TemplPtr < Template.Length) { // Not yet to end-of-template. if ((Template[TemplPtr] == 'n') || (Template[TemplPtr] == 's')) { SwitchType = Template[TemplPtr]; } else { SwitchType = 'b'; } } else { // Reached the end of the template. SwitchType = 'b'; } // Parse the switch's setting: } LogWrite(MethodName + ": SwitchType = \"" + SwitchType + "\""); switch (SwitchType) { case 'n': if ((CmdLinePtr < this.Text.Length) && ("0123456789-+".IndexOf(this.Text[CmdLinePtr]) != -1)) { // The first character is part of an integer. Parse it: string Token = ""; while ((CmdLinePtr < this.Text.Length) && (this.Text[CmdLinePtr] != ' ') && (this.Text[CmdLinePtr] != '\t')) { Token += this.Text[CmdLinePtr]; CmdLinePtr++; } try { // Convert the token to an integer value: int Value = Convert.ToInt32(Token); Switch TheSwitch = new Switch(SwitchID, Value, CmdLinePtr); LogWrite(MethodName + ": IntSwitch value = " + Value.ToString()); Switches.Add(TheSwitch); } catch (Exception) { PipeWrenchCompileException ex = new PipeWrenchCompileException("Integer value is invalid"); ex.Data.Add("CharPos", CmdLinePtr); ex.Data.Add("CmdLine", this.Text); throw ex; } } else { // The first character is not part of an integer. PipeWrenchCompileException ex = new PipeWrenchCompileException("Expected an integer immediately following this switch."); ex.Data.Add("CharPos", CmdLinePtr); ex.Data.Add("CmdLine", this.Text); throw ex; } break; case 's': if ((CmdLinePtr < this.Text.Length) && (this.Text[CmdLinePtr] == '\'')) { // The first character is a quote. Parse the string: string Value; if (xlatStrings) { string tempStr = GetString(this.Text, ref CmdLinePtr, '\'', true); try { Value = XlatEscapes(tempStr); } catch (PipeWrenchCompileException ex) { ex.Data.Add("CmdLine", this.Text); ex.Data["CharPos"] = CmdLinePtr - tempStr.Length + (int)ex.Data["Offset"]; throw ex; } } else { Value = GetString(this.Text, ref CmdLinePtr, '\'', false); } Switch TheSwitch = new Switch(SwitchID, Value, CmdLinePtr); LogWrite(MethodName + ": StrSwitch value = " + Value); Switches.Add(TheSwitch); } else { // The first character is not a quote. PipeWrenchCompileException ex = new PipeWrenchCompileException("Expected a string immediately following this switch."); ex.Data.Add("CharPos", CmdLinePtr); ex.Data.Add("CmdLine", this.Text); throw ex; } break; case 'b': bool SwitchIsValid = (CmdLinePtr == this.Text.Length) || (this.Text[CmdLinePtr] == ' ') || (this.Text[CmdLinePtr] == '\t'); if (SwitchIsValid) { Switch TheSwitch = new Switch(SwitchID, null, CmdLinePtr); LogWrite(MethodName + ": BoolSwitch value = true"); Switches.Add(TheSwitch); } else { // Switch is invalid. PipeWrenchCompileException ex = new PipeWrenchCompileException("Boolean switch is invalid."); ex.Data.Add("CharPos", CmdLinePtr); ex.Data.Add("CmdLine", this.Text); throw ex; } break; } } else { // The switch was not expected. PipeWrenchCompileException ex = new PipeWrenchCompileException("Switch is unexpected."); ex.Data.Add("CharPos", CmdLinePtr); ex.Data.Add("CmdLine", this.Text); throw ex; } }
public void CvsProcesses_InvalidInt() { var switches = new Switches(); switches.Parse("--sandbox", Path.GetTempPath(), "--cvs-processes", "blah"); }
public void GitDir_InvalidChars() { var switches = new Switches(); switches.Parse("--sandbox", Path.GetTempPath(), "--gitdir", "blah:blah"); }
static Switches ParseSwitches(string[] args) { Switches selectedSwitches = new Switches(); for (int i = 2; i < args.Length; i++) { switch (args[i]) { case SWITCH_VERBOSE: selectedSwitches = selectedSwitches | Switches.Verbose; break; case SWITCH_QUIET: selectedSwitches = selectedSwitches | Switches.Quiet; break; case SWITCH_ABORT: selectedSwitches = selectedSwitches | Switches.AbortOnFailure; break; } } if (selectedSwitches.HasFlag(Switches.Quiet) && selectedSwitches.HasFlag(Switches.Verbose)) ExitProgram("Cannot use quiet and verbose switches at the same time!", true); return selectedSwitches; }
public Main() { InitializeComponent(); VkBools = new Switches(); vkDatas = new VkDatas(); playlist = new Playlist(new OwnAudios()); if (File.Exists("auth.dat")) { Token = File.ReadAllText("auth.dat"); GetAuth(); } else { AuthForm f = new AuthForm { Owner = this }; f.ShowDialog(); } player = new WindowsMediaPlayer(); duration_timer.Stop(); vkDatas.Audio = api.Audio.Get(new AudioGetParams { Count = api.Audio.GetCount(vkDatas.user_id) }); playlist.SetAudioInfo(this); LoadText(); play_pause_btn.Image = Resource1.play; artist_name.Font = Roboto_thin; title_name.Font = Roboto_medium; AudioList.Font = Roboto_thin_10; IdSongs_box.Font = Roboto_thin_10; searchAudio_box.Font = Roboto_thin_10; if (File.Exists("user_color.dat")) { byte darkTheme = 20; string[] vs = File.ReadAllText("user_color.dat").Split(' '); MainColor = Color.FromArgb(255, byte.Parse(vs[0]), byte.Parse(vs[1]), byte.Parse(vs[2])); addColor = Color.FromArgb(255, byte.Parse(vs[3]), byte.Parse(vs[4]), byte.Parse(vs[5])); if (byte.Parse(vs[0]) == darkTheme) { VkBools.isBlack = true; } if (byte.Parse(vs[6]) == 0) { artist_name.ForeColor = Color.Black; title_name.ForeColor = Color.Black; AudioList.ForeColor = Color.Black; searchAudio_box.ForeColor = Color.Black; } else { artist_name.ForeColor = Color.White; title_name.ForeColor = Color.White; AudioList.ForeColor = Color.White; searchAudio_box.ForeColor = Color.White; } } else { MainColor = Color.FromArgb(255, 63, 81, 181); addColor = Color.FromArgb(255, 48, 63, 159); } SetColors(MainColor, addColor); Own.BackColor = addColor; BackColor = MainColor; AudioList.ContextMenuStrip = DeleteAudioMenu; KeyPreview = true; VkBools.isPlay = false; if (VkBools.isBlack) { play_pause_btn.Image = Resource1.play_white; } else { play_pause_btn.Image = Resource1.play; } play_pause_btn.Focus(); }
public void MarkerTag_Unspecified_SetToDefault() { var switches = new Switches(); var config = new Config(switches); switches.MarkerTag = null; Assert.AreEqual(config.MarkerTag, "cvs-import"); }
public void Rename_InvalidRegex() { var switches = new Switches(); var config = new Config(switches); switches.RenameTag.Add("**/foo"); }
public void Rename_RuleMissingSlash() { var switches = new Switches(); var config = new Config(switches); switches.RenameTag.Add("blah"); }
public void RenameBranch() { var switches = new Switches(); var config = new Config(switches); switches.RenameBranch.Add("foo/bar"); Assert.AreEqual(config.BranchRename.Process("foobar"), "barbar"); }
public void RenameTag_WhitespaceIsTrimmed() { var switches = new Switches(); var config = new Config(switches); switches.RenameTag.Add(" foo / \tbar"); Assert.AreEqual(config.TagRename.Process("foobar"), "barbar"); }
public void IsHeadOnly_CaseInsensitive() { var switches = new Switches(); var config = new Config(switches); config.ParseCommandLineSwitches("--sandbox", Path.GetTempPath(), "--head-only", "^file", "--include", "^file2"); Assert.IsFalse(config.IsHeadOnly("File1")); Assert.IsTrue(config.IsHeadOnly("File2")); }
public static void Main() { string[] args = Environment.GetCommandLineArgs(); rm = new ResourceManager("Example.CmdResources", Assembly.GetExecutingAssembly()); bool toEncode = false; bool toDecode = false; // Display application name. Console.WriteLine(rm.GetString("AppName")); // Display help text if command line includes /? if (args.Length < 3 | Array.Exists(args, new Switches("/?").IsSwitchSet)) { Console.WriteLine(rm.GetString("HelpText")); return; } if (Array.Exists(args, new Switches("/e").IsSwitchSet)) { toEncode = true; } if (Array.Exists(args, new Switches("/d").IsSwitchSet)) { toDecode = true; } if (Array.Exists(args, new Switches("/s").HasSwitch)) { BufferSize = Switches.GetBufferSize(args); CharsToRead = BufferSize / 2; } // Make sure only an encode or a decode switch is present. if (toEncode & toDecode) { Console.WriteLine(rm.GetString("BadSwitches")); return; } else if (!toEncode & !toDecode) { toEncode = true; } // Make sure the source file exists. string srcFile = args[args.Length - 2]; string targetFile = args[args.Length - 1]; if (!File.Exists(srcFile)) { Console.WriteLine(rm.GetString("FileNotFound"), srcFile); return; } // Perform the encoding or the decoding. if (toEncode) { EncodeFile(srcFile, targetFile); } else { DecodeFile(srcFile, targetFile); } }
public void CommuteASwitch(int number) { Switches.ElementAt(number).Commute(); }
public bool TryGetSwitch(string name, out LogLevel level) { return(Switches.TryGetValue(name, out level)); }
public void MarkerTag_Specified() { var switches = new Switches(); var config = new Config(switches); switches.MarkerTag = "blah"; Assert.AreEqual(config.MarkerTag, "blah"); }
public void IncludeFile_CaseInsensitive() { var switches = new Switches(); var config = new Config(switches); config.ParseCommandLineSwitches("--sandbox", Path.GetTempPath(), "--include", "^file2"); Assert.IsTrue(config.IncludeFile("File2")); }
public void MarkerTag_LeftBlank() { var switches = new Switches(); var config = new Config(switches); switches.MarkerTag = ""; Assert.IsNull(config.MarkerTag); }
private void FlickSwitches() => Switches.Do(flickSwitch => flickSwitch.Notify_Flicked());
public void Nobody_DefaultEmail() { var switches = new Switches() { DefaultDomain = "example.com", NobodyName = "Joe Bloggs", }; var config = new Config(switches); Assert.AreEqual(config.Nobody.Email, "*****@*****.**"); }
public void CvsProcesses_Zero() { var switches = new Switches(); switches.Parse("--sandbox", Path.GetTempPath(), "--cvs-processes", "0"); }
public void Nobody_NoDefaultEmailIfSetExplicitly() { var switches = new Switches() { DefaultDomain = "example.com", NobodyEmail = "*****@*****.**", }; var config = new Config(switches); Assert.AreEqual(config.Nobody.Email, "*****@*****.**"); }
private void switchesToolStripMenuItem_Click(object sender, EventArgs e) { Switches frm = new Switches(); frm.Show(); }
public void Users_EmptyUserCreated() { var switches = new Switches() { NobodyName = "fred", NobodyEmail = "*****@*****.**", }; var config = new Config(switches); var nobody = config.Users.GetUser(""); Assert.AreEqual(nobody.Name, "fred"); }
public static async Task SellOnOnePercentGainAsync() { //setup rest client //var restClient = new RestClient(Switches.AlpacaAPIKey(), Switches.AlpacaSecretAPIKey(), Switches.AlpacaEndPoint()); try { AlpacaTradingClientConfiguration config = new AlpacaTradingClientConfiguration(); config.ApiEndpoint = new Uri(Switches.AlpacaEndPoint()); //config.KeyId = Switches.AlpacaAPIKey(); config.SecurityId = new SecretKey(Switches.AlpacaAPIKey(), Switches.AlpacaSecretAPIKey()); var restClient = new AlpacaTradingClient(config); //var positions1 = await restClient.ListAssetsAsync(AssetStatus.Active); //var positions2 = await restClient.ListPositionsAsync(); /* * foreach (var position in positions) * { * Console.Write(position); * } */ } catch (Exception ex) { throw ex; } /* * if (File.Exists(Switches.stockDirectory + "Portfolio.csv")) * { * var allLines = File.ReadAllLines(Switches.stockDirectory + "Portfolio.csv"); * for (int i = 1; i < allLines.Count(); i++) * { * string[] temp = allLines[i].Split(','); * var p2 = await restClient.GetAssetAsync((temp[0])); * * var position = await restClient.GetPositionAsync(temp[0]); * //double required = temp[] * int numberOfShares = position.Quantity; * int daysAlloted = DateTime.Today.Day - Convert.ToDateTime(temp[1]).Day; * double required = Convert.ToDouble(temp[3]); * * //set minimal required selling point * required *= 1.01; * * try * { * if ((double)position.AssetCurrentPrice > required) * { * var order = await restClient.PostOrderAsync(temp[0], numberOfShares, OrderSide.Sell, OrderType.Market, TimeInForce.Day); * } * } * catch (Exception ex) * { * Console.WriteLine("could not sell because " + ex.ToString()); * } * } * } */ }
public bool TryDivide(string fullCmd) { CommandName = fullCmd.Split(' ')[0].Trim(); ArgString = fullCmd.IndexOf(" ", StringComparison.Ordinal) == -1 ? "" : fullCmd.Substring(fullCmd.IndexOf(" ", StringComparison.Ordinal) + 1, fullCmd.Length - CommandName.Length - 1).Trim(); List <string> splitedParam = new List <string>(); SimpleArgs = ArgString.Split(' ').ToList(); if (ArgString == "") { return(false); } try { splitedParam.AddRange(ArgString.Split(' ')); foreach (var item in splitedParam) { if (Quote.Any(q => ContainsChar(q, item))) { throw new ArgumentException(); } } bool combined = true; foreach (var item in Quote) { for (int i = 0; i < splitedParam.Count - 1; i++) { string cur = splitedParam[i], next = splitedParam[i + 1]; if (cur.StartsWith(item) && !cur.EndsWith(item)) { combined = false; splitedParam[i] = cur + " " + next; splitedParam.Remove(next); if (splitedParam[i].EndsWith(item)) { combined = true; } i--; } } if (!combined) { throw new ArgumentException("Expect '" + item + "'."); } } string tmpKey = null, tmpValue; bool isLastKeyOrValue = false; splitedParam.Add("-"); foreach (var item in splitedParam) { tmpValue = null; if (item.StartsWith('-')) { if (tmpKey != null) { Switches.Add(tmpKey, tmpKey); } tmpKey = item.Remove(0, 1); isLastKeyOrValue = true; } else { foreach (var q in Quote) { tmpValue = tmpValue == null?item.Trim(q) : tmpValue.Trim(q); } if (!isLastKeyOrValue) { FreeArgs.Add(tmpValue); //throw new ArgumentException("Expect key."); } else { Args.Add(tmpKey, tmpValue); tmpKey = null; tmpValue = null; isLastKeyOrValue = false; } } } } catch (Exception ex) { Logger.Debug(ex.Message); return(false); } return(true); }
public static async Task SellStock(string Symbol, int Quantity) { try { var httpWebRequest = (HttpWebRequest)WebRequest.Create(Switches.AlpacaEndPoint() + "/v2/orders"); httpWebRequest.Method = "POST"; httpWebRequest.Headers.Add("APCA-API-KEY-ID", Switches.AlpacaAPIKey()); httpWebRequest.Headers.Add("APCA-API-SECRET-KEY", Switches.AlpacaSecretAPIKey()); httpWebRequest.ContentType = "application/x-www-form-urlencoded"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { //string json = "{" + "\"tracking\": {" + "\"slug\":\"" + Courier + "\"," + "\"tracking_number\":\"" + trackNumber + "\"}}"; SellOrderObject s = new SellOrderObject(); s.symbol = Symbol; s.qty = Quantity; var json = JsonConvert.SerializeObject(s); streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); } } /* * using (var client = new HttpClient()) * using (var request = new HttpRequestMessage(HttpMethod.Post, Switches.AlpacaEndPoint() + "/v2/orders")) * { * SellOrderObject content = new SellOrderObject(); * content.symbol = Symbol; * content.qty = Quantity; * var json = JsonConvert.SerializeObject(content); * using (var stringContent = new StringContent(json, Encoding.UTF8, "application/json")) * { * request.Content = stringContent; * * request.Headers.Add("APCA-API-KEY-ID", Switches.AlpacaAPIKey()); * request.Headers.Add("APCA-API-SECRET-KEY", Switches.AlpacaSecretAPIKey()); * client.DefaultRequestHeaders.Add("APCA-API-KEY-ID", Switches.AlpacaAPIKey()); * client.DefaultRequestHeaders.Add("APCA-API-SECRET-KEY", Switches.AlpacaSecretAPIKey()); * using (var response = await client * .PostAsJsonAsync(Switches.AlpacaEndPoint() + "/v2/orders", content)) * { * response.EnsureSuccessStatusCode(); * } * } * } */ } catch (Exception ex) { //throw Utility.ThrowException(ex); } }
/// <summary> /// Initializes the factory with the given <paramref name="defaultBehavior"/> /// for newly created mocks from the factory. /// </summary> /// <param name="defaultBehavior">The behavior to use for mocks created /// using the <see cref="Create{T}()"/> factory method if not overridden /// by using the <see cref="Create{T}(MockBehavior)"/> overload.</param> public MockFactory(MockBehavior defaultBehavior) { this.defaultBehavior = defaultBehavior; this.defaultValueProvider = DefaultValueProvider.Empty; this.switches = Switches.Default; }
/// <summary> /// Zugriff auf die Schalter per Indexer /// </summary> /// <param name="swi"></param> /// <returns></returns> public Switch this[Switches swi] { get { return(this.switches[(int)swi]); } }
private void GenerateFields() { WaterField TempWaterField2 = null; FieldArray[0, 0] = new EndWaterField { Game = this }; for (int i = 1; i < 12; i++) { WaterField TempWaterField = new WaterField { Game = this }; FieldArray[i, 0] = TempWaterField; if (i == 9) { TempWaterField2 = TempWaterField; } if (i == 11) { TempWaterField.MoveAble = this.Ship; Ship.CurrentField = TempWaterField; ShipField = TempWaterField; } } FieldArray[0, 1] = new EndField(); for (int i = 1; i < 12; i++) { FieldArray[i, 1] = new Field(); if (i == 9) { Quay TempQuay = new Quay { Game = this }; FieldArray[i, 1] = TempQuay; TempWaterField2.LowerField = TempQuay; } } FieldArray[11, 2] = new Field(); Warehouse TempHouse = new Warehouse { Game = this }; FieldArray[0, 3] = TempHouse; Warehouses.Add(TempHouse); for (int i = 1; i < 12; i++) { if (i != 4 && i != 10) { FieldArray[i, 3] = new Field(); } } FieldArray[3, 5] = new Field(); FieldArray[4, 4] = new Field(); FieldArray[10, 4] = new Field(); FieldArray[11, 4] = new Field(); TempHouse = new Warehouse { Game = this }; FieldArray[0, 5] = TempHouse; Warehouses.Add(TempHouse); FieldArray[1, 5] = new Field(); FieldArray[2, 5] = new Field(); FieldArray[5, 5] = new Field(); FieldArray[9, 5] = new Field(); FieldArray[6, 6] = new Field(); FieldArray[8, 6] = new Field(); FieldArray[7, 7] = new Field(); TempHouse = new Warehouse { Game = this }; FieldArray[0, 8] = TempHouse; Warehouses.Add(TempHouse); for (int i = 1; i < 12; i++) { if (i != 7) { FieldArray[i, 8] = new Field(); } } FieldArray[1, 9] = new ManeuveringField(); FieldArray[0, 9] = new EndManeuveringField(); for (int i = 2; i < 12; i++) { FieldArray[i, 9] = new ManeuveringField(); if (i == 9 || i == 10 || i == 11) { FieldArray[i, 9] = new Field(); } } Switch TempSwitch = new Switch { UpperField = FieldArray[5, 3], LowerField = FieldArray[5, 5], MayChangeNextField = true }; FieldArray[5, 4] = TempSwitch; Switches.Add(TempSwitch); TempSwitch = new Switch { UpperField = FieldArray[9, 3], LowerField = FieldArray[9, 5] }; FieldArray[9, 4] = TempSwitch; Switches.Add(TempSwitch); TempSwitch = new Switch { UpperField = FieldArray[8, 6], LowerField = FieldArray[8, 8], MayChangeNextField = true }; FieldArray[8, 7] = TempSwitch; Switches.Add(TempSwitch); TempSwitch = new Switch { UpperField = FieldArray[6, 6], LowerField = FieldArray[6, 8] }; FieldArray[6, 7] = TempSwitch; Switches.Add(TempSwitch); TempSwitch = new Switch { UpperField = FieldArray[3, 3], LowerField = FieldArray[3, 5] }; FieldArray[3, 4] = TempSwitch; Switches.Add(TempSwitch); }
public void ThenIAmOnTheModulePage(string pageTitle) { Switches.AmIOnGridPageSwitch(pageTitle); }
/// <summary> /// Determines if the specified switch is present on the command-line /// </summary> /// <param name="key">The switch value, e.g. "-myswitch"</param> /// <returns>True if present</returns> // ReSharper disable once UnusedMember.Global public bool IsSwitchSet(string key) { return(Switches.Contains(key)); }
public void GivenIAmOnThePage(string modulePage) { NavBar.Click(modulePage); Switches.AmIOnGridPageSwitch(modulePage); }
/// <summary> /// Calculate a statistic from a log /// </summary> /// <param name="log"></param> /// <param name="switches"></param> /// <returns></returns> public Statistics CalculateStatistics(ParsedLog log, Switches switches) { _statistics = new Statistics(); _log = log; SetPresentBoons(); _statistics.Phases = log.FightData.GetPhases(log); if (switches.CalculateCombatReplay && _settings.ParseCombatReplay) { foreach (Player p in log.PlayerList) { if (p.Account == ":Conjured Sword") { continue; } p.InitCombatReplay(log, _settings.PollingRate, false, true); } foreach (Target target in log.FightData.Logic.Targets) { target.InitCombatReplay(log, _settings.PollingRate, true, log.FightData.GetMainTargets(log).Contains(target)); } log.FightData.Logic.InitTrashMobCombatReplay(log, _settings.PollingRate); // Ensuring all combat replays are initialized before extra data (and agent interaction) is computed foreach (Player p in log.PlayerList) { if (p.Account == ":Conjured Sword") { continue; } p.ComputeAdditionalCombatReplayData(log); } foreach (Target target in log.FightData.Logic.Targets) { target.ComputeAdditionalCombatReplayData(log); } foreach (Mob mob in log.FightData.Logic.TrashMobs) { mob.ComputeAdditionalCombatReplayData(log); } } if (switches.CalculateDPS) { CalculateDPS(); } if (switches.CalculateBoons) { CalculateBoons(); } if (switches.CalculateStats) { CalculateStats(); } if (switches.CalculateDefense) { CalculateDefenses(); } if (switches.CalculateSupport) { CalculateSupport(); } if (switches.CalculateConditions) { CalculateConditions(); } if (switches.CalculateMechanics) { log.FightData.Logic.ComputeMechanics(log); } // target health _statistics.TargetsHealth = new Dictionary <Target, double[]> [_statistics.Phases.Count]; for (int i = 0; i < _statistics.Phases.Count; i++) { _statistics.TargetsHealth[i] = new Dictionary <Target, double[]>(); } foreach (Target target in _log.FightData.Logic.Targets) { List <double[]> hps = target.Get1SHealthGraph(_log, _statistics.Phases); for (int i = 0; i < hps.Count; i++) { _statistics.TargetsHealth[i][target] = hps[i]; } } // return(_statistics); }
public void CvsLogFileName_Specified_DoesNotExist() { using (var temp = new TempDir()) { var logFilename = temp.GetPath("blah.log"); var switches = new Switches() { CvsLog = logFilename, }; var config = new Config(switches); Assert.AreEqual(logFilename, config.CvsLogFileName); Assert.IsTrue(config.CreateCvsLog); } }
public void MarkerTag_LeftBlank() { using (var temp = new TempDir()) { var confFileName = temp.GetPath("test.conf"); File.WriteAllText(confFileName, "import-marker-tag \"\"\r\n"); var sandbox = temp.GetPath("sandbox"); Directory.CreateDirectory(sandbox); var switches = new Switches(); switches.Parse("-C", confFileName, "--sandbox", sandbox); Assert.AreEqual(switches.MarkerTag, ""); } }
/// <summary> /// Initializes a new instance of the <see cref="SwitchVolumeCollection"/> class. /// </summary> /// <param name="initial">The initial.</param> /// <param name="additional">The additional.</param> public SwitchVolumeCollection(SwitchVolume initial, params SwitchVolume[] additional) { Switches.Add(initial); Switches.AddRange(additional); }
private static void ParseArgs(string[] args) { Switches lastArg = Switches.None; StringBuilder pathBuilder = new StringBuilder(); foreach (string s in args) { switch (lastArg) { case Switches.None: break; case Switches.Path: break; case Switches.Server: string[] serverSplit = s.Split(','); if (serverSplit.Length > 1) { myServer = serverSplit[0].Trim(); Int32.TryParse(serverSplit[1].Trim(), out myPort); } lastArg = Switches.None; continue; case Switches.ServerEnc: myServerEncrypted = true; lastArg = Switches.None; break; case Switches.ClientEnc: myPatchClient = false; lastArg = Switches.None; break; case Switches.PID: Int32.TryParse(s.Trim(), out myPID); lastArg = Switches.None; continue; } switch (s) { case "--path": lastArg = Switches.Path; break; case "--server": lastArg = Switches.Server; break; case "--serverenc": lastArg = Switches.ServerEnc; break; case "--clientenc": lastArg = Switches.ClientEnc; break; case "--pid": lastArg = Switches.PID; break; default: if (lastArg == Switches.Path) { pathBuilder.Append(" " + s); } break; } } myRazorFolder = pathBuilder.ToString().Trim().Trim(Path.GetInvalidPathChars()); }
/// <summary> /// Initialise the event args. /// </summary> /// <param name="swi">the switch that got changed</param> /// <param name="switchEnabled">the current state of the switch</param> public SwitchEventArgs(Switches swi, bool switchEnabled) { Swi = swi; SwitchEnabled = switchEnabled; }
/// <summary> /// Initialisiert die SwitchEventArgs-Klasse /// </summary> /// <param name="swi">der betroffene Schalter</param> /// <param name="switchEnabled">der aktuelle Zustand des Schalters</param> public SwitchEventArgs(Switches swi, bool switchEnabled) { Swi = swi; SwitchEnabled = switchEnabled; }
public SwitchChangeEvent(Switches _switch, bool _value) { Switch = _switch; Value = _value; }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); if (args.Length == 0) { PrintHelpText(); System.Console.ReadKey(); return; } _packageFile = args[0]; _isListCommand = IsListCommand(args); _selectedSwitches = ParseSwitches(args); ScriptPackage package = LoadPackage(_packageFile); if (_isListCommand) ListScripts(package); else ExecuteScripts(package); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugOutputs.Clear(); _debugInputs.Clear(); var startTime = DateTime.Now; try { Dev2Switch ds = new Dev2Switch { SwitchVariable = Switch }; var firstOrDefault = dataObject.Environment.EvalAsListOfStrings(ds.SwitchVariable, update).FirstOrDefault(); if (dataObject.IsDebugMode()) { InitializeDebug(dataObject); Debug(dataObject, firstOrDefault, ds); DispatchDebugState(dataObject, StateType.Before, update); } if (firstOrDefault != null) { var a = firstOrDefault; if (Switches.ContainsKey(a)) { Result = a; if (dataObject.IsDebugMode()) { DebugOutput(dataObject); } NextNodes = new List <IDev2Activity> { Switches[a] }; } else { if (Default != null) { Result = "Default"; var activity = Default.FirstOrDefault(); if (dataObject.IsDebugMode()) { DebugOutput(dataObject); } NextNodes = new List <IDev2Activity> { activity }; } } } } catch (Exception err) { dataObject.Environment.Errors.Add(err.Message); } finally { if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.After, update); _debugOutputs = new List <DebugItem>(); } } }
/// <summary> /// Zugriff auf die Schalter per Indexer /// </summary> /// <param name="swi"></param> /// <returns></returns> public Switch this[Switches swi] { get { return this.switches[(int)swi]; } }
/// <summary> /// Updates the machine configuration collections. Switches, lamps, coils etc. /// </summary> private void UpdateMachineConfigCollections() { Log("Updating UI Collections"); //Add only the switches not containing dedicated and flipper if (MachineConfig.PRSwitches != null) { Log("Adding dedicated switches"); //Quick hack for PDB switches. Need to put the 64-127 range of switch into the dedicated collection... if (MachineConfig.GetMachineType() == MachineType.PDB) { var lowRange = MachineConfig.PRSwitches.Where(x => x.Number.Contains("SD") && Convert.ToByte(x.Number.Replace("SD", "")) < 64); var hiRange = MachineConfig.PRSwitches.Where(x => x.Number.Contains("SD") && (Convert.ToByte(x.Number.Replace("SD", "")) < 128 && Convert.ToByte(x.Number.Replace("SD", "")) > 63)); Switches.AddRange(lowRange.Select(x => new SwitchViewModel(x))); DedicatedSwitches.AddRange(hiRange.Select(x => new SwitchViewModel(x))); } else { DedicatedSwitches.AddRange(MachineConfig.PRSwitches .Where(x => x.Number.Contains("SD")) .Select(x => new SwitchViewModel(x)).OrderBy(x => x.Number)); Log("Adding switches"); Switches.AddRange(MachineConfig.PRSwitches .Where(x => !x.Number.Contains("F") & !x.Number.Contains("SD")) .Select(x => new SwitchViewModel(x)).OrderBy(x => x.Number)); } Log("Adding flipper switches"); FlippersSwitches.AddRange(MachineConfig.PRSwitches .Where(x => x.Number.Contains("SF")) .Select(x => new SwitchViewModel(x)).OrderBy(x => x.Number)); } else { Log("PRSwitches doesn't exist"); } if (MachineConfig.PRCoils != null) { Coils.AddRange(MachineConfig.PRCoils.Select(x => new SolenoidFlasherViewModel(x)).OrderBy(x => x.Number)); } else { Log("PRCoils doesn't exist"); } if (MachineConfig.PRLamps != null) { Lamps.AddRange(MachineConfig.PRLamps.Select(x => new LampViewModel(x)).OrderBy(x => x.Number)); } else { Log("PRLamps doesn't exist"); } if (MachineConfig.PRLeds != null) { PRLeds.AddRange(MachineConfig.PRLeds.Select(x => new LampViewModel(x)));//.OrderBy(x => x.Number.Replace("A8-", ""))); } else { Log("PRLeds doesn't exist"); } }