danmichaelo / cordova-plugin-appinfo

Cordova plugin that provides a method for getting the app version number across platforms (iOs, Android, WP8, Windows)
MIT License
21 stars 16 forks source link

Update AppInfo.cs #8

Closed claudiobadii closed 8 years ago

claudiobadii commented 8 years ago

In the previous version there is not "using System.Collections.Generic;" useful to use Dictionary. At JsonHelper.Serialize(keys) the variable "keys" is not defined, so I change directly the value passed as jsonString.

This work on WP 8.1

danmichaelo commented 8 years ago

Thanks for noticing! Could you just explain why you're using string concatenation rather than using JsonHelper.Serialize(appInfo); ?

claudiobadii commented 8 years ago

In the first attempt I tried with the line of code that you suggest but the plugin did not work. So to publish the app faster as possible I use string concatenation. In the next weeks if you want I will try again to insert the line of code using the Serialize method.

Claudio

2016-02-05 22:04 GMT+01:00 Dan Michael O. Heggø notifications@github.com:

Thanks for noticing! Could you just explain why you're using string concatenation rather than using JsonHelper.Serialize(appInfo); ?

— Reply to this email directly or view it on GitHub https://github.com/danmichaelo/cordova-plugin-appinfo/pull/8#issuecomment-180553573 .

danmichaelo commented 8 years ago

Ok, would be great if you can give it another try. If it doesn't work I can just merge as it is.

(I don't have a windows phone environment available myself.)

claudiobadii commented 8 years ago

So, I try it again. With the command

JsonHelper.Serialize(appInfo);

and the returned JSON is:

[{"Key": "identifier", "Value": "{00000000-0000-0000-0000-000000000000}"}, {"Key": "version", "Value": "1.0.0"}, {"Key": "build", "Value": ""}]

Obviously a real identifier has the same structure but different number: 000...000 is only an example of the structure. With this structure is very expensive getting a value, instead of simply write AppInfo.version. There is another solution: create a class as indicated in:

http://stackoverflow.com/questions/4861138/c-sharp-json-serialization-of-dictionary-into-keyvalue-instead-of-keyk?rq=1

but for my scope I think that in my version I use the code pulled in this branch. Sorry for my poor english.

Claudio

danmichaelo commented 8 years ago

Ok, I get that. Merging as-is. Thanks for looking into it!