GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - chappoo/MetaEx: MetaEx-tensions. Provides extensions for managing metadata on arbitrary POCO objects. Based heavily on the @ServiceStack UserAuth Meta implementation (uses ServiceStack.Text).

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.nuget
.nuget
 
 
MetaEx.Tests
MetaEx.Tests
 
 
MetaEx
MetaEx
 
 
.gitignore
.gitignore
 
 
MetaEx.sln
MetaEx.sln
 
 
README.md
README.md
 
 

Repository files navigation

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<string,string> 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<T>(this IMeta meta)
public static void SetMeta<T>(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<ThingWithArms>();

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<ThingWithArms>();
var thingWithLegs = testObj.GetMeta<ThingWithLegs>();

###Dependencies###

<packages>
  <package id="NUnit" version="2.6.2" /> (for unit test project)
  <package id="ServiceStack.Text" version="3.9.55" />
</packages>

About

MetaEx-tensions. Provides extensions for managing metadata on arbitrary POCO objects. Based heavily on the @ServiceStack UserAuth Meta implementation (uses ServiceStack.Text).

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.