當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。