public static CardLibrary GetInstance() { if (instance == null) { CLConfig config = CLConfig.GetInstance(); Path = System.AppDomain.CurrentDomain.BaseDirectory; KeepInMemory = string.Equals(config.GetSetting("KeepInMemory"), "true", StringComparison.OrdinalIgnoreCase); if (KeepInMemory) { ramdir = new Lucene.Net.Store.RAMDirectory(Path + "CardIndex"); CardsReader Reader = new LuceneReader(); instance = new CardLibrary(Reader.Read(ramdir)); if (Directory.Exists(Path + "DIYCardIndex")) { ramdiydir = new Lucene.Net.Store.RAMDirectory(Path + "DIYCardIndex"); instance.AddDIYCards(Reader.Read(ramdiydir)); } } else { CardsReader Reader = new LuceneReader(); instance = new CardLibrary(Reader.Read(Path + "CardIndex")); if (Directory.Exists(Path + "DIYCardIndex")) { instance.AddDIYCards(Reader.Read(Path + "DIYCardIndex")); } } } return(instance); }
public static List <IToken <char> > ForwardMovingTokenize(CLConfig config, string text) { var tokenizer = BuildLexingLogic(config); var rv = text.ToCharArray().ForwardMovingTokenizeToCompletion(null, tokenizer); rv.WithEach(x => { }); return(rv); }
public bool isFull(int id) { CardDescription card = CardLibrary.GetInstance().GetCardByID(id); int limit = card.limit; string s = CLConfig.GetInstance().GetSetting("AllowForbiddenCard"); if (string.Equals(s, "True", StringComparison.OrdinalIgnoreCase)) { limit = 3; } return(GetCount(id) >= limit); }
public static List <IToken <char> > ForwardMovingTokenize(CLConfig config, string text) { var tokenizer = BuildLexingLogic(config); int newPos; var rv = text.ToCharArray().ForwardMovingTokenize(null, tokenizer, out newPos); Debug.WriteLine(Environment.NewLine); Debug.WriteLine(string.Format("Tokenizing of {0} complete", text)); rv.WithEach(x => { Debug.Write(x.DumpToken()); }); return(rv); }
private void frmConfig_Load(object sender, EventArgs e) { DB2Config config = DB2Config.GetInstance(); CLConfig clconfig = CLConfig.GetInstance(); if (string.Equals(config.GetSettingNext("NotShowIco"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX1.Checked = true; } if (string.Equals(config.GetSettingNext("NoVirtualMode"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX2.Checked = true; } if (string.Equals(clconfig.GetSetting("AllowForbiddenCard"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX3.Checked = true; } if (string.Equals(config.GetSettingNext("NoDrag"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX4.Checked = true; } if (!string.Equals(clconfig.GetSettingNext("AllowDIY"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX5.Checked = false; } if (!string.Equals(config.GetSetting("SaveLayout"), "True", StringComparison.OrdinalIgnoreCase)) { checkBoxX6.Checked = false; } textBox1.Text = config.GetSetting("ImagePath"); textBox2.Text = config.GetSetting("IcoPath"); textBox3.Text = config.GetSetting("NBXPath"); textBox4.Text = config.GetSetting("DeckPath"); textBox5.Text = config.GetSetting("DIYImagePath"); }
public CLLexingTest() : base(LogicOf <Nothing> .New((x) => { List <string> commands = new List <string>() { "@store.search(#ness.IsThing('x','y',7))", "7.AsId().HasName('name')" }; var config = CLConfig.New(); var tokens = CommandLineLexer.ForwardMovingTokenize(config, commands[0]); //Condition.Requires(cmds).HasLength(2); //Condition.Requires(cmds[1].OperationToken.TokenString).IsEqualTo("dosomethingelse"); //Condition.Requires(cmds[0].ArgTokens[3].TokenString).IsEqualTo(""); Debug.WriteLine(""); })) { }
public string AddCard(int id, int index) { if (decklist.Count >= Capacity && Capacity > 0) { return("卡组已满!"); } int count = 0; if (cardcount[id] != null) { count = (int)cardcount[id]; } CardDescription card = cardLibrary.GetCardByID(id); if (!string.Equals(CLConfig.GetInstance().GetSetting("AllowForbiddenCard"), "True", StringComparison.OrdinalIgnoreCase)) { LimitNum = card.limit; } if (count >= LimitNum) { return(string.Format("卡片[{0}]超出限制数量!", card.name)); } if (index >= 0 && index < decklist.Count) { decklist.Insert(index, new Card(id, Index++)); } else { decklist.Add(new Card(id, Index++)); } cardcount[id] = ++count; isChanged = true; return(null); }
private void buttonX1_Click(object sender, EventArgs e) { DB2Config config = DB2Config.GetInstance(); CLConfig clconfig = CLConfig.GetInstance(); if (checkBoxX1.Checked) { config.SetSettingNext("NotShowIco", "True"); } else { config.SetSettingNext("NotShowIco", "False"); } if (checkBoxX2.Checked) { config.SetSettingNext("NoVirtualMode", "True"); } else { config.SetSettingNext("NoVirtualMode", "False"); } if (checkBoxX3.Checked) { clconfig.SetSetting("AllowForbiddenCard", "True"); } else { clconfig.SetSetting("AllowForbiddenCard", "False"); } if (checkBoxX4.Checked) { config.SetSetting("NoDrag", "True"); } else { config.SetSetting("NoDrag", "False"); } if (checkBoxX5.Checked) { clconfig.SetSetting("AllowDIY", "True"); } else { clconfig.SetSetting("AllowDIY", "False"); } if (checkBoxX6.Checked) { config.SetSetting("SaveLayout", "True"); } else { config.SetSetting("SaveLayout", "False"); } config.SetSetting("ImagePath", textBox1.Text); config.SetSetting("IcoPath", textBox2.Text); config.SetSetting("NBXPath", textBox3.Text); config.SetSetting("DeckPath", textBox4.Text); config.SetSetting("DIYImagePath", textBox5.Text); this.Close(); }
public static IForwardMovingTokenizer <char> BuildLexingLogic(CLConfig config) { /* * CommandExamples: * * Decorating: @[id1]#HasDateCreated(now)#HasId(id2)#HasName(name1) * Saving: .Save() * Deleting: @[id1].Delete() * Getting Ness Value: @[id1]#HasDateCreated.Date * Performing Ness Op: @[id1]#HasDateCreated.SetDate(now)#HasBeep.Beep() * Conditional Ness: #HasDateCreated.IsAfter(now) * * */ //define common separators/punctuation. these will terminate tokens var at = "@".ToCharArray(); var dot = ".".ToCharArray(); var comma = ",".ToCharArray(); var openParenthesis = "(".ToCharArray(); var closeParenthesis = ")".ToCharArray(); var hash = "#".ToCharArray(); var openBracket = "[".ToCharArray(); var closeBracket = "]".ToCharArray(); var emptyParenthesis = "()".ToCharArray(); #region Primitive-y Tokenizers - all routing unhydrated //store token starts with @ and ends with any punctuation var storeTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .HasSuffixDelimitedLengthStrategy(at, dot, comma, openParenthesis, closeParenthesis, hash, openBracket, closeBracket) .HasPrefix(at) .HasSuffix(false, at, dot, comma, openParenthesis, closeParenthesis, hash, openBracket, closeBracket) .HasValueFactory(token => { string storeName = new string(token.TokenData); if (string.IsNullOrEmpty(storeName)) { return(null); //default store strategy } else { var store = config.StoreOfStores.Get <NamedNaturalInMemoryStore>(storeName); return(store); } }) .HasId("Store"); //id token starts with [ and ends with ]. brackets are non-nesting var idTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .HasSuffixDelimitedLengthStrategy(closeBracket) .HasPrefix(openBracket) .HasSuffix(true, closeBracket) .HasValueFactory(token => { string id = new string(token.TokenData); return(id); }).HasId("Id"); //op token starts with . and ends with ( or . var opTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .HasSuffixDelimitedLengthStrategy(dot, openParenthesis) .HasPrefix(dot) .HasSuffix(false, dot, openParenthesis) .HasId("Op"); //ness token starts with # and ends with ( or . var nessTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .HasSuffixDelimitedLengthStrategy(dot, openParenthesis) .HasPrefix(hash) .HasSuffix(false, dot, openParenthesis) .HasValueFactory(token => { string nessName = new string(token.TokenData); //ness is contextual and depends on who is invoking the ness //so we have to get the prior token's value var lastTokenValueFace = token.PriorToken.GetFace <IHasValue>(); var lastTokenValue = lastTokenValueFace.Value; var rv = config.NessManager.GetNess(lastTokenValue, nessName); return(rv); }) .HasId("Ness"); var commaTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .HasConstantValue(comma) .HasId("Comma"); var emptyParenthesisTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .HasConstantValue(emptyParenthesis) .HasId("EmptyParenthesis"); #endregion //now build the compound tokenizers var mainRouterStack = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .MakeRouter(true, true) .HasId("MainRouter"); var mainRouter = mainRouterStack.As <IRoutingTokenizer <char> >(false); //parenthesis token starts with ( and ends with ), and handles nesting //is a compound that recurses the whole stack //uses the mainRouter to recurse, but is not registered with it as it's not a high level token var parenthesisTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New() .HasPairDelimitedLengthStrategy(openParenthesis, closeParenthesis) .HasPrefix(openParenthesis) .HasSuffix(true, closeParenthesis) .MakeComposite(mainRouter) .HasId("Parenthesis"); //Decorating: @[id1]#HasDateCreated(now)#HasId(id2)#HasName(name1) //var decoratingCmdTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() // .MakeCompositeOf(storeTokenizer, idTokenizer, opTokenizer, nessTokenizer, parenthesisTokenizer, commaTokenizer) // .HasId("Decorating"); //object manipulation //Saving:@[id1].Save() //Deleting: @[id1].Delete() //Getting Ness Value: @[id1]#HasDateCreated.Date //Performing Ness Op: @[id1]#HasDateCreated.SetDate(now)#HasBeep.Beep() //Conditional Ness: #HasDateCreated.IsAfter(now) //var hasIdCmdTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() // .MakeCompositeOf(storeTokenizer, idTokenizer, nessTokenizer, parenthesisTokenizer) // .HasId("HasIdCommand"); // mainRouter.AddTokenizer(hasIdCmdTokenizer);//.AddTokenizer(decoratingCmdTokenizer). mainRouter.AddTokenizer(storeTokenizer, idTokenizer, opTokenizer, nessTokenizer, commaTokenizer, parenthesisTokenizer); return(mainRouterStack); }
public static IForwardMovingTokenizer <char> BuildLexingLogic(CLConfig config) { //@store.search(#ness.IsThing("x","y")) //to parse this type of syntax we use prefix routing - ie. we route via prefix var router = NaturallyNotImplementedForwardMovingTokenizer <char> .New().MakeRouter(); //parse store name into store token. eg. @store var storeTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasPrefix("@".ToCharArray()).HasSuffix(".".ToCharArray()) .HasValueFactory(token => { string storeName = new string(token.TokenData); var store = config.StoreOfStores.Get <NamedNaturalInMemoryStore>(storeName); return(store); }).HasId(STORE); router.AddTokenizer(storeTokenizer); //parse ness name into ness token. eg. #ness var nessTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasPrefix("#".ToCharArray()).HasSuffix(".".ToCharArray()) .HasValueFactory(token => { string nessName = new string(token.TokenData); //ness is contextual and depends on who is invoking the ness //so we have to get the prior token's value var lastTokenValueFace = token.PriorToken.GetFace <IHasValue>(); var lastTokenValue = lastTokenValueFace.Value; var rv = config.NessManager.GetNess(lastTokenValue, nessName); return(rv); }).HasId(NESS); router.AddTokenizer(nessTokenizer); //parse thing token - isn't a store or a ness or an op since it has no predecessors. //isn't an arg cos it's not terminated by , or ). eg. "hello" var thingTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasPredecessorTokenizerIds(null).HasSuffix(".".ToCharArray()) .HasValueFactory(token => { string tokenData = new string(token.TokenData); return(tokenData); }) .HasId(THING); router.AddTokenizer(thingTokenizer); //parse operation name into op token. eg. .search var opTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasPrefix(".".ToCharArray()).HasSuffix(".".ToCharArray(), "(".ToCharArray()).HasId(OP); router.AddTokenizer(opTokenizer); //open and close brackets. constants var openParenTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasConstantValue("(".ToCharArray()).HasId(OPENPAREN); var closeParenTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasConstantValue(")".ToCharArray()).HasId(CLOSEPAREN); router.AddTokenizer(openParenTokenizer); router.AddTokenizer(closeParenTokenizer); //the comma. constant var commaTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasConstantValue(",".ToCharArray()).HasId(COMMA); router.AddTokenizer(commaTokenizer); //args. eg. "x", "y" //can have no predecessor tokenizer, or ( or , var argTokenizer = NaturallyNotImplementedForwardMovingTokenizer <char> .New().HasPredecessorTokenizerIds(null, OPENPAREN, COMMA).HasSuffix(",".ToCharArray(), ")".ToCharArray()) .HasValueFactory(token => { string tokenData = new string(token.TokenData); return(tokenData); }) .HasId(ARG); router.AddTokenizer(argTokenizer); return(router); }
public LimitedListManager() { //LoadFromXML(); CLConfig config = CLConfig.GetInstance(); }
public static IForwardMovingTokenizer<char> BuildLexingLogic(CLConfig config) { /* CommandExamples: Decorating: @[id1]#HasDateCreated(now)#HasId(id2)#HasName(name1) Saving: .Save() Deleting: @[id1].Delete() Getting Ness Value: @[id1]#HasDateCreated.Date Performing Ness Op: @[id1]#HasDateCreated.SetDate(now)#HasBeep.Beep() Conditional Ness: #HasDateCreated.IsAfter(now) * * */ //define common separators/punctuation. these will terminate tokens var at = "@".ToCharArray(); var dot = ".".ToCharArray(); var comma = ",".ToCharArray(); var openParenthesis = "(".ToCharArray(); var closeParenthesis = ")".ToCharArray(); var hash = "#".ToCharArray(); var openBracket = "[".ToCharArray(); var closeBracket = "]".ToCharArray(); var emptyParenthesis = "()".ToCharArray(); #region Primitive-y Tokenizers - all routing unhydrated //store token starts with @ and ends with any punctuation var storeTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .HasSuffixDelimitedLengthStrategy(at, dot, comma, openParenthesis, closeParenthesis, hash, openBracket, closeBracket) .HasPrefix(at) .HasSuffix(false, at, dot, comma, openParenthesis, closeParenthesis, hash, openBracket, closeBracket) .HasValueFactory(token => { string storeName = new string(token.TokenData); if (string.IsNullOrEmpty(storeName)) { return null;//default store strategy } else { var store = config.StoreOfStores.Get<NamedNaturalInMemoryStore>(storeName); return store; } }) .HasId("Store"); //id token starts with [ and ends with ]. brackets are non-nesting var idTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .HasSuffixDelimitedLengthStrategy(closeBracket) .HasPrefix(openBracket) .HasSuffix(true, closeBracket) .HasValueFactory(token => { string id = new string(token.TokenData); return id; }).HasId("Id"); //op token starts with . and ends with ( or . var opTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .HasSuffixDelimitedLengthStrategy(dot, openParenthesis) .HasPrefix(dot) .HasSuffix(false, dot, openParenthesis) .HasId("Op"); //ness token starts with # and ends with ( or . var nessTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .HasSuffixDelimitedLengthStrategy(dot, openParenthesis) .HasPrefix(hash) .HasSuffix(false, dot, openParenthesis) .HasValueFactory(token => { string nessName = new string(token.TokenData); //ness is contextual and depends on who is invoking the ness //so we have to get the prior token's value var lastTokenValueFace = token.PriorToken.GetFace<IHasValue>(); var lastTokenValue = lastTokenValueFace.Value; var rv = config.NessManager.GetNess(lastTokenValue, nessName); return rv; }) .HasId("Ness"); var commaTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .HasConstantValue(comma) .HasId("Comma"); var emptyParenthesisTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .HasConstantValue(emptyParenthesis) .HasId("EmptyParenthesis"); #endregion //now build the compound tokenizers var mainRouterStack = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .MakeRouter(true, true) .HasId("MainRouter"); var mainRouter = mainRouterStack.As<IRoutingTokenizer<char>>(false); //parenthesis token starts with ( and ends with ), and handles nesting //is a compound that recurses the whole stack //uses the mainRouter to recurse, but is not registered with it as it's not a high level token var parenthesisTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() .HasPairDelimitedLengthStrategy(openParenthesis, closeParenthesis) .HasPrefix(openParenthesis) .HasSuffix(true, closeParenthesis) .MakeComposite(mainRouter) .HasId("Parenthesis"); //Decorating: @[id1]#HasDateCreated(now)#HasId(id2)#HasName(name1) //var decoratingCmdTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() // .MakeCompositeOf(storeTokenizer, idTokenizer, opTokenizer, nessTokenizer, parenthesisTokenizer, commaTokenizer) // .HasId("Decorating"); //object manipulation //Saving:@[id1].Save() //Deleting: @[id1].Delete() //Getting Ness Value: @[id1]#HasDateCreated.Date //Performing Ness Op: @[id1]#HasDateCreated.SetDate(now)#HasBeep.Beep() //Conditional Ness: #HasDateCreated.IsAfter(now) //var hasIdCmdTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New() // .MakeCompositeOf(storeTokenizer, idTokenizer, nessTokenizer, parenthesisTokenizer) // .HasId("HasIdCommand"); // mainRouter.AddTokenizer(hasIdCmdTokenizer);//.AddTokenizer(decoratingCmdTokenizer). mainRouter.AddTokenizer(storeTokenizer, idTokenizer, opTokenizer, nessTokenizer, commaTokenizer, parenthesisTokenizer); return mainRouterStack; }
public static List<IToken<char>> ForwardMovingTokenize(CLConfig config, string text) { var tokenizer = BuildLexingLogic(config); int newPos; var rv = text.ToCharArray().ForwardMovingTokenize(null, tokenizer, out newPos); Debug.WriteLine(Environment.NewLine); Debug.WriteLine(string.Format("Tokenizing of {0} complete", text)); rv.WithEach(x => { Debug.Write(x.DumpToken()); }); return rv; }
public static IForwardMovingTokenizer<char> BuildLexingLogic(CLConfig config) { //@store.search(#ness.IsThing("x","y")) //to parse this type of syntax we use prefix routing - ie. we route via prefix var router = NaturallyNotImplementedForwardMovingTokenizer<char>.New().MakeRouter(); //parse store name into store token. eg. @store var storeTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasPrefix("@".ToCharArray()).HasSuffix(".".ToCharArray()) .HasValueFactory(token => { string storeName = new string(token.TokenData); var store = config.StoreOfStores.Get<NamedNaturalInMemoryStore>(storeName); return store; }).HasId(STORE); router.AddTokenizer(storeTokenizer); //parse ness name into ness token. eg. #ness var nessTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasPrefix("#".ToCharArray()).HasSuffix(".".ToCharArray()) .HasValueFactory(token => { string nessName = new string(token.TokenData); //ness is contextual and depends on who is invoking the ness //so we have to get the prior token's value var lastTokenValueFace = token.PriorToken.GetFace<IHasValue>(); var lastTokenValue = lastTokenValueFace.Value; var rv = config.NessManager.GetNess(lastTokenValue, nessName); return rv; }).HasId(NESS); router.AddTokenizer(nessTokenizer); //parse thing token - isn't a store or a ness or an op since it has no predecessors. //isn't an arg cos it's not terminated by , or ). eg. "hello" var thingTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasPredecessorTokenizerIds(null).HasSuffix(".".ToCharArray()) .HasValueFactory(token => { string tokenData = new string(token.TokenData); return tokenData; }) .HasId(THING); router.AddTokenizer(thingTokenizer); //parse operation name into op token. eg. .search var opTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasPrefix(".".ToCharArray()).HasSuffix(".".ToCharArray(), "(".ToCharArray()).HasId(OP); router.AddTokenizer(opTokenizer); //open and close brackets. constants var openParenTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasConstantValue("(".ToCharArray()).HasId(OPENPAREN); var closeParenTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasConstantValue(")".ToCharArray()).HasId(CLOSEPAREN); router.AddTokenizer(openParenTokenizer); router.AddTokenizer(closeParenTokenizer); //the comma. constant var commaTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasConstantValue(",".ToCharArray()).HasId(COMMA); router.AddTokenizer(commaTokenizer); //args. eg. "x", "y" //can have no predecessor tokenizer, or ( or , var argTokenizer = NaturallyNotImplementedForwardMovingTokenizer<char>.New().HasPredecessorTokenizerIds(null, OPENPAREN, COMMA).HasSuffix(",".ToCharArray(), ")".ToCharArray()) .HasValueFactory(token => { string tokenData = new string(token.TokenData); return tokenData; }) .HasId(ARG); router.AddTokenizer(argTokenizer); return router; }
public static List<IToken<char>> ForwardMovingTokenize(CLConfig config, string text) { var tokenizer = BuildLexingLogic(config); var rv = text.ToCharArray().ForwardMovingTokenizeToCompletion(null, tokenizer); rv.WithEach(x => { }); return rv; }
public static CardLibrary GetInstance() { //单实例 if (instance == null) { //读取配置 CLConfig config = CLConfig.GetInstance(); //获取路径 path = Global.GetPath(); //清除多余索引文件 if (File.Exists(path + "CardIndex\\list.txt")) { string[] files = File.ReadAllLines(path + "CardIndex\\list.txt", Encoding.UTF8); foreach (string s in Directory.GetFiles(path + "CardIndex")) { string ss = s.Substring(s.LastIndexOf('\\') + 1); bool inlist = false; foreach (string s2 in files) { if (string.Equals(ss, s2, StringComparison.OrdinalIgnoreCase)) { inlist = true; break; } } if (!(inlist || string.Equals(ss, "list.txt", StringComparison.OrdinalIgnoreCase))) { File.Delete(s); } } } //读取主索引 indexdir = new Lucene.Net.Store.SimpleFSDirectory(new DirectoryInfo(path + "CardIndex"), new Lucene.Net.Store.SimpleFSLockFactory()); //读取DIY索引 if (Directory.Exists(path + "DIYCardIndex")) { diydir = new Lucene.Net.Store.SimpleFSDirectory(new DirectoryInfo(path + "DIYCardIndex"), new Lucene.Net.Store.SimpleFSLockFactory()); } //是否使用内存索引 KeepInMemory = string.Equals(config.GetSetting("KeepInMemory"), "true", StringComparison.OrdinalIgnoreCase); if (KeepInMemory) { indexdir = new Lucene.Net.Store.RAMDirectory(indexdir); if (diydir != null) { diydir = new Lucene.Net.Store.RAMDirectory(diydir); } } //读取所有卡片信息,建立卡片数据库实例 LuceneReader Reader = new LuceneReader(); instance = new CardLibrary(Reader.Read(indexdir)); if (diydir != null) { instance.AddDIYCards(Reader.Read(diydir)); } //建立搜索器实例 instance.BuildSearcher(); } return(instance); }