public void SearchGroupTestValid() { string groupName = "Moon"; ICollection <Group> wwtGroups = GetGroups(); Group actual; actual = GroupExtensions.SearchGroup(wwtGroups, groupName); Assert.AreEqual(actual.GroupType, GroupType.ReferenceFrame); Assert.AreEqual(actual.Name, "Moon"); Assert.AreEqual(actual.Path, "/Sun/Earth/Moon"); }
public void SerializeTest() { Group parent = new Group("Sun", GroupType.ReferenceFrame, null); Group group = new Group("Earth", GroupType.ReferenceFrame, parent); string expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?><Group xmlns:d1p1=\"http://schemas.datacontract.org/2004/07/Microsoft.Research.Wwt.Excel.Common\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"Microsoft.Research.Wwt.Excel.Common\"><d1p1:GroupType>ReferenceFrame</d1p1:GroupType><d1p1:Name>Earth</d1p1:Name><d1p1:Parent><d1p1:GroupType>ReferenceFrame</d1p1:GroupType><d1p1:Name>Sun</d1p1:Name><d1p1:Parent i:nil=\"true\" /><d1p1:Path>/Sun</d1p1:Path></d1p1:Parent><d1p1:Path>/Sun/Earth</d1p1:Path></Group>"; string actual; actual = GroupExtensions.Serialize(group); Assert.AreEqual(expected, actual); }
public void GetReferenceFrameTestLayerGroup() { Group sun = new Group("Sun", GroupType.ReferenceFrame, null); Group earth = new Group("Earth", GroupType.ReferenceFrame, sun); Group layerGroup = new Group("LG", GroupType.LayerGroup, earth); string expected = "Earth"; string actual; actual = GroupExtensions.GetReferenceFrame(layerGroup); Assert.AreEqual(expected, actual); }
public void IsPlanetTestEarth() { Group sun = new Group("Sun", GroupType.ReferenceFrame, null); Group earth = new Group("Earth", GroupType.ReferenceFrame, sun); bool expected = true; bool actual; actual = GroupExtensions.IsPlanet(earth); Assert.AreEqual(expected, actual); }
public static PwGroup GetGroupsByAttributes(PwDatabase database, AttributeFlags attribute, bool recursive = false) { foreach (PwGroup rootGroup in database.RootGroup.GetGroups(recursive)) { if (GroupExtensions.IsCustomAttributeSet(rootGroup, attribute)) { return(rootGroup); } } return(null); }
public static T InclusiveScanWithBoundaries <T, TScanOperation>(T value, out ScanBoundaries <T> boundaries) where T : unmanaged where TScanOperation : struct, IScanReduceOperation <T> { var scanned = GroupExtensions.InclusiveScan <T, TScanOperation>(value); boundaries = new ScanBoundaries <T>( Group.Broadcast(scanned, 0), Group.Broadcast(scanned, Group.DimX - 1)); return(scanned); }
public Group GetGroupById(int id) { using (var _context = new EduhubContext(_connectionString)) { var currentGroupDto = _context.Groups .Include(g => g.Invitations) .Include(g => g.Messages) .Include(g => g.Members) .Include(g => g.GroupMessages) .Include(g => g.Kicked) .Include(g => g.Tags) .FirstOrDefault(g => g.Id == id && !g.IsDeleted); Ensure.Any.IsNotNull(currentGroupDto, nameof(currentGroupDto), opt => opt.WithException(new GroupNotFoundException())); var result = GroupExtensions.ParseFromGroupDto(currentGroupDto); return(result); } }
public IEnumerable <Group> GetAll() { using (var _context = new EduhubContext(_connectionString)) { var groups = _context.Groups.AsNoTracking() .Include(g => g.Invitations) .Include(g => g.Members) .Include(g => g.Messages) .Include(g => g.Tags) .Include(g => g.GroupMessages) .Include(g => g.Kicked) .Where(g => !g.IsDeleted) .ToList(); var allGroups = new List <Group>(); groups.ForEach(g => allGroups.Add(GroupExtensions.ParseFromGroupDto(g))); return(allGroups); } }
public IEnumerable <Group> GetGroupsByMemberId(int memberId) { using (var _context = new EduhubContext(_connectionString)) { var foundValues = _context.Groups .Include(g => g.Invitations) .Include(g => g.Members) .Include(g => g.Kicked) .Include(g => g.Messages) .Include(g => g.GroupMessages) .Include(g => g.Tags) .Where(g => g.Members.Any(m => m.Id == memberId) && !g.IsDeleted) .ToList(); var result = new List <Group>(); foundValues.ForEach(groupDto => result.Add(GroupExtensions.ParseFromGroupDto(groupDto))); return(result); } }
/// <summary> /// An explicitly grouped kernel that uses high-level group extensions. /// Use the available scan/reduce operations in the namespace ILGPU.Algorithms.ScanReduceOperations. /// </summary> static void KernelWithGroupExtensions(ArrayView2D <int, Stride2D.DenseX> data) { var globalIndex = Grid.GlobalIndex.X; // Use the all-reduce algorithm to perform a reduction over all lanes in a warp. // Every lane in the warp will receive the resulting value. // Use WarpExtensions.Reduce for faster performance, if you need to have the result // in the first lane only. data[globalIndex, 0] = GroupExtensions.AllReduce <int, AddInt32>(1); // Perform an exclusive scan over all lanes in the whole warp. data[globalIndex, 1] = GroupExtensions.ExclusiveScan <int, AddInt32>(1); // Perform an inclusive scan over all lanes in the whole warp. data[globalIndex, 2] = GroupExtensions.InclusiveScan <int, AddInt32>(1); // Perform a all reduction using a different reduction logic. data[globalIndex, 3] = GroupExtensions.AllReduce <int, MinInt32>(Group.IdxX + 1); }
public async Task <bool> Register(string username, string password, string email, double curLat, double curLong) { if (await Database.Authenticators.AsAsyncEnumerable().AnyAsync(e => e.Email.Equals(email, StringComparison.CurrentCultureIgnoreCase))) { return(false); } username = Censor(username); User user = new(0, username, email); user = (await Database.AddAsync(user)).Entity; Authenticator auth = new(email, CreatePasswordHash(password), DateTime.UtcNow, user); var newChal = await GroupExtensions.GetNewChallenge(null, Database.Challenges, curLong, curLat, true); Group g = new Group(newChal); g = (await Database.AddAsync(g)).Entity; await Database.SaveChangesAsync(); user.GroupMember = new GroupMember(true, false, g); g.SignalRId = g.Id.ToString(); await Groups.AddToGroupAsync(Context.ConnectionId, auth.User.GroupMember.Group.Id.ToString()); //Add to sessionlog var entry = new SessionLogEntry(SessionLogEntryType.UserCreated, user.Id.ToString(), DateTime.UtcNow, user); await Database.AddAsync(entry); await Database.SaveChangesAsync(); return(true); }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length < 2) { this.SendUsage(caller); return; } var name = command[0]; var region = RegionsPlugin.Instance.GetRegion(name, true); if (region == null) { UnturnedChat.Say(caller, "Region \"" + name + "\" not found", Color.red); return; } if (!region.IsOwner(caller) && !PermissionUtil.HasPermission(caller, "flag.override")) { UnturnedChat.Say(caller, "You're not the owner of this region!", Color.red); return; } var flagName = command[1]; var t = RegionFlag.GetFlagType(flagName); if (t == null) { UnturnedChat.Say(caller, "Unknown flag: \"" + flagName + "\"", Color.red); return; } var f = region.GetFlag(t); if (f == null) { f = (RegionFlag)Activator.CreateInstance(t); f.Name = RegionFlag.GetFlagName(t); } var hasFlagPermission = PermissionUtil.HasPermission(caller, "flag." + flagName); var usage = "Usage: /rflag " + name + " " + f.Name + " " + f.Usage + " [-g <group>]"; if (command.Length == 3 && command[2].Equals("--help")) { var description = f.Description; var value = f.GetValue <object>(); UnturnedChat.Say(caller, "Flag: " + f.Name, Color.blue); UnturnedChat.Say(caller, "Description: " + description, Color.blue); if (!hasFlagPermission) { return; } UnturnedChat.Say(caller, usage); UnturnedChat.Say(caller, "Value: " + (value ?? "null"), Color.blue); return; } if (!hasFlagPermission) { UnturnedChat.Say(caller, "You don't have access to this flag!", Color.red); return; } f.Region = region; Group group = Group.ALL; List <string> args = new List <string>(); bool isValue = false; bool groupSet = false; foreach (string arg in command.Skip(2)) { if (!groupSet) { if (isValue) { if (f.SupportsGroups) { group = GroupExtensions.GetGroup(arg); } groupSet = true; isValue = false; continue; } if (arg.ToLower().Equals("-g") || arg.ToLower().Equals("--group")) { if (!f.SupportsGroups) { UnturnedChat.Say(caller, "Warning: Flag does not support groups", Color.red); } isValue = true; continue; } } args.Add(arg); } string shownValue; if (isValue || !f.ParseValue(caller, region, args.ToArray(), out shownValue, group)) { UnturnedChat.Say(caller, usage, Color.red); return; } region.SetFlag(f.Name, f.Value, f.GroupValues); if (shownValue != null) { string msg = $"Flag has been set to: {shownValue}"; if (f.SupportsGroups) { msg += $" for group {group}!"; } UnturnedChat.Say(caller, msg, Color.green); } RegionsPlugin.Instance.Configuration.Save(); }