Skip to content

Commit

Permalink
add - doc - Added ArgumentValues dictionary
Browse files Browse the repository at this point in the history
---

We've added an easy way to get a key/value representation of arguments for easier visualization.

---

Type: add
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Apr 1, 2024
1 parent c8cd409 commit 6d82772
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions VisualCard/Parts/BaseCardPartInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using VisualCard.Parsers;

namespace VisualCard.Parts
{
Expand Down Expand Up @@ -50,6 +52,31 @@ public abstract class BaseCardPartInfo : IEquatable<BaseCardPartInfo>
/// </summary>
public virtual string ValueType { get; internal set; }

/// <summary>
/// Arguments in key/value pair format
/// </summary>
public ReadOnlyDictionary<string, string> ArgumentValues
{
get
{
// Check to see if we have an empty list of arguments
Dictionary<string, string> values = [];
if (Arguments is null || Arguments.Length == 0)
return new(values);

// Now, separate a key from a value
foreach (var arg in Arguments)
{
string key = arg.Substring(0, arg.IndexOf(VcardConstants._argumentValueDelimiter));
string value = arg.Substring(arg.IndexOf(VcardConstants._argumentValueDelimiter) + 1);
values.Add(key, value);
}

// Now, return a read-only dictionary
return new(values);
}
}

/// <summary>
/// Checks to see if both the parts are equal
/// </summary>
Expand Down

0 comments on commit 6d82772

Please sign in to comment.