ForLogic.Prevalence
Examples

Example 02 - Retrieving Objects
Let's imagine you already saved your objects. We're now going to get then back from ForLogic.Prevalence. This example only shows you how to get objects of a specified type. There's other ways to get objects, like by "Id" or by a property value. If you want to know how to store an object, see the Example01.

using System;
using System.Collections;
using ForLogic.Prevalence;

namespace Example02 {

	//stored objects class
	[Serializable]
	public class User: IPersistentObject {
		private long _id;
		private string _name;
		public User(string name) {
			_name = name;
		}
		public long Id {
			get{return _id;}
			set{_id = value;}
		}
		public string Name {
			get{return _name;}
			set{_name = value;}
		}
	}
	
	//main application
	public class MyApplication {
		[STAThread]
		public static void Main(string[] args) {
			Prevalence.start("data", 15);
			ArrayList users = Prevalence.load(typeof(User));
			foreach (User us in users)
				Console.WriteLine("User name: "+ us.Name);
		}
	}
}