Ejemplo n.º 1
0
        private static User[] ResolveGroups(PnPClientContext context, string[] groupNames)
        {
            List <User> groups = new List <User>();

            foreach (var groupName in groupNames)
            {
                var groupCache = MEM_CACHE_GROUPS.FirstOrDefault(g => g.Key == groupName);
                if (groupCache.Value == null)
                {
                    try
                    {
                        var group = context.Web.EnsureUser(groupName);
                        context.Load(group);
                        context.ExecuteQueryRetry();
                        groups.Add(group);
                        MEM_CACHE_GROUPS.Add(groupName, group);
                    }
                    catch (Exception ex)
                    {
                        LogError($"Unable to resolve group: {groupName}", ex);
                    }
                }
                else
                {
                    groups.Add(groupCache.Value);
                }
            }
            return(groups.ToArray());
        }