New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

Shadow.Quack.Xml

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Shadow.Quack.Xml

Shadow.Quack IProxy Implementation for initialisation from an XML string

nugetNuGet
Version
1.4.1
Version published
Maintainers
1
Created
Source

Shadow Quack XML

This package allows the easy population of values directly from a XML string to a dynamically implemented immutable interface with the help of the base Shadow Quack package.

This means that there is almost no effort in deserialising from XML to an interface with no need for concrete implementations or additional code.

Dictionary Example

public interface IWithSimpleDictionary 
{
    public IDictionary<int, string> TestDic { get; }
}
XmlProxy source = @"
<xml>
  <TestDic>
    <Item>
      <Key>1</Key>
      <Value>One</Value>
    </Item>
    <Item>
      <Key>2</Key>
      <Value>Two</Value>
    </Item>
  </TestDic>
</xml>";
var target = Duck.Implement<IWithSimpleDictionary>(source);

Examples

Interface

public interface ITestTarget
{ 
    public IAddress Address { get; }
    public ITestTargetSub Sub { get; }
    public ICustomer Customer { get; }
    public string Name { get;  }
    public int Number { get;  }
    public IEnumerable<string> Hobbies { get; }
    public IEnumerable<ITestTargetSub> Subs { get; }
    public IEnumerable<IAddress> Addresses { get; }
    public IEnumerable<int> Ids { get; }
}

public interface ITestTargetSub
{
    string Name { get; }
}

public interface IAddress
{
}

public interface ICustomer
{
    IEmployment Employment { get; }
    string CustomerType { get; }
}

public interface IEmployment
{
    string Employer { get; }
}

IEnumerable Example

XmlProxy source = @"
<xml>
  <Name>NameValue</Name>
  <number>10</number>
  <Hobbies>
    <Item>Item1</Item>
    <Item>item2</Item>
  </Hobbies>
</xml>";
var target = Duck.Implement<ITestTarget>(source);

IEnumerable<T> Example

XmlProxy source = @"
<xml>
  <Name>NameValue</Name>
  <number>10</number>
  <Subs>
    <Item>
      <Name>Value1</Name>
    </Item>
    <Item>
      <Name>Value2</Name>
    </Item>
  </Subs>
</xml>";
var target = Duck.Implement<ITestTarget>(source);

Sub Interface Example

XmlProxy source = @"
<xml>
  <Name>NameValue</Name>
  <number>10</number>
  <Customer>
    <CustomerType>Value2</CustomerType>
    <Employment>
      <Employer>Employer</Employer>
    </Employment>
  </Customer>
</xml>";
var target = Duck.Implement<ITestTarget>(source);

Keywords

Duck-Type

FAQs

Package last updated on 05 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts