Example #1
0
 public void Reset()
 {
     lock (syncInitObj) {
         if (initializing)
         {
             throw new ServiceInitializingException();
         }
         store = null;
         index = null;
     }
 }
        public void Init(string serverFilename)
        {
            string codeBase = Assembly.GetExecutingAssembly().CodeBase;

            if (codeBase.StartsWith("file:"))
            {
                codeBase = codeBase.Substring(5).TrimStart('/', '\\');
            }
            if (serverFilename.Contains(":"))
            {
                serverFilename = Path.GetFullPath(serverFilename);
            }
            else
            {
                serverFilename = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase), "..", "data", serverFilename));
            }
            if (!File.Exists(serverFilename))
            {
                throw new FileNotFoundException("Store initialization file not found", serverFilename);
            }
            lock (syncInitObj)
            {
                if (initializing)
                {
                    throw new ServiceInitializingException();
                }
                initializing = true;
            }
            if (index != null)
            {
                throw new ServiceAlreadyInitializedException();
            }
            store = new StoreImpl(1024L * 1024L * 10L);
            index = new IndexImpl(store);
            LoadIndexFromFile(serverFilename);

            lock (syncInitObj)
            {
                initializing = false;
            }
        }