本文整理匯總了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;
}