private IRegion Build(IModule module, IComponent assetsComponent, IRegionDefinition regionDefinition) { return(regionDefinition .AssetDeployment(AssetDeployment.PerModule) .DeployIn(module) .NeedsComponent("libraries:Vue") .NeedsComponent("ajax:ajax") .NeedsComponent("data:data") .NeedsComponent("templates:library") .NeedsComponent("liveUpdateClient") .NeedsComponent(assetsComponent) .Build()); }
public void Configure(IRegionDefinition region, AttributeSet attributes) { if (ReferenceEquals(region, null)) { return; } var validationErrros = _attributeMatrix.Validate <IRegionDefinition>(attributes); if (validationErrros != null) { var message = "There are invalid attributes on region of type " + region.GetType().DisplayName(); if (attributes.IsRegion != null && string.IsNullOrEmpty(attributes.IsRegion.Name)) { message += " called '" + attributes.IsRegion.Name + "'."; } foreach (var error in validationErrros) { message += Environment.NewLine + error; } throw new RegionBuilderException(message); } if (!ReferenceEquals(attributes.IsRegion, null)) { region.Name(attributes.IsRegion.Name); } if (!ReferenceEquals(attributes.NeedsDatas, null)) { foreach (var dataNeed in attributes.NeedsDatas) { if (!string.IsNullOrEmpty(dataNeed.DataProviderName)) { region.DataProvider(dataNeed.DataProviderName); } if (dataNeed.DataType != null) { region.BindTo(dataNeed.DataType, dataNeed.Scope); } } } if (!ReferenceEquals(attributes.PartOf, null)) { region.PartOf(attributes.PartOf.PackageName); } if (!ReferenceEquals(attributes.DeployedAs, null)) { region .DeployIn(attributes.DeployedAs.ModuleName) .AssetDeployment(attributes.DeployedAs.Deployment); } if (!ReferenceEquals(attributes.NeedsComponents, null)) { foreach (var need in attributes.NeedsComponents) { region.NeedsComponent(need.ComponentName); } } var contentSpecified = false; if (!ReferenceEquals(attributes.UsesLayout, null)) { region.Layout(attributes.UsesLayout.LayoutName); contentSpecified = true; } if (!ReferenceEquals(attributes.UsesTemplate, null)) { if (contentSpecified) { throw new FluentBuilderException( "A region can contain either a layout, a component, static Html or a template. " + "You can not have more than one of these things on region " + attributes.Type.DisplayName()); } region.Template(attributes.UsesTemplate.TemplatePath); contentSpecified = true; } if (!ReferenceEquals(attributes.UsesComponents, null) && attributes.UsesComponents.Count > 0) { if (contentSpecified) { throw new FluentBuilderException( "A region can contain either a layout, a component, static Html or a template. " + "You can not have more than one of these things on region " + attributes.Type.DisplayName()); } if (attributes.UsesComponents.Count > 1) { throw new FluentBuilderException( "The " + attributes.Type.DisplayName() + " region can not have more than one component." + "To have multiple content areas within a region, define a Layout and put it into the region."); } region.Component(attributes.UsesComponents[0].ComponentName); contentSpecified = true; } if (attributes.RenderHtmls != null && attributes.RenderHtmls.Count > 0) { if (contentSpecified) { throw new FluentBuilderException( "A region can contain either a layout, a component, static Html or a template. " + "You can not have more than one of these things on region " + attributes.Type.DisplayName()); } if (attributes.RenderHtmls.Count > 1) { throw new RegionBuilderException("You can only attach one [RenderHtml] attribute to region. For " + "more complex use cases please define a Component and attach it to the region. There are multiple " + "[RenderHtml] attributes on " + attributes.Type.DisplayName()); } var attribute = attributes.RenderHtmls[0]; region.Html(attribute.TextName, attribute.Html); } if (!ReferenceEquals(attributes.DataScopes, null)) { foreach (var dataScope in attributes.DataScopes) { region.DataScope(dataScope.DataType, dataScope.Scope); } } if (!ReferenceEquals(attributes.Container, null)) { region .Tag(attributes.Container.Tag) .ClassNames(attributes.Container.ClassNames); } if (!ReferenceEquals(attributes.Style, null)) { region.Style(attributes.Style.CssStyle); } if (!ReferenceEquals(attributes.Repeat, null)) { region.ForEach( attributes.Repeat.RepeatType, attributes.Repeat.RepeatScope, attributes.Repeat.ChildTag, attributes.Repeat.ChildStyle, attributes.Repeat.ListScope, attributes.Repeat.ChildClassNames); } }