protected async Task BindPlacementAsync(IBuildShapeContext context) { var theme = await _themeManager.GetThemeAsync(); var shapeTable = _shapeTableManager.GetShapeTable(theme.Id); context.FindPlacement = (shape, differentiator, displayType) => FindPlacementImpl(shapeTable, shape, differentiator, displayType); }
protected async Task BindPlacementAsync(IBuildShapeContext context) { var theme = await _themeManager.GetThemeAsync(); var shapeTable = _shapeTableManager.GetShapeTable(theme.Id); context.FindPlacement = (partShapeType, differentiator, displayType) => { ShapeDescriptor descriptor; if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) { var placementContext = new ShapePlacementContext { Shape = context.Shape }; var placement = descriptor.Placement(placementContext); if (placement != null) { placement.Source = placementContext.Source; return placement; } } return null; }; }
protected async Task BindPlacementAsync(IBuildShapeContext context) { var theme = await _themeManager.GetThemeAsync(); var shapeTable = _shapeTableManager.GetShapeTable(theme.Id); context.FindPlacement = (partShapeType, differentiator, displayType) => { ShapeDescriptor descriptor; if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) { var placementContext = new ShapePlacementContext { Shape = context.Shape }; var placement = descriptor.Placement(placementContext); if (placement != null) { placement.Source = placementContext.Source; return(placement); } } return(null); }; }
protected async Task BindPlacementAsync(IBuildShapeContext context) { var theme = await _themeManager.GetThemeAsync(); var shapeTable = _shapeTableManager.GetShapeTable(theme.Id); context.FindPlacement = (partShapeType, differentiator, defaultLocation) => { ShapeDescriptor descriptor; if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) { var placementContext = new ShapePlacementContext { Shape = context.Shape }; // define which location should be used if none placement is hit descriptor.DefaultPlacement = defaultLocation; var placement = descriptor.Placement(placementContext); if (placement != null) { placement.Source = placementContext.Source; return placement; } } return new PlacementInfo { Location = defaultLocation, Source = String.Empty }; }; }
protected async Task BindPlacementAsync(IBuildShapeContext context) { var theme = await _themeManager.GetThemeAsync(); var shapeTable = _shapeTableManager.GetShapeTable(theme.Id); context.FindPlacement = (shapeType, differentiator, displayType, displayContext) => FindPlacementImpl(shapeTable, shapeType, differentiator, displayType, context); }
protected async Task BindPlacementAsync(IBuildShapeContext context) { var theme = await _themeManager.GetThemeAsync(); // If there is no active theme, do nothing if (theme == null) { return; } var shapeTable = _shapeTableManager.GetShapeTable(theme.Id); context.FindPlacement = (shapeType, differentiator, displayType, displayContext) => FindPlacementImpl(shapeTable, shapeType, differentiator, displayType, context); }
public async Task <IPlacementInfoResolver> BuildPlacementInfoResolverAsync(IBuildShapeContext context) { var theme = await _themeManager.GetThemeAsync(); // If there is no active theme, do nothing if (theme == null) { return(null); } var shapeTable = _shapeTableManager.GetShapeTable(theme.Id); return(new ShapeTablePlacementResolver(shapeTable)); }
protected async Task BindPlacementAsync(IBuildShapeContext context) { var resolvers = new List <IPlacementInfoResolver>(); foreach (var provider in _placementProviders) { var resolver = await provider.BuildPlacementInfoResolverAsync(context); if (resolver != null) { resolvers.Add(resolver); } } context.FindPlacement = (shapeType, differentiator, displayType, displayContext) => FindPlacementImpl(resolvers, shapeType, differentiator, displayType, context); }
private static PlacementInfo FindPlacementImpl(ShapeTable shapeTable, string shapeType, string differentiator, string displayType, IBuildShapeContext context) { ShapeDescriptor descriptor; if (shapeTable.Descriptors.TryGetValue(shapeType, out descriptor)) { var placementContext = new ShapePlacementContext( shapeType, displayType, differentiator, context.Shape ); var placement = descriptor.Placement(placementContext); if (placement != null) { placement.Source = placementContext.Source; return(placement); } } return(null); }
private static PlacementInfo FindPlacementImpl(IList <IPlacementInfoResolver> placementResolvers, string shapeType, string differentiator, string displayType, IBuildShapeContext context) { var delimiterIndex = shapeType.IndexOf("__", StringComparison.Ordinal); if (delimiterIndex > 0) { shapeType = shapeType.Substring(0, delimiterIndex); } var placementContext = new ShapePlacementContext( shapeType, displayType, differentiator, context.Shape ); return(placementResolvers.Aggregate <IPlacementInfoResolver, PlacementInfo>(null, (prev, resolver) => PlacementInfoExtensions.Combine(prev, resolver.ResolvePlacement(placementContext)) )); }
private static PlacementInfo FindDefaultPlacement(string shapeType, string differentiator, string displayType, IBuildShapeContext context) { return(null); }
private PlacementInfo?FindDefaultPlacement( string shapeType, string?differentiator, string?displayType, IBuildShapeContext context) => default;
private static PlacementInfo FindPlacementImpl(ShapeTable shapeTable, string shapeType, string differentiator, string displayType, IBuildShapeContext context) { var delimiterIndex = shapeType.IndexOf("__"); if (delimiterIndex > 0) { shapeType = shapeType.Substring(0, delimiterIndex); } if (shapeTable.Descriptors.TryGetValue(shapeType, out var descriptor)) { var placementContext = new ShapePlacementContext( shapeType, displayType, differentiator, context.Shape ); var placement = descriptor.Placement(placementContext); if (placement != null) { placement.Source = placementContext.Source; return(placement); } } return(null); }
public async Task <IPlacementInfoResolver> BuildPlacementInfoResolverAsync(IBuildShapeContext context) { var placements = await _placementsManager.ListShapePlacementsAsync(); return(new PlacementInfoResolver(placements, _placementNodeFilterProviders)); }