public override void load(JObject jsonRepresentation) { // Set the type this.Type = (string)jsonRepresentation.SelectToken("Type"); // Get the assorted string properties this.DisplayName = (string)jsonRepresentation.SelectToken("DisplalyName"); this.Timer = (double)jsonRepresentation.SelectToken("Timer"); this.IsLockedSite = (bool)jsonRepresentation.SelectToken("IsLockedSite"); this.Address = (string)jsonRepresentation.SelectToken("Address"); // Set up my serializer for the lists // Get the prefixes var prefs = (JArray)jsonRepresentation.SelectToken("Prefixes"); foreach (string pref in prefs) { Prefixes.Add(pref); } // Get the steps var steps = (JArray)jsonRepresentation.SelectToken("Steps"); foreach (string step in steps) { Steps.Add(step); } }
private void ReadInstructions() { Labels.Clear(); _instructions.Clear(); using (var memory = new MemoryStream(_msilBytes)) using (var reader = new BinaryReader(memory)) while (memory.Length > memory.Position) { var opcodeOffset = (int)memory.Position; var instructionValue = (short)memory.ReadByte(); if (Prefixes.Contains(instructionValue)) { instructionValue = (short)((instructionValue << 8) | memory.ReadByte()); } if (!OpCodeLookup.TryGetValue(instructionValue, out OpCode opcode)) { var msg = $"Unknown opcode {instructionValue:X}"; _log.Error(msg); Debug.Assert(false, msg); continue; } if (opcode.Size != memory.Position - opcodeOffset) { throw new Exception( $"Opcode said it was {opcode.Size} but we read {memory.Position - opcodeOffset}"); } var instruction = new MsilInstruction(opcode) { Offset = opcodeOffset }; _instructions.Add(instruction); instruction.Operand?.Read(this, reader); } }
public T CreatePrefix <T>(string constructor = "") where T : SelectorPrefix, new() { var t = new T(); if (Parser.IsId.IsMatch(constructor)) { t.Init(constructor, $"//*[@id='{Parser.IsId.Match(constructor).Groups[1].Value}']"); } else if (Parser.IsElement.IsMatch(constructor)) { t.Init(constructor, $"//{Parser.IsElement.Match(constructor).Groups[1].Value}"); } else if (Parser.IsClass.IsMatch(constructor)) { t.Init(constructor, $"//*[contains(concat(' ', normalize-space(@class), ' '), ' {Parser.IsClass.Match(constructor).Groups[1].Value} ')]"); } else if (Parser.IsXPath.IsMatch(constructor)) { t.Init(constructor, Parser.IsClass.Match(constructor).Groups[1].Value); } else if (Prefixes.ContainsKey(t.Type) && Prefixes[t.Type].Any()) { t.Init(constructor, Prefixes[t.Type]); } else { throw new GherkinException($"the prefix type of '{t.Type}' is not supported."); } return(t); }
bool IEquatable <MetricSystem> .Equals(MetricSystem other) { if (Utils.VerifyStackOverflow()) { return(Name == other.Name); } else { var this_OrderedQuantities = Quantities.OrderBy(q => q.Name); var this_OrderedUnits = Units.OrderBy(u => u.Name); var this_OrderedPrefixes = Prefixes.OrderBy(p => p.Name); var other_OrderedQuantities = Quantities.OrderBy(q => q.Name); var other_OrderedUnits = Units.OrderBy(u => u.Name); var other_OrderedPrefixes = Prefixes.OrderBy(p => p.Name); Func <bool> quantitiesMatch = () => this_OrderedQuantities.SequenceEqual(other_OrderedQuantities, new IEquatableEqualityComparer <Quantity>()); Func <bool> unitsMatch = () => this_OrderedUnits.SequenceEqual(other_OrderedUnits, new IEquatableEqualityComparer <Unit>()); Func <bool> metricPrefixesMatch = () => other_OrderedPrefixes.SequenceEqual(other_OrderedPrefixes, new IEquatableEqualityComparer <MetricPrefix>()); return(Name == other?.Name && quantitiesMatch() && unitsMatch() && metricPrefixesMatch()); } }
private void Editor_ChangesSavedEvent(object sender, ItemEditorSavedEventArgs e) { var node = this.InventoryTree.Nodes[e.InventoryData.SlotType.ToString()].Nodes[e.InventoryData.SlotType.ToString() + e.InventoryData.Slot]; node.Text = $"[{Prefixes.GetPrefixNameById(e.InventoryData.Prefix)}] {e.InventoryData.Item.Name}"; node.Tag = e.InventoryData; }
/// <summary> /// Evaluates Prefix expression /// </summary> /// <param name="m">method call expression</param> private void VisitPrefix(MethodCallExpression m) { string prefix = (string)((ConstantExpression)m.Arguments[1]).Value; string iri = (string)((ConstantExpression)m.Arguments[2]).Value; Prefixes.Add(SPARQL.Prefix(prefix, iri)); }
public void Generate(GameState gameState, EnemyParams enemyParams) { var random = new Random(); Level = random.Next(0, 10); var prefixes = Enum.GetValues(typeof(EnemyPrefix)).Cast <EnemyPrefix>().ToList(); var prefixCount = random.Next(prefixes.Count + 1); for (var i = 0; i < prefixCount; ++i) { var index = random.Next(prefixes.Count); Prefixes.Add(prefixes[index]); prefixes.RemoveAt(index); } var suffixes = Enum.GetValues(typeof(EnemySuffix)).Cast <EnemySuffix>().ToList(); var suffixCount = random.Next(suffixes.Count + 1); for (var i = 0; i < suffixCount; ++i) { var index = random.Next(suffixes.Count); Suffixes.Add(suffixes[index]); suffixes.RemoveAt(index); } var types = Enum.GetValues(typeof(EnemyType)).Cast <EnemyType>().ToList(); Type = (EnemyType)random.Next(types.Count); }
internal void Commit() { try { // non-greedy so they are all reset if (!Prefixes.HasChanges(true) & !Suffixes.HasChanges(true) & !Transpilers.HasChanges(true) & !PostTranspilers.HasChanges(true)) { return; } Revert(); if (Prefixes.Count == 0 && Suffixes.Count == 0 && Transpilers.Count == 0 && PostTranspilers.Count == 0) { return; } _log.Log(PrintMsil ? LogLevel.Info : LogLevel.Debug, $"Begin patching {_method.DeclaringType?.FullName}#{_method.Name}({string.Join(", ", _method.GetParameters().Select(x => x.ParameterType.Name))})"); var patch = ComposePatchedMethod(); _revertAddress = AssemblyMemory.GetMethodBodyStart(_method); var newAddress = AssemblyMemory.GetMethodBodyStart(patch); _revertData = AssemblyMemory.WriteJump(_revertAddress, newAddress); _pinnedPatch = GCHandle.Alloc(patch); _log.Log(PrintMsil ? LogLevel.Info : LogLevel.Debug, $"Done patching {_method.DeclaringType?.FullName}#{_method.Name}({string.Join(", ", _method.GetParameters().Select(x => x.ParameterType.Name))})"); } catch (Exception exception) { _log.Fatal(exception, $"Error patching {_method.DeclaringType?.FullName}#{_method}"); throw; } }
protected bool CheckPrefix(string code) { if (Prefixes.Count > 0) { return(Prefixes.Any(p => code?.StartsWith(p) == true)); } return(true); }
public void ConvertFromCallsPrefix() { var prefix = new Mock <Prefix>(10m); prefix.Setup(mock => mock.ConvertFrom(10m)).Returns(20m); Assert.AreEqual(20m, Prefixes.ConvertFrom(prefix.Object, 10m)); prefix.Verify(mock => mock.ConvertFrom(10m), Times.Once); }
public CustomTerminal(string name, MatchHandler handler, params string[] prefixes) : base(name) { _handler = handler; if (prefixes != null) { Prefixes.AddRange(prefixes); } }
public RegexBasedTerminal(string name, string pattern, params string[] prefixes) : base(name) { Pattern = pattern; if (prefixes != null) { Prefixes.AddRange(prefixes); } }
public bool Equals(StreamFilter other) => Prefixes == null || other.Prefixes == null ? Prefixes == other.Prefixes && Regex.Equals(other.Regex) && MaxSearchWindow.Equals(other.MaxSearchWindow) : Prefixes.SequenceEqual(other.Prefixes) && Regex.Equals(other.Regex) && MaxSearchWindow.Equals(other.MaxSearchWindow);
public CustomTerminal(string name, MatchHandler handler, params string[] prefixes) : base(name) { _handler = handler; if (prefixes != null) { Prefixes.AddRange(prefixes); } this.EditorInfo = new TokenEditorInfo(TokenType.Unknown, TokenColor.Text, TokenTriggers.None); }
/// <summary> /// Determines whether <see cref="piece"/> is a given name component as opposed to an affix, initial or title. /// </summary> /// <param name="piece">A single word from a name</param> /// <returns>False if <see cref="piece"/> is a prefix (de, abu, bin), suffix (jr, iv, cpa), title (mr, pope), or initial (x, e.); true otherwise</returns> private static bool IsRootname(string piece) { var lcPiece = piece.ToLower().Replace(".", string.Empty); return(!Suffixes.Contains(lcPiece) && !Prefixes.Contains(lcPiece) && !Titles.Contains(lcPiece) && !IsAnInitial(piece)); }
public void Configuration_Make_Prefixes() { IEnumerable <string> prefixes = Prefixes.Make(); Assert.AreEqual(3, prefixes.Count()); Assert.AreEqual("RTSX", prefixes.ElementAt(0)); Assert.AreEqual("RTSZ", prefixes.ElementAt(1)); Assert.AreEqual("SiB", prefixes.ElementAt(2)); }
// Mono's C# compiler prefers this overload, which is incorrect. Marking it `private` to // to work around. // // See https://github.com/Pash-Project/Pash/issues/24 // // See https://github.com/Pash-Project/Pash/issues/29 // // See https://bugzilla.xamarin.com/show_bug.cgi?id=6541 private RegexBasedTerminal(string pattern, params string[] prefixes) : base("name") { Pattern = pattern; if (prefixes != null) { Prefixes.AddRange(prefixes); } }
public WebDriver Prefix(SelectorPrefix prefix) { var p = new ValidatedPrefix(); var l = Prefixes.Concat(prefix); var possibles = l.CrossMultiply(); RetryExecutor.RetryFor(() => { var iframes = SeleniumDriver.FindElements(By.XPath("//iframe")); var valid = possibles.AsParallel().AsOrdered().Where(xpath => SeleniumDriver.FindElements(By.XPath(xpath)).Any()).ToList(); if (valid.Any()) { p.Init("filtered", valid); } else if (iframes.Any()) { foreach (var iframe in iframes) { try { SeleniumDriver.SwitchTo().Frame(iframe); valid = possibles.AsParallel().AsOrdered().Where(xpath => SeleniumDriver.FindElements(By.XPath(xpath)).Any()).ToList(); if (valid.Any()) { p.Init("filtered", valid); } } catch { } } SeleniumDriver.SwitchTo().DefaultContent(); } if (!p.IsInitialized) { throw new Exception($"Was unable to find any that matched prefix, tried:{possibles.LogFormat()}"); } }, TimeSpan.FromMilliseconds(SeleniumGridConfiguration.RetryMs)); var wdm = new WebDriver( SeleniumDriver, RootUrl, SeleniumGridConfiguration, RetryExecutor, SelectorFactory, ElementFactory, XpathProvider, MovieLogger, WebElementSourceLog, new List <SelectorPrefix> { p } ); Children.Add(wdm); return(wdm); }
private void FillNodeData(string nodeName, List <InventoryData> data) { var nodes = this.InventoryTree.Nodes[nodeName].Nodes; foreach (var invData in data) { nodes[nodeName + invData.Slot].Text = $"[{Prefixes.GetPrefixNameById(invData.Prefix)}] {invData.Item.Name}"; nodes[nodeName + invData.Slot].Tag = invData; } }
private void HandleOnPrefix(IWampConnection connection, PrefixMessage msg) { if (!Prefixes.ContainsKey(connection)) { Prefixes.Add(connection, new Dictionary <string, Uri>()); } var prefixes = Prefixes[connection]; prefixes[msg.Prefix] = msg.Uri; }
protected void Init(string cachekey, int?cachetime, string[] perfixes) { Key = cachekey; _keyFormat = cachekey; if (cachetime.HasValue) { CacheTime = cachetime.Value; } Prefixes.AddRange(perfixes.Where(perfix => string.IsNullOrEmpty(perfix))); }
public void AddPrefix(string prefix) { if (Prefixes.Contains(prefix)) { throw new Exception("Prefix already exists."); } else { Prefixes.Add(prefix); } }
private void StoreSelectedPrefixes() { if (null != SelectedIncludedUnit) { var unit = (IUnit)SelectedIncludedUnit.Tag; var list = new List <SIPrefix>(Prefixes.Where(x => x.IsSelected).Select(x => (SIPrefix)x.Tag)); _prefixesForUnit[unit] = list; } UpdateAllPrefixedUnits(_allChoosenPrefixedUnits); }
public void RemovePrefix(string prefix) { if (!Prefixes.Contains(prefix)) { throw new Exception("This is not a prefix in this server."); } else { Prefixes.Remove(prefix); } }
/// <summary> /// Returns a new unit with the specified prefix /// </summary> /// <param name="prefix"></param> /// <returns>new Unit</returns> public Unit ChangePrefix(Prefix prefix, BaseUnit baseUnit) { int difference = ((sbyte)GetPrefix(baseUnit) - (sbyte)prefix) * GetPower(baseUnit); var prefixes = new sbyte[Length]; Prefixes.CopyTo(prefixes, 0); prefixes[(sbyte)baseUnit - 1] = (sbyte)prefix; double quantity = Quantity * Math.Pow(10, difference); return(new Unit(quantity, new Vector <sbyte>(prefixes), Powers)); }
/// <summary> /// Init instance of CacheKey /// </summary> /// <param name="cacheKey">Cache key</param> /// <param name="cacheTime">Cache time; set to null to use the default value</param> /// <param name="prefixes">Prefixes to remove by prefix functionality</param> protected void Init(string cacheKey, int?cacheTime = null, params string[] prefixes) { Key = cacheKey; _keyFormat = cacheKey; if (cacheTime.HasValue) { CacheTime = cacheTime.Value; } Prefixes.AddRange(prefixes.Where(prefix => !string.IsNullOrEmpty(prefix))); }
private void HandleOnClose(IWampConnection connection) { // Remove connection from lookup _connections.Remove(connection.WebSocketConnectionInfo.Id); // Remove prefixes Prefixes.Remove(connection); // Remove subscriptions foreach (var topics in Subscriptions) { topics.Value.Remove(connection); } }
public TicketItem CreateTicket(string prefix) { lock (_locker) { var inseartPlase = (ushort)GetInseartPlace(prefix); var ticket = TicketFactory.Create(inseartPlase, prefix); var priority = Prefixes.FirstOrDefault(p => p.Name == prefix)?.Priority; if (priority.HasValue) { ticket.Priority = priority.Value; } return(ticket); } }
/// <summary> /// Constructor /// </summary> public HTTPService(RemoteService service) { //check if (service == null) { throw new Exception("Unable to instanciate HTTPService - Service instance not specified"); } _service = service; //setup http listener _listener = new HttpListener(); _listener.Prefixes.Add(String.Format("http://*:{0}/", _service._config.port)); //set statuses _islistening = false; _isprocessing = false; }
public override void RemovePrefix(UserBase user, char c) { if (Prefixes.ContainsKey(user.Mask.Account)) { string value = Prefixes[user.Mask.Account].Replace(c.ToString(), string.Empty); if (value == string.Empty) { Prefixes.Remove(user.Mask.Account); } else { Prefixes[user.Mask.Account] = value; } Server.Commit(this); } }
public static String WriteSoapMessageStart(XmlWriter writer, Prefixes prefixes, WsXmlNamespaces additionalPrefixes, WsWsaHeader header, AppSequence appSequence) { String messageId = "urn:uuid:" + Guid.NewGuid(); String xml = "<?xml version='1.0' encoding='UTF-8'?>" + "<soap:Envelope xmlns:soap='" + WsWellKnownUri.SoapNamespaceUri + "' " + "xmlns:wsa='" + WsWellKnownUri.WsaNamespaceUri_2005_08 + "' "; if ((prefixes & Prefixes.Wsdp) != Prefixes.None) { xml += "xmlns:wsdp='" + WsWellKnownUri.WsdpNamespaceUri + "' "; } if ((prefixes & Prefixes.Wse) != Prefixes.None) { xml += "xmlns:wse='" + WsWellKnownUri.WseNamespaceUri + "' "; } if ((prefixes & Prefixes.Wsx) != Prefixes.None) { xml += "xmlns:wsx='" + WsWellKnownUri.WsxNamespaceUri + "' "; } if ((prefixes & Prefixes.Wsd) != Prefixes.None || appSequence != null) { xml += "xmlns:wsd='" + WsWellKnownUri.WsdNamespaceUri + "' "; } if (additionalPrefixes != null) { int count = additionalPrefixes.Count; WsXmlNamespace current; for (int i = 0; i < count; i++) { current = additionalPrefixes[i]; xml += "xmlns:" + current.Prefix + "='" + current.NamespaceURI + "' "; } } xml += ">" + "<soap:Header>" + "<wsa:To soap:mustUnderstand=\"1\">" + header.To + "</wsa:To>" + "<wsa:Action soap:mustUnderstand=\"1\">" + header.Action + "</wsa:Action>" + "<wsa:MessageID>" + messageId + "</wsa:MessageID>"; if (header.RelatesTo != null) { xml += "<wsa:RelatesTo>" + header.RelatesTo + "</wsa:RelatesTo>"; } if (header.From != null) { xml += "<wsa:From><wsa:Address>" + header.From.Address.AbsoluteUri + "</wsa:Address></wsa:From>"; } if (header.ReplyTo != null) { xml += "<wsa:ReplyTo><wsa:Address>" + header.ReplyTo.Address.AbsoluteUri + "</wsa:Address></wsa:ReplyTo>"; } if (appSequence != null) { xml += "<wsd:AppSequence InstanceId='" + appSequence.InstanceId + "' " + "SequenceId='" + appSequence.SequenceId + "' " + "MessageNumber='" + appSequence.MessageNumber + "'/>"; } writer.WriteRaw(xml); if (header.Any != null) { header.Any.WriteTo(writer); } writer.WriteRaw("</soap:Header><soap:Body>"); return messageId; }
public static string GetPrefixName(Prefixes Prefix) { return PrefixNames[(int)Prefix]; }
public static string GetPrefix(Prefixes Prefix) { return CachePrefixes[(int)Prefix]; }