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


C# Instance.InstanceKey方法代码示例

本文整理汇总了C#中StructureMap.Pipeline.Instance.InstanceKey方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.InstanceKey方法的具体用法?C# Instance.InstanceKey怎么用?C# Instance.InstanceKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StructureMap.Pipeline.Instance的用法示例。


在下文中一共展示了Instance.InstanceKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Get

        public object Get(Type pluginType, Instance instance, IBuildSession session)
        {
            object result = null;
            int key = instance.InstanceKey(pluginType);
            _lock.EnterUpgradeableReadLock();
            if (_objects.ContainsKey(key))
            {

                result = _objects[key];
                _lock.ExitUpgradeableReadLock();
            }
            else
            {
                _lock.EnterWriteLock();
                try
                {
                    result = buildWithSession(pluginType, instance, session);
                    _objects.Add(key, result);
                }
                finally
                {
                    _lock.ExitWriteLock();
                }
            }

            return result;
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:27,代码来源:LifecycleObjectCache.cs

示例2: Has

 public bool Has(Type pluginType, Instance instance)
 {
     return _lock.Read(() => {
         var key = instance.InstanceKey(pluginType);
         return _objects.ContainsKey(key);
     });
 }
开发者ID:goraw,项目名称:structuremap,代码行数:7,代码来源:LifecycleObjectCache.cs

示例3: Eject

        public void Eject(Type pluginType, Instance instance)
        {
            int key = instance.InstanceKey(pluginType);
            _lock.MaybeWrite(() => {
                if (!_objects.ContainsKey(key)) return;

                _lock.Write(() => {
                    var disposable = _objects[key] as IDisposable;
                    _objects.Remove(key);
                    disposable.SafeDispose();
                });
            });
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:13,代码来源:LifecycleObjectCache.cs

示例4: Eject

        public void Eject(Type pluginType, Instance instance)
        {
            // Prevent null reference exception.
            if (pluginType.AssemblyQualifiedName == null)
                return;

            var key = instance.InstanceKey(pluginType);
            _lock.MaybeWrite(() => {
                if (!_objects.ContainsKey(key)) return;

                _lock.Write(() => {
                    var disposable = _objects[key] as IDisposable;
                    _objects.Remove(key);
                    disposable.SafeDispose();
                });
            });
        }
开发者ID:khellang,项目名称:structuremap,代码行数:17,代码来源:LifecycleObjectCache.cs

示例5: Get

        public object Get(Type pluginType, Instance instance, IBuildSession session)
        {
            object result;
            var key = instance.InstanceKey(pluginType);
            _lock.EnterUpgradeableReadLock();
            try
            {
                if (_instances.Contains(instance))
                {
                    throw new StructureMapBuildException("Bi-directional dependency relationship detected!" +
                                                         Environment.NewLine + "Check the StructureMap stacktrace below:");
                }

                if (_objects.ContainsKey(key))
                {
                    result = _objects[key];
                }
                else
                {
                    _lock.EnterWriteLock();
                    try
                    {
                        _instances.Add(instance);
                        result = buildWithSession(pluginType, instance, session);

                        _objects.Add(key, result);
                    }
                    finally
                    {
                        _instances.Remove(instance);
                        _lock.ExitWriteLock();
                    }
                }
            }
            finally
            {
                _lock.ExitUpgradeableReadLock();
            }

            return result;
        }
开发者ID:goraw,项目名称:structuremap,代码行数:41,代码来源:LifecycleObjectCache.cs

示例6: Set

        public void Set(Type pluginType, Instance instance, object value)
        {
            if (value == null) return;

            _lock.Write(() => {
                int key = instance.InstanceKey(pluginType);
                if (_objects.ContainsKey(key))
                {
                    _objects[key] = value;
                }
                else
                {
                    _objects.Add(key, value);
                }
            });
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:16,代码来源:LifecycleObjectCache.cs


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