The rest is up to you, to use the DynamicLocalhost class however you see fit.
For me, in my WP7 projects I create a static ApplicationSettings class to use throughout the app. The comments below hopefully explain how it works. The only source code you ever check in says ālocalhostā ā and will be dynamically replaced at compile-time to the actual developerās machine name. This means that you are free to check in everything, get latest anytime you want, and never have to worry about someone accidently checking in their real machineās URL, hampering your workflow.
Ā
public static class ApplicationSettings
{
public static string WebServiceBaseUrl { get; private set; }
static ApplicationSettings()
{
#if DEBUG
// Compiling this app on MY machine, WebServiceBaseUrl will become: https://MATT-PC/RealWorldWP7.Web/
// The returned URL will be automatically determined on each compile
// Therefore no issues checking it in and getting latest on any developer machine
WebServiceBaseUrl = DynamicLocalhost.ReplaceLocalhost("https://localhost/RealWorldWP7.Web/");
#else
WebServiceBaseUrl = "https://services.mydomain.com/v1/";
#endif
}
}
I would really, really love feedback on this. I scoured the internet trying to see if something similar already existed and turned up with nothing. If you find it useful, or have any suggestions, please be sure to let me know!
Iām also very new at PowerShell and would not be surprised if I wrote some of the worst .ps1 scripts ever. Any input by PowerShell guruās would be most welcome.
Itās using Mercurial, so fork it, and be sure to send me pull requests if you write something awesome!
Ā
Leave a Comment