public GenericChildKeyStrategy(InformationHandlingFlags typeHandling, [NotNull] ITypeSerializerStrategy <TKeyType> keyTypeSerializerStrategy) { if (keyTypeSerializerStrategy == null) { throw new ArgumentNullException(nameof(keyTypeSerializerStrategy)); } int i; if (!Enum.IsDefined(typeof(InformationHandlingFlags), typeHandling) && Int32.TryParse(typeHandling.ToString(), out i)) { throw new ArgumentOutOfRangeException(nameof(typeHandling), "Value should be defined in the InformationHandlingFlags enum."); } /*int i; * * if (!Enum.IsDefined(typeof(InformationHandlingFlags), typeHandling) && Int32.TryParse(typeHandling.ToString(), out i)) * throw new InvalidEnumArgumentException(nameof(typeHandling), (int)typeHandling, * typeof(InformationHandlingFlags));*/ //Try to get the max value for this type DefaultKey = GenericMath.Convert <TKeyType, int>(GenericMath.Convert <int, TKeyType>(Int32.MaxValue)); typeHandlingFlags = typeHandling; KeyTypeSerializerStrategy = keyTypeSerializerStrategy; }
/// <summary> /// Creates a new Meta-data attribute indicating the type is a WireDataContract. /// </summary> public WireDataContractAttribute(KeyType keyType = KeyType.None, InformationHandlingFlags typeHandling = InformationHandlingFlags.Default, bool expectRuntimeLink = false) { if (!Enum.IsDefined(typeof(KeyType), keyType)) { throw new ArgumentException($"Provided enum argument {nameof(keyType)} of Type {typeof(KeyType)} with value {keyType} was not in valid range.", nameof(keyType)); } int i; if (!Enum.IsDefined(typeof(InformationHandlingFlags), typeHandling) && Int32.TryParse(typeHandling.ToString(), out i)) { throw new ArgumentException($"Provided enum argument {nameof(typeHandling)} of Type {typeof(InformationHandlingFlags)} with value {typeHandling} was not in valid range.", nameof(typeHandling)); } //The keytype provided is optional to be none. //If you want to wire up children to this for polymorphic serialization then //A provided keysize must be declared on the 1 WireDataContract instead of the N many WireBaseType attributes OptionalChildTypeKeySize = keyType; TypeHandling = typeHandling; ExpectRuntimeLink = expectRuntimeLink; }