bool IGroupMembersInterface.TryGetValue(UGUI requestingAgent, UGI group, UGUI principal, out GroupMember gmem)
        {
            GroupMemberCache cache;
            UGUI_UGI         groupCacheId = new UGUI_UGI {
                RequestingAgent = requestingAgent, Group = group
            };
            UGUI_UGUI principalCacheId = new UGUI_UGUI {
                RequestingAgent = requestingAgent, Principal = principal
            };

            if (m_PrincipalGroupMemberCache.TryGetValue(principalCacheId, out cache) && m_ClockSource.TicksElapsed(m_ClockSource.TickCount, cache.ExpiryTickCount) < m_ClockSource.SecsToTicks(MemberCacheTimeout))
            {
                foreach (GroupMember gmem_it in cache.GroupMembers)
                {
                    if (gmem_it.Group.Equals(group))
                    {
                        gmem = gmem_it;
                        return(true);
                    }
                }
            }

            if (m_GroupMemberCache.TryGetValue(groupCacheId, out cache) && m_ClockSource.TicksElapsed(m_ClockSource.TickCount, cache.ExpiryTickCount) < m_ClockSource.SecsToTicks(MemberCacheTimeout))
            {
                foreach (GroupMember gmem_it in cache.GroupMembers)
                {
                    if (gmem_it.Group.Equals(group))
                    {
                        gmem = gmem_it;
                        return(true);
                    }
                }
            }

            foreach (GroupMember gmem_it in Members[requestingAgent, principal])
            {
                if (gmem_it.Principal.Equals(principal))
                {
                    gmem = gmem_it;
                    return(true);
                }
            }
            gmem = default(GroupMember);
            return(false);
        }
Beispiel #2
0
 List <GroupRole> IGroupRolesInterface.this[UGUI requestingAgent, UGI group, UGUI principal]
 {
     get
     {
         UGUI_UGUI cacheId = new UGUI_UGUI {
             RequestingAgent = requestingAgent, Principal = principal
         };
         GroupRoleCache cache;
         if (m_PrincipalGroupRoleCache.TryGetValue(cacheId, out cache) && m_ClockSource.TicksElapsed(m_ClockSource.TickCount, cache.ExpiryTickCount) < m_ClockSource.SecsToTicks(RoleCacheTimeout))
         {
             return(cache.GroupRoles);
         }
         cache = new GroupRoleCache
         {
             GroupRoles = InnerGroupsService.Roles[requestingAgent, group, principal]
         };
         cache.ExpiryTickCount = m_ClockSource.TickCount;
         m_PrincipalGroupRoleCache[cacheId] = cache;
         return(cache.GroupRoles);
     }
 }