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();
        }
Esempio n. 2
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();
        }