本文整理汇总了C#中Rule.SetPropertiesFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Rule.SetPropertiesFrom方法的具体用法?C# Rule.SetPropertiesFrom怎么用?C# Rule.SetPropertiesFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule.SetPropertiesFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (serializer == null)
{
throw new ArgumentNullException(nameof(serializer));
}
IDictionary<string, IRule> incoming = (IDictionary<string, IRule>)value;
Dictionary<string, Rule> outgoing = new Dictionary<string, Rule>();
foreach (string key in incoming.Keys)
{
IRule iRule = incoming[key];
Rule rule = iRule as Rule;
if (rule != null)
{
outgoing[key] = rule;
continue;
}
rule = new Rule
{
DefaultLevel = iRule.DefaultLevel,
FullDescription = iRule.FullDescription,
HelpUri = iRule.HelpUri,
Id = iRule.Id,
MessageFormats = iRule.MessageFormats,
Name = iRule.Name,
ShortDescription = iRule.ShortDescription,
};
rule.SetPropertiesFrom(iRule);
outgoing[key] = rule;
}
serializer.Serialize(writer, outgoing, typeof(Dictionary<string, Rule>));
}