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); }
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; }
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 override unsafe void AddPrefix(UserBase user, char add) { if (user.Level >= Authorizations.Service) { return; } if (add == '$' || add == '!') { return; } if (IsSystem && user.Level >= Authorizations.NetworkOperator) { return; } if (Prefixes.ContainsKey(user.Mask.Account)) { char[] chars = Prefixes[user.Mask.Account].ToCharArray(); int max = chars.Length + 1; int len = 0; char *prefix = stackalloc char[max]; for (int i = 0; i < CoreProtocol.RANK_CHARS.Length && len < max; i++) { char c = CoreProtocol.RANK_CHARS[i]; if (add == c || chars.Contains(c)) { prefix[len++] = c; } } Prefixes[user.Mask.Account] = new string(prefix, 0, len); } else { Prefixes[user.Mask.Account] = add.ToString(); } Server.Commit(this); }
public override string GetPrefix(UserBase user) { if (user.Level >= Authorizations.Service) { return("$"); } else if (IsSystem && user.Level >= Authorizations.NetworkOperator) { return("~"); } else if (Prefixes.ContainsKey(user.Mask.Account)) { return(Prefixes[user.Mask.Account]); } else if (user.Level == Authorizations.NetworkOperator) { return("!"); } else { return(string.Empty); } }