private void SetRoleItems(URM.RoleItemCollection<URM.Role, URM.RoleItem> urmRoleItems, List<RoleItem> roleItems)
        {
            foreach (RoleItem roleItem in roleItems)
            {
                if (roleItem is UserRoleItem)
                {
                    UserRoleItem userRoleItem = (UserRoleItem)roleItem;
                    URM.UserItem urmUserItem = new URM.UserItem();

                    urmUserItem.ExtraData = userRoleItem.ExtraData;
                    urmUserItem.Name = userRoleItem.Name;

                    urmRoleItems.Add(urmUserItem);
                }
                else if (roleItem is GroupRoleItem)
                {
                    GroupRoleItem groupRoleItem = (GroupRoleItem)roleItem;
                    URM.GroupItem urmGroupItem = new URM.GroupItem();

                    urmGroupItem.ExtraData = groupRoleItem.ExtraData;
                    urmGroupItem.Name = groupRoleItem.Name;

                    urmRoleItems.Add(urmGroupItem);
                }
                else
                {
                    throw new NotSupportedException("SmartObject RoleItems aren't supported.");
                }
            }
        }
Ejemplo n.º 2
-1
        private List<RoleItem> CopyRoleItems(URM.RoleItemCollection<URM.Role, URM.RoleItem> urmRoles)
        {
            List<RoleItem> roles = new List<RoleItem>();

            foreach (URM.RoleItem urmRoleItem in urmRoles)
            {
                //TODO: check if this can be refactored to something simpler since UserItem and GroupItem have the same properties.
                if (urmRoleItem is URM.UserItem)
                {
                    URM.UserItem urmUserItem = (URM.UserItem)urmRoleItem;
                    UserRoleItem uri = new UserRoleItem();

                    uri.ExtraData = urmUserItem.ExtraData;
                    uri.Name = urmUserItem.Name;

                    roles.Add(uri);
                }
                else if (urmRoleItem is URM.GroupItem)
                {
                    URM.GroupItem urmGroupItem = (URM.GroupItem)urmRoleItem;
                    GroupRoleItem gri = new GroupRoleItem();

                    gri.ExtraData = urmGroupItem.ExtraData;
                    gri.Name = urmGroupItem.Name;

                    roles.Add(gri);
                }
                else
                {
                    throw new NotSupportedException("SmartObject RoleItems aren't supported.");
                }
            }
            return roles;
        }