public static CodeGroup CreateCodeGroup(SecurityElement el)
{
if (el == null || !el.Tag.Equals("CodeGroup"))
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_WrongElementType"), "<CodeGroup>"));
}
string strA;
int indexA;
int num;
if (XMLUtil.ParseElementForObjectCreation(el, "System.Security.Policy.", out strA, out indexA, out num))
{
switch (num)
{
case 12:
if (string.Compare(strA, indexA, "NetCodeGroup", 0, num, StringComparison.Ordinal) == 0)
{
return(new NetCodeGroup());
}
break;
case 13:
if (string.Compare(strA, indexA, "FileCodeGroup", 0, num, StringComparison.Ordinal) == 0)
{
return(new FileCodeGroup());
}
break;
case 14:
if (string.Compare(strA, indexA, "UnionCodeGroup", 0, num, StringComparison.Ordinal) == 0)
{
return(new UnionCodeGroup());
}
break;
default:
if (num == 19)
{
if (string.Compare(strA, indexA, "FirstMatchCodeGroup", 0, num, StringComparison.Ordinal) == 0)
{
return(new FirstMatchCodeGroup());
}
}
break;
}
}
new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert();
Type classFromElement = XMLUtil.GetClassFromElement(el, true);
if (classFromElement == null)
{
return(null);
}
if (!typeof(CodeGroup).IsAssignableFrom(classFromElement))
{
throw new ArgumentException(Environment.GetResourceString("Argument_NotACodeGroupType"));
}
return((CodeGroup)Activator.CreateInstance(classFromElement, true));
}