static void Main(string[] args) { // The Orleans environment is initialized in its own app domain in order to more // closely emulate the distributed situation, when the client and the server cannot // pass data via shared memory. AppDomain hostDomain = AppDomain.CreateDomain("OrleansHost", null, new AppDomainSetup { AppDomainInitializer = InitSilo, AppDomainInitializerArguments = args, }); Orleans.OrleansClient.Initialize("DevTestClientConfiguration.xml"); var maleGrain = PersonFactory.GetGrain(1); // If the name is set, we've run this code before. if (maleGrain.FirstName.Result == null) { maleGrain.Register(new PersonalAttributes { FirstName = "John", LastName = "Doe", Gender = GenderType.Male }).Wait(); Console.WriteLine("We just wrote something to the persistent store (Id: {0}). Please verify!", maleGrain.GetPrimaryKey()); } else { Console.WriteLine("\n\nThis was found in the persistent store: {0}, {1}, {2}\n\n", maleGrain.FirstName.Result, maleGrain.LastName.Result, maleGrain.Gender.Result.ToString()); } var femaleGrain = PersonFactory.GetGrain(2); // If the name is set, we've run this code before. if (femaleGrain.FirstName.Result == null) { femaleGrain.Register(new PersonalAttributes { FirstName = "Alice", LastName = "Williams", Gender = GenderType.Female }).Wait(); Console.WriteLine("We just wrote something to the persistent store (Id: {0}). Please verify!", femaleGrain.GetPrimaryKey()); } else { Console.WriteLine("\n\nThis was found in the persistent store: {0}, {1}, {2}\n\n", femaleGrain.FirstName.Result, femaleGrain.LastName.Result, femaleGrain.Gender.Result.ToString()); } femaleGrain.Marry(maleGrain.GetPrimaryKey(), maleGrain.LastName.Result); Console.WriteLine("Orleans Silo is running.\nPress Enter to terminate..."); Console.ReadLine(); hostDomain.DoCallBack(ShutdownSilo); }
static void Main(string[] args) { // The Orleans environment is initialized in its own app domain in order to more // closely emulate the distributed situation, when the client and the server cannot // pass data via shared memory. AppDomain hostDomain = AppDomain.CreateDomain("OrleansHost", null, new AppDomainSetup { AppDomainInitializer = InitSilo, AppDomainInitializerArguments = args, }); Orleans.GrainClient.Initialize("DevTestClientConfiguration.xml"); var grain = PersonFactory.GetGrain(0); // If the name is set, we've run this code before. var name = grain.GetFirstName().Result; if (name != null) { Console.WriteLine("\n\nThis was found in the persistent store: {0}, {1}, {2}\n\n", name, grain.GetLastName().Result, grain.GetGender().Result.ToString()); } else { grain.SetPersonalAttributes(new PersonalAttributes { FirstName = "John", LastName = "Doe", Gender = GenderType.Male }).Wait(); Console.WriteLine("\n\nWe just wrote something to the persistent store. Please verify!\n\n"); } Console.WriteLine("Orleans Silo is running.\nPress Enter to terminate..."); Console.ReadLine(); hostDomain.DoCallBack(ShutdownSilo); }