Exemplo n.º 1
0
        internal INodeDetail ToNodeDetail(ModuleJson module, IContainer nodeContainer, SchemaVariables nodeVariables)
        {
            Validation.Validate(Path is null ^ FormatPaths is null,
                                "Exactly one of Path and FormatPaths must be specified");

            if (Path is object)
            {
                var container = nodeContainer.ResolveContainer(nodeVariables.Replace(Path));
                return(container is FieldContainer fc
                    ? new FieldContainerNodeDetail(Description, fc)
                    : throw new ArgumentException($"'{Path}' does not resolve to a field container"));
            }
            else
            {
                var formattableFields = module.GetRepeatSequence(Repeat, SchemaVariables.Empty)
                                        .ToReadOnlyList(tuple => FieldFormattableString.Create(nodeContainer, Format, FormatPaths, tuple.variables));
                return(new ListNodeDetail(Description, formattableFields));
            }
        }
 public DataFieldFormattableString(ModuleData data, FieldFormattableString formattable)
 {
     fields       = formattable.FormatPaths.ToReadOnlyList(path => data.GetDataField(formattable.Container.ResolveField(path)));
     formatString = formattable.FormatString;
 }
 public DataFieldFormattableString(ModuleData data, FieldFormattableString formattable)
 {
     fields = formattable.Fields?.ToReadOnlyList(pair => data.GetDataField(pair.container, pair.field))
              ?? new DataFieldBase[0];
     formatString = formattable.FormatString;
 }