00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 using System.Reflection;
00005 using System.IO;
00006 using Server.Data;
00007 using Server.Net;
00008 using System.Diagnostics;
00009 using System.Runtime.InteropServices;
00010
00014 namespace Server
00015 {
00021 public class Startup
00022 {
00023 private static Catalogue catalogue;
00028 public static void Main(string[] args)
00029 {
00030
00031
00032 IPersistentData persistentdata = new BinaryData(Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location));
00033
00034 #region Win32 Only!
00035
00036 MyWin32.SetConsoleCtrlHandler(new MyWin32.HandlerRoutine(delegate(Server.MyWin32.CtrlTypes type) {
00037 if (catalogue != null)
00038 catalogue.SaveData();
00039
00040 System.Environment.Exit(0);
00041
00042 return true;
00043 }), true);
00044 #endregion
00045
00046
00047 catalogue = new Catalogue(persistentdata);
00048
00049
00050 ServerConsole sc = new ServerConsole(catalogue);
00051
00052 RMIServer rs = new RMIServer(catalogue);
00053
00054 rs.Start();
00055
00056
00057 sc.StartConsole();
00058 catalogue.SaveData();
00059 }
00060
00061 }
00062 #region Win32 Only!
00063
00064
00065
00066 public class MyWin32
00067 {
00068
00069
00070 [DllImport("Kernel32")]
00071 public static extern Boolean SetConsoleCtrlHandler(HandlerRoutine Handler,
00072 Boolean Add);
00073
00074
00075
00076 public delegate Boolean HandlerRoutine(CtrlTypes CtrlType);
00077
00078
00079
00080 public enum CtrlTypes
00081 {
00082 CTRL_C_EVENT = 0,
00083 CTRL_BREAK_EVENT,
00084 CTRL_CLOSE_EVENT,
00085 CTRL_LOGOFF_EVENT = 5,
00086 CTRL_SHUTDOWN_EVENT
00087 }
00088 }
00089 #endregion
00090
00091 }