private RaptorDB GetInstance(string name)
        {
            // load or get instance
            instance_handler inst = null;

            _instances.TryGetValue(name.ToLower(), out inst);
            if (inst == null)
            {
                // no instance found -> err
                _log.Debug("instance name not found : " + name);
                return(null);
            }
            if (inst.rdb == null)
            {
                // try loading raptordb instance
                var r = RaptorDB.Open(inst.dbpath);
                inst.rdb = r;
                // fix : create register and save
                //inst.register
                //inst.save

                if (inst.hasExtensions)
                {
                    // fix: load extension folder
                }
                else
                {
                    // fix: load default extenstions
                }
            }
            return(inst.rdb);
        }
        public RaptorDBServer(int port, string DataPath)
        {
            _path = Directory.GetCurrentDirectory();
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            _server = new NetworkServer();

            if (_S == "/")// unix system
            {
                _datapath = DataPath.Replace("\\", "/");
            }
            else
            {
                _datapath = DataPath;
            }

            if (_datapath.EndsWith(_S) == false)
            {
                _datapath += _S;
            }

            // check if "instances" folder exist -> multi instance mode
            if (Directory.Exists(_datapath + "instances"))
            {
                _log.Debug("Insances exist, loading...");
                _multiInstance = true;
                foreach (var d in Directory.GetDirectories(_datapath + "instances"))
                {
                    var dn = new DirectoryInfo(d);
                    var i  = new instance_handler();
                    i.dbpath = d;
                    if (Directory.Exists(d + _S + "Extensions"))
                    {
                        i.hasExtensions = true;
                    }
                    _instances.Add(dn.Name.ToLower(), i);
                }
            }
            _defaultInstance.rdb      = RaptorDB.Open(DataPath);
            _defaultInstance.register = _defaultInstance.rdb.GetType().GetMethod("RegisterView", BindingFlags.Instance | BindingFlags.Public);
            _defaultInstance.save     = _defaultInstance.rdb.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.Public);

            Initialize();
            _server.Start(port, processpayload);

            // add timer to cleanup connected clients
            _concleanuptimer           = new System.Timers.Timer(30 * 1000);
            _concleanuptimer.AutoReset = true;
            _concleanuptimer.Enabled   = true;
            _concleanuptimer.Elapsed  += _concleanuptimer_Elapsed;

            _unusedinstancetimer           = new System.Timers.Timer(300 * 1000);// FIX : configuration here
            _unusedinstancetimer.AutoReset = true;
            _unusedinstancetimer.Enabled   = true;
            _unusedinstancetimer.Elapsed  += _unusedinstancetimer_Elapsed;
        }