diff --git a/src/Sitecore.Support.96931/ContentSearch/SolrProvider/SolrDocumentBuilder.cs b/src/Sitecore.Support.96931/ContentSearch/SolrProvider/SolrDocumentBuilder.cs index 45fb60b..a9e9883 100644 --- a/src/Sitecore.Support.96931/ContentSearch/SolrProvider/SolrDocumentBuilder.cs +++ b/src/Sitecore.Support.96931/ContentSearch/SolrProvider/SolrDocumentBuilder.cs @@ -11,51 +11,54 @@ namespace Sitecore.Support.ContentSearch.SolrProvider { - public class SolrDocumentBuilder : Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilder - { - private static readonly MethodInfo AddComputedIndexFieldMethodInfo; - static SolrDocumentBuilder() + public class SolrDocumentBuilder : Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilder { - AddComputedIndexFieldMethodInfo = typeof(Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilder).GetMethod("AddComputedIndexField", BindingFlags.Instance | BindingFlags.NonPublic); - } - public SolrDocumentBuilder(IIndexable indexable, IProviderUpdateContext context) : base(indexable, context) - { - } - private void AddComputedIndexField(IComputedIndexField computedIndexField, ParallelLoopState parallelLoopState = null, ConcurrentQueue exceptions = null) - { - AddComputedIndexFieldMethodInfo.Invoke(this, new object[] - { + private static readonly MethodInfo AddComputedIndexFieldMethodInfo; + static SolrDocumentBuilder() + { + AddComputedIndexFieldMethodInfo = typeof(Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilder).GetMethod("AddComputedIndexField", BindingFlags.Instance | BindingFlags.NonPublic); + } + public SolrDocumentBuilder(IIndexable indexable, IProviderUpdateContext context) : base(indexable, context) + { + } + private void AddComputedIndexField(IComputedIndexField computedIndexField, ParallelLoopState parallelLoopState = null, ConcurrentQueue exceptions = null) + { + AddComputedIndexFieldMethodInfo.Invoke(this, new object[] + { computedIndexField, parallelLoopState, exceptions - }); - } + }); + } - protected override void AddComputedIndexFieldsInParallel() - { - ConcurrentQueue exceptions = new ConcurrentQueue(); - this.ParallelForeachProxy.ForEach((IEnumerable)base.Options.ComputedIndexFields, base.ParallelOptions, + protected override void AddComputedIndexFieldsInParallel() + { + ConcurrentQueue exceptions = new ConcurrentQueue(); + var needEnterLanguageFallbackItemSwitcher = LanguageFallbackItemSwitcher.CurrentValue; + this.ParallelForeachProxy.ForEach((IEnumerable)base.Options.ComputedIndexFields, base.ParallelOptions, (Action)((field, parallelLoopState) => { - using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) - { - this.AddComputedIndexField(field, parallelLoopState, exceptions); - } + using (new LanguageFallbackItemSwitcher(needEnterLanguageFallbackItemSwitcher)) + { + using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) + { + this.AddComputedIndexField(field, parallelLoopState, exceptions); + } + } })); - if (!exceptions.IsEmpty) - { - throw new AggregateException(exceptions); - } - } + if (!exceptions.IsEmpty) + { + throw new AggregateException(exceptions); + } + } - protected override void AddComputedIndexFieldsInSequence() - { - foreach (IComputedIndexField field in base.Options.ComputedIndexFields) - { - using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) + protected override void AddComputedIndexFieldsInSequence() { - this.AddComputedIndexField(field, null, null); + foreach (IComputedIndexField field in base.Options.ComputedIndexFields) + { + using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) + { + this.AddComputedIndexField(field, null, null); + } + } } - } } - - } } \ No newline at end of file