storage icon indicating copy to clipboard operation
storage copied to clipboard

Dotnet Core implementation?

Open srini85 opened this issue 8 years ago • 3 comments

@brendandburns burns Would love to see a dotnet core implementation or even get some thoughts around how you see the interfaces of shaping up for it.

srini85 avatar Jan 14 '18 04:01 srini85

I'd love to see this happen, but I think it's tricky. In the javascript case we intercept a bunch of read/writes automagically and persist the data to a central store. I'm not sure what the right way to do this is in C#.

The simplest thing would be to provide a Dictionary and just persist that, but I feel like it doesn't quite mesh with the goals of the storage library which is to make such things "automatic" but if that's the best we can do, I suppose a Dictionary isn't a terrible starting place...

brendandburns avatar Jan 15 '18 03:01 brendandburns

@brendandburns could we use an expando object? this can give us a similar usability to js implementation?

using System;
using System.Dynamic;

namespace storage
{
    class Program
    {
        static void Main(string[] args)
        {
            dynamic dynamicVars = new ExpandoObject();

            try
            {
                Console.WriteLine($"before update of someVar: {dynamicVars.someVar}");
            } 
            catch
            {
                Console.WriteLine("Looks like the someVar doesnt exist.");
            }

            dynamicVars.someVar = "Hello World";

            Console.WriteLine($"after update of someVar: {dynamicVars.someVar}");
        }
    }
}

srini85 avatar Jan 27 '18 22:01 srini85

@brendandburns - thought i will give the dotnet version a stab. WIP https://github.com/srini85/storage/tree/initial-dotnet-version

srini85 avatar Jan 29 '18 09:01 srini85