Example #1
0
        private void LoadMemberships(XmlNode node)
        {
            var res = _memberships;

            if (node != null)
            {
                if (node.ChildNodes.Count != 0)
                {
                    foreach (XmlNode childNode in node.ChildNodes)
                    {
                        var project   = RedmineUtility.LoadNamedObject(childNode["project"], Context.Projects.Lookup);
                        var id        = project.Id;
                        var roles     = new List <UserRole>();
                        var rolesNode = childNode["roles"];
                        if (rolesNode != null)
                        {
                            foreach (XmlNode roleNode in rolesNode.ChildNodes)
                            {
                                var role = RedmineUtility.LoadNamedObject(roleNode, Context.UserRoles.Lookup);
                                roles.Add(role);
                            }
                        }
                        UserMembership membership;
                        if (res.TryGetValue(id, out membership))
                        {
                            membership = new UserMembership(this, project, roles);
                            res[id]    = membership;
                        }
                        else
                        {
                            membership = new UserMembership(this, project, roles);
                            res.Add(id, membership);
                        }
                    }
                }
                else
                {
                    _memberships.Clear();
                }
            }
            else
            {
                _memberships.Clear();
            }
        }
Example #2
0
File: User.cs Project: Kuzq/gitter
 private void LoadMemberships(XmlNode node)
 {
     var res = _memberships;
     if(node != null)
     {
         if(node.ChildNodes.Count != 0)
         {
             foreach(XmlNode childNode in node.ChildNodes)
             {
                 var project = RedmineUtility.LoadNamedObject(childNode["project"], Context.Projects.Lookup);
                 var id = project.Id;
                 var roles = new List<UserRole>();
                 var rolesNode = childNode["roles"];
                 if(rolesNode != null)
                 {
                     foreach(XmlNode roleNode in rolesNode.ChildNodes)
                     {
                         var role = RedmineUtility.LoadNamedObject(roleNode, Context.UserRoles.Lookup);
                         roles.Add(role);
                     }
                 }
                 UserMembership membership;
                 if(res.TryGetValue(id, out membership))
                 {
                     membership = new UserMembership(this, project, roles);
                     res[id] = membership;
                 }
                 else
                 {
                     membership = new UserMembership(this, project, roles);
                     res.Add(id, membership);
                 }
             }
         }
         else
         {
             _memberships.Clear();
         }
     }
     else
     {
         _memberships.Clear();
     }
 }