/// <summary> /// 应用。 /// </summary> /// <param name="descriptor">形状描述符。</param> public void Alter(ShapeDescriptor descriptor) { foreach (var configuration in _configurations) { configuration(descriptor); } }
public ShapeTable GetShapeTable(string themeName) { return(_cacheManager.Get(themeName ?? string.Empty, x => { Logger.Information("开始建立形状表格"); var alterationSets = _parallelCacheContext.RunInParallel(_bindingStrategies, bindingStrategy => { var strategyDefaultFeature = bindingStrategy.Metadata.ContainsKey("Feature") ? (Feature)bindingStrategy.Metadata["Feature"] : null; var builder = new ShapeTableBuilder(strategyDefaultFeature); bindingStrategy.Value.Discover(builder); return builder.BuildAlterations().ToArray(); }); 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("完成形状表格建立"); return result; })); }
public ShapeTable GetShapeTable(string themeName) { return _cacheManager.Get(themeName ?? string.Empty, x => { Logger.Information("开始建立形状表格"); var alterationSets = _parallelCacheContext.RunInParallel(_bindingStrategies, bindingStrategy => { var strategyDefaultFeature = bindingStrategy.Metadata.ContainsKey("Feature") ? (Feature)bindingStrategy.Metadata["Feature"] : null; var builder = new ShapeTableBuilder(strategyDefaultFeature); bindingStrategy.Value.Discover(builder); return builder.BuildAlterations().ToArray(); }); 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("完成形状表格建立"); return result; }); }