本文整理汇总了C#中Plugin.UseSetterRule方法的典型用法代码示例。如果您正苦于以下问题:C# Plugin.UseSetterRule方法的具体用法?C# Plugin.UseSetterRule怎么用?C# Plugin.UseSetterRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin.UseSetterRule方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public void Configure(Plugin plugin)
{
foreach (var rule in _setterRules)
{
plugin.UseSetterRule(rule);
}
}
示例2: PluginCache
static PluginCache()
{
_setterRules = new List<Predicate<PropertyInfo>>();
_plugins = new Cache<Type, Plugin>(t =>
{
var plugin = new Plugin(t);
foreach (var rule in _setterRules)
{
plugin.UseSetterRule(rule);
}
return plugin;
});
_builders = new Cache<Type, IInstanceBuilder>(t =>
{
try
{
Plugin plugin = _plugins[t];
return BuilderCompiler.CreateBuilder(plugin);
}
catch (Exception e)
{
throw new StructureMapException(245, e, t.AssemblyQualifiedName);
}
});
}
示例3: Plugin_uses_setter_rules_to_make_properties_settable
public void Plugin_uses_setter_rules_to_make_properties_settable()
{
var plugin = new Plugin(typeof (PluginTester.ClassWithProperties));
plugin.Setters.IsMandatory("Engine").ShouldBeFalse();
plugin.UseSetterRule(prop => prop.PropertyType == typeof (IEngine));
plugin.Setters.IsMandatory("Engine").ShouldBeTrue();
}
示例4: SetFilledTypes_3
public void SetFilledTypes_3()
{
Func<PropertyInfo, bool> predicate = prop1 => prop1.PropertyType == typeof (IGateway);
var plugin = new Plugin(typeof (ClassWithProperties));
plugin.UseSetterRule(predicate);
plugin.Setters.IsMandatory("Engine").ShouldBeFalse();
plugin.Setters.IsMandatory("Car").ShouldBeFalse();
plugin.Setters.IsMandatory("Gateway").ShouldBeTrue();
}