/* * Copyright 2015-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using Amazon.Util.Internal.PlatformServices; using System.Collections.Generic; using System; using Amazon.Util.Internal; using System.IO; namespace Amazon.Runtime.Internal { /// /// This class composes Client Context header for Amazon Web Service client. /// It contains information like app title, version code, version name, client id, OS platform etc. /// public partial class ClientContext { private const string APP_CLIENT_ID_KEY = "mobile_analytics_client_id"; private static IApplicationSettings _appSetting = ServiceFactory.Instance.GetService(); private static IApplicationInfo _appInfo = ServiceFactory.Instance.GetService(); private static IEnvironmentInfo _envInfo = ServiceFactory.Instance.GetService(); /// /// Initializes a new instance of the /// class. /// public ClientContext(string appId) { this.AppID = appId; this._custom = new Dictionary(); if (string.IsNullOrEmpty(_clientID)) { _clientID = _appSetting.GetValue(APP_CLIENT_ID_KEY, ApplicationSettingsMode.Local); if (string.IsNullOrEmpty(_clientID)) { _clientID = Guid.NewGuid().ToString(); _appSetting.SetValue(APP_CLIENT_ID_KEY, _clientID, ApplicationSettingsMode.Local); } } } } }