Exemplo n.º 1
0
        public override IEnumerable <ValidationMessage> Validate(IInterfaceDefinition interfaceDefinition)
        {
            if (interfaceDefinition == null)
            {
                throw new ArgumentNullException(nameof(interfaceDefinition));
            }

            foreach (var method in interfaceDefinition.Methods)
            {
                if (interfaceDefinition.Methods.Where(m => m.Name == method.Name).Count() > 1)
                {
                    yield return(new ValidationMessage
                    {
                        LogLevel = LogLevel.Error,
                        Message = string.Format("There is more than one method with name '{0}'", method.Name)
                    });
                }
            }

            var validations = base.Validate(interfaceDefinition);

            foreach (var item in validations)
            {
                yield return(item);
            }
        }
Exemplo n.º 2
0
        public virtual IEnumerable <ValidationMessage> Validate(IInterfaceDefinition interfaceDefinition)
        {
            if (interfaceDefinition == null)
            {
                throw new ArgumentNullException(nameof(interfaceDefinition));
            }

            if (string.IsNullOrEmpty(interfaceDefinition.Name))
            {
                yield return(new ValidationMessage
                {
                    LogLevel = LogLevel.Error,
                    Message = "There isn't name for interface definition"
                });
            }

            foreach (var property in interfaceDefinition.Properties)
            {
                if (interfaceDefinition.Properties.Where(p => p.Name == property.Name).Count() > 1)
                {
                    yield return(new ValidationMessage
                    {
                        LogLevel = LogLevel.Error,
                        Message = string.Format("There is more than one property with name '{0}'", property.Name)
                    });
                }
            }
        }
Exemplo n.º 3
0
        public override ValidationResult Validate(IInterfaceDefinition interfaceDefinition)
        {
            if (interfaceDefinition == null)
            {
                throw new ArgumentNullException(nameof(interfaceDefinition));
            }

            var validationResult = base.Validate(interfaceDefinition);

            foreach (var method in interfaceDefinition.Methods)
            {
                if (interfaceDefinition.Methods.Where(m => m.Name == method.Name).Count() > 1)
                {
                    validationResult.ValidationMessages.Add(new ValidationMessage(LogLevel.Error, string.Format("There is more than one method with name '{0}'", method.Name)));
                }
            }

            return(validationResult);
        }
Exemplo n.º 4
0
        public virtual ValidationResult Validate(IInterfaceDefinition interfaceDefinition)
        {
            if (interfaceDefinition == null)
            {
                throw new ArgumentNullException(nameof(interfaceDefinition));
            }

            var result = new ValidationResult
            {
                IsValid = true
            };

            if (string.IsNullOrEmpty(interfaceDefinition.Name))
            {
                result.IsValid = false;

                result.ValidationMessages.Add(new ValidationMessage
                {
                    LogLevel = LogLevel.Error,
                    Message  = "There isn't name for interface definition"
                });
            }

            foreach (var property in interfaceDefinition.Properties)
            {
                result.IsValid = false;

                if (interfaceDefinition.Properties.Where(p => p.Name == property.Name).Count() > 1)
                {
                    result.ValidationMessages.Add(new ValidationMessage
                    {
                        LogLevel = LogLevel.Error,
                        Message  = string.Format("There is more than one property with name '{0}'", property.Name)
                    });
                }
            }

            return(result);
        }