當前位置: 首頁>>代碼示例>>C#>>正文


C# ShapeTableBuilder.BuildAlterations方法代碼示例

本文整理匯總了C#中Orchard.DisplayManagement.Descriptors.ShapeTableBuilder.BuildAlterations方法的典型用法代碼示例。如果您正苦於以下問題:C# ShapeTableBuilder.BuildAlterations方法的具體用法?C# ShapeTableBuilder.BuildAlterations怎麽用?C# ShapeTableBuilder.BuildAlterations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Orchard.DisplayManagement.Descriptors.ShapeTableBuilder的用法示例。


在下文中一共展示了ShapeTableBuilder.BuildAlterations方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetShapeTable

        public ShapeTable GetShapeTable(string themeName)
        {
            // Use a lazy initialized factory to prevent multiple threads from building
            // the same table in parallel as it is costly
            return _shapeTables.GetOrAdd(themeName ?? "", new Lazy<ShapeTable>(() =>
               {
               _logger.LogInformation("Start building shape table");

               IList<IReadOnlyList<ShapeAlteration>> alterationSets = new List<IReadOnlyList<ShapeAlteration>>();
               foreach (var bindingStrategy in _bindingStrategies)
               {
                   Feature strategyDefaultFeature =
                       _typeFeatureProvider.GetFeatureForDependency(bindingStrategy.GetType());

                   var builder = new ShapeTableBuilder(strategyDefaultFeature);
                   bindingStrategy.Discover(builder);
                   var builtAlterations = builder.BuildAlterations().ToReadOnlyCollection();
                   if (builtAlterations.Any())
                   {
                       alterationSets.Add(builtAlterations);
                   }
               }

               var alterations = alterationSets
               .SelectMany(shapeAlterations => shapeAlterations)
               .Where(alteration => IsModuleOrRequestedTheme(alteration, themeName))
               .OrderByDependenciesAndPriorities(AlterationHasDependency, GetPriority)
               .ToList();

               var descriptors = alterations.GroupBy(alteration => alteration.ShapeType, StringComparer.OrdinalIgnoreCase)
                   .Select(group => group.Aggregate(
                       new ShapeDescriptor { ShapeType = group.Key },
                       (descriptor, alteration) =>
                       {
                           alteration.Alter(descriptor);
                           return descriptor;
                       })).ToList();

               foreach (var descriptor in descriptors)
               {
                   foreach (var alteration in alterations.Where(a => a.ShapeType == descriptor.ShapeType).ToList())
                   {
                       var local = new ShapeDescriptor { ShapeType = descriptor.ShapeType };
                       alteration.Alter(local);
                       descriptor.BindingSources.Add(local.BindingSource);
                   }
               }

               var result = new ShapeTable
               {
                   Descriptors = descriptors.ToDictionary(sd => sd.ShapeType, StringComparer.OrdinalIgnoreCase),
                   Bindings = descriptors.SelectMany(sd => sd.Bindings).ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase),
               };

                //await _eventBus.NotifyAsync<IShapeTableEventHandler>(x => x.ShapeTableCreated(result));

                _logger.LogInformation("Done building shape table");
               return result;
               })).Value;
        }
開發者ID:alimohammad,項目名稱:Orchard2,代碼行數:60,代碼來源:DefaultShapeTableManager.cs

示例2: GetShapeTable

        public ShapeTable GetShapeTable(string themeName)
        {
            return _cacheManager.Get(themeName ?? "", x => {
                Logger.Information("Start building shape table");

                var alterationSets = _parallelCacheContext.RunInParallel(_bindingStrategies, bindingStrategy => {
                    Feature strategyDefaultFeature = bindingStrategy.Metadata.ContainsKey("Feature") ?
                                                               (Feature)bindingStrategy.Metadata["Feature"] :
                                                               null;

                    var builder = new ShapeTableBuilder(strategyDefaultFeature);
                    bindingStrategy.Value.Discover(builder);
                    return builder.BuildAlterations().ToReadOnlyCollection();
                });

                var alterations = alterationSets
                .SelectMany(shapeAlterations => shapeAlterations)
                .Where(alteration => IsModuleOrRequestedTheme(alteration, themeName))
                .OrderByDependenciesAndPriorities(AlterationHasDependency, GetPriority)
                .ToList();

                var descriptors = alterations.GroupBy(alteration => alteration.ShapeType, StringComparer.OrdinalIgnoreCase)
                    .Select(group => group.Aggregate(
                        new ShapeDescriptor { ShapeType = group.Key },
                        (descriptor, alteration) => {
                            alteration.Alter(descriptor);
                            return descriptor;
                        })).ToList();

                foreach(var descriptor in descriptors) {
                    foreach(var alteration in alterations.Where(a => a.ShapeType == descriptor.ShapeType).ToList()) {
                        var local = new ShapeDescriptor { ShapeType = descriptor.ShapeType };
                        alteration.Alter(local);
                        descriptor.BindingSources.Add(local.BindingSource);
                    }
                }

                var result = new ShapeTable {
                    Descriptors = descriptors.ToDictionary(sd => sd.ShapeType, StringComparer.OrdinalIgnoreCase),
                    Bindings = descriptors.SelectMany(sd => sd.Bindings).ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase),
                };

                _shapeTableEventHandlers.Invoke(ctx => ctx.ShapeTableCreated(result), Logger);

                Logger.Information("Done building shape table");
                return result;
            });
        }
開發者ID:dioptre,項目名稱:nkd,代碼行數:48,代碼來源:DefaultShapeTableManager.cs

示例3: GetAlterationBuilders

 static IEnumerable<ShapeAlteration> GetAlterationBuilders(IShapeTableProvider strategy) {
     var builder = new ShapeTableBuilder(null);
     strategy.Discover(builder);
     return builder.BuildAlterations();
 }
開發者ID:Higea,項目名稱:Orchard,代碼行數:5,代碼來源:ShapeAttributeBindingStrategyTests.cs

示例4: GetShapeTable

        public ShapeTable GetShapeTable(string themeName)
        {
            var cacheKey = $"ShapeTable:{themeName}";

            ShapeTable shapeTable;
            if (!_memoryCache.TryGetValue(cacheKey, out shapeTable))
            {

                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("Start building shape table");
                }
                IList<IReadOnlyList<ShapeAlteration>> alterationSets = new List<IReadOnlyList<ShapeAlteration>>();
                foreach (var bindingStrategy in _bindingStrategies)
                {
                    Feature strategyDefaultFeature =
                        _typeFeatureProvider.GetFeatureForDependency(bindingStrategy.GetType());

                    var builder = new ShapeTableBuilder(strategyDefaultFeature);
                    bindingStrategy.Discover(builder);
                    var builtAlterations = builder.BuildAlterations().ToReadOnlyCollection();
                    if (builtAlterations.Any())
                    {
                        alterationSets.Add(builtAlterations);
                    }
                }

                var alterations = alterationSets
                .SelectMany(shapeAlterations => shapeAlterations)
                .Where(alteration => IsModuleOrRequestedTheme(alteration, themeName))
                .OrderByDependenciesAndPriorities(AlterationHasDependency, GetPriority)
                .ToList();

                var descriptors = alterations.GroupBy(alteration => alteration.ShapeType, StringComparer.OrdinalIgnoreCase)
                    .Select(group => group.Aggregate(
                        new ShapeDescriptor { ShapeType = group.Key },
                        (descriptor, alteration) =>
                        {
                            alteration.Alter(descriptor);
                            return descriptor;
                        })).ToList();

                foreach (var descriptor in descriptors)
                {
                    foreach (var alteration in alterations.Where(a => a.ShapeType == descriptor.ShapeType).ToList())
                    {
                        var local = new ShapeDescriptor { ShapeType = descriptor.ShapeType };
                        alteration.Alter(local);
                        descriptor.BindingSources.Add(local.BindingSource);
                    }
                }

                shapeTable = new ShapeTable
                {
                    Descriptors = descriptors.ToDictionary(sd => sd.ShapeType, StringComparer.OrdinalIgnoreCase),
                    Bindings = descriptors.SelectMany(sd => sd.Bindings).ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase),
                };

                //await _eventBus.NotifyAsync<IShapeTableEventHandler>(x => x.ShapeTableCreated(result));

                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("Done building shape table");
                }

                _memoryCache.Set(cacheKey, shapeTable, new MemoryCacheEntryOptions { Priority = CacheItemPriority.NeverRemove });
            }

            return shapeTable;
        }
開發者ID:adwardliu,項目名稱:Orchard2,代碼行數:70,代碼來源:DefaultShapeTableManager.cs


注:本文中的Orchard.DisplayManagement.Descriptors.ShapeTableBuilder.BuildAlterations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。