Пример #1
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);
        }
        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();
        }
Пример #3
0
 // Fields
 // Results
 // Business constructor
 public Director(
     Individual individual
     ,Company company
     )
 {
     InitializeResults();
     _individual = new PredecessorObj<Individual>(this, RoleIndividual, individual);
     _company = new PredecessorObj<Company>(this, RoleCompany, company);
 }
Пример #4
0
            public CorrespondenceFact CreateFact(FactMemento memento)
            {
                Individual newFact = new Individual(memento);

                // Create a memory stream from the memento data.
                using (MemoryStream data = new MemoryStream(memento.Data))
                {
                    using (BinaryReader output = new BinaryReader(data))
                    {
                        newFact._anonymousId = (string)_fieldSerializerByType[typeof(string)].ReadData(output);
                    }
                }

                return newFact;
            }
 public CompanySelectionViewModel(Individual individual, CompanySelectionModel selection)
 {
     _individual = individual;
     _selection = selection;
 }