コード例 #1
0
        public void Initialize()
        {
            _community = new Community(new MemoryStorageStrategy())
                .Register<Model.CorrespondenceModel>();

            _identity = _community.AddFact(new Identity("mike"));
            Cloud cloud = _community.AddFact(new Cloud(_identity));
            _cloudViewModel = new CloudViewModel(cloud, new CloudNavigationModel(cloud));
        }
コード例 #2
0
        public void Initialize()
        {
            InitializeData();

            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _attendee.Conference)
                .Subscribe(() => _individual)
                .Subscribe(() => _attendee.ScheduledSessions)
                ;

            Individual identity = _community.AddFact(new Individual(GetAnonymousUserId()));
            _attendee = identity.GetAttendee(CommonSettings.ConferenceID);
            configurationProvider.Individual = identity;

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                Synchronize();
            };

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();

            //DataLoader.Load(conference);
        }
コード例 #3
0
        public void Initialize()
        {
            var storage = IsolatedStorageStorageStrategy.Load();
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);
            var notification = new WindowsPhoneNotificationStrategy(http);
            communication.SetNotificationStrategy(notification);

            _community = new Community(storage);
            //_community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => _individual);

            _individual = _community.AddFact(new Individual(GetAnonymousUserId()));
            http.Individual = _individual;

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                Synchronize();
            };

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
        public void Initialize()
        {
            POXConfigurationProvider configurationProvider = new POXConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new POXAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _navigationModel.CurrentUser)
                .Subscribe(() => _navigationModel.CurrentUser.SharedClouds)
                ;

            _navigationModel.CurrentUser = _community.AddFact(new Identity("mike2"));

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: michaellperry/Reversi
        private static void ServiceThreadProc()
        {
            // Load the correspondence database.
            string databaseFileName = Directory.ApplicationData / "FacetedWorlds" / "ReversiIdentificationService" / "Correspondence.sdf";

            Community community = new Community(new SSCEStorageStrategy(databaseFileName))
                .AddCommunicationStrategy(new WebServiceCommunicationStrategy())
                .Register<CorrespondenceModule>()
                .Subscribe(() => _service);

            _service = community.AddFact(new IdentityService());

            while (!_stop.WaitOne(TimeSpan.FromSeconds(15.0)))
            {
                try
                {
                    Synchronize(community);
                    if (RunService())
                        Synchronize(community);
                }
                catch (Exception ex)
                {
                    // Wait 1 minute between exceptions.
                    _stop.WaitOne(TimeSpan.FromMinutes(1.0));
                }
            }
        }
コード例 #6
0
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>();

            _domain = _community.AddFact(new Domain("Improving Enterprises"));
            _community.Subscribe(_domain);

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
コード例 #7
0
        public void Initialize()
        {
            _community = new Community(new MemoryStorageStrategy())
                .Register<CorrespondenceModel>();

            _identity = _community.AddFact(new Identity("mike"));
            _viewModel = new HomeViewModel(_identity, new NavigationModel());
        }
コード例 #8
0
ファイル: Machine.cs プロジェクト: michaellperry/Reversi
        public Machine(string userName)
        {
            _community = new Community(new MemoryStorageStrategy())
                .AddAsynchronousCommunicationStrategy(new POXAsynchronousCommunicationStrategy(new POXConfigurationProvider()))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _user);

            _user = _community.AddFact(new User(userName));
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: michaellperry/MyCon
        static void Main(string[] args)
        {
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FacetedWorlds", "MyConSurveys");
            Community community = new Community(FileStreamStorageStrategy.Load(path))
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(new HTTPConfigurationProvider()))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _conference)
                .Subscribe(() => _conference.AllSessionSurveys);

            _conference = community.AddFact(new Conference(CommonSettings.ConferenceID));

            Console.WriteLine("Receiving facts.");
            community.BeginReceiving();
            WaitWhileSynchronizing(community);

            var completedSurveys =
                from survey in _conference.AllSessionSurveys
                from completed in survey.Completed
                select new
                {
                    SessionName = completed.SessionEvaluation.Schedule.SessionPlace.Session.Name,
                    SpeakerName = completed.SessionEvaluation.Schedule.SessionPlace.Session.Speaker.Name,
                    Ratings =
                        from ratingAnswer in completed.SessionEvaluation.RatingAnswers
                        select new
                        {
                            Question = ratingAnswer.Rating.Question.Text,
                            Answer = ratingAnswer.Value
                        },
                    Essays =
                        from essayAnswer in completed.SessionEvaluation.EssayAnswers
                        select new
                        {
                            Question = essayAnswer.Essay.Question.Text,
                            Answer = essayAnswer.Value
                        }
                };

            foreach (var completedSurvey in completedSurveys)
            {
                Console.WriteLine(completedSurvey.SessionName);
                Console.WriteLine(completedSurvey.SpeakerName);
                foreach (var rating in completedSurvey.Ratings)
                    Console.WriteLine(String.Format("{0}: {1}", rating.Question, rating.Answer));
                foreach (var essay in completedSurvey.Essays)
                    Console.WriteLine(String.Format("{0}: {1}", essay.Question, essay.Answer));
                Console.WriteLine();
            }

            Console.WriteLine("Finished.");
            Console.ReadKey();
        }
コード例 #10
0
        public void Initialize()
        {
            MemoryCommunicationStrategy sharedCommunication = new MemoryCommunicationStrategy();
            _frontOfficeCommunity = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .RegisterAssembly(typeof(Machine))
                .Subscribe(() => _frontOfficeCompany);

            _kitchenCommunity = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .RegisterAssembly(typeof(Machine))
                .Subscribe(() => _kitchen.Company);

            Machine frontOfficeMachine = _frontOfficeCommunity.AddFact(new Machine());
            _frontOfficeCompany = _frontOfficeCommunity.AddFact(new Company("NanasNook"));
            _frontOfficeCommunity.AddFact(new ProvisionFrontOffice(frontOfficeMachine, _frontOfficeCompany));

            Machine kitchenMachine = _kitchenCommunity.AddFact(new Machine());
            Company kitchenCompany = _kitchenCommunity.AddFact(new Company("NanasNook"));
            _kitchen = _kitchenCommunity.AddFact(new Kitchen(kitchenCompany, "Main Street"));
            _kitchenCommunity.AddFact(new ProvisionKitchen(kitchenMachine, _kitchen));
        }
コード例 #11
0
        public MachineViewModel(
            Community community,
            MachineNavigationModel navigation)
        {
            _community = community;
            _navigation = navigation;

            _depUser = new Dependent(delegate
            {
                _user = String.IsNullOrEmpty(_navigation.UserName)
                    ? null
                    : _community.AddFact(new User(_navigation.UserName));
            });
        }
コード例 #12
0
        public SynchronizationService()
        {
            IStorageStrategy storageStrategy = IsolatedStorageStorageStrategy.Load();
            //IStorageStrategy storageStrategy = new MemoryStorageStrategy();
            POXConfigurationProvider configurationProvider = new POXConfigurationProvider();
            _community = new Community(storageStrategy)
                .AddAsynchronousCommunicationStrategy(new POXAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _identity)
                .Subscribe(() => _identity.Claims)
                .Subscribe(() => _identity.ApprovedUsers)
                .Subscribe(() => _identity.ApprovedUsers
                    .SelectMany(user => user.ActivePlayers)
                    .Select(player => player.Game)
                )
                .Subscribe(() => _identity.ApprovedUsers
                    .SelectMany(user => user.PendingGameRequests)
                );

            _identity = _community.AddFact(new Identity(GetAnonymousUserId()));
            configurationProvider.Identity = _identity;

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                Synchronize();
            };

            // Synchronize periodically while waiting for a response to a claim.
            _synchronizeTimer.Interval = TimeSpan.FromSeconds(3.0);
            _synchronizeTimer.Tick += (sender, e) =>
            {
                if (_identity.User != null)
                    _synchronizeTimer.Stop();
                else if (_identity.Claims.Any(claim => !claim.Responses.Any()))
                    Synchronize();
            };
            _synchronizeTimer.Start();

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
コード例 #13
0
        protected void InitializeCommunity()
        {
            var sharedCommunication = new MemoryCommunicationStrategy();
            _communityFlynn = NewCommunity(sharedCommunication);
            _communityAlan = NewCommunity(sharedCommunication);
            _communityModerator = NewCommunity(sharedCommunication);

            _individualFlynn = _communityFlynn.AddFact(new Individual("flynn"));
            _individualAlan = _communityAlan.AddFact(new Individual("alan"));
            _domainModerator = _communityModerator.AddFact(new Domain("Improving Enterprises"));

            _communityFlynn.Subscribe(_individualFlynn);
            _communityAlan.Subscribe(_individualAlan);
            _communityModerator.Subscribe(_domainModerator);
        }
コード例 #14
0
        public void Initialize()
        {
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .Register<CorrespondenceModel>()
                ;

            _community.AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(new HttpConfigurationProvider()));

            _identity = _community.LoadFact<Identity>(ThisIdentity);
            if (_identity == null)
            {
                string randomId = Punctuation.Replace(Guid.NewGuid().ToString(), String.Empty).ToLower();
                _identity = _community.AddFact(new Identity(randomId));
                _community.SetFact(ThisIdentity, _identity);
            }

            _community.BeginSending();
        }
コード例 #15
0
        public void Initialize()
        {
            var sharedCommunication = new MemoryCommunicationStrategy();
            _mikesCommunity = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .Register<Model.CorrespondenceModel>()
                .Subscribe(() => _mikesIdentity)
                .Subscribe(() => _mikesIdentity.SharedClouds)
				;
            _russellsCommunity = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .Register<Model.CorrespondenceModel>()
                .Subscribe(() => _russellsIdentity)
                .Subscribe(() => _russellsIdentity.SharedClouds)
				;

            _mikesIdentity = _mikesCommunity.AddFact(new Identity("mike"));
            _russellsIdentity = _russellsCommunity.AddFact(new Identity("russell"));
		}
コード例 #16
0
ファイル: Program.cs プロジェクト: michaellperry/MyCon
        static void Main(string[] args)
        {
            string folderPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "FacetedWorlds",
                "MyCon");
            Community community = new Community(FileStreamStorageStrategy.Load(folderPath))
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(new HTTPConfigurationProvider()))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _conference);

            _conference = community.AddFact(new Conference(CommonSettings.ConferenceID));

            Console.WriteLine("Receiving facts.");
            community.BeginReceiving();
            WaitWhileSynchronizing(community);

            Console.WriteLine("Finished.");
            Console.ReadKey();
        }
コード例 #17
0
ファイル: ModelTest.cs プロジェクト: michaellperry/Multichat
        public void Initialize()
        {
            var sharedCommunication = new MemoryCommunicationStrategy();
            _communityFlynn = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .Register<CorrespondenceModel>()
                .Subscribe(() => _individualFlynn)
                .Subscribe(() => _individualFlynn.MessageBoards)
                ;
            _communityAlan = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .Register<CorrespondenceModel>()
                .Subscribe(() => _individualAlan)
                .Subscribe(() => _individualAlan.MessageBoards)
                ;

            _individualFlynn = _communityFlynn.AddFact(new Individual("flynn"));
            _individualAlan = _communityAlan.AddFact(new Individual("alan"));
            _individualFlynn.JoinMessageBoard("The Grid");
            _individualAlan.JoinMessageBoard("The Grid");
        }
コード例 #18
0
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            string correspondenceDatabase = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CorrespondenceApp", "Multichat", "Correspondence.sdf");
            _community = new Community(new SSCEStorageStrategy(correspondenceDatabase))
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _individual)
                .Subscribe(() => _individual.MessageBoards)
                ;

            _individual = _community.LoadFact<Individual>(ThisIndividual);
            if (_individual == null)
            {
                string randomId = Punctuation.Replace(Guid.NewGuid().ToString(), String.Empty).ToLower();
                _individual = _community.AddFact(new Individual(randomId));
                _community.SetFact(ThisIndividual, _individual);
            }

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
コード例 #19
0
ファイル: App.xaml.cs プロジェクト: mallardsoft/NanasNook
        private void Application_Startup(
			object sender, StartupEventArgs e)
        {
            // Load the correspondence database.
            string databaseFileName = Directory.ApplicationData / "Correspondence" / "NanasNook" / "Correspondence.sdf";

            _community = new Community(new SSCEStorageStrategy(databaseFileName))
                .AddCommunicationStrategy(new WebServiceCommunicationStrategy())
                .RegisterAssembly(typeof(Machine))
                .Subscribe(() => _machine.CurrentProvisionFrontOffice.Select(p => p.Company))
                .Subscribe(() => _machine.CurrentProvisionKitchen.Select(p => p.Kitchen.Company));

            // Load or create the current machine.
            string machineIdentifier = "NanasNook.Model.Machine.thisMachine";
            _machine = _community.LoadFact<Machine>(machineIdentifier);
            if (_machine == null)
            {
                _machine = _community.AddFact(new Machine());
                _community.SetFact(machineIdentifier, _machine);
            }

            // Recycle durations when the application is idle.
            DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.ApplicationIdle);
            timer.Interval = TimeSpan.FromSeconds(1.0);
            timer.Tick += Timer_Tick;
            timer.Start();

            BeginDuration();

            // Display the main window.
            MainWindow = new Window1();
            MainWindow.DataContext = ForView.Wrap(new MainViewModel(_machine));
            MainWindow.Show();

            _synchronizationThread = new SynchronizationThread(_community);
            _community.FactAdded += () => _synchronizationThread.Wake();
            _synchronizationThread.Start();
        }
コード例 #20
0
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>();

            _individual = _community.LoadFact<Individual>(ThisIndividual);
            if (_individual == null)
            {
                string randomId = Punctuation.Replace(Guid.NewGuid().ToString(), String.Empty).ToLower();
                _individual = _community.AddFact(new Individual(randomId));
                _community.SetFact(ThisIndividual, _individual);
            }

            _community.Subscribe(_individual);

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
コード例 #21
0
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            string path = Path.Combine(HostingEnvironment.MapPath("~/App_Data"), "Correspondence");
            _community = new Community(FileStreamStorageStrategy.Load(path))
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _conference)
                ;
            _community.ClientApp = false;

            string conferenceId = ConfigurationManager.AppSettings["ConferenceID"];
            if (string.IsNullOrEmpty(conferenceId))
                conferenceId = CommonSettings.ConferenceID;
            _conference = _community.AddFact(new Conference(conferenceId));

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Resume in 5 minutes if there is an error.
            Timer synchronizeTimer = new Timer();
            synchronizeTimer.Elapsed += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = 5.0 * 60.0 * 1000.0;
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
コード例 #22
0
        public void SetupFrontOffice()
        {
            _frontOfficeCommunity = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(_sharedCommunication)
                .RegisterAssembly(typeof(Machine))
                .Subscribe(() => _frontOfficeCompany);

            Machine frontOfficeMachine = _frontOfficeCommunity.AddFact(new Machine());
            _frontOfficeCompany = _frontOfficeCommunity.AddFact(new Company("NanasNook"));
            _frontOfficeCommunity.AddFact(new ProvisionFrontOffice(frontOfficeMachine, _frontOfficeCompany));
        }
コード例 #23
0
        public void SetupKitchen()
        {
            _kitchenCommunity = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(_sharedCommunication)
                .RegisterAssembly(typeof(Machine))
                .Subscribe(() => _kitchen.Company);

            Machine kitchenMachine = _kitchenCommunity.AddFact(new Machine());
            Company kitchenCompany = _kitchenCommunity.AddFact(new Company("NanasNook"));
            _kitchen = _kitchenCommunity.AddFact(new Kitchen(kitchenCompany, "Main Street"));
            _kitchenCommunity.AddFact(new ProvisionKitchen(kitchenMachine, _kitchen));
        }
コード例 #24
0
 private void ProvisionKitchen(MemoryCommunicationStrategy sharedCommunicationStrategy)
 {
     _kitchenCommunity = new Community(new MemoryStorageStrategy())
         .AddCommunicationStrategy(sharedCommunicationStrategy)
         .RegisterAssembly(typeof(Machine))
         .Subscribe(() => _kitchenCompany);
     _kitchenCompany = _kitchenCommunity.AddFact(new Company("Nanas Nook"));
     Kitchen kitchen = _kitchenCompany.NewKitchen("Market Street");
     _kitchenViewModel = new k.KitchenViewModel(kitchen, new k.KitchenNavigationModel());
 }
コード例 #25
0
 private void ProvisionFrontOffice(MemoryCommunicationStrategy sharedCommunicationStrategy)
 {
     _frontOfficeCommunity = new Community(new MemoryStorageStrategy())
         .AddCommunicationStrategy(sharedCommunicationStrategy)
         .RegisterAssembly(typeof(Machine))
         .Subscribe(() => _frontOfficeCompany);
     _frontOfficeCompany = _frontOfficeCommunity.AddFact(new Company("Nanas Nook"));
     _frontOfficeViewModel = new f.FrontOfficeViewModel(_frontOfficeCompany, new f.FrontOfficeNavigationModel());
 }