Skip to content

Conversation

Odonno
Copy link
Contributor

@Odonno Odonno commented Sep 5, 2016

Here is a basic implementation of local and roaming storage using Windows.Storage api.

What do you think ?

Task list :

  • Create LocalStorageService
  • Create RoamingStorageService
  • Reuse of StorageFileHelper
  • Sample page

@msftclas
Copy link

msftclas commented Sep 5, 2016

Hi @Odonno, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!
We will now validate the agreement and then real humans will evaluate your PR.

TTYL, MSBOT;

/// <typeparam name="T">Type of object retrieved</typeparam>
/// <param name="key">Key of the object</param>
/// <returns>The T object</returns>
public T Retrieve<T>(string key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about a default value as well as a third optional parameter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would name tit Read to be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems possible. 👍

@ScottIsAFool
Copy link
Contributor

I'm not 100% convinced these changes fit in the scope of this toolkit. Even if it were, I think there would need to be a large refactor done in order to remove all the duplicated code (since the only thing that changes is the folder/settings location in each implementation. If it's the abstraction that appeals, I would suggest having a look at the Cimbalino toolkit which does this very well with its StorageService and SettingsService.

/// <summary>
/// Store data in the Local environment (only on the current device)
/// </summary>
public interface ILocalStorageService : IStorageService
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? I see no value added here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am commonly using C# interface, mainly with a DI solution. So, in case I want both a local and roaming storage service in my project, I need both interfaces.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure but as this is a general framework, we do not want to add more things NGOs to maintain with no obvious reasons. Here an empty interface does not make sense in the context of the toolkit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll remove it

@deltakosh
Copy link
Contributor

Moving our conversation back to main thread. I'm for adding this helper to the toolkit but Scott's point is still valid.

@deltakosh
Copy link
Contributor

Actually the current version is fine if we remove the saveasync I mentioned. @ScottIsAFool: thoughts?

@Odonno
Copy link
Contributor Author

Odonno commented Sep 7, 2016

@deltakosh If we remove the SaveAsync, we should remove the ReadAsync too, no ?

@ScottIsAFool
Copy link
Contributor

@Odonno In terms of a toolkit that lets you do this kind of stuff in a line of code, as mentioned previously, Cimbalino allows you to do this, with easy access to either local/roaming storage, etc. I would highly recommend having a look, happy to answer any questions on it if you have any.

@Odonno
Copy link
Contributor Author

Odonno commented Sep 7, 2016

@ScottIsAFool I took a look at the documentation but I did not found a strongly typed (generic) implementation of the IStorageServiceHandler, I mean, saving/reading app data with the type (exemple: List<Card> or simply Card).

@deltakosh
Copy link
Contributor

Hello, we plan to close v1.1 this monday (9/26). There is no rush but if you want to be part of v1.1 we ahve to merge your code before this Friday

@Odonno
Copy link
Contributor Author

Odonno commented Sep 19, 2016

@deltakosh I am sorry, I did not know if it was still maintained. It's good to merge for me.

Could make a sample page if you think it's necessary.

@deltakosh
Copy link
Contributor

There is still a debate for sure :) but at least people can try it
I still need more thoughts about whether we want it or not in the toolkit

@Odonno
Copy link
Contributor Author

Odonno commented Sep 19, 2016

Ok. I understand.

@deltakosh
Copy link
Contributor

@ScottIsAFool pointed out to me that https://github.com/Microsoft/UWPCommunityToolkit/blob/dev/Microsoft.Toolkit.Uwp/Helpers/StorageFileHelper.cs contains already a lot of helpers
You should rely on them

@Odonno
Copy link
Contributor Author

Odonno commented Sep 20, 2016

@deltakosh Yeah, that could work.

But I still have two Save/Retrieve methods, one for simple object and another for large object. it's because of the limitation of Settings : The name of each setting can be 255 characters in length at most. Each setting can be up to 8K bytes in size and each composite setting can be up to 64K bytes in size..

@deltakosh
Copy link
Contributor

I'm not opposed to keep your class like this but I would like to have it internally use the StorageHelper class

@Odonno
Copy link
Contributor Author

Odonno commented Sep 25, 2016

@deltakosh Really good idea. Now, what do you think about a sample page ?

@deltakosh
Copy link
Contributor

Definitely! I added helpers section in the sample page.

@deltakosh
Copy link
Contributor

I've just noticed that your code is in services and not helpers :(
Can you please move it to toolkit project? (and not toolkit.services)

@Odonno
Copy link
Contributor Author

Odonno commented Sep 26, 2016

@deltakosh Ok. I moved the folder to Helpers folder.

{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"Newtonsoft.Json": "9.0.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Odonno
Copy link
Contributor Author

Odonno commented Sep 26, 2016

Ok, it should be good now. I am working on a sample page.

@deltakosh
Copy link
Contributor

LGTM

@Odonno
Copy link
Contributor Author

Odonno commented Sep 26, 2016

@deltakosh I have started a sample and it looks good.

But there is one bug I don't know how to fix. I create a StorageCode.bind file and when set the property CodeFile, the app crash when I navigate to the page, saying it does not find the file but it shoud... If I remove this property from the json, the navigation works like expected but of course C# code does not appear.

Do you have a solution ?

@deltakosh
Copy link
Contributor

It works for all other sample so there must be something wrong in what you did:)

@Odonno
Copy link
Contributor Author

Odonno commented Sep 26, 2016

Ok, I found out why it didn't work. I think it's good now.

<tags>UWP Toolkit Windows</tags>
<dependencies>
<group>
<dependency id="Newtonsoft.Json" version="[9.0.1,)" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something wrong with parenthesis right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean ? This is a notation to say I only take package with a version >= 9.0.1
If you want the specific version to be 9.0.1 only, I can make the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It starts with a [ and ends with a )
Is it expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's like that. I am not in the head of the NuGet team. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I understand :) I was not aware of this notation
Thanks a lto!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deltakosh
Copy link
Contributor

LGTM

@deltakosh
Copy link
Contributor

Can you just fix conflicts? I'll merge it :)

@deltakosh
Copy link
Contributor

And I may have missed it but we also need a doc here:
https://github.com/Microsoft/UWPCommunityToolkit-docs/tree/dev/en-us/helpers

@deltakosh deltakosh added this to the v1.1 milestone Sep 27, 2016
@Odonno
Copy link
Contributor Author

Odonno commented Sep 28, 2016

@deltakosh Shoudl be good now. I'll check the documentation.

@deltakosh deltakosh merged commit 9c3b44c into CommunityToolkit:dev Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants