public MustBeList(IMust item, int?minCount, int?MaxCount, IEnumerable <ContentSchemaRule> rules) : base(rules) { Item = item ?? throw new ArgumentNullException(nameof(item)); MinItemCount = minCount; MaxItemCount = MaxCount; }
public virtual bool TryGetSchema(ContentPath path, out IMust schema) { schema = null; if (path.Length > 0) { return(false); } schema = this; return(true); }
public static ContentSchemaNodeDto ToDto(this IMust n) { switch (n) { case MustBeOneOf oneOf: return(new OneOfDto { Options = oneOf.Options.Select(o => o.ToDto()).ToArray() }); case CanBeAnything anything: return(new AnyDto()); case MustBeList list: return(new ListDto { Rules = list.Rules.Select(r => r.ToDto()).ToArray(), Item = list.Item.ToDto(), MinItemCount = list.MinItemCount, MaxItemCount = list.MaxItemCount }); case MustBeNull mustBeNull: return(new NullDto()); case MustBeObject obj: return(new ObjectDto { Rules = obj.Rules.Select(r => r.ToDto()).ToArray(), Properties = obj.Properties.Select(prop => prop.ToDto()).ToArray() }); case MustHaveType <ContentText> mustBeText: return(new TextDto { Rules = mustBeText.Rules.Select(r => r.ToDto()).ToArray(), }); case MustHaveType <ContentNumber> mustBeNumber: return(new NumberDto { Rules = mustBeNumber.Rules.Select(r => r.ToDto()).ToArray(), }); case MustBeDateTime mustBeDateTime: return(new DateTimeDto { HasDate = mustBeDateTime.HasDate, HasTime = mustBeDateTime.HasTime, Rules = mustBeDateTime.Rules.Select(r => r.ToDto()).ToArray(), }); case MustHaveType <ContentBoolean> mustBeBool: return(new BooleanDto { Rules = mustBeBool.Rules.Select(r => r.ToDto()).ToArray(), }); case MustBeEntityWithName mustBeEntity: return(new EntityDto { Rules = mustBeEntity.Rules.Select(r => r.ToDto()).ToArray(), Name = mustBeEntity.EntityName }); default: throw new NotSupportedException(); } }
public DocumentType(Type fromType) { Name = fromType.AssemblyQualifiedName; Schema = ContentSchemaNodeFactory.Default.CreateSchemaNodeFrom(fromType); }
public bool TryGetSchema(ContentPath path, out IMust schema) { schema = new CanBeAnything(); return(true); }
public ContentProperty(string key, IMust value, bool isRequired) { Key = key; Value = value; IsRequired = isRequired; }
public bool TryGetSchema(ContentPath path, out IMust schema) { throw new NotImplementedException(); }
public MustBeObject(IMust itemType, IEnumerable <ContentSchemaRule> rules) : base(rules) { Properties = null; ItemType = itemType ?? throw new ArgumentNullException(nameof(itemType)); }