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


C# InstanceReference.IfInstanceIs方法代码示例

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


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

示例1: Deactivate

        /// <summary>
        /// Disposes the specified instance.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="reference">A reference to the instance being deactivated.</param>
        public override void Deactivate(IContext context, InstanceReference reference)
        {
            reference.IfInstanceIs<ICommunicationObject>(x =>
                {
                    if (x.State == CommunicationState.Faulted)
                    {
                        x.Abort();
                    }
                    else
                    {
                        try
                        {
                            x.Close();
                        }
                        catch
                        {
                            x.Abort();
                        }
                    }
                });

            base.Deactivate(context, reference);
        }
开发者ID:kimbouwman,项目名称:ninject.extensions.wcf,代码行数:28,代码来源:WcfDisposableStrategy.cs

示例2: Activate

 /// <summary>
 /// Initializes the specified instance.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="reference">A reference to the instance being activated.</param>
 public override void Activate(IContext context, InstanceReference reference)
 {
     reference.IfInstanceIs<IInitializable>(x => x.Initialize());
 }
开发者ID:LuckyStarry,项目名称:Ninject,代码行数:9,代码来源:InitializableStrategy.cs

示例3: Deactivate

 /// <summary>
 /// Disposes the specified instance.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="reference">A reference to the instance being deactivated.</param>
 public override void Deactivate(IContext context, InstanceReference reference)
 {
     reference.IfInstanceIs<IDisposable>(x => x.Dispose());
 }
开发者ID:ArthurYiL,项目名称:JustMockLite,代码行数:9,代码来源:DisposableStrategy.cs

示例4: Deactivate

 /// <summary>
 /// Stops the specified instance.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="reference">A reference to the instance being deactivated.</param>
 public override void Deactivate(IContext context, InstanceReference reference)
 {
     reference.IfInstanceIs<IStartable>(x => x.Stop());
 }
开发者ID:shijucv,项目名称:ninject,代码行数:9,代码来源:StartableStrategy.cs

示例5: Deactivate

        /// <summary>
        /// Disposes the specified instance.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="reference">A reference to the instance being deactivated.</param>
        public override void Deactivate(IContext context, InstanceReference reference)
        {
            reference.IfInstanceIs<ICommunicationObject>(x => x.CloseOrAbort());

            base.Deactivate(context, reference);
        }
开发者ID:bozhink,项目名称:Ninject.Extensions.Wcf,代码行数:11,代码来源:WcfDisposableStrategy.cs

示例6: Deactivate

 public void Deactivate(IContext context, InstanceReference reference) {
     reference.IfInstanceIs<ISubscriber>(s => {
                                             var eventAggregator = context.Kernel.Get<IEventAggregator>();
                                             eventAggregator.Unsubscribe(s);
                                         });
 }
开发者ID:rho24,项目名称:Rholiver.Mvvm,代码行数:6,代码来源:SubcribeToEventAggregatorStrategy.cs

示例7: Activate

 /// <summary>
 /// Activates the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="reference">The reference.</param>
 public override void Activate(IContext context, InstanceReference reference)
 {
     reference.IfInstanceIs<ContextPreservingResolutionRoot>(namedScopeResolutionRoot => DefineParentContext(context, namedScopeResolutionRoot));
 }
开发者ID:ninject,项目名称:Ninject.Extensions.ContextPreservation,代码行数:9,代码来源:ContextPreservingResolutionRootActivationStrategy.cs


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