/// <summary> /// Constructor /// </summary> /// <param name="onPath">Role path to be treated</param> public ONPath(ONPath onPath) { if ((onPath as object) == null) Roles = new List<string>(); else Roles = new List<string>(onPath.Roles); }
public object this[ONPath onPath] { get { if ((onPath == null) || (onPath.Count == 0)) return this; 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 ONQuery)[onPath]; } return null; } }
public static ONPath operator+(ONPath obj1, ONPath obj2) { ONPath lPath = new ONPath(obj1); lPath.Roles.AddRange(obj2.Roles); return(lPath); }
public void AddSqlAttribute(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type, string domainArgument) { foreach (ONOrderCriteriaItem lOCItem in OrderCriteriaSqlItem) if ((lOCItem.OnPath == onPath) && (lOCItem.Attribute == attribute)) return; OrderCriteriaSqlItem.Add(new ONOrderCriteriaItem(onPath, facet, attribute, type, domainArgument)); }
/// <summary> /// Constructor /// </summary> /// <param name="onPath">Role path to be treated</param> public ONPath(ONPath onPath) { if ((onPath as object) == null) { Roles = new List <string>(); } else { Roles = new List <string>(onPath.Roles); } }
public static ONPath operator+(ONPath obj1, string obj2) { ONPath lPath = new ONPath(obj1); char[] lDelimiter = { '.' }; string[] lRoles = obj2.Split(lDelimiter); foreach (string lRol in lRoles) { lPath.Roles.Add(lRol); } return(lPath); }
/// <summary> /// Checks if the attributes of a determinate class are visible according to the agent connected /// </summary> /// <param name="typeInstance">Type fo the class to check the visibility</param> /// <param name="attributeVisibility">Attribute to be checked, it is not owned to the class that is being checked</param> /// <param name="onContext">Request context </param> public static bool IsVisibleInv(Type typeInstance, ONPath attributeVisibility, ONContext onContext) { if (attributeVisibility.Count == 0) return true; ONPath lAttributeVisibility = new ONPath(attributeVisibility); string lRol = lAttributeVisibility.RemoveHead(); // Attributes if (lAttributeVisibility.Count == 0) { ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return (lAttributeAttribute.IsVisible(onContext)); } // Roles ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) { Type lTypeInstanceInv = ONContext.GetType_Instance(lRoleAttribute.Domain); return (IsVisible(lTypeInstanceInv, lRoleAttribute.RoleInv, onContext) && IsVisibleInv(lTypeInstanceInv, lAttributeVisibility, onContext)); } return false; }
public static bool HasHorizontalVisibility(Type typeInstance, string rolePath, StringCollection activeAgentFacets) { ONPath lRolePath = new ONPath(rolePath); return HasHorizontalVisibility(typeInstance, lRolePath, activeAgentFacets); }
public static ONPath operator +(ONPath obj1, ONPath obj2) { ONPath lPath = new ONPath(obj1); lPath.Roles.AddRange(obj2.Roles); return lPath; }
public static bool HasHorizontalVisibility(Type typeInstance, ONPath rolePath, StringCollection activeAgentFacets) { ONPath lRolePath = new ONPath(rolePath); string lRol = lRolePath.RemoveHead(); // Attributes if (lRolePath.Count == 0) { ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return false; } ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) { if(lRoleAttribute.HasHorizontalVisibility(activeAgentFacets)) return true; if (lRolePath.Count == 0) return false; else return (HasHorizontalVisibility(ONContext.GetType_Instance(lRoleAttribute.Domain), lRolePath, activeAgentFacets)); } return false; }
/// <summary> /// Obtains the data type of an atribute. It is used to construcut the response message XML /// </summary> /// <param name="typeInstance">Type fo the class to check the visibility</param> /// <param name="attributeInDisplay">Attribute to be checked, it is not owned to the class that is being checked</param> public static string GetTypeOfAttribute(Type typeInstance, ONPath attributeInDisplay) { string lRol = attributeInDisplay.RemoveHead(); // Attributes if (attributeInDisplay.Count == 0) { ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return (lAttributeAttribute.Type); } // Roles ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) { if (attributeInDisplay.Count == 0) return ""; else return GetTypeOfAttribute(ONContext.GetType_Instance(lRoleAttribute.Domain), attributeInDisplay); } return ""; }
public static ONPath operator +(ONPath obj1, string obj2) { ONPath lPath = new ONPath(obj1); char[] lDelimiter = {'.'}; string[] lRoles = obj2.Split(lDelimiter); foreach (string lRol in lRoles) lPath.Roles.Add(lRol); return lPath; }
public static string InversePath(Type typeInstance, ONPath rolePath) { ONPath lRolePath = new ONPath(rolePath); string lRol = lRolePath.RemoveHead(); ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) { if (lRolePath.Count == 0) return (lRoleAttribute.RoleInv); else return ((InversePath(ONContext.GetType_Instance(lRoleAttribute.Domain), lRolePath)) + "." + (lRoleAttribute.RoleInv)); } return ""; }
public virtual string InhGetTargetClassName(ONPath onPath) { if ((onPath == null) || (onPath.Count == 0)) return ClassName; else return ""; }
/// <summary> /// Obtains by reflection if an attribute is optimized /// </summary> /// <param name="typeInstance">Type of the class</param> /// <param name="attributeInDisplay">Attribute to be checked</param> public static bool IsOptimized(Type typeInstance, ONPath path) { if (path == null) return true; if (path.Count == 0) return true; ONPath lPath = new ONPath(path); string lRol = lPath.RemoveHead(); // Attributes if (lPath.Count == 0) { ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return (lAttributeAttribute.IsOptimized); } // Roles ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) { if (lPath.Count == 0) return (!lRoleAttribute.IsLegacy); else if (!lRoleAttribute.IsLegacy) return IsOptimized(ONContext.GetType_Instance(lRoleAttribute.Domain), lPath); } return false; }
//, ONOid agentOid) public static bool IsLocal(Type typeInstance, string rolePath) { ONPath lRolePath = new ONPath(rolePath); return IsLocal(typeInstance, lRolePath); }
public static bool IsLocal(Type typeInstance, ONPath rolePath) { if (rolePath.Count == 0) return true; ONPath lRolePath = new ONPath(rolePath); string lRol = lRolePath.RemoveHead(); // Attributes if (lRolePath.Count == 0) { ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return (!lAttributeAttribute.IsLegacy); } ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) { if (lRolePath.Count == 0) return (!lRoleAttribute.IsLegacy); else return ((!lRoleAttribute.IsLegacy) && (IsLocal(ONContext.GetType_Instance(lRoleAttribute.Domain), lRolePath))); } return false; }
/// <summary> /// Construction the part of SQL sentence that is Oder By /// </summary> /// <param name="onPath">Role path in case that the attribute is from another class</param> /// <param name="facet">Name of the class that has the attribute to be fixed in SQL sentence</param> /// <param name="attribute">Name of the attribute that is needed to the sort</param> /// <param name="type">Direction of the order. Could be ascending o descending</param> public void AddSqlAttribute(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type) { AddSqlAttribute(onPath, facet, attribute, type, ""); }
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; }
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 static string GetTargetClass(ONContext onContext, Type typeInstance, ONPath path) { foreach (string lRole in path.Roles) { // Attributes ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRole + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return (lAttributeAttribute.FacetOfField); // Roles ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRole + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) typeInstance = ONContext.GetType_Instance(lRoleAttribute.Domain); else break; } if (typeInstance != null) { object[] lParameters = new object[1]; lParameters[0] = onContext; ONInstance lInstance = Activator.CreateInstance(typeInstance, lParameters) as ONInstance; return lInstance.ClassName; } else return ""; }