Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyInfo"/> class.
 /// </summary>
 /// <param name="description">
 /// The description of the property, for use in a summary comment.
 /// </param>
 /// <param name="serializedName">
 /// The name of the property as serialized in the JSON file.
 /// </param>
 /// <param name="comparisonKind">
 /// The kind of comparison code required by the property.
 /// </param>
 /// <param name="hashKind">
 /// The kind of hash value computation code required by the property.
 /// </param>
 /// <param name="initializationKind">
 /// The kind of initialization code required by the property.
 /// </param>
 /// <param name="type">
 /// The type of the property.
 /// </param>
 /// <param name="typeName">
 /// The name of the type of the property.
 /// </param>
 /// <param name="namespaceName">
 /// The qualified name of the namespace declaration required by this type,
 /// or <code>null</code> if no namespace declaration is required.
 /// </param>
 /// <param name="isRequired">
 /// <code>true</code> if this property is required by the schema;
 /// otherwise <code>false</code>.
 /// </param>
 /// <param name="isOfSchemaDefinedType">
 /// <code>true</code> if this property is of a type defined by the schema (or an;
 /// array of a schema-defined type otherwise <code>false</code>.
 /// </param>
 /// <param name="arrayRank">
 /// The array rank of the property type. 0 means the property is not an array.
 /// </param>
 /// <param name="declarationOrder">
 /// The 0-based order in which the property was declared in the schema.
 /// </param>
 public PropertyInfo(
     string description,
     string serializedName,
     ComparisonKind comparisonKind,
     HashKind hashKind,
     InitializationKind initializationKind,
     TypeSyntax type,
     string namespaceName,
     bool isRequired,
     bool isOfSchemaDefinedType,
     int arrayRank,
     int declarationOrder)
 {
     Description        = description;
     SerializedName     = serializedName;
     ComparisonKind     = comparisonKind;
     HashKind           = hashKind;
     InitializationKind = initializationKind;
     Type                  = type;
     TypeName              = type.ToString();
     NamespaceName         = namespaceName;
     IsRequired            = isRequired;
     IsOfSchemaDefinedType = isOfSchemaDefinedType;
     ArrayRank             = arrayRank;
     DeclarationOrder      = declarationOrder;
 }
Пример #2
0
        private StatementSyntax GeneratePropertyHashCodeContribution(string hashKindKey, ExpressionSyntax expression)
        {
            HashKind hashKind = _propertyInfoDictionary[hashKindKey].HashKind;

            switch (hashKind)
            {
            case HashKind.ScalarValueType:
                return(GenerateScalarHashCodeContribution(expression));

            case HashKind.ScalarReferenceType:
                return(GenerateScalarReferenceTypeHashCodeContribution(expression));

            case HashKind.ObjectModelType:
                return(GenerateObjectModelTypeHashCodeContribution(expression));

            case HashKind.Collection:
                return(GenerateCollectionHashCodeContribution(hashKindKey, expression));

            case HashKind.Dictionary:
                return(GenerateDictionaryHashCodeContribution(expression));

            default:
                throw new ArgumentException($"Property {hashKindKey} has unknown comparison type {hashKind}.");
            }
        }
Пример #3
0
 public Hash(HashKind hashsum, int output_bits)
 {
     if (UnmanagedError.RegisterThread() != ErrorKind.K_ESUCCESS)
         throw new Exception("unable to register libk error handler");
     if ((context = SafeNativeMethods.k_hash_init(hashsum, (uint)output_bits)) == (UIntPtr)0)
         UnmanagedError.ThrowLastError();
 }
Пример #4
0
        public BloomFilter(int elementNum, double errorRate, HashKind hashKind = HashKind.SimpleHash, bool isUserRedis = false, string filterKeyName = "")
        {
            _filterKeyName = filterKeyName;
            _redisService  = new RedisService();
            _isUserRedis   = isUserRedis;

            var m = GetBitLength(elementNum, errorRate);
            var k = GetHashFuncCount(m, elementNum);

            Console.WriteLine($"m={m} n={elementNum} p={errorRate} k={k} ");
            Console.WriteLine($"ErrorRate={GetFalsePositiveProbability(k, elementNum, m)}");

            //Hash计算类
            _bloomFilterHash = new BloomFilterHash(m, k, hashKind);

            //创建本地的布隆过滤器bit数组
            _bitArray = new BitArray(m);
        }
        public static string ComputeHash(string value, HashKind hashKind = HashKind.MD5)
        {
            HashAlgorithm hashAlgorithm;

            switch (hashKind)
            {
            case HashKind.MD5:
                hashAlgorithm = new MD5CryptoServiceProvider();
                break;

            case HashKind.SHA256:
                hashAlgorithm = new SHA256Managed();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(hashKind), hashKind, null);
            }

            byte[] hash = hashAlgorithm.ComputeHash(DefaultEncoding.GetBytes(value));
            return(BitConverter.ToString(hash).Replace("-", string.Empty));
        }
Пример #6
0
 /// <summary>
 ///构造函数
 /// </summary>
 /// <param name="bitLength">Bit位数</param>
 /// <param name="hashFuncCount">Hash函数数量</param>
 public BloomFilterHash(int bitLength, int hashFuncCount, HashKind hashKind = HashKind.SimpleHash)
 {
     _bitLength = bitLength;
     _seeds     = GetPrimes(hashFuncCount);
     _hashKind  = hashKind;
 }
Пример #7
0
 internal static extern UIntPtr k_hash_init(HashKind hashsum, uint output_bits);
        public FolderWatcherSetting()
        {
            sizeUnit = SizeUnitKind.Auto;

            isSaveSettingFile = false;

            fileItemList = new FileItemKind[6];
            fileItemList[0] = FileItemKind.Name;
            fileItemList[1] = FileItemKind.LastModifyDate;
            fileItemList[2] = FileItemKind.DataSize;
            fileItemList[3] = FileItemKind.Kind;
            fileItemList[4] = FileItemKind.FileCount;
            fileItemList[5] = FileItemKind.DirectoryCount;

            folderListViewMode = View.Details;

            isDisplayDetailPain = true;

            isDisplayNavigatinPain = true;

            hashKind = HashKind.None;

            opacity = 0;
        }