[System] Throw PlatformNotSupportedException if NetworkInformation.NetworkChange...
[mono.git] / mcs / class / System / System.Net.NetworkInformation / NetworkInformationPermissionAttribute.cs
index 1da8272c07972c142a60886098eb804efa786fc9..6b37c4fdf96a1fdfac7114c5a718fce44446c4b9 100644 (file)
@@ -25,7 +25,6 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
 using System;
 using System.Security;
 using System.Security.Permissions;
@@ -41,17 +40,35 @@ namespace System.Net.NetworkInformation {
                {
                }
 
-               [MonoTODO]
+               [MonoTODO ("verify implementation")]
                public override IPermission CreatePermission ()
                {
-                       throw new NotImplementedException ();
+                       NetworkInformationAccess a = NetworkInformationAccess.None;
+                       switch (Access) {
+                       case "Read":
+                               a = NetworkInformationAccess.Read;
+                               break;
+                       case "Full":
+                               a = NetworkInformationAccess.Read | NetworkInformationAccess.Ping;
+                               break;
+                       }
+                       return new NetworkInformationPermission (a);
                }
 
                public string Access {
                        get { return access; }
-                       set { access = value; }
+                       set {
+                               switch (access) {
+                               case "Read":
+                               case "Full":
+                               case "None":
+                                       break;
+                               default:
+                                       throw new ArgumentException ("Only 'Read', 'Full' and 'None' are allowed");
+                               }
+                               access = value; 
+                       }
                }
        }
 }
-#endif