Ejemplo n.º 1
0
        public ClientContext(string appId, ClientContextConfig config)
        {
            _config = config;
            this.AppID = appId;
            this._custom = new Dictionary<string, string>();

            if (string.IsNullOrEmpty(_clientID))
            {
                string fullPath = InternalSDKUtils.DetermineAppLocalStoragePath(CLIENT_ID_CACHE_FILENAME);
                var directoryPath = InternalSDKUtils.DetermineAppLocalStoragePath();

                lock (_lock)
                {
                    if (!Directory.Exists(directoryPath))
                    {
                        Directory.CreateDirectory(directoryPath);
                    }

                    if (!System.IO.File.Exists(fullPath) || new System.IO.FileInfo(fullPath).Length == 0)
                    {
                        _clientID = Guid.NewGuid().ToString();
                        System.IO.File.WriteAllText(fullPath, _clientID);
                    }
                    else
                    {
                        using (System.IO.StreamReader file = new System.IO.StreamReader(fullPath))
                        {
                            _clientID = file.ReadToEnd();
                            file.Close();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public ClientContext(string appId, ClientContextConfig config)
        {
            _config      = config;
            this.AppID   = appId;
            this._custom = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(_clientID))
            {
                string fullPath = InternalSDKUtils.DetermineAppLocalStoragePath(CLIENT_ID_CACHE_FILENAME);

                var directoryPath = InternalSDKUtils.DetermineAppLocalStoragePath();
                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }

                if (!System.IO.File.Exists(fullPath) || new System.IO.FileInfo(fullPath).Length == 0)
                {
                    _clientID = Guid.NewGuid().ToString();
                    System.IO.File.WriteAllText(fullPath, _clientID);
                }
                else
                {
                    using (System.IO.StreamReader file = new System.IO.StreamReader(fullPath))
                    {
                        _clientID = file.ReadToEnd();
                        file.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManagerConfig"/>
        /// </summary>
        public MobileAnalyticsManagerConfig()
        {
            SessionTimeout = defaultSessionTimeout;
            MaxDBSize = defaultMaxDBSize;
            DBWarningThreshold = defaultDBWarningThreshold;
            MaxRequestSize = defaultMaxRequestSize;
            AllowUseDataNetwork = defaultAllowUseDataNetwork;
#if BCL
            ClientContextConfiguration = new ClientContextConfig();
#endif
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManagerConfig"/>
        /// </summary>
        public MobileAnalyticsManagerConfig()
        {
            SessionTimeout = defaultSessionTimeout;
            MaxDBSize = defaultMaxDBSize;
            DBWarningThreshold = defaultDBWarningThreshold;
            MaxRequestSize = defaultMaxRequestSize;
            AllowUseDataNetwork = defaultAllowUseDataNetwork;
#if BCL
            ClientContextConfiguration = new ClientContextConfig();
#endif

#if UNITY
            var root = new RootConfig();
            var section = root.GetServiceSection(mobileAnalyticsKey);
            if (section == null)
            {
                return;
            }

            var rootSection = new MobileAnalyticsManagerConfigSectionRoot(section);
            if (rootSection.SectionConfig != null)
                Configure(rootSection.SectionConfig);
#endif
        }