Add a more functional (i.e. fewer-stubs) implementation of System.Data.Linq.
[mono.git] / mono / tests / cas / demand / sucs4.cs
1 using System;
2 using System.Runtime.InteropServices;
3 using System.Security;
4 using System.Security.Permissions;
5
6 [SuppressUnmanagedCodeSecurity]
7 public class Program {
8
9         // for Mono
10         [DllImport ("libc", SetLastError=true)]
11         [SuppressUnmanagedCodeSecurity]
12         public static extern uint getuid ();
13
14         // for Microsoft
15         [DllImport ("kernel32.dll", SetLastError=true)]
16         [SuppressUnmanagedCodeSecurity]
17         public static extern uint GetTickCount ();
18
19         static bool RunningOnMono ()
20         {
21                 bool mono = (Type.GetType ("Mono.Math.BigInteger") != null); 
22                 Console.WriteLine ("Running on {0} runtime...", mono ? "Mono" : "Microsoft");
23                 return mono;
24         }
25
26         static int Test ()
27         {
28                 try {
29                         uint u = (RunningOnMono ()) ? getuid () : GetTickCount ();
30                         Console.WriteLine ("*0* P/Invoke: {0}", u);
31                         return 0;
32                 }
33                 catch (SecurityException se) {
34                         Console.WriteLine ("*1* Unexpected SecurityException\n{0}", se);
35                         return 1;
36                 }
37                 catch (Exception e) {
38                         Console.WriteLine ("*2* Unexpected exception\n{0}", e);
39                         return 2;
40                 }
41         }
42
43         [SecurityPermission (SecurityAction.Deny, UnmanagedCode=true)]
44         static int Main ()
45         {
46                 return Test ();
47         }
48 }