IsolatedStorageSettings extension method
I noticed that my Windows Phone 7 applications started to have lots of these kinds of statements in the OnLaunch and OnActivate event handlers:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; bool allowLocationService; AllowLocationServiceProperty = settings.TryGetValue( "AllowLocationService", out allowLocationService ) ? allowLocationService : false;
I came up with simple this extension method to reduce the repetition:
/// <summary>
/// Gets a value for the specified key
/// </summary>
///
Which means I can now do:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
AllowLocationServiceProperty = settings.TryGetValue( "AllowLocationService", false );
That's a bit better!
There's a few other examples in this thread in the Windows Phone 7 forums.
Categories: .NET, Windows Phone