public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider)
                    .SetNotificationStrategy(new WindowsPhoneNotificationStrategy(configurationProvider)))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _individual)
                .Subscribe(() => _individual.MessageBoards)
                ;

            _individual = _community.AddFact(new Individual(GetAnonymousUserId()));
            configurationProvider.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();
        }
Ejemplo n.º 2
0
        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");
        }
        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();
        }
 public JoinMessageBoardViewModel(MessageBoardSelectionModel selection, Individual individual)
 {
     _selection = selection;
     _individual = individual;
 }
Ejemplo n.º 5
0
 // Fields
 // Results
 // Business constructor
 public Share(
     Individual individual
     ,MessageBoard messageBoard
     )
 {
     InitializeResults();
     _individual = new PredecessorObj<Individual>(this, RoleIndividual, individual);
     _messageBoard = new PredecessorObj<MessageBoard>(this, RoleMessageBoard, messageBoard);
 }
Ejemplo n.º 6
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;
            }
Ejemplo n.º 7
0
 // Fields
 // Results
 // Business constructor
 public EnableToastNotification(
     Individual individual
     )
 {
     _unique = Guid.NewGuid();
     InitializeResults();
     _individual = new PredecessorObj<Individual>(this, RoleIndividual, individual);
 }
Ejemplo n.º 8
0
 public MainViewModel(Individual individual, SynchronizationService synhronizationService, MessageBoardSelectionModel selection)
 {
     _individual = individual;
     _synhronizationService = synhronizationService;
     _selection = selection;
 }
Ejemplo n.º 9
0
 public SelectorViewModel(Individual individual, MessageBoardSelectionModel selection)
 {
     _individual = individual;
     _selection = selection;
 }