Equals() public method

public Equals ( EntityToken entityToken ) : bool
entityToken EntityToken
return bool
Exemplo n.º 1
0
        private static IReadOnlyCollection <PermissionType> RecursiveUpdateCurrentUserPermissionTypes(UserToken userToken, EntityToken entityToken, IEnumerable <UserPermissionDefinition> userPermissionDefinitions, HashSet <EntityTokenPair> alreadyProcessedTokens)
        {
            IReadOnlyCollection <PermissionType> cached = PermissionTypeFacadeCaching.GetUserPermissionTypes(userToken, entityToken);

            if (cached != null)
            {
                return(cached);
            }

            UserPermissionDefinition userPermissionDefinition = userPermissionDefinitions
                                                                .Where(f => entityToken.Equals(f.EntityToken)).SingleOrDefaultOrException("More then one UserPermissionDefinition for the same entity token");

            var thisPermisstionTypes = new List <PermissionType>();

            if (userPermissionDefinition != null)
            {
                thisPermisstionTypes.AddRange(userPermissionDefinition.PermissionTypes);
            }


            if (thisPermisstionTypes.Count > 0)
            {
                thisPermisstionTypes = thisPermisstionTypes.Distinct().ToList();

                if (thisPermisstionTypes.Contains(PermissionType.ClearPermissions))
                {
                    thisPermisstionTypes = new List <PermissionType>();
                }

                PermissionTypeFacadeCaching.SetUserPermissionTypes(userToken, entityToken, thisPermisstionTypes);

                // Local defined permission overrules all other permissions
                return(thisPermisstionTypes);
            }

            // Call resursively on all parents
            List <EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            IEnumerable <PermissionType> parentsPermisstionTypes = new List <PermissionType>();

            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                EntityTokenPair pair = new EntityTokenPair(entityToken, parentEntityToken);
                if (alreadyProcessedTokens.Contains(pair) == false)
                {
                    alreadyProcessedTokens.Add(pair);

                    IEnumerable <PermissionType> thisParentPermisstionTypes = RecursiveUpdateCurrentUserPermissionTypes(userToken, parentEntityToken, userPermissionDefinitions, alreadyProcessedTokens);

                    parentsPermisstionTypes = parentsPermisstionTypes.Concat(thisParentPermisstionTypes);
                }
            }

            List <PermissionType> permisstionTypes = parentsPermisstionTypes.Distinct().ToList();

            PermissionTypeFacadeCaching.SetUserPermissionTypes(userToken, entityToken, permisstionTypes);

            return(permisstionTypes);
        }
Exemplo n.º 2
0
        private static IEnumerable<PermissionType> GetInheritedGroupPermissionsTypesRecursivly(EntityToken entityToken, IEnumerable<UserGroupPermissionDefinition> userGroupPermissionDefinitions, List<EntityToken> visitedParents = null)
        {
            UserGroupPermissionDefinition selectedUserGroupPermissionDefinition = userGroupPermissionDefinitions.Where(f => entityToken.Equals(f.EntityToken)).SingleOrDefault();
            if (selectedUserGroupPermissionDefinition != null)
            {
                if (selectedUserGroupPermissionDefinition.PermissionTypes.Contains(PermissionType.ClearPermissions) == false)
                {
                    foreach (PermissionType permissionType in selectedUserGroupPermissionDefinition.PermissionTypes)
                    {
                        yield return permissionType;
                    }
                }

                yield break;
            }

            List<EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);           

            if (visitedParents == null)
            {
                visitedParents = new List<EntityToken>();
            }

            IEnumerable<PermissionType> parentsPermisstionTypes = new List<PermissionType>();
            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                if (visitedParents.Contains(parentEntityToken)) continue;
                visitedParents.Add(parentEntityToken);

                IEnumerable<PermissionType> result = GetInheritedGroupPermissionsTypesRecursivly(parentEntityToken, userGroupPermissionDefinitions, visitedParents).ToList();

                parentsPermisstionTypes = parentsPermisstionTypes.Concat(result);
            }

            foreach (PermissionType permissionType in parentsPermisstionTypes.Distinct())
            {
                yield return permissionType;
            }
        }
Exemplo n.º 3
0
        private static IReadOnlyCollection<PermissionType> RecursiveUpdateCurrentUserGroupPermissionTypes(UserToken userToken, EntityToken entityToken, IEnumerable<UserGroupPermissionDefinition> userGroupPermissionDefinitions, HashSet<EntityTokenPair> alreadyProcessedTokens)
        {
            IReadOnlyCollection<PermissionType> cached = PermissionTypeFacadeCaching.GetUserGroupPermissionTypes(userToken, entityToken);
            if (cached != null)
            {
                return cached;
            }

            IEnumerable<UserGroupPermissionDefinition> selectedUserGroupPermissionDefinitions = userGroupPermissionDefinitions.Where(f => entityToken.Equals(f.EntityToken));

            List<PermissionType> thisPermisstionTypes = new List<PermissionType>();
            foreach (UserGroupPermissionDefinition userGroupPermissionDefinition in selectedUserGroupPermissionDefinitions)
            {
                List<PermissionType> groupPermissionTypes = userGroupPermissionDefinition.PermissionTypes.ToList();

                thisPermisstionTypes.AddRange(groupPermissionTypes);
            }

            if (thisPermisstionTypes.Count > 0)
            {
                thisPermisstionTypes = thisPermisstionTypes.Distinct().ToList();

                if (thisPermisstionTypes.Contains(PermissionType.ClearPermissions))
                {
                    thisPermisstionTypes = new List<PermissionType>();
                }

                PermissionTypeFacadeCaching.SetUserGroupPermissionTypes(userToken, entityToken, thisPermisstionTypes);

                // Local defined permission overrules all other permissions
                return thisPermisstionTypes;
            }

            // Call resursively on all parents
            List<EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            IEnumerable<PermissionType> parentsPermisstionTypes = new List<PermissionType>();
            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                EntityTokenPair pair = new EntityTokenPair(entityToken, parentEntityToken);
                if (alreadyProcessedTokens.Contains(pair) == false)
                {
                    alreadyProcessedTokens.Add(pair);

                    IEnumerable<PermissionType> thisParentPermisstionTypes = RecursiveUpdateCurrentUserGroupPermissionTypes(userToken, parentEntityToken, userGroupPermissionDefinitions, alreadyProcessedTokens);

                    parentsPermisstionTypes = parentsPermisstionTypes.Concat(thisParentPermisstionTypes);
                }
            }

            List<PermissionType> permisstionTypes = parentsPermisstionTypes.Distinct().ToList();

            PermissionTypeFacadeCaching.SetUserGroupPermissionTypes(userToken, entityToken, permisstionTypes);

            return permisstionTypes;
        }
Exemplo n.º 4
0
        /// <exclude />
        public void AddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext)
        {
            var piggybag = dynamicContext.Piggybag;
            if (!entityToken.Equals(dynamicContext.CurrentEntityToken))
            {
                piggybag = piggybag.PreparePiggybag(dynamicContext.CurrentTreeNode, dynamicContext.CurrentEntityToken);
            }

            var replaceContext = new DynamicValuesHelperReplaceContext(entityToken, piggybag);

            OnAddAction(actionAdder, entityToken, dynamicContext, replaceContext);
        }
Exemplo n.º 5
0
 public override bool IsAttachmentPoint(EntityToken parentEntityToken)
 {
     return parentEntityToken.Equals(_parentEntityToken);
 }
Exemplo n.º 6
0
        private static IEnumerable <PermissionType> GetInheritedGroupPermissionsTypesRecursivly(EntityToken entityToken, IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions, List <EntityToken> visitedParents = null)
        {
            UserGroupPermissionDefinition selectedUserGroupPermissionDefinition = userGroupPermissionDefinitions.Where(f => entityToken.Equals(f.EntityToken)).SingleOrDefault();

            if (selectedUserGroupPermissionDefinition != null)
            {
                if (selectedUserGroupPermissionDefinition.PermissionTypes.Contains(PermissionType.ClearPermissions) == false)
                {
                    foreach (PermissionType permissionType in selectedUserGroupPermissionDefinition.PermissionTypes)
                    {
                        yield return(permissionType);
                    }
                }

                yield break;
            }

            List <EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            if (visitedParents == null)
            {
                visitedParents = new List <EntityToken>();
            }

            IEnumerable <PermissionType> parentsPermisstionTypes = new List <PermissionType>();

            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                if (visitedParents.Contains(parentEntityToken))
                {
                    continue;
                }
                visitedParents.Add(parentEntityToken);

                IEnumerable <PermissionType> result = GetInheritedGroupPermissionsTypesRecursivly(parentEntityToken, userGroupPermissionDefinitions, visitedParents).ToList();

                parentsPermisstionTypes = parentsPermisstionTypes.Concat(result);
            }

            foreach (PermissionType permissionType in parentsPermisstionTypes.Distinct())
            {
                yield return(permissionType);
            }
        }