API Reference
ValueShaper
The one model of what a value is, shared by every view (tables, lists, cards, trees, JSON, the automatic view and the object comparison): whether it is a scalar, a record or a collection, which fields a record has, how a value is written inside a cell or a title, and how nested records flatten. A type is supported once here and works everywhere. Records are read through adapters in this order: adapters registered with , the built-in data adapters (dictionaries, data rows, XML elements, JSON objects and nodes, files and folders, dictionary entries), , then reflection over public properties when allows it. Shapers registered with or turn a value into another one first (for example an object into an ordered dictionary of the fields worth showing).
Inheritance
- Object
- ValueShaper
Methods
public static Object? Cell(Object? value, ShapeOptions? options = null, ShapeBudget? budget = null) #Object?The value a table cell holds for value: scalars stay typed (so presenters format numbers, dates and Booleans), secure strings and byte arrays become their safe text, collections, dictionaries and records become one line of text (see ValueShaper.Text), an empty collection a muted dash, a failed getter a warning marker.
Parameters
- value System.Object?
- The value.
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
- budget ConsoleMonster.Values.ShapeBudget? = null
- The pass budget, or null.
Returns
A scalar, a string or a TableCell.
public static IReadOnlyList<InspectMember> Fields(Object record, ShapeOptions? options = null) #IReadOnlyList<InspectMember>The fields of a record, in display order: a Hashtable's keys sorted, other dictionaries in their own order, columns of a data row, attributes and child elements of an XML element, properties of an object. Plumbing members of objects (ValueShaper.IsPlumbing) are left out; dictionary keys and data columns are data and always kept.
Parameters
- record System.Object
- The record (prepared).
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
Returns
The fields (values are read lazily), or an empty list when the value is not a record.
public static IMemberSource? FindAdapter(Object value, ShapeOptions options) #IMemberSource?The adapter that reads a record's fields, or null when the value has none.
Parameters
- value System.Object
- The value (prepared).
- options ConsoleMonster.Values.ShapeOptions
- Options.
Returns
The adapter, or null.
public static IReadOnlyList<KeyValuePair<String, Object?>> Flatten(Object record, Int32 depth, ShapeOptions? options = null, ShapeBudget? budget = null) #IReadOnlyList<KeyValuePair<String, Object?>>The fields of a record with nested records spread into dotted names (Owner.Name, Owner.Id) down to depth levels. Collections stay one value; a record seen again on the way down becomes (cycle).
Parameters
- record System.Object
- The record.
- depth System.Int32
- How many levels of nesting to spread (1 = one level).
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
- budget ConsoleMonster.Values.ShapeBudget? = null
- The pass budget, or null.
Returns
The dotted names and values.
public static Boolean IsPlumbing(String name) #BooleanWhether a member name is plumbing (provider paths, CIM metadata, collection synchronisation, DOM links).
Parameters
- name System.String
- The member name.
Returns
True for plumbing.
public static Boolean IsScalar(Object? value) #BooleanWhether a value is shown as one value: ObjectInspector.IsScalarValue plus secure strings.
Parameters
- value System.Object?
- The value (already prepared).
Returns
True for a scalar.
public static Boolean IsStructural(Object? value) #BooleanWhether a value is read by a built-in data adapter (a dictionary, data row, XML element, JSON object or node, file or folder, dictionary entry) or is a data table or view: its keys or columns are its fields, whatever wraps it.
Parameters
- value System.Object?
- The value (unwrapped).
Returns
True for a structural value.
public static Object? Prepare(Object? value, ShapeOptions? options = null) #Object?The value to show for value: wrappers unwrapped, registered shapers applied, an XML document as its root element, a text-only XML element as its text, JSON scalars as .NET scalars and DBNull as null.
Parameters
- value System.Object?
- The value.
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
Returns
The prepared value.
public static Object? Read(InspectMember member, ShapeBudget? budget = null) #Object?Reads one field: the value, a FieldError when the getter throws, or BudgetExceeded once the budget is spent.
Parameters
- member ConsoleMonster.Data.InspectMember
- The field.
- budget ConsoleMonster.Values.ShapeBudget? = null
- The pass budget, or null for none.
Returns
The value or a marker.
public static Void Register(Type type, Func<Object, Object?> shaper) #VoidRegisters a shaper for a type (and types derived from it): values of that type are replaced by what it returns before they are shown.
Parameters
- type System.Type
- The type.
- shaper System.Func<System.Object, System.Object?>
- Returns the value to show instead (for example an ordered dictionary), or the value itself.
public static Void Register(String typeName, Func<Object, Object?> shaper) #VoidRegisters a shaper for a type name: the full name of the value's type or a base type, or any name ShapeOptions.TypeNames reports (PowerShell type names, so deserialized objects can opt in).
Parameters
- typeName System.String
- The type name.
- shaper System.Func<System.Object, System.Object?>
- Returns the value to show instead.
public static Void RegisterAdapter(IMemberSource adapter) #VoidRegisters a record adapter, tried before the built-in ones.
Parameters
- adapter ConsoleMonster.Data.IMemberSource
- The adapter.
public static Void Register<T>(Func<T, Object?> shaper) #VoidRegisters a shaper for T.
Type Parameters
- T
- The type.
Parameters
- shaper System.Func<T, System.Object?>
- Returns the value to show instead.
public static String ScalarText(Object? value, ShapeOptions? options = null) #StringA scalar as text: secure strings masked, byte arrays as their size, dates as yyyy-MM-dd HH:mm in local time (as tables show them), numbers and the rest in the culture.
Parameters
- value System.Object?
- The scalar.
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
Returns
The text.
public static ValueShape ShapeOf(Object? value, ShapeOptions? options = null) #ValueShapeWhat value is for display: empty, scalar, record or collection.
Parameters
- value System.Object?
- The value.
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
Returns
The shape.
public static String Text(Object? value, ShapeOptions? options = null, ShapeBudget? budget = null) #StringA value as one line of text, as it appears inside a cell, a title or a joined list: scalars in the culture, collections by ShapeOptions.Collections, a dictionary as Key=Value pairs, another record as its title, a secure string as ValueShaper.SecureText, a byte array as its size.
Parameters
- value System.Object?
- The value.
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
- budget ConsoleMonster.Values.ShapeBudget? = null
- The pass budget, or null.
Returns
The text.
public static String Title(Object record, ShapeOptions? options = null, ShapeBudget? budget = null, Boolean withId = true) #StringThe title of a record: the first name-like field (see ValueShaper.TitleIndex) with a short text value, then the first short text field, never a Boolean, date, number (except an Id or Key), collection or nested record; the type name when nothing qualifies. With withId, an Id next to a name is added: pwsh (90836).
Parameters
- record System.Object
- The record (prepared).
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
- budget ConsoleMonster.Values.ShapeBudget? = null
- The pass budget, or null.
- withId System.Boolean = true
- Whether to add the Id after a name.
Returns
The title.
public static Int32 TitleIndex(IReadOnlyList<String> names) #Int32The index of the field that titles a record, by name: Name, DisplayName, the first other …Name (ProcessName, ServiceName, SamAccountName), then Title, Label, Caption, Key, Id, Identity.
Parameters
- names System.Collections.Generic.IReadOnlyList<System.String>
- The field names.
Returns
The index, or -1 when no name qualifies.
public static Boolean TryGetField(Object record, String name, out Object? value, ShapeOptions? options = null, ShapeBudget? budget = null) #BooleanReads a named field of a record, preferring exact spelling before a case-insensitive match, or returns false when absent.
Parameters
- record System.Object
- The record (prepared).
- name System.String
- The field name.
- value System.Object?
- The value or a marker (see ValueShaper.Read).
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
- budget ConsoleMonster.Values.ShapeBudget? = null
- The pass budget, or null.
Returns
True when the field exists.
public static Boolean TryGetItems(Object? value, out IEnumerable? items) #BooleanThe items of a collection: arrays, lists and other sequences (never a string, a dictionary, a byte array or an XML node), a data table's rows, a data set's tables and a JSON array's values.
Parameters
- value System.Object?
- The value (prepared).
- items System.Collections.IEnumerable?
- The items.
Returns
True for a collection.
public static String TypeName(Object value, ShapeOptions? options = null) #StringA short type name for a value: the adapter's name, an XML element's tag, or the .NET type name.
Parameters
- value System.Object
- The value (prepared).
- options ConsoleMonster.Values.ShapeOptions? = null
- Options, or null.
Returns
The name.
public static Boolean Unregister(String typeName) #BooleanRemoves the shaper registered for a type name.
Parameters
- typeName System.String
- The type name.
Returns
True when one was removed.
public static Boolean Unregister(Type type) #BooleanRemoves the shaper registered for a type.
Parameters
- type System.Type
- The type.
Returns
True when one was removed.
public static Boolean UnregisterAdapter(IMemberSource adapter) #BooleanRemoves a registered record adapter.
Parameters
- adapter ConsoleMonster.Data.IMemberSource
- The adapter.
Returns
True when it was removed.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
Fields
public const String SecureText #The text a secure string is shown as: never its content or length.
••••••