本文整理汇总了C#中StructureMap.Graph.PluginFamily.SetDefault方法的典型用法代码示例。如果您正苦于以下问题:C# PluginFamily.SetDefault方法的具体用法?C# PluginFamily.SetDefault怎么用?C# PluginFamily.SetDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StructureMap.Graph.PluginFamily
的用法示例。
在下文中一共展示了PluginFamily.SetDefault方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public PluginFamily Build(Type type)
{
if (type != typeof (IFancy)) return null;
var family = new PluginFamily(type);
family.SetDefault(new SmartInstance<Very>());
return family;
}
示例2: Build
public PluginFamily Build(Type type)
{
if (EnumerableInstance.IsEnumerable(type))
{
var family = new PluginFamily(type);
family.SetDefault(new AllPossibleInstance(type));
return family;
}
return null;
}
示例3: Build
public PluginFamily Build(Type type)
{
if (type.Name.EndsWith("Settings") && type.IsConcreteWithDefaultCtor())
{
var family = new PluginFamily(type);
var instance = buildInstanceForType(type);
family.SetDefault(instance);
return family;
}
return null;
}
示例4: Build
public PluginFamily Build(Type pluginType)
{
if (!pluginType.IsAbstract && pluginType.IsClass)
{
return null;
}
var family = new PluginFamily(pluginType);
family.SetDefault(() => {
var service = _locator.Service(pluginType);
return new ObjectInstance(service);
});
return family;
}
示例5: PluginFamily
PluginFamily IFamilyPolicy.Build(Type pluginType)
{
if (pluginType.IsConcrete())
{
return null;
}
var family = new PluginFamily(pluginType);
var service = _locator.Service(pluginType);
var instance = new ObjectInstance(service);
family.SetDefault(instance);
return family;
}
示例6: CreateTemplatedClone
public PluginFamily CreateTemplatedClone(Type[] templateTypes)
{
Type templatedType = _pluginType.MakeGenericType(templateTypes);
var templatedFamily = new PluginFamily(templatedType);
templatedFamily.copyLifecycle(this);
_instances.GetAll().Select(x => {
Instance clone = x.CloseType(templateTypes);
if (clone == null) return null;
clone.Name = x.Name;
return clone;
}).Where(x => x != null).Each(templatedFamily.AddInstance);
if (GetDefaultInstance() != null)
{
string defaultKey = GetDefaultInstance().Name;
Instance @default = templatedFamily.Instances.FirstOrDefault(x => x.Name == defaultKey);
if (@default != null)
{
templatedFamily.SetDefault(@default);
}
}
//Are there instances that close the templatedtype straight away?
_instances.GetAll()
.Where(x => x.ConcreteType.CanBeCastTo(templatedType))
.Each(templatedFamily.AddInstance);
return templatedFamily;
}