public static GetRepositoryInstance ( String repType, RepositoryConfiguration config ) : Persistence.Repository | ||
repType | String | Stringa rappresentante il tipo di repository richiesto. |
config | RepositoryConfiguration | |
return | Persistence.Repository |
/// <summary> /// Constructor for the Kademlia Repository. This begins with compiling regular expressions for whitespace and semanticless /// words and setting timespan sing the given values (if they are not passed, it uses the default). Then instantiates the /// repository of the fiven type and creates two indexes over the instantiatied repository. The first index is used to /// find keywords with an empty tag list; the second one is used to query keyword using tag identifier. Both indexes are /// necessary in order to cleanly delete resources and keywords from the repository /// </summary> /// <param name="repType">Name of the repository type. The default repository type is RavenDB ("Raven")</param> /// <param name="conf">Repository Configureation</param> /// <param name="elementValidity">Validity period of a Dht Element. Default value is 24 hours (1 day). The validity must /// be expressed in timespan format as described in MSDN reference for this type.</param> /// <param name="semanticFilter">Regular expression that will be used to remove semanticless word.</param> public KademliaRepository(string repType = "Raven", RepositoryConfiguration conf = null, string elementValidity = "1", string semanticFilter = KademliaRepository.DefaultSemanticFilterRegexString) { log.Debug("Semantic Filter Regex used is " + DefaultSemanticFilterRegexString); if (!(TimeSpan.TryParse(elementValidity, out this._elementValidity))) { this._elementValidity = new TimeSpan(24, 0, 0); } this._semanticRegex = new Regex(DefaultSemanticFilterRegexString, RegexOptions.Compiled | RegexOptions.IgnoreCase); this._whiteSpaceRegex = new Regex(@"[ ]{2,}", RegexOptions.Compiled); this._repository = RepositoryFactory.GetRepositoryInstance(repType, conf); this._repository.CreateIndex("KademliaKeywords/KeysByTag", "from key in docs.KademliaKeywords\nfrom tag in key.Tags\nselect new { Kid = key.Id , Tid = tag}"); this._repository.CreateIndex("KademliaKeywords/EmptyKeys", "from key in docs.KademliaKeywords\nwhere key.Tags.Count() == 0\nselect new { key.Id }"); }
/// <summary> /// Repository Constructor that initializes the repository of the given type. /// </summary> /// <param name="repType">Name of the repository Type</param> /// <param name="conf">Configuration for the repository</param> public TrackRepository(string repType, RepositoryConfiguration conf) { this._repository = RepositoryFactory.GetRepositoryInstance(repType, conf); }