IVSoftware.Portable.Xml.Linq.XBoundObject
1.1.0-prerelease
dotnet add package IVSoftware.Portable.Xml.Linq.XBoundObject --version 1.1.0-prerelease
NuGet\Install-Package IVSoftware.Portable.Xml.Linq.XBoundObject -Version 1.1.0-prerelease
<PackageReference Include="IVSoftware.Portable.Xml.Linq.XBoundObject" Version="1.1.0-prerelease" />
paket add IVSoftware.Portable.Xml.Linq.XBoundObject --version 1.1.0-prerelease
#r "nuget: IVSoftware.Portable.Xml.Linq.XBoundObject, 1.1.0-prerelease"
// Install IVSoftware.Portable.Xml.Linq.XBoundObject as a Cake Addin #addin nuget:?package=IVSoftware.Portable.Xml.Linq.XBoundObject&version=1.1.0-prerelease&prerelease // Install IVSoftware.Portable.Xml.Linq.XBoundObject as a Cake Tool #tool nuget:?package=IVSoftware.Portable.Xml.Linq.XBoundObject&version=1.1.0-prerelease&prerelease
XBoundAttribute
A lightweight extension for System.Xml.Linq
that provides a Tag
property for XAttribute
, enabling runtime object storage and action binding.
Overview
XBoundAttribute enhances XAttribute
by introducing a runtime-only Tag
property, allowing attributes to store and retrieve objects in a type-safe manner using xel.To<T>()
. This makes XML more dynamic and interactive without altering its structure.
While the Tag
property can be visualized in-memory (e.g., when printed), it is not intended to be serializable. That is, objects attached at runtime are not reconstructed when the file is read back.
Features
- Extended XAttribute Functionality � Introduces a
Tag
property forXAttribute
, enabling metadata enrichment. - Runtime Object Storage � Attach arbitrary objects to XML attributes at runtime for flexible data management.
- Action Binding � Store and invoke actions associated with XML attributes, facilitating event-driven XML processing.
- Enhanced XML Processing � Ideal for scenarios requiring richer, context-aware attributes, such as serialization, templating, and dynamic transformations.
Use Cases
- Dynamic XML Metadata � Store additional information within attributes without modifying XML structures.
- Templating & Transformation � Bind runtime behaviors to XML attributes for dynamic rendering.
- Workflow & Event Binding � Attach callbacks to attributes, enabling event-driven XML interactions.
XBoundAttribute bridges the gap between XML structures and runtime logic, making XML more powerful and adaptive in modern applications.
XBound Object Extensions
/// <summary>
/// Fully qualified XBoundAttribute Setter
/// </summary>
public static void SetBoundAttributeValue(
this XElement xel,
object tag,
string name = null,
string text = null,
SetOption options = SetOption.NameToLower){...}
/// <summary>
/// Name supplied by user-defined standard enumerated names.
/// </summary>
public static void SetBoundAttributeValue(
this XElement xel,
object tag,
Enum stdName,
string text = null,
SetOption options = SetOption.NameToLower){...}
/// <summary>
/// Return Single or Default where type is T. Null testing will be done by client.
/// </summary>
public static T To<T>(this XElement xel, bool @throw = false){...}
/// <summary>
/// Return true if xel has any attribute of type T"/>
/// </summary>
public static bool Has<T>(this XElement xel){...}
Nested Enum Extensions
/// <summary>
/// Retrieves all descendant enum values related to the specified enum type.
/// This method identifies hierarchical relationships among "flat" enum groups
/// by searching for other enums that share names with the current enum values.
/// </summary>
public static IEnumerable<Enum> Descendants(
this Type type,
DiscoveryScope options = DiscoveryScope.ConstrainToAssembly | DiscoveryScope.ConstrainToNamespace){... }
/// <summary>
/// Constructs a hierarchical XML representation of an enum and its related enums,
/// effectively mapping "flat" enum structures into a nested format.
/// </summary>
public static XElement BuildNestedEnum(
this Type type,
DiscoveryScope options = DiscoveryScope.ConstrainToAssembly | DiscoveryScope.ConstrainToNamespace,
string root = "root"){...}
/// <summary>
/// Generates a fully qualified string representation of an enum value,
/// including its type name and value.
/// </summary>
public static string ToFullKey(this Enum @this){...}
Examples
Build Nested Enum Example
Convert a set of flat enumerations and turn it into a runtime hierarchy.
XBound Clickable Objects
Using xroot
from the prior example, iterate the XML, attach a clickable object to each node then use the ID to fire its click event.
Dual Key Lookup
When an Enum type is expanded to an XML hierarchy, a two way lookup is xbound to the root node. A typical flow might be:
- Use the
enum
"Friendly Name" to look up anXElement
to which other objects are bound. - Use the
To<T>()
extension to retrieve objects or actions to perform.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|