internal override void AddToHashCodeCombiner(HashCodeCombiner combiner)
 {
     base.AddToHashCodeCombiner(combiner);
     combiner.AddEnumerable(this.Arguments);
     combiner.AddObject(this.Method);
     combiner.AddFingerprint(this.Target);
 }
        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {
            base.AddToHashCodeCombiner(combiner);

            combiner.AddFingerprint(Test);
            combiner.AddFingerprint(IfTrue);
            combiner.AddFingerprint(IfFalse);
        }
        public override void AddToHashCodeCombiner(HashCodeCombiner combiner)
        {
            base.AddToHashCodeCombiner(combiner);

            combiner.AddObject(Method);
            combiner.AddFingerprint(Operand);
        }
        public override void AddToHashCodeCombiner(HashCodeCombiner combiner)
        {
            base.AddToHashCodeCombiner(combiner);

            combiner.AddObject(Member);
            combiner.AddFingerprint(Target);
        }
Ejemplo n.º 5
0
 public override int GetHashCode()
 {
     var combiner = new HashCodeCombiner();
     combiner.AddObject(Id);
     combiner.AddObject(Version);
     return combiner.CombinedHash;
 }
Ejemplo n.º 6
0
 public override int GetHashCode()
 {
     HashCodeCombiner combiner = new HashCodeCombiner();
     combiner.AddObject(SourcePath);
     combiner.AddObject(TargetPath);
     return combiner.CombinedHash;
 }
        public override void AddToHashCodeCombiner(HashCodeCombiner combiner)
        {
            base.AddToHashCodeCombiner(combiner);

            combiner.AddEnumerable(Arguments);
            combiner.AddObject(Method);
            combiner.AddFingerprint(Target);
        }
 private void CalculateProfilePropertySettingsHash(ProfilePropertySettingsCollection settings, HashCodeCombiner hashCombiner)
 {
     foreach (ProfilePropertySettings settings2 in settings)
     {
         hashCombiner.AddObject(settings2.Name);
         hashCombiner.AddObject(settings2.Type);
     }
 }
 protected override void ComputeHashCode(HashCodeCombiner hashCodeCombiner)
 {
     base.ComputeHashCode(hashCodeCombiner);
     CompilationSection compilationConfig = MTConfigUtil.GetCompilationConfig(base.VirtualPath);
     hashCodeCombiner.AddObject(compilationConfig.RecompilationHash);
     PagesSection pagesConfig = MTConfigUtil.GetPagesConfig(base.VirtualPath);
     hashCodeCombiner.AddObject(Util.GetRecompilationHash(pagesConfig));
 }
        public override void AddToHashCodeCombiner(HashCodeCombiner combiner)
        {
            base.AddToHashCodeCombiner(combiner);

            combiner.AddFingerprint(_test);
            combiner.AddFingerprint(_ifTrue);
            combiner.AddFingerprint(_ifFalse);
        }
Ejemplo n.º 11
0
        internal override void AddToHashCodeCombiner(HashCodeCombiner combiner) {
            base.AddToHashCodeCombiner(combiner);

            combiner.AddInt32(IsLiftedToNull.GetHashCode());
            combiner.AddFingerprint(Left);
            combiner.AddObject(Method);
            combiner.AddFingerprint(Right);
        }
 public override int GetHashCode()
 {
     HashCodeCombiner combiner = new HashCodeCombiner();
     combiner.AddObject(this._varyByCustom);
     combiner.AddArray(this._varyByParams);
     combiner.AddArray(this._varyByControls);
     return combiner.CombinedHash32;
 }
 internal override string ComputeSourceDependenciesHashCode(VirtualPath virtualPath)
 {
     if (virtualPath == null)
     {
         virtualPath = base.VirtualPath;
     }
     HashCodeCombiner combiner = new HashCodeCombiner();
     combiner.AddResourcesDirectory(virtualPath.MapPathInternal());
     return combiner.CombinedHashString;
 }
 public override int GetHashCode()
 {
     HashCodeCombiner combiner = new HashCodeCombiner();
     combiner.AddObject(this._varyByAllParams);
     combiner.AddObject(this._varyByCustom);
     combiner.AddArray(this._contentEncodings);
     combiner.AddArray(this._headers);
     combiner.AddArray(this._params);
     return combiner.CombinedHash32;
 }
 private string ComputeNonVaryCacheKey(HashCodeCombiner combinedHashCode)
 {
     combinedHashCode.AddObject(this._guid);
     HttpBrowserCapabilities browser = this.Context.Request.Browser;
     if (browser != null)
     {
         combinedHashCode.AddObject(browser.TagWriter);
     }
     return ("l" + combinedHashCode.CombinedHashString);
 }
 int IEqualityComparer.GetHashCode(object obj)
 {
     byte[] buffer = (byte[]) obj;
     HashCodeCombiner combiner = new HashCodeCombiner();
     foreach (byte num in buffer)
     {
         combiner.AddObject(num);
     }
     return combiner.CombinedHash32;
 }
 public override int GetHashCode()
 {
     HashCodeCombiner combiner = new HashCodeCombiner();
     foreach (DictionaryEntry entry in this._bag)
     {
         combiner.AddObject(entry.Key);
         combiner.AddObject(entry.Value);
     }
     return combiner.CombinedHash32;
 }
        /// <summary>
        /// Create a unique hash code for the given set of items
        /// </summary>
        internal static int GetHashCode(params object[] objects)
        {
            HashCodeCombiner combiner = new HashCodeCombiner();

            foreach (object obj in objects)
            {
                combiner.AddObject(obj);
            }

            return combiner.CombinedHash;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Create a unique hash code for the given set of items
        /// </summary>
        public static int GetHashCode(params object[] objects)
        {
            var combiner = new HashCodeCombiner();

            foreach (var obj in objects)
            {
                combiner.AddObject(obj);
            }

            return combiner.CombinedHash;
        }
    public override string GetFileHash(string virtualPath, IEnumerable virtualPathDependencies) {

        HashCodeCombiner hashCodeCombiner = new HashCodeCombiner();

        // Calculate the hash based on the time stamps of all the virtual paths
        foreach (string virtualDependency in virtualPathDependencies) {
            string physicalDependency = HostingEnvironment.MapPathInternal(virtualDependency);
            hashCodeCombiner.AddFile(physicalDependency);
        }

        return hashCodeCombiner.CombinedHashString;
    }
 protected override void ComputeHashCode(HashCodeCombiner hashCodeCombiner)
 {
     base.ComputeHashCode(hashCodeCombiner);
     if (base.VirtualPath != null)
     {
         Assembly localResourcesAssembly = BuildManager.GetLocalResourcesAssembly(base.VirtualPath.Parent);
         if (localResourcesAssembly != null)
         {
             hashCodeCombiner.AddFile(localResourcesAssembly.Location);
         }
     }
 }
Ejemplo n.º 22
0
        public void GivenTheSameInputs_ItProducesTheSameOutput()
        {
            var hashCode1 = new HashCodeCombiner();
            var hashCode2 = new HashCodeCombiner();

            hashCode1.Add(42);
            hashCode1.Add("foo");
            hashCode2.Add(42);
            hashCode2.Add("foo");

            Assert.Equal(hashCode1.CombinedHash, hashCode2.CombinedHash);
        }
        int IEqualityComparer.GetHashCode(object obj) {
            if (obj == null) {
                return 0;
            }

            HashCodeCombiner combiner = new HashCodeCombiner();
            foreach (object item in (IList)obj) {
                combiner.AddObject(item);
            }

            return combiner.CombinedHash32;
        }
 private long CalculateHash()
 {
     HashCodeCombiner hashCombiner = new HashCodeCombiner();
     this.CalculateProfilePropertySettingsHash(this.PropertySettings, hashCombiner);
     if (this.PropertySettings != null)
     {
         foreach (ProfileGroupSettings settings in this.PropertySettings.GroupSettings)
         {
             hashCombiner.AddObject(settings.Name);
             this.CalculateProfilePropertySettingsHash(settings.PropertySettings, hashCombiner);
         }
     }
     return hashCombiner.CombinedHash;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Hash code of the id and version
        /// </summary>
        public int GetHashCode(PackageIdentity obj)
        {
            if (ReferenceEquals(obj, null))
            {
                return 0;
            }

            var combiner = new HashCodeCombiner();

            combiner.AddObject(obj.Id.ToUpperInvariant());
            combiner.AddObject(_versionComparer.GetHashCode(obj.Version));

            return combiner.CombinedHash;
        }
Ejemplo n.º 26
0
        public void HashCombiner_Test_Int()
        {
            var combiner1 = new HashCodeCombiner();
            combiner1.AddInt(1234);

            var combiner2 = new HashCodeCombiner();
            combiner2.AddInt(1234);

            Assert.AreEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());

            combiner2.AddInt(1);

            Assert.AreNotEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
        }
Ejemplo n.º 27
0
        public void HashCombiner_Test_String()
        {
            var combiner1 = new HashCodeCombiner();
            combiner1.AddCaseInsensitiveString("Hello");

            var combiner2 = new HashCodeCombiner();
            combiner2.AddCaseInsensitiveString("hello");

            Assert.AreEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());

            combiner2.AddCaseInsensitiveString("world");

            Assert.AreNotEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
        }
Ejemplo n.º 28
0
        public void HashCombiner_Test_DateTime()
        {
            var dt = DateTime.Now;
            var combiner1 = new HashCodeCombiner();
            combiner1.AddDateTime(dt);

            var combiner2 = new HashCodeCombiner();
            combiner2.AddDateTime(dt);

            Assert.AreEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());

            combiner2.AddDateTime(DateTime.Now);

            Assert.AreNotEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
        }
Ejemplo n.º 29
0
        public void HashCombiner_Test_Bool()
        {
            var combiner1 = new HashCodeCombiner();
            combiner1.AddBool(true);

            var combiner2 = new HashCodeCombiner();
            combiner2.AddBool(true);

            var combiner3 = new HashCodeCombiner();
            combiner3.AddBool(false);

            Assert.AreEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
            Assert.AreNotEqual(combiner2.GetCombinedHashCode(), combiner3.GetCombinedHashCode());

            combiner2.AddBool(true);

            Assert.AreNotEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
        }
Ejemplo n.º 30
0
        public void HashCombiner_Test_Type()
        {
            var combiner1 = new HashCodeCombiner();
            combiner1.AddType(typeof(HashCodeCombiner));

            var combiner2 = new HashCodeCombiner();
            combiner2.AddType(typeof(HashCodeCombiner));

            var combiner3 = new HashCodeCombiner();
            combiner3.AddType(typeof(HashCodeCombinerTests));

            Assert.AreEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
            Assert.AreNotEqual(combiner2.GetCombinedHashCode(), combiner3.GetCombinedHashCode());

            combiner2.AddType(typeof(HashCodeCombiner));

            Assert.AreNotEqual(combiner1.GetCombinedHashCode(), combiner2.GetCombinedHashCode());
        }
Ejemplo n.º 31
0
 internal virtual void AddToHashCodeCombiner(HashCodeCombiner combiner)
 {
     combiner.AddInt32((int)NodeType);
     combiner.AddObject(Type);
 }
Ejemplo n.º 32
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.GetHashCode(Parent, Range, Child));
 }
 public override int GetHashCode() => HashCodeCombiner.Combine <object>(Text, Key, DeepNestedField, DeepNestedProperty);
 public override int GetHashCode() => HashCodeCombiner.Combine(Field, Property, ChildField, ChildProperty);
Ejemplo n.º 35
0
        public virtual void AnonymizeData <TEntity>(TEntity entity, Expression <Func <TEntity, object> > expression, IdentifierDataType type, Language language = null)
            where TEntity : BaseEntity
        {
            Guard.NotNull(entity, nameof(entity));
            Guard.NotNull(expression, nameof(expression));

            var    originalValue = expression.Compile().Invoke(entity);
            object maskedValue   = null;

            if (originalValue is DateTime d)
            {
                maskedValue = MinDate;
            }
            else if (originalValue is string s)
            {
                if (s.IsEmpty())
                {
                    return;
                }

                language = language ?? (entity as Customer)?.GetLanguage();

                switch (type)
                {
                case IdentifierDataType.Address:
                case IdentifierDataType.Name:
                case IdentifierDataType.Text:
                    maskedValue = T("Gdpr.DeletedText", language.Id).Text;
                    break;

                case IdentifierDataType.LongText:
                    maskedValue = T("Gdpr.DeletedLongText", language.Id).Text;
                    break;

                case IdentifierDataType.EmailAddress:
                    //maskedValue = s.Hash(Encoding.ASCII, true) + "@anony.mous";
                    maskedValue = HashCodeCombiner.Start()
                                  .Add(entity.GetHashCode())
                                  .Add(s)
                                  .CombinedHashString + "@anony.mous";
                    break;

                case IdentifierDataType.Url:
                    maskedValue = "https://anony.mous";
                    break;

                case IdentifierDataType.IpAddress:
                    maskedValue = AnonymizeIpAddress(s);
                    break;

                case IdentifierDataType.UserName:
                    maskedValue = T("Gdpr.Anonymous", language.Id).Text.ToLower();
                    break;

                case IdentifierDataType.PhoneNumber:
                    maskedValue = "555-00000";
                    break;

                case IdentifierDataType.PostalCode:
                    maskedValue = "00000";
                    break;

                case IdentifierDataType.DateTime:
                    maskedValue = MinDate.ToString(CultureInfo.InvariantCulture);
                    break;
                }
            }

            if (maskedValue != null)
            {
                var pi = expression.ExtractPropertyInfo();
                pi.SetValue(entity, maskedValue);
            }
        }
Ejemplo n.º 36
0
 internal override void AddToHashCodeCombiner(HashCodeCombiner combiner)
 {
     combiner.AddObject(Method);
     base.AddToHashCodeCombiner(combiner);
 }
        public override int GetHashCode()
        {
            var code = HashCodeCombiner.Combine(Name, Type);

            return(HashCodeCombiner.CombineCodes(code, CanWrite.GetHashCode()));
        }
Ejemplo n.º 38
0
 public void Add(int value)
 {
     this.currentHash = HashCodeCombiner.Combine(this.currentHash, value);
 }
Ejemplo n.º 39
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.GetHashCode(LibraryRange, Framework));
 }
Ejemplo n.º 40
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Combine(flags.GetHashCode(), data.GetHashCode()));
 }
Ejemplo n.º 41
0
 internal override void AddToHashCodeCombiner(HashCodeCombiner combiner)
 {
     combiner.AddInt32(ParameterIndex);
     base.AddToHashCodeCombiner(combiner);
 }
Ejemplo n.º 42
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Combine(Alternatives.Select(p => p.GetHashCode()).ToArray()));
 }
Ejemplo n.º 43
0
 internal override void AddToHashCodeCombiner(HashCodeCombiner combiner)
 {
     combiner.AddObject(TypeOperand);
     base.AddToHashCodeCombiner(combiner);
 }
 public override int GetHashCode()
 {
     return(HashCodeCombiner.CombineHashCodes(this.type.GetHashCode(), [email protected]()));
 }
Ejemplo n.º 45
0
 public override int GetHashCode() => HashCodeCombiner.Combine(Property, NullableProperty);
        internal static Assembly GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, string assemblyName, StringSet excludedSubdirectories, bool isDirectoryAllowed)
        {
            string path = virtualDir.MapPath();

            if (!isDirectoryAllowed && Directory.Exists(path))
            {
                throw new HttpException(System.Web.SR.GetString("Bar_dir_in_precompiled_app", new object[] { virtualDir }));
            }
            bool        supportLocalization  = IsResourceCodeDirectoryType(dirType);
            string      cacheKey             = assemblyName;
            BuildResult buildResultFromCache = BuildManager.GetBuildResultFromCache(cacheKey);
            Assembly    a = null;

            if ((buildResultFromCache != null) && (buildResultFromCache is BuildResultCompiledAssembly))
            {
                if (buildResultFromCache is BuildResultMainCodeAssembly)
                {
                    _mainCodeBuildResult = (BuildResultMainCodeAssembly)buildResultFromCache;
                }
                a = ((BuildResultCompiledAssembly)buildResultFromCache).ResultAssembly;
                if (!supportLocalization)
                {
                    return(a);
                }
                if (!isDirectoryAllowed)
                {
                    return(a);
                }
                BuildResultResourceAssembly assembly2 = (BuildResultResourceAssembly)buildResultFromCache;
                if (HashCodeCombiner.GetDirectoryHash(virtualDir) == assembly2.ResourcesDependenciesHash)
                {
                    return(a);
                }
            }
            if (!isDirectoryAllowed)
            {
                return(null);
            }
            if ((dirType != CodeDirectoryType.LocalResources) && !StringUtil.StringStartsWithIgnoreCase(path, HttpRuntime.AppDomainAppPathInternal))
            {
                throw new HttpException(System.Web.SR.GetString("Virtual_codedir", new object[] { virtualDir.VirtualPathString }));
            }
            if (!Directory.Exists(path))
            {
                if (dirType != CodeDirectoryType.MainCode)
                {
                    return(null);
                }
                if (!ProfileBuildProvider.HasCompilableProfile)
                {
                    return(null);
                }
            }
            BuildManager.ReportDirectoryCompilationProgress(virtualDir);
            DateTime utcNow = DateTime.UtcNow;
            CodeDirectoryCompiler compiler = new CodeDirectoryCompiler(virtualDir, dirType, excludedSubdirectories);
            string outputAssemblyName      = null;

            if (a != null)
            {
                outputAssemblyName = a.GetName().Name;
                compiler._onlyBuildLocalizedResources = true;
            }
            else
            {
                outputAssemblyName = BuildManager.GenerateRandomAssemblyName(assemblyName);
            }
            BuildProvidersCompiler compiler2 = new BuildProvidersCompiler(virtualDir, supportLocalization, outputAssemblyName);

            compiler._bpc = compiler2;
            compiler.FindBuildProviders();
            compiler2.SetBuildProviders(compiler._buildProviders);
            CompilerResults results = compiler2.PerformBuild();

            if (results != null)
            {
                DateTime time2 = DateTime.UtcNow.AddMilliseconds(3000.0);
                do
                {
                    if (UnsafeNativeMethods.GetModuleHandle(results.PathToAssembly) == IntPtr.Zero)
                    {
                        a = results.CompiledAssembly;
                        goto Label_01E6;
                    }
                    Thread.Sleep(250);
                }while (DateTime.UtcNow <= time2);
                throw new HttpException(System.Web.SR.GetString("Assembly_already_loaded", new object[] { results.PathToAssembly }));
            }
Label_01E6:
            if (a == null)
            {
                return(null);
            }
            if (dirType == CodeDirectoryType.MainCode)
            {
                _mainCodeBuildResult = new BuildResultMainCodeAssembly(a);
                buildResultFromCache = _mainCodeBuildResult;
            }
            else if (supportLocalization)
            {
                buildResultFromCache = new BuildResultResourceAssembly(a);
            }
            else
            {
                buildResultFromCache = new BuildResultCompiledAssembly(a);
            }
            buildResultFromCache.VirtualPath = virtualDir;
            if (BuildManager.OptimizeCompilations && (dirType != CodeDirectoryType.LocalResources))
            {
                buildResultFromCache.AddVirtualPathDependencies(new SingleObjectCollection(virtualDir.AppRelativeVirtualPathString));
            }
            if (dirType != CodeDirectoryType.LocalResources)
            {
                buildResultFromCache.CacheToMemory = false;
            }
            BuildManager.CacheBuildResult(cacheKey, buildResultFromCache, utcNow);
            return(a);
        }
Ejemplo n.º 47
0
 /// <internalonly/>
 public override int GetHashCode()
 {
     return(HashCodeCombiner.CombineHashCodes(_isPersonalizable.GetHashCode(), _scope.GetHashCode(),
                                              _isSensitive.GetHashCode()));
 }
Ejemplo n.º 48
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Combine(IsPositive.GetHashCode(), CharSet.GetHashCode(),
                                     HashCodeCombiner.Combine(ChildPatterns.Select(p => p.GetHashCode()).ToArray())));
 }
Ejemplo n.º 49
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Combine(From.GetHashCode(), To.GetHashCode()));
 }
Ejemplo n.º 50
0
 public HashMethodKey(Type type, string methodName, IEnumerable <Type> parameterTypes)
 {
     _hash = HashCodeCombiner.Start().Add(type).Add(methodName).Add(parameterTypes).CombinedHash;
 }
 public override int GetHashCode()
 {
     return(HashCodeCombiner.GetHashCode(TargetFramework, Packages));
 }
Ejemplo n.º 52
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Combine(Item1.GetHashCode(), Item2.GetHashCode()));
 }
Ejemplo n.º 53
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Start()
            .Add(Prefix)
            .CombinedHash);
 }
Ejemplo n.º 54
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Combine(Captures.Select(c => c.GetHashCode()).ToArray()));
 }
 public override int GetHashCode()
 {
     return(HashCodeCombiner.Start()
            .Add(base.GetHashCode())
            .CombinedHash);
 }
Ejemplo n.º 56
0
 public static int Combine(int code1, int code2, int code3, int code4)
 {
     return(HashCodeCombiner.Combine(HashCodeCombiner.Combine(code1, code2), HashCodeCombiner.Combine(code3, code4)));
 }
Ejemplo n.º 57
0
 public override int GetHashCode()
 {
     return(HashCodeCombiner.GetHashCode(PluginFilePath, PackageSourceRepository));
 }
    /// <inheritdoc />
    public int GetHashCode(TagHelperDescriptor descriptor)
    {
        if (descriptor == null)
        {
            throw new ArgumentNullException(nameof(descriptor));
        }

        var hash = HashCodeCombiner.Start();

        hash.Add(descriptor.Kind, StringComparer.Ordinal);
        hash.Add(descriptor.AssemblyName, StringComparer.Ordinal);
        hash.Add(descriptor.Name, StringComparer.Ordinal);
        hash.Add(descriptor.DisplayName, StringComparer.Ordinal);
        hash.Add(descriptor.CaseSensitive ? 1 : 0);

        if (descriptor.BoundAttributes != null)
        {
            for (var i = 0; i < descriptor.BoundAttributes.Count; i++)
            {
                hash.Add(descriptor.BoundAttributes[i]);
            }
        }

        if (descriptor.TagMatchingRules != null)
        {
            for (var i = 0; i < descriptor.TagMatchingRules.Count; i++)
            {
                hash.Add(descriptor.TagMatchingRules[i]);
            }
        }

        if (descriptor.AllowedChildTags != null)
        {
            for (var i = 0; i < descriptor.AllowedChildTags.Count; i++)
            {
                hash.Add(descriptor.AllowedChildTags[i]);
            }
        }

        if (descriptor.Diagnostics != null)
        {
            for (var i = 0; i < descriptor.Diagnostics.Count; i++)
            {
                hash.Add(descriptor.Diagnostics[i]);
            }
        }

        if (descriptor.Metadata != null)
        {
            // � Avoid enumerator allocations for Dictionary<TKey, TValue>
            if (descriptor.Metadata is Dictionary <string, string> metadata)
            {
                foreach (var kvp in metadata)
                {
                    hash.Add(kvp.Key, StringComparer.Ordinal);
                    hash.Add(kvp.Value, StringComparer.Ordinal);
                }
            }
            else
            {
                foreach (var kvp in descriptor.Metadata)
                {
                    hash.Add(kvp.Key, StringComparer.Ordinal);
                    hash.Add(kvp.Value, StringComparer.Ordinal);
                }
            }
        }

        return(hash.CombinedHash);
    }
 public override int GetHashCode()
 {
     return(HashCodeCombiner.CombineHashCodes(base.GetHashCode(), GroupSettings.GetHashCode()));
 }
Ejemplo n.º 60
0
        internal static long GetRecompilationHash(CompilationSection ps)
        {
            HashCodeCombiner                   recompilationHash = new HashCodeCombiner();
            AssemblyCollection                 assemblies;
            BuildProviderCollection            builders;
            FolderLevelBuildProviderCollection buildProviders;
            CodeSubDirectoriesCollection       codeSubDirs;

            // Combine items from Compilation section
            recompilationHash.AddObject(ps.Debug);
            recompilationHash.AddObject(ps.TargetFramework);
            recompilationHash.AddObject(ps.Strict);
            recompilationHash.AddObject(ps.Explicit);
            recompilationHash.AddObject(ps.Batch);
            recompilationHash.AddObject(ps.OptimizeCompilations);
            recompilationHash.AddObject(ps.BatchTimeout);
            recompilationHash.AddObject(ps.MaxBatchGeneratedFileSize);
            recompilationHash.AddObject(ps.MaxBatchSize);
            recompilationHash.AddObject(ps.NumRecompilesBeforeAppRestart);
            recompilationHash.AddObject(ps.DefaultLanguage);
            recompilationHash.AddObject(ps.UrlLinePragmas);
            recompilationHash.AddObject(ps.DisableObsoleteWarnings);
            if (ps.AssemblyPostProcessorTypeInternal != null)
            {
                recompilationHash.AddObject(ps.AssemblyPostProcessorTypeInternal.FullName);
            }
            if (!String.IsNullOrWhiteSpace(ps.ControlBuilderInterceptorType))
            {
                recompilationHash.AddObject(ps.ControlBuilderInterceptorType);
            }

            // Combine items from Compilers collection
            foreach (Compiler compiler in ps.Compilers)
            {
                recompilationHash.AddObject(compiler.Language);
                recompilationHash.AddObject(compiler.Extension);
                recompilationHash.AddObject(compiler.Type);
                recompilationHash.AddObject(compiler.WarningLevel);
                recompilationHash.AddObject(compiler.CompilerOptions);
            }

            // Combine items from <expressionBuilders> section
            foreach (System.Web.Configuration.ExpressionBuilder eb in ps.ExpressionBuilders)
            {
                recompilationHash.AddObject(eb.ExpressionPrefix);
                recompilationHash.AddObject(eb.Type);
            }

            // Combine items from the Assembly collection
            assemblies = ps.Assemblies;

            if (assemblies.Count == 0)
            {
                recompilationHash.AddObject("__clearassemblies");
            }
            else
            {
                foreach (AssemblyInfo ai in assemblies)
                {
                    recompilationHash.AddObject(ai.Assembly);
                }
            }

            // Combine items from the Builders Collection
            builders = ps.BuildProviders;

            if (builders.Count == 0)
            {
                recompilationHash.AddObject("__clearbuildproviders");
            }
            else
            {
                foreach (System.Web.Configuration.BuildProvider bp in builders)
                {
                    recompilationHash.AddObject(bp.Type);
                    recompilationHash.AddObject(bp.Extension);
                }
            }

            // Combine items from the FolderLevelBuildProviderCollection
            buildProviders = ps.FolderLevelBuildProviders;

            if (buildProviders.Count == 0)
            {
                recompilationHash.AddObject("__clearfolderlevelbuildproviders");
            }
            else
            {
                foreach (System.Web.Configuration.FolderLevelBuildProvider bp in buildProviders)
                {
                    recompilationHash.AddObject(bp.Type);
                    recompilationHash.AddObject(bp.Name);
                }
            }

            codeSubDirs = ps.CodeSubDirectories;
            if (codeSubDirs.Count == 0)
            {
                recompilationHash.AddObject("__clearcodesubdirs");
            }
            else
            {
                foreach (CodeSubDirectory csd in codeSubDirs)
                {
                    recompilationHash.AddObject(csd.DirectoryName);
                }
            }

            // Make sure the <system.CodeDom> section is hashed properly.
            CompilerInfo[] compilerInfoArray = CodeDomProvider.GetAllCompilerInfo();
            if (compilerInfoArray != null)
            {
                CompilerInfo cppCodeProvider = CodeDomProvider.GetCompilerInfo("cpp");
                foreach (CompilerInfo info in compilerInfoArray)
                {
                    // Skip cpp code provider (Dev11 193323).
                    if (info == cppCodeProvider)
                    {
                        continue;
                    }

                    // Ignore it if the type is not valid.
                    if (!info.IsCodeDomProviderTypeValid)
                    {
                        continue;
                    }

                    CompilerParameters parameters = info.CreateDefaultCompilerParameters();
                    string             option     = parameters.CompilerOptions;
                    if (!String.IsNullOrEmpty(option))
                    {
                        Type type = info.CodeDomProviderType;
                        if (type != null)
                        {
                            recompilationHash.AddObject(type.FullName);
                        }
                        // compilerOptions need to be hashed.
                        recompilationHash.AddObject(option);
                    }

                    // DevDiv 62998
                    // The tag providerOption needs to be added to the hash,
                    // as the user could switch between v2 and v3.5.
                    if (info.CodeDomProviderType == null)
                    {
                        continue;
                    }

                    // Add a hash for each providerOption added, specific for each codeDomProvider, so that
                    // if some codedom setting has changed, we know we have to recompile.
                    IDictionary <string, string> providerOptions = GetProviderOptions(info);
                    if (providerOptions != null && providerOptions.Count > 0)
                    {
                        string codeDomProviderType = info.CodeDomProviderType.FullName;
                        foreach (string key in providerOptions.Keys)
                        {
                            string value = providerOptions[key];
                            recompilationHash.AddObject(codeDomProviderType + ":" + key + "=" + value);
                        }
                    }
                }
            }

            return(recompilationHash.CombinedHash);
        }