Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tallesl/net-xpando
Utilities for dealing with ExpandoObject.
https://github.com/tallesl/net-xpando
csharp dot-net dynamic expandoobject nuget
Last synced: 3 months ago
JSON representation
Utilities for dealing with ExpandoObject.
- Host: GitHub
- URL: https://github.com/tallesl/net-xpando
- Owner: tallesl
- Created: 2015-08-18T17:00:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-02T20:33:43.000Z (about 7 years ago)
- Last Synced: 2024-11-05T05:07:32.551Z (3 months ago)
- Topics: csharp, dot-net, dynamic, expandoobject, nuget
- Language: C#
- Homepage:
- Size: 312 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Xpando
[![][build-img]][build]
[![][nuget-img]][nuget]Utilities for dealing with [ExpandoObject].
[build]: https://ci.appveyor.com/project/TallesL/net-xpando
[build-img]: https://ci.appveyor.com/api/projects/status/github/tallesl/net-xpando?svg=true
[nuget]: https://www.nuget.org/packages/Xpando
[nuget-img]: https://badge.fury.io/nu/Xpando.svg
[ExpandoObject]: https://msdn.microsoft.com/library/System.Dynamic.ExpandoObject## Converting an object
```cs
using XpandoLibrary;var boringUser = new { Name ="John Smith" };
dynamic coolUser = boringUser.ToExpando(); // does the magiccoolUser.NickName = "Johny";
```## Checking if has any property
```cs
using XpandoLibrary;var expando = new ExpandoObject();
dynamic dynamic = expando;expando.Empty(); // True
dynamic.Foo = "Bar";
expando.Empty(); // False
```## Checking if has a specific property
```cs
using XpandoLibrary;var expando = new ExpandoObject();
dynamic dynamic = expando;dynamic.Foo = "Bar";
expando.HasProperty("Foo"); // True
expando.HasProperty("Qux"); // False
```## Removing a property
```cs
using XpandoLibrary;var expando = new ExpandoObject();
dynamic dynamic = expando;dynamic.Foo = "Bar"; // creates the property
expando.RemoveProperty("Foo"); // removes the property
```## Making a copy
```cs
using XpandoLibrary;var expando = new ExpandoObject();
// (some initialization with nested ExpandoObject)
expando.ShallowCopy(); // creates a shallow copy of object (doesn't copy nested ExpandoObject)
expando.DeepCopy(); // creates a deep copy of object (copies nested ExpandoObject)
```