This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace HtmlTagClosing | |
{ | |
public static class StringExtensions | |
{ | |
public static string CloseTags(this string html) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1) 原代码问题 | |
// firstBuffer.Flush() 后如果添加 Item 到两 Buffer, | |
// 再执行 secondBuffer.Flush() 时,会导致新添加的 Item 先执行 Second() 方法 | |
// | |
// 2) 修复思路: | |
// 把两个 Buffer 连接起来,第一个 Buffer Flush 之后才将 Item 添加到第二个 Buffer, | |
// 这样第二个 Buffer 在Flush时始终都是 Flush 第一个 Buffer 已经 Flush 过的 Item | |
// | |
// NOTE: 代码中忽略方法参数验证 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. 不管是否用作字典 Key, 结构体都应实现为不可变的; | |
// 2. 既然是用作字典 Key,则应重写 GetHashCode 以及 Equals; | |
// 3. 为防止哈希碰撞时判等操作的装箱性能损耗,应实现 IEquatable<T> (引用类型的 Key 没有这烦恼); | |
public class MyKey : IEquatable<MyKey> | |
{ | |
private int _field1; | |
private int _field2; | |
public int Field1 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestItem | |
{ | |
public string Id { get; set; } | |
public double Weight { get; set; } | |
} | |
public class TestItemIndex : AbstractIndexCreationTask<TestItem> | |
{ | |
public TestItemIndex() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Lucene.Net.Linq; | |
using Lucene.Net.Store; | |
using System; | |
using System.Linq; | |
namespace ConsoleApp | |
{ | |
public class Major | |
{ | |
public string Code { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reg1 = new RegExp('^http:\\/\\/abc\\.com\\/\\d+$'); | |
var reg2 = /^http:\/\/abc\.com\/\d+$/; | |
var url = 'http://abc.com/1657706754'; | |
// 期待输出: true, 实际输出: true | |
document.write(reg1.test(url)); | |
document.write('<br/>'); | |
// 期待输出: true, 实际输出: true | |
document.write(reg2.test(url)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query = new BooleanQuery(); | |
query.Add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST); | |
var term = new Term("Name", "name1"); | |
query.Add(new TermQuery(term), BooleanClause.Occur.MUST_NOT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// 连续调用两次 | |
var code1 = RandomCodeGenerator.Generate(); | |
var code2 = RandomCodeGenerator.Generate(); | |
// 会输出True,即两次生成的随机数是一样的 | |
Console.WriteLine(code1 == code2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
using Raven.Client.Linq; | |
using Raven.Client.Indexes; | |
using Raven.Client; | |
using Raven.Client.Document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Raven.Client; | |
using Raven.Client.Document; | |
using Raven.Client.Indexes; | |
namespace RavenTest | |
{ |
NewerOlder