Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tbm0115/dictionary handling #25

Merged
merged 2 commits into from
Jul 31, 2023
Merged

Conversation

tbm0115
Copy link
Member

@tbm0115 tbm0115 commented Jul 26, 2023

Allow the processing of Dictionary<string,> and List<> properties within the IAdapterDataModel. For example:

public sealed class Model : IAdapterDataModel
{
  [Event("avail")]
  public Availability Availability { get; set; }
  
  [DataItemPartial("path_")]
  public Dictionary<string, Path> Paths { get; set; } = new Dictionary<string, Path>();
}

public sealed class path : IAdapterDataModel
{
  [Event("exec")]
  public Execution Execution { get; set; } = new Execution();
}

public static void Main()
{
  var model = new Model();
  model.Paths.Add("primary", new Path());
  model.Paths.Add("secondary", new Path());
}

This will result in three data items: avail, path_primaryexec, path_secondaryexec.

tbm0115 added 2 commits July 21, 2023 14:51
Added logic to detect `Dictionary<string, T>` and `List<T>` properties for more complex data models
@tbm0115 tbm0115 added the enhancement New feature or request label Jul 26, 2023
@tbm0115 tbm0115 self-assigned this Jul 26, 2023
@@ -258,14 +359,79 @@ private static bool TryUpdateValues(this Adapter adapter, object model, string d
switch (dataItemAttribute)
{
case DataItemPartialAttribute _:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this switch case to me. I'm trying to understand your notation here.....case DataItemPartialAttribute _:

Copy link

@jmurphy2973 jmurphy2973 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some notation i'd like to understand better

@jmurphy2973 jmurphy2973 added this pull request to the merge queue Jul 31, 2023
Merged via the queue into master with commit 65fc5ed Jul 31, 2023
@jmurphy2973 jmurphy2973 deleted the tbm0115/DictionaryHandling branch July 31, 2023 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants