-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(services): implementation local & roaming storage service #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @Odonno, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems possible. 👍
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Moving our conversation back to main thread. I'm for adding this helper to the toolkit but Scott's point is still valid. |
Actually the current version is fine if we remove the saveasync I mentioned. @ScottIsAFool: thoughts? |
@deltakosh If we remove the SaveAsync, we should remove the ReadAsync too, no ? |
@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. |
@ScottIsAFool I took a look at the documentation but I did not found a strongly typed (generic) implementation of the |
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 |
@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. |
There is still a debate for sure :) but at least people can try it |
Ok. I understand. |
@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 |
@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 : |
I'm not opposed to keep your class like this but I would like to have it internally use the StorageHelper class |
@deltakosh Really good idea. Now, what do you think about a sample page ? |
Definitely! I added helpers section in the sample page. |
I've just noticed that your code is in services and not helpers :( |
@deltakosh Ok. I moved the folder to Helpers folder. |
{ | ||
"dependencies": { | ||
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0", | ||
"Newtonsoft.Json": "9.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may need to update the nuspec as well:
https://github.com/Microsoft/UWPCommunityToolkit/blob/dev/build/Microsoft.Toolkit.Uwp.nuspec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Ok, it should be good now. I am working on a sample page. |
LGTM |
@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 Do you have a solution ? |
It works for all other sample so there must be something wrong in what you did:) |
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,)" /> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM |
Can you just fix conflicts? I'll merge it :) |
And I may have missed it but we also need a doc here: |
@deltakosh Shoudl be good now. I'll check the documentation. |
Here is a basic implementation of local and roaming storage using
Windows.Storage
api.What do you think ?
Task list :