Exemple #1
0
 public static bool TryCreate(Uri uri, out CommandKey key)
 {
     if (uri == null)
     {
         key = null;
         return(false);
     }
     return(TryCreate(uri.ToString(), out key));
 }
Exemple #2
0
 public static bool TryCreate(string s, out CommandKey key)
 {
     if (string.IsNullOrWhiteSpace(s))
     {
         key = null;
         return(false);
     }
     key = new CommandKey(s);
     return(true);
 }
Exemple #3
0
        public static bool TryGetOrCreate(Uri uri, out CommandKey key)
        {
            if (uri == null)
            {
                key = null;
                return(false);
            }

            return(TryGetOrCreate(uri.OriginalString, out key));
        }
Exemple #4
0
        public static bool TryGetOrCreate(string text, out CommandKey key)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                key = null;
                return(false);
            }

            key = Cache.GetOrAdd(text, s => new CommandKey(s));
            return(true);
        }
Exemple #5
0
 public bool Equals(CommandKey other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(string.Equals(this.key, other.key, StringComparison.InvariantCultureIgnoreCase));
 }
Exemple #6
0
        internal static bool TryGetOrCreate(object key, out CommandKey commandKey)
        {
            if (key is string s)
            {
                return(TryGetOrCreate(s, out commandKey));
            }

            if (key is Uri uri)
            {
                return(TryGetOrCreate(uri, out commandKey));
            }

            commandKey = null;
            return(false);
        }
Exemple #7
0
        internal static bool TryCreate(object key, out CommandKey commandKey)
        {
            var s = key as string;

            if (s != null)
            {
                return(TryCreate(s, out commandKey));
            }

            var uri = key as Uri;

            if (uri != null)
            {
                return(TryCreate(uri, out commandKey));
            }
            commandKey = null;
            return(false);
        }