Пример #1
0
        public override ValidationResult Validate()
        {
            var result = new ValidationResult();

            // ChunkId
            if (ChunkId == FourCc.Zero)
                result.EditValidity(Validity.Invalid, "\"ChunkId\" must be greater than zero");

            return result;
        }
Пример #2
0
 private static void WaveListChunkValidationProcedure(RiffChunk chunk, ref ValidationResult result)
 {
     var listChunk = chunk as ListChunk;
     if (listChunk == null)
         throw new FormatException("\"chunk\" must be a ListChunk");
 }
Пример #3
0
        public override ValidationResult Validate()
        {
            var result = new ValidationResult();

            // Text
            if (_text.Length == 0)
                result.EditValidity(Validity.Unknown, "\"Text\" has not been set");

            return result;
        }
Пример #4
0
 private static void SilentChunkValidationProcedure(RiffChunk chunk, ref ValidationResult result)
 {
 }
Пример #5
0
 private static void ValidateChunk(RiffChunk chunk, ref ValidationResult result)
 {
 }
Пример #6
0
        public override ValidationResult Validate()
        {
            var result = new ValidationResult();

            // Purpose
            if (Purpose == FourCc.Zero)
                result.EditValidity(Validity.Unknown, "\"Purpose\" has not been set");

            // Country
            /*if (Country == CountryCode.None)
                result.EditValidity(Validity.Unknown, "\"Country\" has not been set");*/
            if (!Enum.IsDefined(typeof(CountryCode), Country))
                result.EditValidity(Validity.Invalid, $"Unrecognized country code: {Country}");

            // Language
            /*if (Language == LanguageCode.None)
                result.EditValidity(Validity.Unknown, "\"Language\" has not been set");*/
            if (!Enum.IsDefined(typeof(LanguageCode), Language))
                result.EditValidity(Validity.Invalid, $"Unrecognized language code: {Language}");

            return result;
        }
Пример #7
0
 private static void LabeledTextChunkValidationProcedure(RiffChunk chunk, ref ValidationResult result)
 {
 }
Пример #8
0
        public override ValidationResult Validate()
        {
            var result = new ValidationResult();

            // UnshiftedNote
            if (_unshiftedNote.NoteNumber < 0 || _unshiftedNote.NoteNumber > 127)
                result.EditValidity(Validity.Invalid, "\"UnshiftedNote\" must be between 0 and 127");

            // FineTune
            if (FineTune < -50 || FineTune > 50)
                result.EditValidity(Validity.Invalid, "\"FineTune\" must be between -50 and 50");

            // Gain
            if (Gain < -64 || Gain > 64)
                result.EditValidity(Validity.Invalid, "\"Gain\" must be between -64 and 64");

            // LowNote
            if (LowNote < 0 || LowNote > 127)
                result.EditValidity(Validity.Invalid, "\"LowNote\" must be between 0 and 127");

            // HighNote
            if (HighNote < 0 || HighNote > 127)
                result.EditValidity(Validity.Invalid, "\"HighNote\" must be between 0 and 127");

            // LowVelocity
            if (LowVelocity < 1 || LowVelocity > 127)
                result.EditValidity(Validity.Invalid, "\"LowVelocity\" must be between 1 and 127");

            // HighVelocity
            if (HighVelocity < 1 || HighVelocity > 127)
                result.EditValidity(Validity.Invalid, "\"HighVelocity\" must be between 1 and 127");

            return result;
        }
Пример #9
0
 /// <summary>
 /// Allows two <c>ValidationResult</c> objects to combine their reason lists
 /// if they indicate the same state of validity.
 /// </summary>
 /// <param name="other">The <c>ValidationResult</c> with which to merge.</param>
 public void Merge(ValidationResult other)
 {
     if (other._validity <= _validity) return;
     _validity = other._validity;
     Reasons.AddRange(other.Reasons);
 }
Пример #10
0
        public override sealed ValidationResult Validate()
        {
            var result = new ValidationResult();
            if (Id == FourCc.Zero)
                result.EditValidity(Validity.Invalid, "\"Id\" cannot be equal to zero");

            _validationProcedure?.Invoke(this, ref result);

            foreach (var component in Children)
            {
                result.Merge(component.Validate());
            }
            return result;
        }
Пример #11
0
        private static void ValidateChunk(RiffChunk chunk, ref ValidationResult result)
        {
            var listChunk = chunk as ListChunk;
            if (listChunk == null)
                throw new FormatException("\"chunk\" must be a ListChunk");

            if (listChunk.TypeId == FourCc.Zero)
                result.EditValidity(Validity.Invalid, "\"TypeId\" cannot be equal to zero");

            listChunk._validationProcedure?.Invoke(listChunk, ref result);
        }
Пример #12
0
        public override ValidationResult Validate()
        {
            var result = new ValidationResult();

            // UnityNote
            if (_unityNote.NoteNumber > 127)
                result.EditValidity(Validity.Invalid, "\"UnityNote\" must be between 0 and 127");

            // Timecode
            if (SmpteFormat == SmpteFormat.None && SmpteOffset > 0)
                result.EditValidity(Validity.Invalid, "\"SmpteOffset\" must = 0 if \"SmpteFormat\" = 0 (None)");

            return result;
        }