private SBExpressionData ResolveDotIdentifierInstanceReference(SBExpressionData left, SBExpressionData right, bool includeBaseAndInterfaces) { var leftType = left.DataType.Type; var rightString = right.Value as string; if (left.DataType.DynamicType is IFileElement) { FileElement element = left.DataType.DynamicType as FileElement; var partner = element.ListPartners().FirstOrDefault(p => p.Name.Equals(rightString, StringComparison.InvariantCulture)); if (partner != null) { FileProcedure partnerProcedure = partner.ProcedureReference as FileProcedure; var procType = partnerProcedure.ProcedureReferenceType; MethodInfo getPartnerTyped; Expression elementReference; if (left.DataType.DynamicType is IFileProcedure) { getPartnerTyped = s_GetPartnerFromProcedure.MakeGenericMethod(partnerProcedure.DelegateType); elementReference = Expression.Convert(left.ExpressionCode, typeof(IProcedureReference)); } else { getPartnerTyped = s_GetPartner.MakeGenericMethod(partnerProcedure.DelegateType); elementReference = Expression.Convert(left.ExpressionCode, typeof(IFileElement)); } var getPartnerProc = Expression.Call( getPartnerTyped, m_currentProcedure.ContextReferenceInternal, elementReference, Expression.Constant(rightString)); return new SBExpressionData( HomeType.Immediate, SBExpressionType.Expression, partnerProcedure.DataType, getPartnerProc, instance: left.ExpressionCode); // Reference to the procedure reference } } foreach (var type in left.DataType.Type.SelfBasesAndInterfaces(includeBaseAndInterfaces, includeBaseAndInterfaces)) { var methods = type.GetMethods().Where(mi => mi.Name == rightString).ToList(); methods.AddRange(m_addonManager.ListExtensionMethods(left.DataType.Type, mi => mi.Name == rightString)); var properties = type.GetProperties().Where(pi => pi.Name == rightString).ToList(); //if (methods.Count > 0 && properties.Count > 1) //{ // throw new NotImplementedException("No handling when both methods and props are matching."); //} if (properties.Count == 1) { return new SBExpressionData( HomeType.Immediate, SBExpressionType.PropertyReference, // Expression type (TypeReference)properties[0].PropertyType, // Data type Expression.Property(left.ExpressionCode, properties[0]), // The property access expression properties[0]); // Reference to the found properties } else if (properties.Count > 1) { throw new NotImplementedException("More than one property with same name !!!?"); } if (methods.Count > 0) { return new SBExpressionData( left.ExpressionCode, // The instance expression methods); // Reference to the found methods } } if (typeof(IDynamicStepBroObject).IsAssignableFrom(left.DataType.Type)) { //if (left.Value != null) //{ // var variable = left.Value as IValueContainer; // IDynamicStepBroObject dynamicObject = (IDynamicStepBroObject)variable.GetValue(null); // if (dynamicObject != null) // { // Type propType; // bool isReadonly; // var propSupport = dynamicObject.HasProperty(rightString, out propType, out isReadonly); // if (propSupport == DynamicSupport.Yes) // { // return new SBExpressionData( // HomeType.Immediate, // isReadonly ? SBExpressionType.DynamicObjectPropertyReadonly : SBExpressionType.DynamicObjectProperty, // value: rightString, // Name of property // instance: left.ExpressionCode, // Instance reference // token: right.Token); // } // NamedData<Type>[] parameters; // Type returnType; // var methodSupport = dynamicObject.HasMethod(rightString, out parameters, out returnType); // if (methodSupport == DynamicSupport.Yes) // { // return new SBExpressionData( // HomeType.Immediate, // SBExpressionType.DynamicObjectProcedure, // value: rightString, // Name of method // instance: left.ExpressionCode, // Instance reference // token: right.Token); // } // if (propSupport == DynamicSupport.No && methodSupport == DynamicSupport.No) // { // m_errors.SymanticError(right.Token.Line, right.Token.Column, false, ""); // // Just leave with 'unknown' to enable parsing to finish without troubles. // } // } //} return new SBExpressionData( HomeType.Immediate, SBExpressionType.DynamicObjectMember, value: rightString, // Name of method instance: left.ExpressionCode, // Instance reference token: right.Token); } if (typeof(IDynamicAsyncStepBroObject).IsAssignableFrom(left.DataType.Type)) { return new SBExpressionData( HomeType.Immediate, SBExpressionType.DynamicAsyncObjectMember, value: rightString, // Name of method instance: left.ExpressionCode, // Instance reference token: right.Token); } return null; }