namespace System.Security.Permissions {
-#if NET_2_0
[ComVisible (true)]
-#endif
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
AttributeTargets.Struct | AttributeTargets.Constructor |
AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
private string name;
private bool isUnicodeEncoded;
private string xml;
-#if NET_2_0
private string hex;
-#endif
// Constructor
public PermissionSetAttribute (SecurityAction action)
get { return file; }
set { file = value; }
}
-#if NET_2_0
public string Hex {
get { return hex; }
set { hex = value; }
}
-#endif
public string Name {
get { return name; }
set { name = value; }
private PermissionSet CreateFromXml (string xml)
{
+#if !NET_2_1
SecurityParser sp = new SecurityParser ();
try {
sp.LoadXml (xml);
ps.FromXml (se);
return ps;
}
+#endif
return null;
}
public PermissionSet CreatePermissionSet ()
{
PermissionSet pset = null;
+#if !NET_2_1
if (this.Unrestricted)
pset = new PermissionSet (PermissionState.Unrestricted);
else {
else if (xml != null) {
pset = CreateFromXml (xml);
}
-#if NET_2_0
else if (hex != null) {
// Unicode isn't supported
//Encoding e = ((isUnicodeEncoded) ? System.Text.Encoding.Unicode : System.Text.Encoding.ASCII);
byte[] bin = CryptoConvert.FromHex (hex);
pset = CreateFromXml (e.GetString (bin, 0, bin.Length));
}
-#endif
}
+#endif
return pset;
}
}