/// <summary> /// Receives client's call and gets the predicates /// </summary> /// <param name="eventArgument">The field's type</param> public void RaiseCallbackEvent(string eventArgument) { IField f = getField(eventArgument); if (f == null) { return; } List <MethodInfo> constr = FieldsManager.GetConstraints(f.GetType()); foreach (MethodInfo mi in constr) { object[] attributes = mi.GetCustomAttributes(true); Fields.ConstraintAttribute attribute = (Fields.ConstraintAttribute)attributes[0]; constraints += attribute.Name + '&' + attribute.Description + '&' + mi.Name; foreach (ParameterInfo pi in mi.GetParameters()) { constraints += "#" + pi.Name; } constraints += "|"; } }
/// <summary> /// Receives client's call and gets the predicates /// </summary> /// <param name="eventArgument">The constraints string</param> public void RaiseCallbackEvent(string eventArgument) { string[] property = eventArgument.Split('|'); //property[0] -> field.basType IBaseType f = getField(property[0]); if (f != null) { returnValue = ""; //Applying costraints if (!property[1].Equals("")) //apply only if some costraints are defined { //--------------------------- // COSTRAINTS STRING FORMAT: // & CostraintName # CostraintParameter1 | .. | CostraintParameterNN //--------------------------- string[] constraints = property[1].Split('@'); for (int k = 0; k < constraints.Length; k++) { string[] constraintRapresentation = constraints[k].Split('#'); //divide costraint name from parameters string[] tmpParams; if (constraintRapresentation[1].Equals("")) { tmpParams = null; } else { tmpParams = constraintRapresentation[1].Split('$'); //divide each param } List <MethodInfo> constraintList = FieldsManager.GetConstraints(f.GetType()); bool constraint_loaded = false; foreach (MethodInfo c in constraintList) { if (constraintRapresentation[0].Equals(c.Name)) { constraint_loaded = (bool)c.Invoke(f, tmpParams); //apply costraint to field break; } } if (!constraint_loaded) { List <MethodInfo> constr = FieldsManager.GetConstraints(f.GetType()); string constrName = ""; foreach (MethodInfo mi in constr) { if (mi.Name.Equals(constraintRapresentation[0])) { object[] attributes = mi.GetCustomAttributes(true); Fields.ConstraintAttribute attribute = (Fields.ConstraintAttribute)attributes[0]; constrName += attribute.Name; break; } } returnValue = "Error applying constraint \"" + constrName + "\""; if (tmpParams != null) { returnValue += " with parameter"; if (tmpParams.Length > 1) { returnValue += "s "; for (int i = 0; i < tmpParams.Length; i++) { returnValue += ((i != 0)?", ":"") + tmpParams[i]; } } else { returnValue += " " + tmpParams[0]; } } } } } } }