// ------------------------------------------------------------------------ // private final MdaClass parentMdaClass; .. see super // private final String methodName; .. see super.getName // constructors // ------------------------------------------------------------------------- public MdaMethodImpl(MdaClass parentMdaClass, int internalMethodIndex, System.Reflection.MethodInfo method, PropertiesNode tags) : base(method.Name, tags, parentMdaClass) { this.internalMethodIndex = internalMethodIndex; this.method = method; this.returnType = method.ReturnType; if (returnType == null) { throw new System.InvalidOperationException("returnType == null for Method " + this); } }
public MdaFieldImpl(MdaClass ownerMdaClass, int internalFieldIndex, string fieldName, PropertiesNode tags, PropMethodsDescriptor methods) : base(fieldName, tags, ownerMdaClass) { this.internalFieldIndex = internalFieldIndex; System.Type modelClass = ownerMdaClass.getModelClass(); if (methods == null) { throw new System.ArgumentException(); } // TODO fieldType is badly set // should be set correctly using MethodRecognizer + PropertFact / PropMethodsDescriptor System.Reflection.MethodInfo getterMethod = methods.getMethod; if (getterMethod == null) { log.error("failed to find read Method for " + modelClass + "." + fieldName + " ... subsequent calls to fieldInfo.getValue(object) will not work!"); this.fieldType = typeof(object); } else { this.fieldType = getterMethod.ReturnType; } }
public static MdaFormulaExpr formulaExpr(string type, string expr, MdaClass declaredResultType) { return new MdaFormulaExpr(type, expr, declaredResultType); }
public MdaNthListEltExpr(int index, MdaClass eltType) { this.index = index; this.eltType = eltType; }
// <summary> TODO parameters MdaExpr for ctors ??? /// </summary> // private readonly MdaExpr[] constructorParameterExprs; public MdaNewObjectExpr(MdaClass factoryMdaClass) { this.factoryMdaClass = factoryMdaClass; }
public MdaIndexedMapEltExpr(object key, MdaClass valueType) { this.key = key; this.valueType = valueType; }
public MdaFormulaExpr(string interpreterType, string exprText, MdaClass declaredResultType) { // TOADD private transient Object compiledExpr; this.interpreterType = interpreterType; this.exprText = exprText; this.declaredResultType = declaredResultType; }
public MdaCtxObjectByNameExpr(string objectName, MdaClass declaredObjectType) { this.objectName = objectName; this.declaredObjectType = declaredObjectType; }
public MdaConstExpr(object constValue, MdaClass declaredType, PropertiesNode props) { this.constValue = constValue; this.declaredType = declaredType; this.props = props; }
public MdaConstExpr(object constValue, MdaClass declaredType) : this(constValue, declaredType, null) { }
public MdaMemberImpl(string name, PropertiesNode tags, MdaClass parentMdaClass) : base(name, tags) { this.parentMdaClass = parentMdaClass; }
public bool TryParse(MdaClass objectType, string exprText, out MdaExpr expr) { expr = null; if (exprText == null || exprText == string.Empty) return false; int indexFirstDot = exprText.IndexOf('.'); if (indexFirstDot == -1) { Match match; if ((match = REGEX_simpleProp.Match(exprText)).Success) { string propName = match.Groups[1].Value; MdaField prop = objectType.findField(propName); if (prop == null) { return false; } expr = MdaExprUtil.propExpr(prop); return true; } else if (exprText.StartsWith("id()")) { expr = MdaExprUtil.identityExpr(); return true; } else if (exprText.StartsWith("const(")) { int indexRightParent = exprText.IndexOf(")"); string constValText = exprText.Substring("const(".Length, indexRightParent-1); object value; if (!TryParseLitteralValue(constValText, out value)) { expr = null; return false; } expr = MdaExprUtil.constExpr(value); return true; } else if (exprText.StartsWith("meth:")) { int indexLeftParent = exprText.IndexOf("("); int indexRightParent = exprText.IndexOf(")"); string methodName = exprText.Substring("meth:".Length, indexLeftParent-1); string paramsText = exprText.Substring(indexLeftParent, indexRightParent-1); // TODO NOT IMPLEMENTED YET ... parse params expr + thisExpr?? ... // expr = MdaExprUtill.applyMethExpr(null, ); expr = null; return false; } else if (exprText.StartsWith("formula(")) { // TODO NOT IMPLEMENTED YET ... parse ... // expr = MdaExprUtill.formulaExpr(type, expr, declaredResultType); expr = null; return false; } else if ((match = REGEX_arrayIndex.Match(exprText)).Success) { string propName = match.Groups[1].Value; string indexValueText = match.Groups[2].Value; MdaField prop = objectType.findField(propName); if (prop == null) { return false; } object indexValueObj; if (!TryParseLitteralValue(indexValueText, out indexValueObj)) { return false; } // TODO NOT IMPLEMENTED YET ... // expr = MdaExprUtill.indexedExpr(...); return false; } else { // unrecognized expr type! return false; } } else { // sub expr "leftExpr.rightExpr" => recurse string leftPart = exprText.Substring(0, indexFirstDot); string rightPart = exprText.Substring(indexFirstDot+1, exprText.Length-indexFirstDot-1); MdaExpr leftExpr; // *** recurse leftExpr *** if (!TryParse(objectType, leftPart, out leftExpr)) { return false; } MdaClass leftExprType = leftExpr.GetReturnMdaType(); MdaExpr rightExpr; // *** recurse rightExpr *** if (!TryParse(leftExprType, rightPart, out rightExpr)) { return false; } expr = MdaExprUtil.subExpr(leftExpr, rightExpr); return true; } }
// ------------------------------------------------------------------------ public MdaCollectionFieldImpl(MdaClass ownerMdaClass, int internalFieldIndex, string fieldName, PropertiesNode tags, CollectionPropMethodsDescriptor methods) : base(ownerMdaClass, internalFieldIndex, fieldName, tags, methods) { this.methods = methods; }
public MdaRefFieldImpl(MdaClass ownerMdaClass, int internalFieldIndex, string fieldName, PropertiesNode tags, RefPropMethodsDescriptor methods) : base(ownerMdaClass, internalFieldIndex, fieldName, tags, methods) { }
public virtual MdaClass[] getMdaInterfaces() { System.Type[] tmp = modelClass.GetInterfaces (); int size = tmp.Length; MdaClass[] res = new MdaClass[size]; for (int i = 0; i < size; i++) { res [i] = MdaUtil.GetMdaType (tmp [i]); } return res; }
public virtual MdaClass getReturnMdaType() { // TODO this is currently a lazy field to avoid infinite loop in MdaClass loading! MdaClass res = returnMdaType; if (res == null) { returnMdaType = MdaUtil.GetMdaType(returnType); res = returnMdaType; } return res; }