Beispiel #1
0
        public static BaseMetadata CreateInstance(MetadataField field, BaseMetadata metadata, Guid?referenceCode = null)
        {
            BaseMetadata result = null;

            if (referenceCode.IsNull())
            {
                referenceCode = Guid.Empty;
            }

            switch (field.Type)
            {
            case FieldType.Store:
                result = new StoreMetadata()
                {
                    StoreCode = referenceCode.Value
                };
                break;

            case FieldType.Account:
                result = new AccountMetadata()
                {
                    AccountCode = referenceCode.Value
                };
                break;
            }

            result.Field = field;

            if (!metadata.IsNull())
            {
                result.Value = metadata.Value;
            }

            return(result);
        }
Beispiel #2
0
        public BaseMetadata Update(BaseMetadata metadata)
        {
            this.Value      = metadata.Value;
            this.UpdateDate = DateTime.Now;

            return(this);
        }
Beispiel #3
0
        public override bool IsValid(BaseMetadata metadata)
        {
            if (metadata.Value.IsNullorEmpty() || Values.IsNull() || Values.Count.IsZero())
            {
                return(true);
            }

            bool valid = Values.Any(v => v == metadata.Value);

            return(valid);
        }
Beispiel #4
0
        public override bool IsValid(BaseMetadata metadata)
        {
            if (metadata.Value.IsNullorEmpty())
            {
                return(true);
            }

            var schema = JsonSchema.FromJsonAsync(Schema);

            schema.Wait();

            var errors = schema.Result.Validate(metadata.Value);

            bool valid = errors.Count == 0;

            return(valid);
        }
Beispiel #5
0
 public abstract bool IsValid(BaseMetadata metadata);