public object this [ONPath onPath] { get { if ((onPath == null) || (onPath.Count == 0)) { return(this); } // Search in preloaded related attributes if (RelatedValues.ContainsKey(onPath.Path)) { return(RelatedValues[onPath.Path]); } string lRol = onPath.RemoveHead(); PropertyInfo lProperty = null; // Last unique role (like attributes) if (onPath.Count == 0) { lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>"); if (lProperty != null) { return(lProperty.GetValue(this, null)); } } // Roles lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>"); if (lProperty != null) { if (onPath.Count == 0) { return(lProperty.GetValue(this, null)); } else { return((lProperty.GetValue(this, null) as ONCollection)[onPath]); } } return(null); } }
public ONSimpleType DisplaysetItemValue(ONPath displaysetItem) { if ((displaysetItem == null) || (displaysetItem.Count == 0)) { return(null); } ONPath lDisplaysetItem = new ONPath(displaysetItem); string lRol = lDisplaysetItem.RemoveHead(); PropertyInfo lProperty = null; MethodInfo lMethod = null; string methodName = lRol + "RoleHV"; // Last unique role (like attributes) if (lDisplaysetItem.Count == 0) { lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>"); if (lProperty != null) { return((lProperty.GetValue(this, null)) as ONSimpleType); } } // Roles lMethod = GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); if (lMethod != null) { ONCollection lCollection = lMethod.Invoke(this, null) as ONCollection; if (lCollection.Count <= 0) { return(ONSimpleType.Null(ONInstance.GetTypeOfAttribute(GetType(), displaysetItem))); } ONInstance lInstance = lCollection[0]; return(lInstance.DisplaysetItemValue(lDisplaysetItem)); } return(null); }