예제 #1
0
        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;
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        /// <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;
        }
예제 #4
0
        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;
        }
예제 #5
0
        /// <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;
        }
예제 #6
0
        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;
        }
예제 #7
0
 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 "";
 }
예제 #8
0
        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;
        }
예제 #9
0
        /// <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 "";
        }