예제 #1
0
        public Maybe <List <TagBuilder> > RenderHtmlFromItem(IConfigurationItemViewModel configurationItem,
                                                             SelectorForItemsGroup selectorForItemsGroup, int depthLevel = 0)
        {
            IRuntimePropertyViewModel defaultProperty = configurationItem as IRuntimePropertyViewModel;

            return(Maybe <List <TagBuilder> > .FromValue(new List <TagBuilder>()
            {
                ConfigTableRowRenderer
                .Create()
                .SetDepth(depthLevel)
                .SetName(new RenderData(defaultProperty.Header))
                .SetDeviceData(Result <string> .Create(() => defaultProperty.DeviceValue.AsString(),
                                                       defaultProperty.DeviceValue != null))
                .SetLocalData(Result <string> .Create(() => defaultProperty.LocalValue
                                                      .AsString(),
                                                      defaultProperty.LocalValue != null))
                .SetRange(Result <string> .Create(
                              $"[{defaultProperty.RangeViewModel.RangeFrom} : {defaultProperty.RangeViewModel.RangeTo}]",
                              defaultProperty.IsRangeEnabled))
                .SetMeasureUnit(Result <string> .Create(defaultProperty.MeasureUnit,
                                                        defaultProperty.IsMeasureUnitEnabled))
                .SetSelectors(selectorForItemsGroup.IsPrintDeviceValuesAllowed,
                              selectorForItemsGroup.IsPrintLocalValuesAllowed)
                .Render()
            }));
        }
예제 #2
0
        public Maybe <List <TagBuilder> > RenderHtmlFromItem(IConfigurationItemViewModel configurationItem,
                                                             SelectorForItemsGroup selectorForItemsGroup, int depthLevel = 0)
        {
            if (selectorForItemsGroup == null || !selectorForItemsGroup.IsSelected)
            {
                return(Maybe <List <TagBuilder> > .Empty());
            }

            var group = configurationItem as IItemGroupViewModel;
            List <TagBuilder> tagBuilders = new List <TagBuilder>
            {
                ConfigTableRowRenderer
                .Create()
                .SetName(new RenderData(group.Header, depthLevel == 0 ? "rootItem" : null))
                .SetDepth(depthLevel)
                .SetShouldRenderEmptyItems(depthLevel != 0)
                .SetSelectors(selectorForItemsGroup.IsPrintDeviceValuesAllowed, selectorForItemsGroup.IsPrintLocalValuesAllowed)
                .Render()
            };

            group.ChildStructItemViewModels.ForEach((item =>
            {
                _itemRendererFactory
                .GetConfigurationItemRenderer(item)
                .RenderHtmlFromItem(item,
                                    selectorForItemsGroup.Selectors.FirstOrDefault((itemsGroup =>
                                                                                    itemsGroup.RelatedItemsGroup == item)) ?? selectorForItemsGroup, depthLevel + 1)
                .OnNotEmpty(result => tagBuilders.AddRange(result));
            }));
            return(Maybe <List <TagBuilder> > .FromValue(tagBuilders));
        }
예제 #3
0
 public Maybe <List <TagBuilder> > RenderHtmlFromItem(IConfigurationItemViewModel configurationItem,
                                                      SelectorForItemsGroup selectorForItemsGroup = null, int depthLevel = 0)
 {
     return(Maybe <List <TagBuilder> > .FromValue(new List <TagBuilder>()
     {
         ConfigTableRowRenderer
         .Create()
         .SetDepth(depthLevel)
         .SetName(new RenderData(configurationItem.Header))
         .SetSelectors(selectorForItemsGroup.IsPrintDeviceValuesAllowed, selectorForItemsGroup.IsPrintLocalValuesAllowed)
         .Render()
     }));
 }