/// <summary> /// Make the struct a strongly typed ID /// </summary> /// <param name="generateJsonConverter">If true generates a JsonConverter for the strongly typed ID (requires a reference to Newtonsoft.Json in the project)</param> /// <param name="backingType">The <see cref="Type"/> to use to store the strongly-typed ID value. Defaults to <see cref="StronglyTypedIdBackingType.Guid"/></param> public StronglyTypedIdAttribute( bool generateJsonConverter = true, StronglyTypedIdBackingType backingType = StronglyTypedIdBackingType.Guid) { GenerateJsonConverter = generateJsonConverter; BackingType = backingType; }
/// <summary> /// Make the struct a strongly typed ID /// </summary> /// <param name="generateJsonConverter">If true generates a JsonConverter for the strongly typed ID (requires a reference to Newtonsoft.Json in the project)</param> /// <param name="backingType">The <see cref="Type"/> to use to store the strongly-typed ID value. Defaults to <see cref="StronglyTypedIdBackingType.Guid"/></param> /// <param name="jsonConverter">JSON library used to serialize/deserialize strongly-typed ID value. Defaults to <see cref="StronglyTypedIdJsonConverter.NewtonsoftJson"/></param> public StronglyTypedIdAttribute( bool generateJsonConverter = true, StronglyTypedIdBackingType backingType = StronglyTypedIdBackingType.Guid, StronglyTypedIdJsonConverter jsonConverter = StronglyTypedIdJsonConverter.NewtonsoftJson) { GenerateJsonConverter = generateJsonConverter; BackingType = backingType; JsonConverter = jsonConverter; }
public StronglyTypedIdGenerator(AttributeData attributeData) { if (attributeData == null) { throw new ArgumentNullException(nameof(attributeData)); } _generateJsonConverter = (bool)attributeData.ConstructorArguments[0].Value; _backingType = (StronglyTypedIdBackingType)attributeData.ConstructorArguments[1].Value; }