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