Created
January 10, 2016 16:13
-
-
Save arjancornelissen/e25ee7a3d1d28b73649e to your computer and use it in GitHub Desktop.
Content type with Managed Metadata Feature receiver03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Extension to search for a groupName | |
/// </summary> | |
public static class GroupExtension | |
{ | |
/// <summary> | |
/// Search for the Group by its name | |
/// </summary> | |
/// <param name="groupCollection">The group collection to search in</param> | |
/// <param name="name">The name to search for</param> | |
/// <returns>The <see cref="Group"/> if it's found</returns> | |
public static Group GetByName(this GroupCollection groupCollection, string name) | |
{ | |
if (String.IsNullOrEmpty(name)) | |
{ | |
throw new ArgumentException("Not a valid group name", "name"); | |
} | |
foreach (var group in groupCollection) | |
{ | |
if (group.Name == name) | |
{ | |
return group; | |
} | |
} | |
throw new ArgumentOutOfRangeException("name", name, "Could not find the group"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment