示例#1
0
 /// <summary>
 /// Creates a new Dataset
 /// </summary>
 /// <param name="datasetName">The name of the dataset</param>
 /// <param name="cognitoCredentials">The Cognito Credentials associated with the dataset</param>
 /// <param name="local">Local storage, can be InMemoryStorage or SQLiteStorage or Some Custom Storage Class which implements <see cref="Amazon.CognitoSync.SyncManager.ILocalStorage"/></param>
 /// <param name="remote">Remote storage</param>
 internal Dataset(string datasetName, CognitoAWSCredentials cognitoCredentials, ILocalStorage local, CognitoSyncStorage remote)
 {
     this._datasetName        = datasetName;
     this._cognitoCredentials = cognitoCredentials;
     this._local  = local;
     this._remote = remote;
     _logger      = Logger.GetLogger(this.GetType());
     DatasetSetupInternal();
 }
示例#2
0
        public CognitoSyncManager(CognitoAWSCredentials cognitoCredentials, AmazonCognitoSyncConfig config)
        {
            if (cognitoCredentials == null)
            {
                throw new ArgumentNullException("cognitoCredentials");
            }

            if (string.IsNullOrEmpty(cognitoCredentials.IdentityPoolId))
            {
                throw new ArgumentNullException("cognitoCredentials.IdentityPoolId");
            }
            this.cognitoCredentials = cognitoCredentials;
            Local  = new SQLiteLocalStorage(System.IO.Path.Combine(Application.persistentDataPath, DATABASE_NAME));
            remote = new CognitoSyncStorage(cognitoCredentials, config);
            cognitoCredentials.IdentityChangedEvent += this.IdentityChanged;

            _logger = Logger.GetLogger(this.GetType());
        }
示例#3
0
        /// <summary>
        /// Creates an instance of CognitoSyncManager using cognito credentials and a configuration object
        /// <code>
        /// CognitoSyncManager cognitoSyncManager = new CognitoSyncManager(credentials,new AmazonCognitoSyncConfig { RegionEndpoint =  RegionEndpoint.USEAST1})
        /// </code>
        /// </summary>
        /// <param name="cognitoCredentials"><see cref="Amazon.CognitoIdentity.CognitoAWSCredentials"/></param>
        /// <param name="config"><see cref="Amazon.CognitoSync.AmazonCognitoSyncConfig"/></param>
        /// <seealso href="http://docs.aws.amazon.com/cognito/latest/developerguide/synchronizing-data.html#initializing-client">Amazon Cognito Sync Dev. Guide - Initializing Client</seealso>
        public CognitoSyncManager(CognitoAWSCredentials cognitoCredentials, AmazonCognitoSyncConfig config)
        {
            if (cognitoCredentials == null)
            {
                throw new ArgumentNullException("cognitoCredentials");
            }

#if BCL
            ValidateParameters();
#endif

            this.CognitoCredentials = cognitoCredentials;
            Local  = new SQLiteLocalStorage();
            Remote = new CognitoSyncStorage(CognitoCredentials, config);

            cognitoCredentials.IdentityChangedEvent += this.IdentityChanged;

            _logger = Logger.GetLogger(this.GetType());
        }
        public DefaultCognitoSyncManager(CognitoAWSCredentials cognitoCredentials, AmazonCognitoSyncConfig config)
        {
            if (cognitoCredentials == null)
            {
                throw new ArgumentNullException("cognitoCredentials is null");
            }
            if (StringUtils.IsEmpty(cognitoCredentials.IdentityProvider.IdentityPoolId))
            {
                throw new ArgumentException("invalid identity pool id");
            }
            this.cognitoCredentials = cognitoCredentials;
#if UNITY_WEBPLAYER
            local = new InMemoryStorage();
#else
            local = new SQLiteLocalStorage(System.IO.Path.Combine(AmazonInitializer.persistentDataPath, DATABASE_NAME));
#endif
            remote = new CognitoSyncStorage(cognitoCredentials, config);
            //remote.setUserAgent(USER_AGENT);
            cognitoCredentials.IdentityProvider.IdentityChangedEvent += this.IdentityChanged;
        }