public ApiModelRelationInfo(
     [NotNull] string name,
     [NotNull] string idName,
     ModelRelationType type,
     [NotNull] string modelTypeAsCsType)
 {
     Name              = name ?? throw new ArgumentNullException(nameof(name));
     IdName            = idName ?? throw new ArgumentNullException(nameof(idName));
     Type              = type;
     ModelTypeAsCsType = modelTypeAsCsType ?? throw new ArgumentNullException(nameof(modelTypeAsCsType));
 }
Example #2
0
        public ModelRelationAttribute(ModelRelationType relationType, [NotNull] string relationName, bool isId, [CanBeNull] string relatedPropertyName = null)
        {
            if (!Enum.IsDefined(typeof(ModelRelationType), relationType))
            {
                throw new InvalidEnumArgumentException(nameof(relationType), (int)relationType, typeof(ModelRelationType));
            }

            if (string.IsNullOrWhiteSpace(relationName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(relationName));
            }

            RelationType        = relationType;
            RelationName        = relationName;
            IsId                = isId;
            RelatedPropertyName = relatedPropertyName;
        }