Click here to Skip to main content
11,704,315 members (60,682 online)

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? Pin
Marc Clifton4-Mar-13 2:18
protectorMarc Clifton4-Mar-13 2:18 
GeneralRe: What technique do you use to persist state? Pin
c24234-Mar-13 2:26
memberc24234-Mar-13 2:26 
GeneralRe: What technique do you use to persist state? Pin
S Douglas4-Mar-13 19:54
memberS Douglas4-Mar-13 19:54 
GeneralRe: What technique do you use to persist state? Pin
DaveAuld4-Mar-13 2:30
protectorDaveAuld4-Mar-13 2:30 
GeneralRe: What technique do you use to persist state? Pin
DaveAuld4-Mar-13 2:32
protectorDaveAuld4-Mar-13 2:32 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton4-Mar-13 4:03
protectorMarc Clifton4-Mar-13 4:03 
GeneralRe: What technique do you use to persist state? Pin
leppie4-Mar-13 2:32
memberleppie4-Mar-13 2:32 
GeneralRe: What technique do you use to persist state? Pin
Ravi Bhavnani4-Mar-13 2:40
memberRavi Bhavnani4-Mar-13 2:40 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton4-Mar-13 4:04
protectorMarc Clifton4-Mar-13 4:04 
GeneralRe: What technique do you use to persist state? Pin
harold aptroot4-Mar-13 2:41
memberharold aptroot4-Mar-13 2:41 
GeneralRe: What technique do you use to persist state? Pin
CPallini4-Mar-13 2:53
mvpCPallini4-Mar-13 2:53 
GeneralRe: What technique do you use to persist state? Pin
Nagy Vilmos4-Mar-13 2:59
memberNagy Vilmos4-Mar-13 2:59 
GeneralRe: What technique do you use to persist state? Pin
ChrisElston4-Mar-13 3:14
memberChrisElston4-Mar-13 3:14 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton4-Mar-13 4:10
protectorMarc Clifton4-Mar-13 4: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? Pin
Forogar4-Mar-13 4:33
memberForogar4-Mar-13 4:33 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton4-Mar-13 4:46
protectorMarc Clifton4-Mar-13 4:46 
GeneralRe: What technique do you use to persist state? Pin
Marco Bertschi4-Mar-13 3:20
memberMarco Bertschi4-Mar-13 3:20 
GeneralRe: What technique do you use to persist state? Pin
OriginalGriff4-Mar-13 3:32
mvpOriginalGriff4-Mar-13 3:32 
GeneralRe: What technique do you use to persist state? Pin
Ennis Ray Lynch, Jr.4-Mar-13 3:53
memberEnnis Ray Lynch, Jr.4-Mar-13 3:53 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton4-Mar-13 4:18
protectorMarc Clifton4-Mar-13 4:18 
GeneralRe: What technique do you use to persist state? Pin
Ravi Bhavnani4-Mar-13 6:32
memberRavi Bhavnani4-Mar-13 6:32 
GeneralRe: What technique do you use to persist state? Pin
Kabwla.Phone5-Mar-13 6:06
memberKabwla.Phone5-Mar-13 6:06 
GeneralRe: What technique do you use to persist state? Pin
Klaus-Werner Konrad4-Mar-13 4:05
memberKlaus-Werner Konrad4-Mar-13 4:05 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton4-Mar-13 4:17
protectorMarc Clifton4-Mar-13 4:17 
GeneralRe: What technique do you use to persist state? Pin
Klaus-Werner Konrad4-Mar-13 5:07
memberKlaus-Werner Konrad4-Mar-13 5:07 
GeneralRe: What technique do you use to persist state? Pin
wizardzz4-Mar-13 4:13
memberwizardzz4-Mar-13 4:13 
GeneralRe: What technique do you use to persist state? Pin
Eddy Vluggen4-Mar-13 5:00
mvpEddy Vluggen4-Mar-13 5:00 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton4-Mar-13 6:04
protectorMarc Clifton4-Mar-13 6:04 
GeneralRe: What technique do you use to persist state? Pin
S Houghtelin4-Mar-13 5:11
memberS Houghtelin4-Mar-13 5:11 
GeneralRe: What technique do you use to persist state? Pin
PIEBALDconsult4-Mar-13 5:19
memberPIEBALDconsult4-Mar-13 5:19 
GeneralRe: What technique do you use to persist state? Pin
BobJanova4-Mar-13 6:42
memberBobJanova4-Mar-13 6:42 
GeneralRe: What technique do you use to persist state? Pin
Gary Wheeler4-Mar-13 7:16
memberGary Wheeler4-Mar-13 7:16 
GeneralRe: What technique do you use to persist state? Pin
Kabwla.Phone5-Mar-13 6:11
memberKabwla.Phone5-Mar-13 6:11 
GeneralRe: What technique do you use to persist state? Pin
_Maxxx_4-Mar-13 10:06
member_Maxxx_4-Mar-13 10:06 
GeneralRe: What technique do you use to persist state? Pin
Mycroft Holmes4-Mar-13 13:29
memberMycroft Holmes4-Mar-13 13:29 
GeneralRe: What technique do you use to persist state? Pin
Brady Kelly4-Mar-13 20:39
memberBrady Kelly4-Mar-13 20:39 
GeneralRe: What technique do you use to persist state? Pin
Marc Clifton5-Mar-13 3:01
protectorMarc Clifton5-Mar-13 3:01 
GeneralRe: What technique do you use to persist state? Pin
RafagaX5-Mar-13 4:50
memberRafagaX5-Mar-13 4:50 
GeneralRe: What technique do you use to persist state? Pin
Dan Sutton5-Mar-13 6:01
memberDan Sutton5-Mar-13 6:01 
GeneralRe: What technique do you use to persist state? Pin
Michael K Gray5-Mar-13 14:58
memberMichael K Gray5-Mar-13 14:58 
General"How much time it would take to port this ASP.NET app to MVC" Pin
n.podbielski4-Mar-13 2:07
membern.podbielski4-Mar-13 2:07 
AnswerRe: "How much time it would take to port this ASP.NET app to MVC" Pin
ihoecken4-Mar-13 2:36
memberihoecken4-Mar-13 2:36 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pin
n.podbielski4-Mar-13 4:58
membern.podbielski4-Mar-13 4:58 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pin
ihoecken4-Mar-13 23:10
memberihoecken4-Mar-13 23:10 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pin
n.podbielski5-Mar-13 6:52
membern.podbielski5-Mar-13 6:52 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pin
BobJanova4-Mar-13 6:43
memberBobJanova4-Mar-13 6:43 
GeneralRe: "How much time it would take to port this ASP.NET app to MVC" Pin
n.podbielski4-Mar-13 7:54
membern.podbielski4-Mar-13 7:54 
GeneralAnyone know how to remove the ads when staring up Opera? Pin
swampwiz4-Mar-13 1:55
memberswampwiz4-Mar-13 1:55 
GeneralRe: Anyone know how to remove the ads when staring up Opera? Pin
OriginalGriff4-Mar-13 2:02
mvpOriginalGriff4-Mar-13 2:02 
GeneralRe: Anyone know how to remove the ads when staring up Opera? Pin
Nagy Vilmos4-Mar-13 2:05
memberNagy Vilmos4-Mar-13 2: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.150819.1 | Last Updated 28 Aug 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid