This is a dynamic wrapper around log4net so we can avoid log4net being required to be distributed with the SDK.
Esempio n. 1
0
 /// <summary>
 /// This method is called called when the script instance is
 /// being loaded.
 /// </summary>
 public void Awake()
 {
     _logger = Logger.GetLogger(this.GetType());
     // Call the method to process requests at a regular interval.
     _nextUpdateTime  = Time.unscaledTime;
     _nextUpdateTime += _updateInterval;
 }
 /// <summary>
 /// This method is called called when the script instance is
 /// being loaded.
 /// </summary>
 public void Awake()
 {
     _logger = Amazon.Runtime.Internal.Util.Logger.GetLogger(this.GetType());
     // Call the method to process requests at a regular interval.
     // TODO : Perf testing to figure out appropriate value for interval.
     InvokeRepeating("ProcessRequests", 0.1f, 0.1f);
 }
Esempio n. 3
0
        /// <summary>
        /// Remove a trace listener from SDK logging.
        /// </summary>
        /// <param name="source">The source the listener was added to.</param>
        /// <param name="name">The name of the listener.</param>
        public static void RemoveTraceListener(string source, string name)
        {
            if (string.IsNullOrEmpty(source))
            {
                throw new ArgumentException("Source cannot be null or empty", "source");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name cannot be null or empty", "name");
            }

            lock (_traceListeners)
            {
                if (_traceListeners.ContainsKey(source))
                {
                    foreach (var l in _traceListeners[source])
                    {
                        if (l.Name.Equals(name, StringComparison.Ordinal))
                        {
                            _traceListeners[source].Remove(l);
                            break;
                        }
                    }
                }
            }

            Logger.ClearLoggerCache();
        }
 /// <summary>
 /// This method is called called when the script instance is
 /// being loaded.
 /// </summary>
 public void Awake()
 {
     _logger = Logger.GetLogger(this.GetType());
     // Call the method to process requests at a regular interval.
     _nextUpdateTime = Time.unscaledTime;
     _nextUpdateTime += _updateInterval;
 }
 /// <summary>
 /// This method is called called when the script instance is
 /// being loaded.
 /// </summary>
 public void Awake()
 {
     _logger = Logger.GetLogger(this.GetType());
     // Call the method to process requests at a regular interval.
     //InvokeRepeating("ProcessRequests", 0.1f, 0.1f);
     _nextUpdateTime = Time.unscaledTime;
     _nextUpdateTime += _updateInterval;
 }
 /// <summary>
 /// This method is called called when the script instance is
 /// being loaded.
 /// </summary>
 public void Awake()
 {
     _logger = Logger.GetLogger(this.GetType());
     // Call the method to process requests at a regular interval.
     //InvokeRepeating("ProcessRequests", 0.1f, 0.1f);
     _nextUpdateTime  = Time.unscaledTime;
     _nextUpdateTime += _updateInterval;
 }
Esempio n. 7
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();
 }
Esempio n. 8
0
 public Dataset(string datasetName, CognitoAWSCredentials cognitoCredentials, ILocalStorage local, IRemoteDataStorage remote)
 {
     this._datasetName        = datasetName;
     this._cognitoCredentials = cognitoCredentials;
     this._local  = local;
     this._remote = remote;
     _logger      = Logger.GetLogger(this.GetType());
     UnityMainThreadDispatcher.OnRefresh += HandleConnectivityRefresh;
 }
Esempio n. 9
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());
        }
        /// <summary>
        /// The constructor for UnityWebResponseData.
        /// </summary>
        /// <param name="wwwRequest">
        /// An instance of WWW after the web request has
        /// completed and response fields are set
        /// </param>
        public UnityWebResponseData(WWW wwwRequest)
        {
            _logger = Logger.GetLogger(this.GetType());
            CopyHeaderValues(wwwRequest.responseHeaders);

            try
            {
                _responseBody = wwwRequest.bytes;
            }
            catch (Exception)
            {
                _responseBody = null;
            }

            if ((_responseBody != null && _responseBody.Length > 0) || (_responseBody.Length == 0 && wwwRequest.error == null))
            {
                _responseStream = new MemoryStream(_responseBody);
            }

            this.ContentLength = wwwRequest.bytesDownloaded;

            string contentType = null;

            this._headers.TryGetValue(
                HeaderKeys.ContentTypeHeader, out contentType);
            this.ContentType = contentType;
            try
            {
                if (string.IsNullOrEmpty(wwwRequest.error))
                {
                    string statusHeader = string.Empty;
                    if (this._headers.TryGetValue(HeaderKeys.StatusHeader, out statusHeader))
                    {
                        this.StatusCode = (HttpStatusCode)Enum.Parse(
                            typeof(HttpStatusCode),
                            statusHeader.Substring(9, 3).Trim());
                    }
                    else
                    {
                        this.StatusCode = 0;
                    }
                }
                else
                {
                    int statusCode;
                    if (Int32.TryParse(wwwRequest.error.Substring(0, 3), out statusCode))
                    {
                        this.StatusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode),
                                                                     wwwRequest.error.Substring(3).Replace(" ", "").Replace(":", "").Trim(), true);//ignored case
                    }
                    else
                    {
                        this.StatusCode = 0;
                    }
                }
            }
            catch
            {
                this.StatusCode = 0;
            }
            this.IsSuccessStatusCode = wwwRequest.error == null ? true : false;
        }
Esempio n. 11
0
 /// <summary>
 /// Creates a new instance of SQLiteLocalStorage
 /// </summary>
 public SQLiteLocalStorage()
 {
     _logger = Logger.GetLogger(this.GetType());
     SetupDatabase();
 }
Esempio n. 12
0
 /// <summary>
 /// Creates a new instance of SQLiteLocalStorage
 /// </summary>
 public SQLiteLocalStorage()
 {
     _logger = Logger.GetLogger(this.GetType());
     SetupDatabase();
 }
Esempio n. 13
0
 public SQLiteLocalStorage(string path)
 {
     _logger       = Logger.GetLogger(this.GetType());
     this.dataPath = path;
     this.SetupDatabase();
 }
Esempio n. 14
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();
 }
Esempio n. 15
0
 /// <summary>
 /// This method is called called when the script instance is
 /// being loaded.
 /// </summary>
 public void Awake()
 {
     _logger         = Amazon.Runtime.Internal.Util.Logger.GetLogger(this.GetType());
     _nextUpdateTime = Time.unscaledTime;
     _nextUpdateTime = calculateNextUpdateTime();
 }
        /// <summary>
        /// The constructor for UnityWebResponseData.
        /// </summary>
        /// <param name="wwwRequest">
        /// An instance of WWW after the web request has
        /// completed and response fields are set
        /// </param>
        public UnityWebResponseData(WWW wwwRequest)
        {
            _logger  = Logger.GetLogger(this.GetType());
            _headers = wwwRequest.responseHeaders;
            try
            {
                _responseBody = wwwRequest.bytes;
            }
            catch (Exception)
            {
                _logger.DebugFormat(@"setting response body to null");
                _responseBody = null;
            }

            if (wwwRequest.error == null)
            {
                _logger.DebugFormat(@"recieved successful response");
            }
            else
            {
                _logger.DebugFormat(@"recieved error response");
                _logger.DebugFormat(@"recieved = {0}", wwwRequest.error);
            }

            if ((_responseBody != null && _responseBody.Length > 0) || (_responseBody.Length == 0 && wwwRequest.error == null))
            {
                _logger.DebugFormat(@"{0}", System.Text.UTF8Encoding.UTF8.GetString(_responseBody));
                _responseStream = new MemoryStream(_responseBody);
            }

            this.ContentLength = wwwRequest.bytesDownloaded;

            string contentType = null;

            this._headers.TryGetValue(
                HeaderKeys.ContentTypeHeader.ToUpperInvariant(), out contentType);
            this.ContentType = contentType;
            try
            {
                if (string.IsNullOrEmpty(wwwRequest.error))
                {
                    string statusHeader = string.Empty;
                    this._headers.TryGetValue(HeaderKeys.StatusHeader.ToUpperInvariant(), out statusHeader);
                    if (!string.IsNullOrEmpty(statusHeader))
                    {
                        this.StatusCode = (HttpStatusCode)Enum.Parse(
                            typeof(HttpStatusCode),
                            statusHeader.Substring(9, 3).Trim());
                    }
                    else
                    {
                        this.StatusCode = 0;
                    }
                }
                else
                {
                    int statusCode;
                    if (Int32.TryParse(wwwRequest.error.Substring(0, 3), out statusCode))
                    {
                        this.StatusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode),
                                                                     wwwRequest.error.Substring(3).Replace(" ", "").Replace(":", "").Trim(), true);//ignored case
                    }
                    else
                    {
                        this.StatusCode = 0;
                    }
                }
            }
            catch
            {
                this.StatusCode = 0;
            }
            _logger.DebugFormat(@"Status = {0}", StatusCode);
            this.IsSuccessStatusCode = wwwRequest.error == null?true:false;
        }