public String GetPropertyNameFor(MethodInfo method) { PropertyAccessor propertyAccessor = AnnotationUtil.GetAnnotation <PropertyAccessor>(method, true); if (propertyAccessor != null) { return(propertyAccessor.PropertyName); } Match matcher = getSetIsPattern.Match(method.Name); if (!matcher.Success) { return(""); } int paramLength = method.GetParameters().Length; String getSetIs = matcher.Groups[1].Value; if (("get_".Equals(getSetIs) || "Get".Equals(getSetIs) || "get".Equals(getSetIs)) && (0 != paramLength || typeof(void).Equals(method.ReturnType))) { return(""); } else if (("set_".Equals(getSetIs) || "Set".Equals(getSetIs) || "set".Equals(getSetIs)) && 1 != paramLength) { return(""); } else if (("Is".Equals(getSetIs) || "is".Equals(getSetIs)) && (0 != paramLength || typeof(void).Equals(method.ReturnType))) { return(""); } String name = matcher.Groups[2].Value; return(StringConversionHelper.UpperCaseFirst(name)); }
protected RelationConfigLegathy ReadRelationConfig(XElement relationElement, bool localEntity, bool toOne) { String relationName = XmlConfigUtil.GetRequiredAttribute(relationElement, XmlConstants.NAME, true); try { RelationConfigLegathy relationConfig = new RelationConfigLegathy(relationName, toOne); String linkedEntityName = XmlConfigUtil.GetRequiredAttribute(relationElement, XmlConstants.TARGET_ENTITY); Type linkedEntityType = XmlConfigUtil.GetTypeForName(linkedEntityName); relationConfig.LinkedEntityType = linkedEntityType; bool doDelete = XmlConfigUtil.AttributeIsTrue(relationElement, XmlConstants.DO_DELETE); relationConfig.DoDelete = doDelete; bool mayDelete = XmlConfigUtil.AttributeIsTrue(relationElement, XmlConstants.MAY_DELETE); relationConfig.MayDelete = mayDelete; if (localEntity) { XElement joinTableTag = XmlConfigUtil.GetChildUnique(relationElement, XmlConstants.JOIN_TABLE); if (joinTableTag == null) { String constraintName = XmlConfigUtil.GetAttribute(relationElement, XmlConstants.CONSTRAINT_NAME); if (constraintName.Length == 0 && !IndependentMetaData) { throw new ArgumentException("Either nested element '" + XmlConstants.JOIN_TABLE + "' or attribute '" + XmlConstants.CONSTRAINT_NAME + "' required to map link"); } relationConfig.ConstraintName = constraintName; } else { String joinTableName = XmlConfigUtil.GetRequiredAttribute(joinTableTag, XmlConstants.NAME); relationConfig.JoinTableName = joinTableName; String fromFieldName = XmlConfigUtil.GetChildElementAttribute(joinTableTag, XmlConstants.JOIN_COLUMN, XmlConstants.NAME, "Join column name has to be set exactly once"); relationConfig.FromFieldName = fromFieldName; String toFieldName = XmlConfigUtil.GetChildElementAttribute(joinTableTag, XmlConstants.INV_JOIN_COLUMN, XmlConstants.NAME, null); relationConfig.ToFieldName = toFieldName; String toAttributeName = XmlConfigUtil.GetChildElementAttribute(joinTableTag, XmlConstants.INV_JOIN_ATTR, XmlConstants.NAME, null); toAttributeName = StringConversionHelper.UpperCaseFirst(toAttributeName); relationConfig.ToAttributeName = toAttributeName; if (toFieldName == null && toAttributeName == null) { throw new ArgumentException("Inverse join column or attribute name has to be set"); } } } return(relationConfig); } catch (Exception e) { throw new Exception("Error occured while processing relation '" + relationName + "'", e); } }
public MethodInfo GetMethod(Type serviceType) { if (method == null) { method = serviceType.GetMethod(StringConversionHelper.UpperCaseFirst(MethodName), ParamTypes); if (method == null) { method = serviceType.GetMethod(StringConversionHelper.LowerCaseFirst(MethodName), ParamTypes); } if (method == null) { throw new Exception("No matching method found on type " + serviceType.FullName + "'"); } } return(method); }