.NetStandard based cross-platform storage

Is there any .NetStandard based cross-platform storage implementation available (something like PCLStorage, but .NetStandard-based, to support also UWP) ?

Posts

  • andrewmorris.meandrewmorris.me USMember ✭✭

    @abra did you ever manage to find something? I'm looking for some storage package available for .netstandard too?

  • abraabra ADMember ✭✭✭

    Unfortunately not...

  • andrewmorris.meandrewmorris.me USMember ✭✭
    edited August 2017

    @abra Thanks for the reply. I was unable to find anything either. The best thing I could come up with was to use the Settings Plugin (Link Below) and use a custom class that will deserialize/serialize back and forth from json, storing the json string against a Settings Plugin property.

    For example:

    Settings.cs
    private static ISettings AppSettings => CrossSettings.Current;
    public static string UserCookie
    {
        get => AppSettings.GetValueOrDefault(nameof(UserCookie), string.Empty);
        set => AppSettings.AddOrUpdateValue(nameof(UserCookie), value);
    }
    
    UserService.cs
    public Cookie UserCookie
     {
        get => !string.IsNullOrEmpty(Settings.UserCookie) ? JsonConvert.DeserializeObject<Cookie>(Settings.UserCookie) : null;
        set
        {
            var cookie = !string.IsNullOrEmpty(Settings.UserCookie) ? JsonConvert.DeserializeObject<Cookie>(Settings.UserCookie) : null;
            if (cookie == value)
                return;
    
            Settings.UserCookie = value != null ? JsonConvert.SerializeObject(value) : null;
        }
    }
    
    LoginViewModel.cs
    public bool IsAuthenticated()
    {
        if (UserService.UserCookie != null)
        {
            if (!UserService.UserCookie.Expired)
            {
                return true;
            }
    
             UserService.UserCookie = null;
        }
    
        return false;
    }
    

    https://github.com/jamesmontemagno/SettingsPlugin

    Not sure if the above will help your situation or give you any ideas or not though?

  • abraabra ADMember ✭✭✭

    I forgot about this one. You might take a look, if you dont need the async methods.
    https://nuget.org/packages/Plugin.NetStandardStorage

  • abraabra ADMember ✭✭✭

    I was looking actually for a solution for some generic storage (image, pdf, json,... files), not only for the settings.

Sign In or Register to comment.