/// <summary> /// Deserializes Json into a Key instance. /// </summary> /// <param name="reader"></param> /// <param name="objectType"></param> /// <param name="existingValue"></param> /// <param name="serializer"></param> /// <returns></returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { // TODO: null checks? Key key = new Key((string)reader.Value); return key; }
/// <summary> /// Creates a new KeyScope containing the scope of the provided key. /// </summary> /// <throws>DataAccessException when key has no domain.</throws> /// <param name="key">The key from which the scope will be created.</param> /// <returns>The KeyScope</returns> public static KeyScope FromKey(Key key) { if (!key.Value.StartsWith(Domain, StringComparison.InvariantCulture)) { // Key must have a domain in order to get a KeyScope from it. throw new DataAccessException(String.Format("Can't create KeyScope from key [{0}] as it has no domain.", key)); } // last separator before the key segment (so we can trim it below). var lastSep = key.Value.LastIndexOf(Separator, StringComparison.InvariantCulture); // substring starts at first non-domain segment int subStart = Domain.Length + 1; int subLen = lastSep - subStart; return new KeyScope(key.Value.Substring(subStart, subLen)); }
private void AddKey(Key key) { _keys.Add(key); }
public bool Equals(Key key) { if (key == null) return false; return Equals(Value, key.Value); }
private void ResetInputBinding(MenuItem menu, Key key) { KeyConverter k = new KeyConverter(); menu.InputGestureText = k.ConvertToString(key); foreach (KeyBinding item in InputBindings) { if (item.Key == key) { item.Modifiers = ModifierKeys.None; break; } } }