}// onPropertiesClick void onImport(Object o, EventArgs e) { OpenFileDialog fd = new OpenFileDialog(); fd.Title = CResourceStore.GetString("CNewPermSetWiz2:FDTitle"); fd.Filter = CResourceStore.GetString("XMLFDMask"); System.Windows.Forms.DialogResult dr = fd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { try { SecurityElement se = SecurityXMLStuff.GetSecurityElementFromXMLFile(fd.FileName); if (se == null) { throw new Exception("Null Element"); } Type type; String className = se.Attribute("class"); if (className == null) { throw new Exception("Bad classname"); } type = Type.GetType(className); IPermission perm = (IPermission)Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, new Object[] { PermissionState.None }, null); if (perm == null) { throw new Exception("Unable to create class"); } perm.FromXml(se); // We should check to see if this permission is already being stored if (CheckForDuplicatePermission(ref perm)) { PermissionPair pp = new PermissionPair(); int nIndexOfPermName = className.LastIndexOf('.'); String sPermissionName = className.Substring(nIndexOfPermName + 1); pp.sPermName = sPermissionName; pp.perm = perm; m_alPermissions.Add(pp); m_lbAssignedPerm.Items.Add(pp.sPermName); RemoveThisTypeFromAvailablePermissions(perm); } } catch (Exception) { MessageBox(CResourceStore.GetString("Csinglecodegroupmemcondprop:BadXML"), CResourceStore.GetString("Csinglecodegroupmemcondprop:BadXMLTitle"), MB.ICONEXCLAMATION); } } }// onImport
internal IPermission ToPermission(bool ignoreTypeLoadFailures) { IPermission permission = XMLUtil.CreatePermission(this, PermissionState.None, ignoreTypeLoadFailures); if (permission == null) { return(null); } permission.FromXml(this); PermissionToken.GetToken(permission); return(permission); }
// internal stuff internal static IPermission CreatePermission(string fullname, SecurityElement se) { Type classType = Type.GetType(fullname); if (classType == null) { string msg = Locale.GetText("Can't create an instance of permission class {0}."); throw new TypeLoadException(String.Format(msg, fullname)); } IPermission p = Create(classType); p.FromXml(se); return(p); }
internal static IPermission CreatePermission(string fullname, SecurityElement se) { Type type = Type.GetType(fullname); if (type == null) { string text = Locale.GetText("Can't create an instance of permission class {0}."); throw new TypeLoadException(string.Format(text, fullname)); } IPermission permission = PermissionBuilder.Create(type); permission.FromXml(se); return(permission); }
public static IPermission GetPermissionFromXml(string permissionXml) { try { if (!String.IsNullOrEmpty(permissionXml)) { SecurityElement securityElement = SecurityElement.FromString(permissionXml); string typeName = securityElement.Attribute("class"); //string assemblyName = securityElement.Attribute("assembly"); IPermission result = (IPermission)ReflectionHelper.CreateObject(typeName); result.FromXml(securityElement); return(result); } } catch (Exception e) { Tracing.Tracer.LogError(e); } return(null); }
internal IPermission ToPermission(bool ignoreTypeLoadFailures) { IPermission ip = XMLUtil.CreatePermission(this, PermissionState.None, ignoreTypeLoadFailures); if (ip == null) { return(null); } ip.FromXml(this); // Get the permission token here to ensure that the token // type is updated appropriately now that we've loaded the type. PermissionToken token = PermissionToken.GetToken(ip); BCLDebug.Assert((token.m_type & PermissionTokenType.DontKnow) == 0, "Token type not properly assigned"); return(ip); }
// internal stuff internal static IPermission CreatePermission(string fullname, SecurityElement se) { Type classType = Type.GetType(fullname); if (classType == null) { string msg = Locale.GetText("Can't create an instance of permission class {0}."); #if NET_2_0 throw new TypeLoadException(String.Format(msg, fullname)); #else throw new ArgumentException(String.Format(msg, fullname)); #endif } #if !DISABLE_SECURITY IPermission p = Create(classType); p.FromXml(se); return(p); #else return(null); #endif }