当前位置: 首页>>代码示例>>C#>>正文


C# PluginFamily.SetDefault方法代码示例

本文整理汇总了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;
        }
开发者ID:slahn,项目名称:structuremap,代码行数:9,代码来源:try_get_instance.cs

示例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;
        }
开发者ID:e-tobi,项目名称:structuremap,代码行数:12,代码来源:EnumerableFamilyPolicy.cs

示例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;
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:13,代码来源:SettingPolicy.cs

示例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;
        }
开发者ID:rossipedia,项目名称:structuremap,代码行数:16,代码来源:AutoMockedContainer.cs

示例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;
        }
开发者ID:Kingefosa,项目名称:structuremap,代码行数:17,代码来源:AutoMockedContainer.cs

示例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;
    }
开发者ID:rossipedia,项目名称:structuremap,代码行数:31,代码来源:PluginFamily.cs


注:本文中的StructureMap.Graph.PluginFamily.SetDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。