示例#1
0
 public static bool TryCreate(Uri uri, out CommandKey key)
 {
     if (uri == null)
     {
         key = null;
         return(false);
     }
     return(TryCreate(uri.ToString(), out key));
 }
示例#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);
 }
示例#3
0
        public static bool TryGetOrCreate(Uri uri, out CommandKey key)
        {
            if (uri == null)
            {
                key = null;
                return(false);
            }

            return(TryGetOrCreate(uri.OriginalString, out key));
        }
示例#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);
        }
示例#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));
 }
示例#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);
        }
示例#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);
        }