Example #1
0
 public static KeyTypeAttribute GetKeyTypeAttribute(KeyType keyType)
 {
     if (!_keyTypeDictionary.ContainsKey(keyType))
     {
         var type = keyType.GetType();
         var name = Enum.GetName(type, keyType);
         _keyTypeDictionary[keyType] = type.GetField(name)
                                       .GetCustomAttributes(typeof(KeyTypeAttribute), false)
                                       .SingleOrDefault() as KeyTypeAttribute;
     }
     return(_keyTypeDictionary[keyType]);
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MissingKeyException"/> class with serialized data.
 /// </summary>
 /// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
 /// <param name="context">The <see cref="StreamingContext"/>  that contains contextual information about the source or destination.</param>
 protected MissingKeyException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     Name = info.GetString(nameof(Name));
     Type = (KeyType)(info.GetValue(nameof(Type), Type.GetType()) ?? default(KeyType));
 }