コード例 #1
0
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string retStr = "";
            Enums  enums  = new Enums(LanguageRequest);
            PolSourceObsInfoChild polSourceObsInfoChild = validationContext.ObjectInstance as PolSourceObsInfoChild;

            polSourceObsInfoChild.HasErrors = false;

            retStr = enums.EnumTypeOK(typeof(PolSourceObsInfoEnum), (int?)polSourceObsInfoChild.PolSourceObsInfo);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                polSourceObsInfoChild.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "PolSourceObsInfo"), new[] { "PolSourceObsInfo" }));
            }

            retStr = enums.EnumTypeOK(typeof(PolSourceObsInfoEnum), (int?)polSourceObsInfoChild.PolSourceObsInfoChildStart);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                polSourceObsInfoChild.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "PolSourceObsInfoChildStart"), new[] { "PolSourceObsInfoChildStart" }));
            }

            if (!string.IsNullOrWhiteSpace(polSourceObsInfoChild.PolSourceObsInfoText) && polSourceObsInfoChild.PolSourceObsInfoText.Length > 100)
            {
                polSourceObsInfoChild.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "PolSourceObsInfoText", "100"), new[] { "PolSourceObsInfoText" }));
            }

            if (!string.IsNullOrWhiteSpace(polSourceObsInfoChild.PolSourceObsInfoChildStartText) && polSourceObsInfoChild.PolSourceObsInfoChildStartText.Length > 100)
            {
                polSourceObsInfoChild.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "PolSourceObsInfoChildStartText", "100"), new[] { "PolSourceObsInfoChildStartText" }));
            }

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                polSourceObsInfoChild.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
        private PolSourceObsInfoChild GetFilledRandomPolSourceObsInfoChild(string OmitPropName)
        {
            PolSourceObsInfoChild polSourceObsInfoChild = new PolSourceObsInfoChild();

            if (OmitPropName != "PolSourceObsInfo")
            {
                polSourceObsInfoChild.PolSourceObsInfo = (PolSourceObsInfoEnum)GetRandomEnumType(typeof(PolSourceObsInfoEnum));
            }
            if (OmitPropName != "PolSourceObsInfoChildStart")
            {
                polSourceObsInfoChild.PolSourceObsInfoChildStart = (PolSourceObsInfoEnum)GetRandomEnumType(typeof(PolSourceObsInfoEnum));
            }
            if (OmitPropName != "PolSourceObsInfoText")
            {
                polSourceObsInfoChild.PolSourceObsInfoText = GetRandomString("", 5);
            }
            if (OmitPropName != "PolSourceObsInfoChildStartText")
            {
                polSourceObsInfoChild.PolSourceObsInfoChildStartText = GetRandomString("", 5);
            }

            return(polSourceObsInfoChild);
        }
コード例 #3
0
 public PolSourceObsInfoChildTest()
 {
     polSourceObsInfoChild = new PolSourceObsInfoChild();
 }