コード例 #1
0
        // Instantiates and loads a StaticQueryable from an index directory
        internal static Queryable LoadStaticQueryable(DirectoryInfo index_dir, QueryDomain query_domain)
        {
            StaticQueryable static_queryable = null;

            if (!index_dir.Exists)
            {
                return(null);
            }

            try {
                static_queryable = new StaticQueryable(index_dir.Name, index_dir.FullName, true);
            } catch (InvalidOperationException) {
                Logger.Log.Warn("Unable to create read-only index (likely due to index version mismatch): {0}", index_dir.FullName);
                return(null);
            } catch (Exception e) {
                Logger.Log.Error(e, "Caught exception while instantiating static queryable: {0}", index_dir.Name);
                return(null);
            }

            if (static_queryable == null)
            {
                return(null);
            }

            // Load StaticIndex.xml from index_dir.FullName/config
            string config_file_path = Path.Combine(index_dir.FullName, "StaticIndex.xml");
            Config static_index_config;

            try {
                static_index_config = Conf.LoadFrom(config_file_path);
                if (static_index_config == null)
                {
                    Log.Error("Unable to read config from {0}", config_file_path);
                    return(null);
                }
            } catch (Exception e) {
                Log.Error(e, "Caught exception while reading config from {0}", config_file_path);
                return(null);
            }

            string source = static_index_config.GetOption("Source", null);

            if (source == null)
            {
                Log.Error("Invalid config file: {0}", config_file_path);
                return(null);
            }

            QueryableFlavor flavor = new QueryableFlavor();

            flavor.Name   = source;
            flavor.Domain = query_domain;

            Queryable queryable = new Queryable(flavor, static_queryable);

            return(queryable);
        }
コード例 #2
0
ファイル: StaticQueryable.cs プロジェクト: zweib730/beagrep
		// Instantiates and loads a StaticQueryable from an index directory
		internal static Queryable LoadStaticQueryable (DirectoryInfo index_dir, QueryDomain query_domain)
		{
			StaticQueryable static_queryable = null;
			
			if (!index_dir.Exists)
				return null;
			
			try {
				static_queryable = new StaticQueryable (index_dir.Name, index_dir.FullName, true);
			} catch (InvalidOperationException) {
				Logger.Log.Warn ("Unable to create read-only index (likely due to index version mismatch): {0}", index_dir.FullName);
				return null;
			} catch (Exception e) {
				Logger.Log.Error (e, "Caught exception while instantiating static queryable: {0}", index_dir.Name);
				return null;
			}

			if (static_queryable == null)
				return null;

			// Load StaticIndex.xml from index_dir.FullName/config
			string config_file_path = Path.Combine (index_dir.FullName, "StaticIndex.xml");
			Config static_index_config;
			try {
				static_index_config = Conf.LoadFrom (config_file_path);
				if (static_index_config == null) {
					Log.Error ("Unable to read config from {0}", config_file_path);
					return null;
				}
			} catch (Exception e) {
				Log.Error (e, "Caught exception while reading config from {0}", config_file_path);
				return null;
			}

			string source = static_index_config.GetOption ("Source", null);
			if (source == null) {
				Log.Error ("Invalid config file: {0}", config_file_path);
				return null;
			}

			QueryableFlavor flavor = new QueryableFlavor ();
			flavor.Name = source;
			flavor.Domain = query_domain;

			Queryable queryable = new Queryable (flavor, static_queryable);
			return queryable;
		}
コード例 #3
0
 public Queryable(QueryableFlavor flavor, IQueryable iqueryable)
 {
     this.flavor     = flavor;
     this.iqueryable = iqueryable;
 }
コード例 #4
0
ファイル: Queryable.cs プロジェクト: zweib730/beagrep
		public Queryable (QueryableFlavor flavor, IQueryable iqueryable)
		{
			this.flavor = flavor;
			this.iqueryable = iqueryable;
		}