本文整理汇总了C#中System.Platform.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Platform.Contains方法的具体用法?C# Platform.Contains怎么用?C# Platform.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Platform
的用法示例。
在下文中一共展示了Platform.Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetJsonString
/// <summary>
/// 获取通知的Json格式字符串
/// <example>
/// 格式:{"n_builder_id":"通知样式","n_title":"通知标题","n_content":"通知内容", "n_extras":{"ios":{"badge":8, "sound":"happy"}, "user_param_1":"value1", "user_param_2":"value2"}}
/// </example>
/// </summary>
/// <param name="platform">The platform.</param>
/// <returns></returns>
public string GetJsonString(Platform platform = Platform.Android|Platform.iOS)
{
IDictionary<string, object> data = new Dictionary<string, object> { { "n_title", this.Title ?? string.Empty }, { "n_content", this.Content ?? string.Empty } };
IDictionary<string, object> extra = new Dictionary<string, object>();
if (this.CustomizedValue != null)
foreach (string key in this.CustomizedValue.Keys)
{
extra[key] = this.CustomizedValue[key];
}
if (platform.Contains(Platform.Android))
{
if (this.Android_BuilderId > 0 && this.Android_BuilderId <= 1000)
data["n_builder_id"] = this.Android_BuilderId;
}
if (platform.Contains(Platform.iOS))
{
IDictionary<string, object> iOSExtra = new Dictionary<string, object>();
iOSExtra["badge"] = this.iOS_Badge;
if (!string.IsNullOrWhiteSpace(this.iOS_Sound))
iOSExtra["sound"] = this.iOS_Sound;
extra["ios"] = iOSExtra;
}
data.Add("n_extras", extra);
return JsonConvert.SerializeObject(data);
}