Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chappoo/metaex
MetaEx-tensions. Provides extensions for managing metadata on arbitrary POCO objects. Based heavily on the @ServiceStack UserAuth Meta implementation (uses ServiceStack.Text).
https://github.com/chappoo/metaex
Last synced: about 1 month ago
JSON representation
MetaEx-tensions. Provides extensions for managing metadata on arbitrary POCO objects. Based heavily on the @ServiceStack UserAuth Meta implementation (uses ServiceStack.Text).
- Host: GitHub
- URL: https://github.com/chappoo/metaex
- Owner: chappoo
- Created: 2013-07-15T06:33:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-15T09:48:44.000Z (over 11 years ago)
- Last Synced: 2023-03-29T03:39:36.436Z (almost 2 years ago)
- Language: C#
- Homepage:
- Size: 398 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
MetaEx
======MetaEx-tensions. Provides extensions for managing metadata on arbitrary POCO objects. Based heavily on the @ServiceStack UserAuth Meta implementation (uses ServiceStack.Text).
###What for?###
I found myself working with an ORM (no names mentioned) and wanting to extend a table type with various parameters. Rather than repeatedly writing database migration scripts and resyncing the (unmentioned) model every time a new parameter was required, I opted to create a string field in the database and manage a `Dictionary` approach with serialization, much like the simple implementation in @ServiceStack **UserAuth.Meta**.
This implementation provides a really simple approach for such use-cases.
Kudos to the guys at @ServiceStack for the core tech.
###Usage###
`IMeta` interface requires the Meta string field on the POCO. This field is then used with whatever persistence model you wish.
public class TestObjectWithMetaData : IMeta
{
public string Meta { get; set; }
}This hooks up a couple of extension methods on the POCO (via `IMeta`)
public static T GetMeta(this IMeta meta)
public static void SetMeta(this IMeta meta, T value)Allowing for use such as
var testObj = new TestObjectWithMetaData();
testObj.SetMeta(new ThingWithArms { FirstName = "Nancy", LastName = "Sinatra", NumberOfArms = 2 });Get the meta object via:
var thingWithArms = testObj.GetMeta();
You can save multiple meta objects (of different types):
var testObj = new TestObjectWithMetaData();
testObj.SetMeta(new ThingWithArms { FirstName = "Nancy", LastName = "Sinatra", NumberOfArms = 2 });
testObj.SetMeta(new ThingWithLegs { FirstName = "Frank", LastName = "Sinatra", NumberOfLegs = 2 });and get them:
var thingWithArms = testObj.GetMeta();
var thingWithLegs = testObj.GetMeta();###Dependencies###
(for unit test project)