[build] Use multiple inputs in profiled aot
[mono.git] / mcs / class / corlib / System.Security.Permissions / StrongNamePermissionAttribute.cs
index 27f240ed65f1792a1268a12c76bc8b6aaedd97e7..52a120d4909c23905247a6c79b14a4199a599666 100644 (file)
@@ -1,13 +1,12 @@
 //
 // System.Security.Permissions.StrongNameIdentityPermissionAttribute.cs
 //
-// Duncan Mak <duncan@ximian.com>
+// Authors:
+//     Duncan Mak <duncan@ximian.com>
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //
 // (C) 2002 Ximian, Inc.                       http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
 
 namespace System.Security.Permissions {
 
+       [ComVisible (true)]
        [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
                         AttributeTargets.Struct | AttributeTargets.Constructor |
                         AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
@@ -45,23 +46,23 @@ namespace System.Security.Permissions {
                private string version;
                
                // Constructor
-               public StrongNameIdentityPermissionAttribute (SecurityAction action) : base (action) {}
+               public StrongNameIdentityPermissionAttribute (SecurityAction action) 
+                       : base (action)
+               {
+               }
                
                // Properties
-               public string Name
-               {
+               public string Name {
                        get { return name; }
                        set { name = value; }
                }
 
-               public string PublicKey
-               {
+               public string PublicKey {
                        get { return key; }
                        set { key = value; }
                }
 
-               public string Version
-               {
+               public string Version {
                        get { return version; }
                        set { version = value; }
                }
@@ -69,31 +70,27 @@ namespace System.Security.Permissions {
                // Methods
                public override IPermission CreatePermission ()
                {
+#if MOBILE
+                       return null;
+#else
                        if (this.Unrestricted)
-                               throw new ArgumentException ("Unsupported PermissionState.Unrestricted");
+                               return new StrongNameIdentityPermission (PermissionState.Unrestricted);
 
-                       StrongNameIdentityPermission perm = null;
                        if ((name == null) && (key == null) && (version == null))
-                               perm = new StrongNameIdentityPermission (PermissionState.None);
-                       else {
-                               if (key == null)
-                                       throw new ArgumentException ("PublicKey is required");
+                               return new StrongNameIdentityPermission (PermissionState.None);
 
-                               byte[] keyblob = Convert.FromBase64String (key);
-                               StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (keyblob);
+                       if (key == null) {
+                               throw new ArgumentException (Locale.GetText (
+                                       "PublicKey is required"));
+                       }
+                       StrongNamePublicKeyBlob blob = StrongNamePublicKeyBlob.FromString (key);
                                
-                               Version v = null;
-                               if (version != null)
-                                       v = new Version (version);
-                               else
-                                       v = new Version ();
+                       Version v = null;
+                       if (version != null)
+                               v = new Version (version);
 
-                               if (name == null)
-                                       name = String.Empty;
-
-                               perm = new StrongNameIdentityPermission (blob, name, v);
-                       }
-                       return perm;
+                       return new StrongNameIdentityPermission (blob, name, v);
+#endif
                }
        }
 }