using System;
using System.Collections.Generic;
namespace ThinkingAnalytics
{
///
/// Preset Properties
///
public class TDPresetProperties
{
public TDPresetProperties(Dictionary properties)
{
properties = TDEncodeDate(properties);
mPresetProperties = properties;
}
///
/// Returns Preset Properties
/// The key starts with "#", it is not recommended to use it directly as a user properties
///
/// preset properties
public Dictionary ToEventPresetProperties()
{
return mPresetProperties;
}
public string AppVersion
{
get { return (string)(mPresetProperties.ContainsKey("#app_version") ? mPresetProperties["#app_version"] : ""); }
}
public string BundleId
{
get { return (string)(mPresetProperties.ContainsKey("#bundle_id") ? mPresetProperties["#bundle_id"] : ""); }
}
public string Carrier
{
get { return (string)(mPresetProperties.ContainsKey("#carrier") ? mPresetProperties["#carrier"] : ""); }
}
public string DeviceId
{
get { return (string)(mPresetProperties.ContainsKey("#device_id") ? mPresetProperties["#device_id"] : ""); }
}
public string DeviceModel
{
get { return (string)(mPresetProperties.ContainsKey("#device_model") ? mPresetProperties["#device_model"] : ""); }
}
public string Manufacturer
{
get { return (string)(mPresetProperties.ContainsKey("#manufacturer") ? mPresetProperties["#manufacturer"] : ""); }
}
public string NetworkType
{
get { return (string)(mPresetProperties.ContainsKey("#network_type") ? mPresetProperties["#network_type"] : ""); }
}
public string OS
{
get { return (string)(mPresetProperties.ContainsKey("#os") ? mPresetProperties["#os"] : ""); }
}
public string OSVersion
{
get { return (string)(mPresetProperties.ContainsKey("#os_version") ? mPresetProperties["#os_version"] : ""); }
}
public double ScreenHeight
{
get { return Convert.ToDouble(mPresetProperties.ContainsKey("#screen_height") ? mPresetProperties["#screen_height"] : 0); }
}
public double ScreenWidth
{
get { return Convert.ToDouble(mPresetProperties.ContainsKey("#screen_width") ? mPresetProperties["#screen_width"] : 0); }
}
public string SystemLanguage
{
get { return (string)(mPresetProperties.ContainsKey("#system_language") ? mPresetProperties["#system_language"] : ""); }
}
public double ZoneOffset
{
get { return Convert.ToDouble(mPresetProperties.ContainsKey("#zone_offset") ? mPresetProperties["#zone_offset"] : 0); }
}
public string InstallTime
{
get { return (string)(mPresetProperties.ContainsKey("#install_time") ? mPresetProperties["#install_time"] : ""); }
}
public string Disk
{
get { return (string)(mPresetProperties.ContainsKey("#disk") ? mPresetProperties["#disk"] : ""); }
}
public string Ram
{
get { return (string)(mPresetProperties.ContainsKey("#ram") ? mPresetProperties["#ram"] : ""); }
}
public double Fps
{
get { return Convert.ToDouble(mPresetProperties.ContainsKey("#fps") ? mPresetProperties["#fps"] : 0); }
}
public bool Simulator
{
get { return (bool)(mPresetProperties.ContainsKey("#simulator") ? mPresetProperties["#simulator"] : false); }
}
private Dictionary mPresetProperties { get; set; }
private Dictionary TDEncodeDate(Dictionary properties)
{
Dictionary mProperties = new Dictionary();
foreach (KeyValuePair kv in properties)
{
if (kv.Value is DateTime)
{
DateTime dateTime = (DateTime)kv.Value;
mProperties.Add(kv.Key, dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture));
}
else
{
mProperties.Add(kv.Key, kv.Value);
}
}
return mProperties;
}
}
}