本文整理汇总了C#中IHasher类的典型用法代码示例。如果您正苦于以下问题:C# IHasher类的具体用法?C# IHasher怎么用?C# IHasher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHasher类属于命名空间,在下文中一共展示了IHasher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultUrlManager
public DefaultUrlManager(IOptions<SmidgeOptions> options, ISmidgeConfig config, IHasher hasher, IUrlHelper urlHelper)
{
_hasher = hasher;
_urlHelper = urlHelper;
_options = options.Value.UrlOptions;
_config = config;
}
示例2: RetryableFileWriter
public RetryableFileWriter(int bufferSize, Encoding encoding, IRetryableFileOpener retryableFileOpener, IHasher hasher)
{
BufferSize = bufferSize;
Encoding = encoding;
RetryableFileOpener = retryableFileOpener;
Hasher = hasher;
}
示例3: RetryableFileWriter
public RetryableFileWriter(int bufferSize, IRetryableFileOpener retryableFileOpener, IHasher hasher)
{
BufferSize = bufferSize;
RetryableFileOpener = retryableFileOpener;
Hasher = hasher;
_encoding = Encoding.UTF8;
}
示例4: EmbeddedResourceEntityResponder
public EmbeddedResourceEntityResponder(ICacheManager cacheManager, IMimeTyper mimeTyper, IHasher hasher, long maxFileSizeToServe, int bufferSize, MimeSettingProvider mimeSettingProvider, Assembly assembly, string resourcePath)
{
_assembly = assembly;
_resourcePath = resourcePath;
ResourcePath = string.Format("{0}.{1}", assembly.GetName().Name, resourcePath.Replace("/", "."));
ResourceExtension = Path.GetExtension(ResourcePath);
var version = _assembly.GetName().Version;
ResourceLastModified = new DateTime(2000, 1, 1)
.AddDays(version.Build)
.AddSeconds(version.Revision * 2)
.ToUniversalTime();
using (var bodyStream = assembly.GetManifestResourceStream(ResourcePath))
{
if (bodyStream != null)
{
ResourceSize = (int)bodyStream.Length;
}
}
MimeSetting = mimeSettingProvider.GetSetting(ResourceExtension.ToLower());
BufferSize = bufferSize;
MaxFileSizeToServe = maxFileSizeToServe;
Hasher = hasher;
MimeTyper = mimeTyper;
CacheManager = cacheManager;
}
示例5: CSSAssetsFileHasher
public CSSAssetsFileHasher(string hashQueryStringKeyName, IResolver fileResolver, IHasher hasher, IPathTranslator pathTranslator)
{
HashQueryStringKeyName = hashQueryStringKeyName;
FileSystemResolver = fileResolver;
Hasher = hasher;
this.pathTranslator = pathTranslator;
}
示例6: Key
public Key(string value, IHasher hasher)
{
this.Value = value;
this.bytes = hasher.GetBytes(string.Format("{0}_{1}_{2}",
value, Common.Properties.SqlServer, Common.Properties.SqlDatabase));
this.Hash = BitConverter.ToString(this.bytes).Replace("-", ""); ;
}
示例7: ReadIndex
public ReadIndex(IPublisher bus,
int readerCount,
Func<ITransactionFileSequentialReader> seqReaderFactory,
Func<ITransactionFileReader> readerFactory,
ITableIndex tableIndex,
IHasher hasher,
ILRUCache<string, StreamCacheInfo> streamInfoCache)
{
Ensure.NotNull(bus, "bus");
Ensure.Positive(readerCount, "readerCount");
Ensure.NotNull(seqReaderFactory, "seqReaderFactory");
Ensure.NotNull(readerFactory, "readerFactory");
Ensure.NotNull(tableIndex, "tableIndex");
Ensure.NotNull(hasher, "hasher");
Ensure.NotNull(streamInfoCache, "streamInfoCache");
_bus = bus;
_tableIndex = tableIndex;
_hasher = hasher;
_streamInfoCache = streamInfoCache;
for (int i = 0; i < readerCount; ++i)
{
_seqReaders.Push(seqReaderFactory());
_readers.Push(readerFactory());
}
}
示例8: ReadIndex
public ReadIndex(IPublisher bus,
int initialReaderCount,
int maxReaderCount,
Func<ITransactionFileReader> readerFactory,
ITableIndex tableIndex,
IHasher hasher,
ILRUCache<string, StreamCacheInfo> streamInfoCache,
bool additionalCommitChecks,
int metastreamMaxCount)
{
Ensure.NotNull(bus, "bus");
Ensure.Positive(initialReaderCount, "initialReaderCount");
Ensure.Positive(maxReaderCount, "maxReaderCount");
if (initialReaderCount > maxReaderCount)
throw new ArgumentOutOfRangeException("initialReaderCount", "initialReaderCount is greater than maxReaderCount.");
Ensure.NotNull(readerFactory, "readerFactory");
Ensure.NotNull(tableIndex, "tableIndex");
Ensure.NotNull(hasher, "hasher");
Ensure.NotNull(streamInfoCache, "streamInfoCache");
Ensure.Positive(metastreamMaxCount, "metastreamMaxCount");
_tableIndex = tableIndex;
_hasher = hasher;
_bus = bus;
_streamInfoCache = streamInfoCache;
_readers = new ObjectPool<ITransactionFileReader>("ReadIndex readers pool", initialReaderCount, maxReaderCount, readerFactory);
_additionalCommitChecks = additionalCommitChecks;
_metastreamMetadata = new StreamMetadata(metastreamMaxCount, null, null, null);
}
示例9: PaymentManager
public PaymentManager(IOrderFacade orderFacade, IHasher hasher, IResultParser resultParser, IPayExSettings payExSettings)
{
_orderFacade = orderFacade;
_hasher = hasher;
_resultParser = resultParser;
_payExSettings = payExSettings;
}
示例10: BundleBase
protected BundleBase(IFileWriterFactory fileWriterFactory, IFileReaderFactory fileReaderFactory, IDebugStatusReader debugStatusReader, ICurrentDirectoryWrapper currentDirectoryWrapper, IHasher hasher)
{
this.fileWriterFactory = fileWriterFactory;
this.fileReaderFactory = fileReaderFactory;
this.debugStatusReader = debugStatusReader;
this.currentDirectoryWrapper = currentDirectoryWrapper;
this.hasher = hasher;
}
示例11: SanityTest
//----------------------------------------------------------------------------
// Basic sanity checks:
// - A hash function should not be reading outside the bounds of the key.
// - Flipping a bit of a key should, with overwhelmingly high probability, result in a different hash.
// - Hashing the same key twice should always produce the same result.
// - The memory alignment of the key should not affect the hash result.
public static bool SanityTest(IHasher hasher)
{
var rnd = new Random(883741);
bool result = true;
const int reps = 10;
const int keymax = 256;
const int pad = 16;
const int buflen = keymax + pad*3;
byte[] buffer1 = new byte[buflen];
byte[] buffer2 = new byte[buflen];
//----------
for (int irep = 0; irep < reps; irep++)
{
if (irep % (reps/10) == 0) Console.Write(".");
for (int len = 4; len <= keymax; len++)
{
for(int offset = pad; offset < pad*2; offset++)
{
// byte* key1 = &buffer1[pad];
// byte* key2 = &buffer2[pad+offset];
rnd.NextBytes(buffer1);
rnd.NextBytes(buffer2);
//memcpy(key2, key1, len);
Buffer.BlockCopy(buffer2, pad + offset, buffer1, pad, len);
// hash1 = hash(key1, len, 0)
var hash1 = hasher.Hash(buffer1, pad, (uint)len, 0);
for(int bit = 0; bit < (len * 8); bit++)
{
// Flip a bit, hash the key -> we should get a different result.
//Flipbit(key2,len,bit);
Flipbit(buffer2, pad + offset, len, bit);
var hash2 = hasher.Hash(buffer2, pad + offset, (uint)len, 0);
if (hash1 == hash2)
result = false;
// Flip it back, hash again -> we should get the original result.
//flipbit(key2,len,bit);
Flipbit(buffer2, pad + offset, len, bit);
//hash(key2, len, 0, hash2);
hash2 = hasher.Hash(buffer2, pad + offset, (uint)len, 0);
if (hash1 != hash2)
result = false;
}
}
}
}
return result;
}
示例12: DefaultOAuthService
/// <summary>
/// ctor the Mighty
/// </summary>
public DefaultOAuthService(IFacebookConnectService facebookService, IBrewgrRepository repository, IHasher hasher, IUserService userService)
{
this.FacebookService = facebookService;
this.Repository = repository;
this.Hasher = hasher;
this.UserService = userService;
Mapper.CreateMap<OAuthUserInfo, User>();
}
示例13: IndexCommitter
public IndexCommitter(IPublisher bus, IIndexBackend backend, IIndexReader indexReader,
ITableIndex tableIndex, IHasher hasher, bool additionalCommitChecks)
{
_bus = bus;
_backend = backend;
_indexReader = indexReader;
_tableIndex = tableIndex;
_hasher = hasher;
_additionalCommitChecks = additionalCommitChecks;
}
示例14: FileEntity
public FileEntity(IRetryableFileOpener retryableFileOpener, IMimeTyper mimeTyper, IHasher hasher, long maxFileSizeToServe, int bufferSize, FileInfo fileInfo, FileEntitySetting fileEntitySetting)
{
RetryableFileOpener = retryableFileOpener;
MimeTyper = mimeTyper;
Hasher = hasher;
BufferSize = bufferSize;
MaxFileSizeToServe = maxFileSizeToServe;
FileInfo = fileInfo;
FileEntitySetting = fileEntitySetting;
}
示例15: TestFixtureSetUp
public override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
_indexDir = PathName;
var fakeReader = new TFReaderLease(new FakeTfReader());
_lowHasher = new XXHashUnsafe();
_highHasher = new Murmur3AUnsafe();
_tableIndex = new TableIndex(_indexDir, _lowHasher, _highHasher,
() => new HashListMemTable(_ptableVersion, maxSize: 10),
() => fakeReader,
_ptableVersion,
maxSizeForMemory: 5);
_tableIndex.Initialize(long.MaxValue);
_tableIndex.Add(0, "0xDEAD", 0, 0xFF00);
_tableIndex.Add(0, "0xDEAD", 1, 0xFF01);
_tableIndex.Add(0, "0xBEEF", 0, 0xFF00);
_tableIndex.Add(0, "0xBEEF", 1, 0xFF01);
_tableIndex.Add(0, "0xABBA", 0, 0xFF00); // 1st ptable0
_tableIndex.Add(0, "0xABBA", 1, 0xFF01);
_tableIndex.Add(0, "0xABBA", 2, 0xFF02);
_tableIndex.Add(0, "0xABBA", 3, 0xFF03);
_tableIndex.Add(0, "0xADA", 0, 0xFF00); // simulates duplicate due to concurrency in TableIndex (see memtable below)
_tableIndex.Add(0, "0xDEAD", 0, 0xFF10); // 2nd ptable0
_tableIndex.Add(0, "0xDEAD", 1, 0xFF11); // in memtable
_tableIndex.Add(0, "0xADA", 0, 0xFF00); // in memtable
}