2008-01-15 Stephane Delcroix <sdelcroix@novell.com>
[mono.git] / mcs / class / corlib / System.Security.Policy / PermissionRequestEvidence.cs
old mode 100755 (executable)
new mode 100644 (file)
index a7a86d9..992811a
@@ -3,12 +3,10 @@
 //\r
 // Authors:\r
 //      Nick Drochak (ndrochak@gol.com)\r
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //\r
 // (C) 2003 Nick Drochak\r
-//\r
-
-//
-// 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
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
+
+using System.Runtime.InteropServices;
 \r
-using System.Security;\r
-using System.Text;\r
+namespace System.Security.Policy {
 \r
-namespace System.Security.Policy\r
-{\r
        [Serializable]\r
-       public sealed class PermissionRequestEvidence : IBuiltInEvidence {\r
-               PermissionSet requested, optional, denied;\r
+#if NET_2_0
+       [ComVisible (true)]
+#endif
+       public sealed class PermissionRequestEvidence : IBuiltInEvidence {
+\r
+               private PermissionSet requested, optional, denied;\r
 \r
-               public PermissionRequestEvidence(PermissionSet requested, \r
-                               PermissionSet optional, PermissionSet denied) {\r
-                       this.requested = requested;\r
-                       this.optional = optional;\r
-                       this.denied = denied;\r
+               public PermissionRequestEvidence (PermissionSet requested, PermissionSet optional, PermissionSet denied) 
+               {
+                       if (requested != null)\r
+                               this.requested = new PermissionSet (requested);
+                       if (optional != null)\r
+                               this.optional = new PermissionSet (optional);
+                       if (denied != null)\r
+                               this.denied = new PermissionSet (denied);\r
                }\r
 \r
                public PermissionSet DeniedPermissions {\r
-                       get {return denied;}\r
+                       get { return denied; }\r
                }\r
 \r
                public PermissionSet OptionalPermissions {\r
-                       get {return optional;}\r
+                       get { return optional; }\r
                }\r
 \r
                public PermissionSet RequestedPermissions {\r
-                       get {return requested;}\r
+                       get { return requested; }\r
                }\r
 \r
                public PermissionRequestEvidence Copy ()\r
@@ -88,23 +92,34 @@ namespace System.Security.Policy
 \r
                // interface IBuiltInEvidence\r
 \r
-               [MonoTODO]\r
                int IBuiltInEvidence.GetRequiredSize (bool verbose) \r
-               {\r
-                       return 0;\r
+               {
+                       int size = verbose ? 3 : 1;
+                       if (requested != null) {
+                               int r = requested.ToXml ().ToString ().Length + (verbose ? 5 : 0);
+                               size += r;
+                       }\r
+                       if (optional != null) {
+                               int o = optional.ToXml ().ToString ().Length + (verbose ? 5 : 0);
+                               size += o;
+                       }\r
+                       if (denied != null) {
+                               int d = denied.ToXml ().ToString ().Length + (verbose ? 5 : 0);
+                               size += d;
+                       }\r
+                       return size;\r
                }\r
 \r
-               [MonoTODO]\r
+               [MonoTODO ("IBuiltInEvidence")]\r
                int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position) \r
                {\r
                        return 0;\r
                }\r
 \r
-               [MonoTODO]\r
+               [MonoTODO ("IBuiltInEvidence")]\r
                int IBuiltInEvidence.OutputToBuffer (char [] buffer, int position, bool verbose) \r
                {\r
                        return 0;\r
                }\r
-\r
        }\r
 }