protected static void AssertInvalidObject(BusinessObjectBase o, string property, Type expectedValidatorType) { AssertInvalidObject(o); if (property != null) { AssertInvalidProperty(o, property, expectedValidatorType); } }
public override bool Validate(BusinessObjectBase businessObject) { var codiceDestinatario = GetPropertyValue(businessObject, "CodiceDestinatario"); var formatoTrasmissione = GetPropertyValue(businessObject, "FormatoTrasmissione"); if (formatoTrasmissione != null && (string)formatoTrasmissione == Impostazioni.FormatoTrasmissione.Privati) { if (codiceDestinatario == null || ((string)codiceDestinatario).Length != 7) { Description = string.Format( "1.1.4 CodiceDestinatario diverso da 7 caratteri a fronte di 1.1.3 FormatoTrasmissione con valore {0}", Impostazioni.FormatoTrasmissione.Privati); return(false); } } if (formatoTrasmissione != null && (string)formatoTrasmissione == Impostazioni.FormatoTrasmissione.PubblicaAmministrazione) { if (codiceDestinatario == null || ((string)codiceDestinatario).Length != 6) { Description = string.Format( "1.1.4 CodiceDestinatario diverso da 6 caratteri a fronte di 1.1.3 FormatoTrasmissione con valore {0}", Impostazioni.FormatoTrasmissione.PubblicaAmministrazione); return(false); } } return(true); }
protected static void AssertInvalidProperty(BusinessObjectBase o, string property, Type expectedValidatorType) { Assert.AreEqual(o.GetBrokenRules(property).Count, 1); Assert.IsNotNull(o[property]); var v = o.GetBrokenRules()[0]; Assert.AreEqual(property, v.PropertyName); Assert.IsNotNull(v.Description); Assert.IsInstanceOfType(v, expectedValidatorType); }
protected static void AssertInvalidProperty(BusinessObjectBase o, string property, Type expectedValidatorType) { Assert.AreEqual(o.GetBrokenRules(property).Count, 1); Assert.IsNotNull(o[property]); var v = o.GetBrokenRules()[0]; Assert.AreEqual(property, v.PropertyName); Assert.IsNotNull(v.Description); Assert.IsInstanceOf(expectedValidatorType, v); }
/// <summary> /// Validates that the rule has been followed. /// </summary> /// <remarks>Description will only express broken validation rules, or null.</remarks> public override bool Validate(BusinessObjectBase businessObject) { var result = true; Description = null; foreach (var v in _validators.Where(v => !v.Validate(businessObject))) { Description += v.Description; result = false; } return result; }
public BusinessObjectException(BusinessObjectBase obj, string msgFormat, params object[] args) : base(string.Concat(string.Format(msgFormat, args))) { this.BizObj = obj; var slot = obj.GetSlot(); //Esegue log debug slot.LogDebugException(DebugLevel.Error_3, this); //Se presente handler di eccezione lo richiama slot.BizObjectExceptionCatch(this); }
/// <summary> /// Validates that the rule has been followed. /// </summary> /// <remarks>Description will only express broken validation rules, or null.</remarks> public override bool Validate(BusinessObjectBase businessObject) { var result = true; Description = null; foreach (var v in _validators.Where(v => !v.Validate(businessObject))) { Description += v.Description; result = false; } return(result); }
/// <summary> /// Validates that the rule has been followed. /// </summary> public override bool Validate(BusinessObjectBase businessObject) { var v = GetPropertyValue(businessObject, PropertyName); var @string = v as string; if (@string != null) { return !string.IsNullOrEmpty((string)v); } var @base = v as BusinessObjectBase; if (@base != null) { return [email protected](); } return v != null; }
public override bool Validate(BusinessObjectBase businessObject) { var v = (List <string>)GetPropertyValue(businessObject, PropertyName); for (var i = 0; i < v.Count; i++) { var s = v[i]; if (string.IsNullOrEmpty(s) || (s.Length >= Min && s.Length <= Max)) { continue; } _offendingIndex = i; return(false); } return(true); }
public static TypeReference FindType(this BusinessObjectBase propertyType, Dictionary <BusinessObjectBase, TypeReference> definedTypes) { if (propertyType == null) { return(null); } try { return(definedTypes[propertyType]); } catch (Exception ex) { throw ex; } }
public static TypeReference GetTypeReference(this BusinessObjectBase bo) { try { if (TypeReferences.ContainsKey(bo)) { return(TypeReferences[bo]); } else { return(null); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Validates that the rule has been followed. /// </summary> public override bool Validate(BusinessObjectBase businessObject) { var v = GetPropertyValue(businessObject, PropertyName); var @string = v as string; if (@string != null) { return(!string.IsNullOrEmpty((string)v)); } var @base = v as BusinessObjectBase; if (@base != null) { return([email protected]()); } return(v != null); }
//public FPECDestinatarioValidator(string propertyName) : base(propertyName) { } public override bool Validate(BusinessObjectBase businessObject) { var codiceDestinatario = GetPropertyValue(businessObject, "CodiceDestinatario"); var pecDestinatario = GetPropertyValue(businessObject, PropertyName); if (codiceDestinatario != null && (string)codiceDestinatario == "0000000") { if (pecDestinatario == null || string.IsNullOrEmpty((string)pecDestinatario)) { Description = "00426: 1.1.6 PECDestinatario non valorizzato a fronte di 1.1.4 <CodiceDestinatario> con valore 0000000"; return(false); } } else { if (pecDestinatario != null && !string.IsNullOrEmpty((string)pecDestinatario)) { Description = "00426: 1.1.6 PECDestinatario valorizzato a fronte di 1.1.4 <Codice Destinatario> con valore diverso da 0000000"; return(false); } } return(true); }
/// <summary> /// Validates that the rule has been followed. /// </summary> public override bool Validate(BusinessObjectBase businessObject) { var v = (string)GetPropertyValue(businessObject, PropertyName); return string.IsNullOrEmpty(v) || System.Text.RegularExpressions.Regex.Match(v, Regex).Success; }
public override bool Validate(BusinessObjectBase businessObject) { var v = (string)GetPropertyValue(businessObject, PropertyName); return(string.IsNullOrEmpty(v) || v.Length >= Min && v.Length <= Max); }
protected static void AssertValidObject(BusinessObjectBase o, string property) { AssertValidObject(o); AssertValidProperty(o, property); }
/// <summary> /// Given a BusinessObeject property name, returnes its value. /// </summary> /// <param name="businessObject">A BusinessObject instance.</param> /// <param name="propertyName">Name of the property.</param> /// <returns>A property value.</returns> protected object GetPropertyValue(BusinessObjectBase businessObject, string propertyName) { var pi = businessObject.GetType().GetProperty(propertyName); return pi.GetValue(businessObject, null); }
protected static void AssertValidProperty(BusinessObjectBase o, string property) { Assert.AreEqual(o.GetBrokenRules(property).Count, 0); Assert.IsNull(o[property]); }
protected static void AssertValidObject(BusinessObjectBase o) { Assert.IsTrue(o.IsValid); Assert.IsNull(o.Error); Assert.AreEqual(o.GetBrokenRules().Count, 0); }
public static void AddToTypeReferences(this TypeReference self, BusinessObjectBase bo) { TypeReferences.Add(bo, self); }
/// <summary> /// Validates that the rule has been followed. /// </summary> public override bool Validate(BusinessObjectBase businessObject) { var v = (string)GetPropertyValue(businessObject, PropertyName); return(string.IsNullOrEmpty(v) || System.Text.RegularExpressions.Regex.Match(v, Regex).Success); }
/// <summary> /// Validates that the rule has not been broken. /// </summary> /// <param name="businessObject">The domain object being validated.</param> /// <returns>True if the rule has not been broken, or false if it has.</returns> public override bool Validate(BusinessObjectBase businessObject) { return(ValidatorDelegate()); }
public override bool Validate(BusinessObjectBase businessObject) { var v = (string)GetPropertyValue(businessObject, PropertyName); return string.IsNullOrEmpty(v) || v.Length >= _min && v.Length <= _max; }
protected static void AssertInvalidObject(BusinessObjectBase o) { Assert.IsFalse(o.IsValid); Assert.AreEqual(o.GetBrokenRules().Count, 1); }
/// <summary> /// Given a BusinessObeject property name, returnes its value. /// </summary> /// <param name="businessObject">A BusinessObject instance.</param> /// <param name="propertyName">Name of the property.</param> /// <returns>A property value.</returns> protected object GetPropertyValue(BusinessObjectBase businessObject, string propertyName) { var pi = businessObject.GetType().GetProperty(propertyName); return(pi.GetValue(businessObject, null)); }
public TrackingParams(BusinessContext businessManager, BusinessObjectBase businessObject, EntityEntry entityEntry) { BusinessManager = businessManager; BusinessObject = businessObject; EntityEntry = entityEntry; }
public override bool Validate(BusinessObjectBase businessObject) { var v = (string)GetPropertyValue(businessObject, PropertyName); return string.IsNullOrEmpty(v) || Array.IndexOf(Domain, v) != -1; }
/// <summary> /// Validates that the rule has been followed. /// </summary> public override bool Validate(BusinessObjectBase businessObject) { var cnt = Properties.Select(prop => GetPropertyValue(businessObject, prop)).Count(v => v != null && (string)v != string.Empty); return cnt == 1; }
/// <summary> /// Validates that the rule has been followed. /// </summary> public abstract bool Validate(BusinessObjectBase businessObject);
public override bool Validate(BusinessObjectBase businessObject) { var v = (string)GetPropertyValue(businessObject, PropertyName); return(string.IsNullOrEmpty(v) || Array.IndexOf(Domain, v) != -1); }
/// <summary> /// Validates that the rule has not been broken. /// </summary> /// <param name="businessObject">The domain object being validated.</param> /// <returns>True if the rule has not been broken, or false if it has.</returns> public override bool Validate(BusinessObjectBase businessObject) { return ValidatorDelegate(); }
public override bool Validate(BusinessObjectBase businessObject) { var v = (decimal)GetPropertyValue(businessObject, PropertyName); return(v == 0 || v >= 1.00M); }
/// <summary> /// Create a basic instance of the @Dynamic class /// <summary> /// <param name="bob">A reference to an initialized Business Object</param> public @Dynamic(BusinessObjectBase bob) : base(bob) { }
/// <summary> /// Validates that the rule has been followed. /// </summary> public override bool Validate(BusinessObjectBase businessObject) { var cnt = Properties.Select(prop => GetPropertyValue(businessObject, prop)).Count(v => v != null && (string)v != string.Empty); return(cnt == 1); }