Click here to Skip to main content

Welcome to the Lounge

   

For lazing about and discussing anything in a software developer's life that takes your fancy except programming questions.

Technical discussions are encouraged, but click here to ask your programming question.

The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct, no programming questions and please don't post ads.


 
GeneralWhat technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 3:18 
GeneralRe: What technique do you use to persist state? Pinmemberc24234-Mar-13 3:26 
GeneralRe: What technique do you use to persist state? PinmemberS Douglas4-Mar-13 20:54 
GeneralRe: What technique do you use to persist state? PinprotectorDaveAuld4-Mar-13 3:30 
GeneralRe: What technique do you use to persist state? PinprotectorDaveAuld4-Mar-13 3:32 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 5:03 
GeneralRe: What technique do you use to persist state? Pinmemberleppie4-Mar-13 3:32 
GeneralRe: What technique do you use to persist state? PinmemberRavi Bhavnani4-Mar-13 3:40 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 5:04 
GeneralRe: What technique do you use to persist state? Pinmemberharold aptroot4-Mar-13 3:41 
GeneralRe: What technique do you use to persist state? PinmvpCPallini4-Mar-13 3:53 
GeneralRe: What technique do you use to persist state? PinmemberNagy Vilmos4-Mar-13 3:59 
GeneralRe: What technique do you use to persist state? PinmemberChrisElston4-Mar-13 4:14 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 5:10 
Nagy Vilmos wrote:
Dang Marc, have you been reading my hard drive again?

 
Who, me? Unsure | :~
 
Nagy Vilmos wrote:
I need to work out an article for just this

 
That would be great. The impetus, partly, for my survey'ish question is because I've been adding state/configuration persistence to an app, and I was wondering what sort of "best practices" there might be out there. The .NET class seems not configurable enough - I'd like to leave it open to the developer as to how to persist the state information. On the other hand, it also seems to closely coupled to "the Microsoft way", what with all the binding support, not that one needs to use it.
 
At the moment, I've decided to go for an interface-less, more functional approach, resulting in this raw usage example:
 
public ApplicationFormController()
{
	Program.AppState.Register("Form", () =>
		{
			return new List<State>()
				{
					new State("X", View.Location.X),
					new State("Y", View.Location.Y),
					new State("W", View.Size.Width),
					new State("H", View.Size.Height),
					new State("WindowState", View.WindowState.ToString()),
				};
 
		},
		state =>
		{
			// Silently handle exceptions for when we add state items that are part of the state file until we 
			// save the state.  This allows me to add new state information without crashing the app on startup.
			Program.Try(() => View.Location = new Point(state.Single(t => t.Key == "X").Value.to_i(), state.Single(t => t.Key == "Y").Value.to_i()));
			Program.Try(() => View.Size = new Size(state.Single(t => t.Key == "W").Value.to_i(), state.Single(t => t.Key == "H").Value.to_i()));
			Program.Try(() => View.WindowState = state.Single(t => t.Key == "WindowState").Value.ToEnum<FormWindowState>());
		});
}
 
public override void EndInit()
{
	Program.AppState.RestoreState("appState.xml");
}
 
Marc

GeneralRe: What technique do you use to persist state? PinmemberForogar4-Mar-13 5:33 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 5:46 
GeneralRe: What technique do you use to persist state? PinmemberMarco Bertschi4-Mar-13 4:20 
GeneralRe: What technique do you use to persist state? PinmvpOriginalGriff4-Mar-13 4:32 
GeneralRe: What technique do you use to persist state? PinmemberEnnis Ray Lynch, Jr.4-Mar-13 4:53 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 5:18 
GeneralRe: What technique do you use to persist state? PinmemberRavi Bhavnani4-Mar-13 7:32 
GeneralRe: What technique do you use to persist state? PinmemberKabwla.Phone5-Mar-13 7:06 
GeneralRe: What technique do you use to persist state? PinmemberKlaus-Werner Konrad4-Mar-13 5:05 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 5:17 
GeneralRe: What technique do you use to persist state? PinmemberKlaus-Werner Konrad4-Mar-13 6:07 
GeneralRe: What technique do you use to persist state? Pinmemberwizardzz4-Mar-13 5:13 
GeneralRe: What technique do you use to persist state? PinmvpEddy Vluggen4-Mar-13 6:00 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton4-Mar-13 7:04 
GeneralRe: What technique do you use to persist state? PinmemberS Houghtelin4-Mar-13 6:11 
GeneralRe: What technique do you use to persist state? PinmemberPIEBALDconsult4-Mar-13 6:19 
GeneralRe: What technique do you use to persist state? PinmemberBobJanova4-Mar-13 7:42 
GeneralRe: What technique do you use to persist state? PinmemberGary Wheeler4-Mar-13 8:16 
GeneralRe: What technique do you use to persist state? PinmemberKabwla.Phone5-Mar-13 7:11 
GeneralRe: What technique do you use to persist state? Pinmember_Maxxx_4-Mar-13 11:06 
GeneralRe: What technique do you use to persist state? PinmemberMycroft Holmes4-Mar-13 14:29 
GeneralRe: What technique do you use to persist state? PinmemberBrady Kelly4-Mar-13 21:39 
GeneralRe: What technique do you use to persist state? PinprotectorMarc Clifton5-Mar-13 4:01 
GeneralRe: What technique do you use to persist state? PinmemberRafagaX5-Mar-13 5:50 
GeneralRe: What technique do you use to persist state? PinmemberDan Sutton5-Mar-13 7:01 
GeneralRe: What technique do you use to persist state? PinmemberMichael K Gray5-Mar-13 15:58 
General"How much time it would take to port this ASP.NET app to MVC" Pinmembern.podbielski4-Mar-13 3:07 
AnswerRe: "How much time it would take to port this ASP.NET app to MVC" Pinmemberihoecken4-Mar-13 3:36 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pinmembern.podbielski4-Mar-13 5:58 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pinmemberihoecken5-Mar-13 0:10 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pinmembern.podbielski5-Mar-13 7:52 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" PinmemberBobJanova4-Mar-13 7:43 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pinmembern.podbielski4-Mar-13 8:54 
GeneralAnyone know how to remove the ads when staring up Opera? Pinmemberswampwiz4-Mar-13 2:55 
GeneralRe: Anyone know how to remove the ads when staring up Opera? PinmvpOriginalGriff4-Mar-13 3:02 
GeneralRe: Anyone know how to remove the ads when staring up Opera? PinmemberNagy Vilmos4-Mar-13 3:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 1 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid