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


C# Pipeline.Instance类代码示例

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


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

示例1: FindObject

        public override object FindObject(Type pluginType, Instance instance)
        {
            _dependencyStack.Push(new BuildDependency(pluginType, instance));

            try
            {
                //clearBuildStack();
                return base.FindObject(pluginType, instance);
            }
            catch (StructureMapException ex)
            {
                _dependencyStack.Pop();

                // Don't log exceptions for inline instances.  I
                // think it would cause more confusion that not
                // because the name is a Guid
                if (!_explicitInstances.Contains(instance))
                {
                    throw;
                }

                _errors.LogError(instance, pluginType, ex, _dependencyStack);

                throw;
            }
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:26,代码来源:ValidationBuildSession.cs

示例2: Apply

        public void Apply(Type pluginType, Instance instance)
        {
            _policies.Where(x => !instance.AppliedPolicies.Contains(x))
                .Each(policy =>
                {
                    try
                    {
                        policy.Apply(pluginType, instance);
                    }
                    finally
                    {
                        instance.AppliedPolicies.Add(policy);
                    }
                });

            var configured = instance.As<IConfiguredInstance>();
            if (configured != null)
            {
                configured.Constructor.GetParameters()
                    .Each(param => param.ForAttribute<StructureMapAttribute>(att => att.Alter(configured, param)));

                configured.SettableProperties()
                    .Each(prop => prop.ForAttribute<StructureMapAttribute>(att => att.Alter(configured, prop)));
            }
        }
开发者ID:Kingefosa,项目名称:structuremap,代码行数:25,代码来源:Policies.cs

示例3: DetermineInterceptors

 public IEnumerable<IInterceptor> DetermineInterceptors(Type pluginType, Instance instance)
 {
     if (pluginType == typeof(IService))
     {
         yield return new FuncInterceptor<IService>((context, service) => new DecoratorService(instance.Name, service));
     }
 }
开发者ID:joelweiss,项目名称:structuremap,代码行数:7,代码来源:Bug_436.cs

示例4: ValidationError

 public ValidationError(Type pluginType, Instance instance, Exception exception, MethodInfo method)
 {
     PluginType = pluginType;
     Instance = instance;
     Exception = exception;
     MethodName = method.Name;
 }
开发者ID:slahn,项目名称:structuremap,代码行数:7,代码来源:ValidationError.cs

示例5: FillTypeInto

 public void FillTypeInto(Type pluginType, Instance instance)
 {
     if (!_instances.ContainsKey(pluginType))
     {
         _instances.Add(pluginType, instance);
     }
 }
开发者ID:hp4711,项目名称:structuremap,代码行数:7,代码来源:Profile.cs

示例6: BuildPlan

 /// <summary>
 /// FOR TESTING ONLY!
 /// </summary>
 /// <param name="pluginType"></param>
 /// <param name="instance"></param>
 /// <param name="inner"></param>
 /// <param name="interceptionPlan"></param>
 public BuildPlan(Type pluginType, Instance instance, IDependencySource inner, IInterceptionPlan interceptionPlan)
 {
     _pluginType = pluginType;
     _instance = instance;
     _inner = inner;
     _interceptionPlan = interceptionPlan;
 }
开发者ID:goraw,项目名称:structuremap,代码行数:14,代码来源:BuildPlan.cs

示例7: 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

示例8: 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

示例9: LogError

        public void LogError(
            Instance instance,
            Type pluginType,
            StructureMapException ex,
            IEnumerable<BuildDependency> dependencies)
        {
            if (_buildErrors.ContainsKey(instance))
            {
                BuildError existingError = _buildErrors[instance];
                addDependenciesToError(instance, dependencies, existingError);
            }

            if (_brokenInstances.Contains(instance))
            {
                return;
            }

            InstanceToken token = ((IDiagnosticInstance) instance).CreateToken();
            var error = new BuildError(pluginType, instance);
            error.Exception = ex;

            _buildErrors.Add(instance, error);

            addDependenciesToError(instance, dependencies, error);
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:25,代码来源:ErrorCollection.cs

示例10: DetermineInterceptors

 public IEnumerable<IInterceptor> DetermineInterceptors(Type pluginType, Instance instance)
 {
     if (MatchesType(instance.ReturnedType))
      {
      Expression<Action<IContext, object>> register = (c, o) => c.GetInstance<IEventPublisher>().Subscribe(o);
      yield return new ActivatorInterceptor<object>(register);
      }
 }
开发者ID:himmelreich-it,项目名称:opencbs,代码行数:8,代码来源:EventAggregatorInterceptor.cs

示例11: WrapFunc

        public static Expression WrapFunc(Type returnType, Instance instance, Expression inner)
        {
            var push = Expression.Call(Parameters.Session, PushMethod, Expression.Constant(instance));
            var block = Expression.Block(returnType, push, inner);
            var pop = Expression.Call(Parameters.Session, PopMethod);

            return Expression.TryFinally(block, pop);
        }
开发者ID:goraw,项目名称:structuremap,代码行数:8,代码来源:PushPopWrapper.cs

示例12: Apply

 /// <summary>
 /// Applies explicit configuration to an IConfiguredInstance
 /// </summary>
 /// <param name="pluginType"></param>
 /// <param name="instance"></param>
 public void Apply(Type pluginType, Instance instance)
 {
     var configured = instance as IConfiguredInstance;
     if (configured != null)
     {
         apply(pluginType, configured);
     }
 }
开发者ID:slahn,项目名称:structuremap,代码行数:13,代码来源:ConfiguredInstancePolicy.cs

示例13: Eject

        public void Eject(Type pluginType, Instance instance)
        {
            var key = new InstanceKey(instance, pluginType);
            if (!_objects.Has(key)) return;

            var disposable = _objects[key] as IDisposable;
            _objects.Remove(key);
            disposable.SafeDispose();
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:9,代码来源:MainObjectCache.cs

示例14: DetermineInterceptors

 public IEnumerable<IInterceptor> DetermineInterceptors(Type pluginType, Instance instance)
 {
     if (_filter(pluginType, instance))
     {
         var interceptorType = typeof(DynamicProxyInterceptor<>).MakeGenericType(pluginType);
         var interceptor = (IInterceptor)Activator.CreateInstance(interceptorType, new object[] { _interceptionBehaviors });
         yield return interceptor;
     }
 }
开发者ID:asbjornu,项目名称:structuremap,代码行数:9,代码来源:DynamicProxyInterceptorPolicy.cs

示例15: Get

        public object Get(Type pluginType, Instance instance, IBuildSession session)
        {
            var @object = session.BuildNewInSession(pluginType, instance);
            if (@object is IDisposable)
            {
                _tracked.Add(@object);
            }

            return @object;
        }
开发者ID:slahn,项目名称:structuremap,代码行数:10,代码来源:TrackingTransientCache.cs


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