• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Lifetime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetDefaultSettingsStream

 public Stream GetDefaultSettingsStream(Lifetime lifetime)
 {
   var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("JetBrains.ReSharper.PowerToys.ZenCoding.resources.PredefinedZenCodingSettings.xml");
   Assertion.AssertNotNull(stream, "stream == null");
   lifetime.AddDispose(stream);
   return stream;
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:PredefinedZenCodingSettings.cs


示例2: RsDocOptionsPage

        public RsDocOptionsPage(Lifetime lifetime, OptionsSettingsSmartContext optionsSettingsSmartContext)
            : base(lifetime, optionsSettingsSmartContext)
        {
            // output path
              IProperty<FileSystemPath> outputPath = new Property<FileSystemPath>(lifetime, "RsDocOptionsPage::OutputPath");
              outputPath.SetValue(FileSystemPath.TryParse(optionsSettingsSmartContext.StoreOptionsTransactionContext.GetValue((RsDocSettingsKey key) => key.RsDocOutputFolder)));
              outputPath.Change.Advise(lifetime, a =>
              {
            if (!a.HasNew || a.New == null) return;
            optionsSettingsSmartContext.StoreOptionsTransactionContext.SetValue((RsDocSettingsKey key) => key.RsDocOutputFolder, a.New.FullPath);
              });
              AddText("Output folder for generated content:");
              var outputPathOption = AddFolderChooserOption(outputPath, null, null);
              outputPathOption.IsEnabledProperty.SetValue(true);

              // folder with samples for context actions
              IProperty<FileSystemPath> caFolder = new Property<FileSystemPath>(lifetime, "RsDocOptionsPage::CaFolder");
              caFolder.SetValue(FileSystemPath.TryParse(optionsSettingsSmartContext.StoreOptionsTransactionContext.GetValue((RsDocSettingsKey key) => key.RsDocCaFolder)));
              caFolder.Change.Advise(lifetime, a =>
              {
            if (!a.HasNew || a.New == null) return;
            optionsSettingsSmartContext.StoreOptionsTransactionContext.SetValue((RsDocSettingsKey key) => key.RsDocCaFolder, a.New.FullPath);
              });
              AddText("Folder with context actions samples:");
              var caFoolderOption = AddFolderChooserOption(caFolder, null, null);
              caFoolderOption.IsEnabledProperty.SetValue(true);
        }
开发者ID:dmimat,项目名称:RsDocGenerator,代码行数:27,代码来源:RsDocOptionsPage.cs


示例3: Add

        public void Add(Severity severity, Lifetime lifeTime, Scope scope, string title, string message, params NotificationAction[] actions)
        {
            if (scope == Scope.User)
                throw new ArgumentException("Scope 'User' is not allowed for this overload as no IPrincipal is provided.", "scope");

            this.Add(severity, lifeTime, scope, null, title, message, actions);
        }
开发者ID:ppittle,项目名称:LBi.LostDoc,代码行数:7,代码来源:NotificationManager.cs


示例4: PsiCodeFormatter

 public PsiCodeFormatter(Lifetime lifetime, PsiLanguage language, ISettingsStore settingsStore, IViewable<IPsiCodeFormatterExtension> extensions, ISettingsOptimization settingsOptimization)
   : base(settingsStore)
 {
   myLanguage = language;
   myExtensions = extensions.ToLiveEnumerable(lifetime);
   mySettingsOptimization = settingsOptimization;
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:PsiCodeFormatter.cs


示例5: T4PsiModuleProvider

 public T4PsiModuleProvider([NotNull] Lifetime lifetime, [NotNull] IShellLocks shellLocks, [NotNull] ChangeManager changeManager, [NotNull] T4Environment t4Environment)
 {
     _lifetime = lifetime;
     _shellLocks = shellLocks;
     _changeManager = changeManager;
     _t4Environment = t4Environment;
 }
开发者ID:remcoros,项目名称:ForTea,代码行数:7,代码来源:T4PsiModuleProvider.cs


示例6: ComplexityAnalysisOptionPage

        public ComplexityAnalysisOptionPage(Lifetime lifetime, OptionsSettingsSmartContext optionsSettingsSmartContext, 
                                        ILanguages languages, ILanguageManager languageManager)
            : base(lifetime, optionsSettingsSmartContext)
        {
            AddText("Specify cyclomatic complexity thresholds:");

              var thresholds = OptionsSettingsSmartContext.Schema.GetIndexedEntry((CyclomaticComplexityAnalysisSettings s) => s.Thresholds);

              var list = new List<LanguageSpecificComplexityProperties>();
              foreach (var languageType in languages.All.Where(languageManager.HasService<IControlFlowBuilder>).OrderBy(GetPresentableName))
              {
            var presentableName = GetPresentableName(languageType);
            var thing = new LanguageSpecificComplexityProperties(lifetime, optionsSettingsSmartContext, thresholds, languageType.Name, presentableName, CyclomaticComplexityAnalysisSettings.DefaultThreshold);
            list.Add(thing);
              }

              // TODO: Do we want to add any keywords for the list view?
              // We would use OptionEntities.Add if the view model also implements IOptionEntity,
              // or use RegisterWord if we just want to add keyword(s)
              // (But the list view is just language name + threshold, so not very interesting)
              AddCustomOption(new ComplexityAnalysisOptionsViewModel(list));
              OptionEntities.Add(new HyperlinkOptionViewModel(lifetime, "What is a good threshold value?",
            new DelegateCommand(() => Process.Start("https://github.com/JetBrains/resharper-cyclomatic-complexity/blob/master/docs/ThresholdGuidance.md#readme"))));
              FinishPage();
        }
开发者ID:ciwchris,项目名称:resharper-cyclomatic-complexity,代码行数:25,代码来源:ComplexityAnalysisOptionPage.cs


示例7: MockMetricsOptionPage

 public MockMetricsOptionPage(Lifetime lifetime, UIApplication environment, OptionsSettingsSmartContext settings)
     : base(lifetime, environment, PID)
 {
     myLifetime = lifetime;
     mySettings = settings;
     InitControls();
 }
开发者ID:KozhevnikovDmitry,项目名称:MockMetrics,代码行数:7,代码来源:MockMetricsOptionPage.cs


示例8: JetBoxOptionsPage

        public JetBoxOptionsPage(Lifetime lifetime, IUIApplication environment, ClientFactory clientFactory, JetBoxSettingsStorage jetBoxSettings, JetPopupMenus jetPopupMenus)
            : base(lifetime, environment, PID)
        {
            mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              myLifetimes = new SequentialLifetimes(lifetime);

              myClient = clientFactory.CreateClient();
              myClient.UserLogin = mySettingsStore.GetValue(JetBoxSettingsAccessor.Login);

              // init UI
              myLoggedPanel = new FlowLayoutPanel { Visible = false, AutoSize = true };
              myLoggedPanel.Controls.Add(myLoginLabel = new RichTextLabel(environment));
              myLoggedPanel.Controls.Add(new LinkLabel("Logout", Logout, jetPopupMenus));

              myNonLoggedPanel = new FlowLayoutPanel { Visible = false, AutoSize = true, FlowDirection = FlowDirection.TopDown };
              myNonLoggedPanel.Controls.Add(new LinkLabel("Login", Login, jetPopupMenus)
              {
            Image = Environment.Theming.Icons[UnnamedThemedIcons.Dropbox.Id].CurrentGdipBitmapScreenDpi,
            ImageAlign = ContentAlignment.MiddleLeft,
            Padding = new Padding(20, 0, 0, 0)
              });

              Controls.Add(myLoggedPanel);
              Controls.Add(myNonLoggedPanel);

              InitLoginState();
        }
开发者ID:derigel23,项目名称:JetBox,代码行数:27,代码来源:JetBoxOptionsPage.cs


示例9: CreateCounterExample2

        public static Animation CreateCounterExample2(Lifetime life)
        {
            var animation = new Animation();

            var state = Ani.Anon(step => {
                var t = (step.TotalSeconds * 8).SmoothCycle(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);

                var t1 = TimeSpan.Zero;
                var t2 = t.Seconds();

                var ra = new EndPoint("Robot A", skew: 0.Seconds() + t1);
                var rb = new EndPoint("Robot B", skew: 0.Seconds() + t2);

                var graph = new EndPointGraph(
                    new[] { ra, rb },
                    new Dictionary<Tuple<EndPoint, EndPoint>, TimeSpan> {
                        {Tuple.Create(ra, rb), 2.Seconds() + t2 - t1},
                        {Tuple.Create(rb, ra), 2.Seconds() + t1 - t2},
                    });

                var m1 = new Message("I think it's t=0s.", graph, ra, rb, ra.Skew + 0.Seconds());
                var m2 = new Message("Received at t=2s", graph, rb, ra, m1.ArrivalTime);

                var s1 = new Measurement("Apparent Time Mistake = 2s+2s", ra, ra, m2.ArrivalTime, m2.ArrivalTime + 4.Seconds(), 60);
                var s2 = new Measurement("Time mistake = RTT - 4s", ra, ra, m2.ArrivalTime + 4.Seconds(), m2.ArrivalTime + 4.Seconds(), 140);

                return new GraphMessages(graph, new[] { m1, m2}, new[] { s1, s2});
            });

            return CreateNetworkAnimation(animation, state, life);
        }
开发者ID:siddht1,项目名称:AnimatronTheTerrible,代码行数:31,代码来源:NetworkSequenceDiagram.cs


示例10: Init

        /// <summary>
        /// The initializer for this ShellComponent.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime for this object.
        /// </param>
        private void Init(Lifetime lifetime)
        {
            RegistryUtils registryUtils = new RegistryUtils();

            object oneTimeInitializationRequiredRegistryKey = registryUtils.CUGetValue("LastInitializationDate");
            DateTime initializationDate = Convert.ToDateTime(oneTimeInitializationRequiredRegistryKey);

            string todayAsString = DateTime.Today.ToString("yyyy-MM-dd");

            string value = registryUtils.LMGetValue("InstallDate") as string;

            DateTime lastInstalledDate;

            try
            {
                lastInstalledDate = Convert.ToDateTime(value);

                // If the installer stored a date that has now been read back in and seems to be in the future
                // then use the LocalUserInstallDate value.
                if (lastInstalledDate > DateTime.Today)
                {
                    lastInstalledDate = GetInstallDateFromLocalUserRegistry(registryUtils, todayAsString);
                }
            }
            catch (FormatException ex)
            {
                // In some locales the installer saves the date in a format we can't parse back out.
                // Use today as the installed date and store it in the HKCU key.
                lastInstalledDate = GetInstallDateFromLocalUserRegistry(registryUtils, todayAsString);
            }

            if (oneTimeInitializationRequiredRegistryKey == null || initializationDate < lastInstalledDate)
            {
                SettingsStore settingsStore = Shell.Instance.GetComponent<SettingsStore>();

                IContextBoundSettingsStoreLive settings = settingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);

                bool checkReSharperCodeStyleOptionsAtStartUp = settings.GetValue((StyleCopOptionsSettingsKey key) => key.CheckReSharperCodeStyleOptionsAtStartUp);

                if (checkReSharperCodeStyleOptionsAtStartUp)
                {
                    if (!CodeStyleOptions.CodeStyleOptionsValid(settings, Core.Utils.GetSolution()))
                    {
                        DialogResult result =
                            MessageBox.Show(
                                @"Your ReSharper code style settings are not completely compatible with StyleCop. Would you like to reset them now?", 
                                @"StyleCop", 
                                MessageBoxButtons.YesNo, 
                                MessageBoxIcon.Question, 
                                MessageBoxDefaultButton.Button2);
                        if (result == DialogResult.Yes)
                        {
                            CodeStyleOptions.CodeStyleOptionsReset(settings, Core.Utils.GetSolution());
                        }
                    }
                }
            }

            registryUtils.CUSetValue("LastInitializationDate", todayAsString);
        }
开发者ID:icnocop,项目名称:StyleCop,代码行数:66,代码来源:StyleCopCodeStyleChecker.cs


示例11: UpdatesNotifier

        public UpdatesNotifier(Lifetime lifetime, UpdatesManager updatesManager)
        {
            var uri = new Uri("https://raw.github.com/hmemcpy/Nancy-ReSharper-Plugin/master/updates.xslt");

            var category = updatesManager.Categories.AddOrActivate("NancyFxSupport", uri);
            category.CustomizeLocalEnvironmentInfo.Advise(lifetime, args =>
            {
                // We can customize the local environment info that the xslt will be applied to
                // It should be an instance of UpdateLocalEnvironmentInfo, bail out early if it's
                // not. The only reason it wouldn't be is if someone has got hold of the "NancyFxSupport"
                // category and subscribed to the CustomizeLocalEnvironmentInfo signal. Unlikely.
                if (!(args.Out is UpdateLocalEnvironmentInfoVs))
                    return;

                // Set the data the xslt will be applied against. Pass in the current environment,
                // in case we ever need it, but really, we only care about the current version
                args.Out = new PluginLocalEnvironmentInfo
                {
                    LocalEnvironment = args.Out as UpdateLocalEnvironmentInfoVs,
                    PluginVersion = new UpdateLocalEnvironmentInfo.VersionSubInfo(GetThisVersion())
                };
            });

            RemoveStaleUpdateNotification(category);
        }
开发者ID:jimmason,项目名称:Nancy.ReSharper,代码行数:25,代码来源:UpdatesNotifier.cs


示例12: BindCommand

        private static ToolStripMenuItem BindCommand(this ToolStripDropDown dropDown, Lifetime<ICommand> command, object argument)
        {
            ToolStripMenuItem item = dropDown.Add(string.Empty);
            item.Tag = new ToolStripItemCommandBinding(dropDown, item, command, argument);

            return item;
        }
开发者ID:Giftednewt,项目名称:audio-switcher,代码行数:7,代码来源:ToolStripExtensions.cs


示例13: PatternManagerCache

        public PatternManagerCache(Lifetime lifetime, CacheManagerEx cacheManager, PsiProjectFileTypeCoordinator projectFileTypeCoordinator, SolutionAnalyzer solutionAnalyzer)
        {
            this.projectFileTypeCoordinator = projectFileTypeCoordinator;
            this.solutionAnalyzer = solutionAnalyzer;

            lifetime.AddBracket(() => cacheManager.RegisterCache(this), () => cacheManager.UnregisterCache(this));
        }
开发者ID:dpvreony-forks,项目名称:AgentMulder,代码行数:7,代码来源:PatternManagerCache.cs


示例14: ComplexityAnalysisOptionPage

 /// <summary>
 /// Creates new instance of ComplexityAnalysisOptionPage
 /// </summary>
 public ComplexityAnalysisOptionPage(Lifetime lifetime, FontsManager fontsManager, OptionsSettingsSmartContext settings)
   : base(lifetime, fontsManager, PID)
 {
   myLifetime = lifetime;
   mySettings = settings;
   InitControls();
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:10,代码来源:ComplexityAnalysisOptionPage.cs


示例15: Get

        public static ILifetimeStrategy Get(Lifetime lifetime, INCopDependencyResolver container)
        {
            switch (lifetime) {
                case Lifetime.None:
                    return defaultLifetimeStrategy;

                case Lifetime.PerThread :
                    return PerThreadLifetimeStrategy.Instance;

                case Lifetime.HttpRequest:
                    return HttpRequestLifetimeStrategy.Instance;

                case Lifetime.Hierarchy:
                    return new HierarchySingletonLifetimeStrategy();

                case Lifetime.Container:
                    return new ContainerSingletonLifetimeStrategy(container);

                case Lifetime.HybridRequest:
                    return hybridRequestLifetimeStrategy;

                default:
                    throw new ResolutionException(Resources.UnknownLifetime);
            }
        }
开发者ID:sagifogel,项目名称:NCop,代码行数:25,代码来源:LifetimeStrategyFactory.cs


示例16: NancyReferenceProviderFactory

 public NancyReferenceProviderFactory(Lifetime lifetime, ISolution solution, ISettingsStore settingsStore, MvcReferenceProviderValidator providerValidator)
 {
     this.solution = solution;
     
     lifetime.AddBracket(() => providerValidator.OnChanged += FireOnChanged,
                         () => providerValidator.OnChanged -= FireOnChanged);
 }
开发者ID:jimmason,项目名称:Nancy.ReSharper,代码行数:7,代码来源:NancyReferenceProviderFactory.cs


示例17: package

        private ILookup<string, FileSystemPath> installedPackages; // there can be several versions of one package (different versions)

        #endregion Fields

        #region Constructors

        public NuGetApi(ISolution solution, Lifetime lifetime, IComponentModel componentModel, IThreading threading, ProjectModelSynchronizer projectModelSynchronizer)
        {
            this.solution = solution;
            this.threading = threading;
            this.projectModelSynchronizer = projectModelSynchronizer;
            try
            {
                vsPackageInstallerServices = componentModel.GetExtensions<IVsPackageInstallerServices>().SingleOrDefault();
                vsPackageInstaller = componentModel.GetExtensions<IVsPackageInstaller>().SingleOrDefault();
                vsPackageInstallerEvents = componentModel.GetExtensions<IVsPackageInstallerEvents>().SingleOrDefault();
            }
            catch (Exception e)
            {
                Logger.LogException("Unable to get NuGet interfaces.", e);
            }

            if (!IsNuGetAvailable)
            {
                Logger.LogMessage(LoggingLevel.VERBOSE, "[NUGET PLUGIN] Unable to get NuGet interfaces. No exception thrown");
                return;
            }

            lifetime.AddBracket(
              () => vsPackageInstallerEvents.PackageInstalled += RecalcInstalledPackages,
              () => vsPackageInstallerEvents.PackageInstalled -= RecalcInstalledPackages);

              lifetime.AddBracket(
              () => vsPackageInstallerEvents.PackageUninstalled += RecalcInstalledPackages,
              () => vsPackageInstallerEvents.PackageUninstalled -= RecalcInstalledPackages);

              RecalcInstalledPackages(null);
        }
开发者ID:netProgrammer,项目名称:resharper-nuget,代码行数:38,代码来源:NuGetApi.cs


示例18: GetDefaultSettingsStream

 public Stream GetDefaultSettingsStream(Lifetime lifetime)
 {
     var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("JetBrains.ReSharper.Plugins.CyclomaticComplexity.Resources.DefaultSettings.xml");
       Assertion.Assert(stream != null, "stream != null");
       lifetime.AddDispose(stream);
       return stream;
 }
开发者ID:ciwchris,项目名称:resharper-cyclomatic-complexity,代码行数:7,代码来源:DefaultCyclomaticComplexitySettings.cs


示例19: ProductSettingsTracker

        public ProductSettingsTracker(Lifetime lifetime, IProductNameAndVersion product, ClientFactory clientFactory, GlobalPerProductStorage globalPerProductStorage, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
              mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

              myRootFolder = FileSystemPath.Parse(product.ProductName);
              InitClient();

              var productSettingsPath = globalPerProductStorage.XmlFileStorage.Path;

              SyncFromCloud(productSettingsPath.Value);

              var fileTrackingLifetime = new SequentialLifetimes(lifetime);
              productSettingsPath.Change.Advise(lifetime,
            args =>
            {
              var path = args.Property.Value;
              if (lifetime.IsTerminated || path.IsNullOrEmpty())
              {
            fileTrackingLifetime.TerminateCurrent();
              }
              else
              {
            fileTrackingLifetime.Next(lt => fileSystemTracker.AdviseFileChanges(lt, path, delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
              }
            });
        }
开发者ID:jrote1,项目名称:JetBox,代码行数:28,代码来源:ProductSettingsTracker.cs


示例20: Open

    public void Open(Lifetime lifetime, IShellLocks shellLocks, ChangeManager changeManager, ISolution solution, DocumentManager documentManager, IActionManager actionManager, ICommandProcessor commandProcessor, TextControlChangeUnitFactory changeUnitFactory, JetPopupMenus jetPopupMenus)
    {
      Debug.Assert(!IsOpened);

      _solution = solution;
      DocumentManager = documentManager;
      _jetPopupMenus = jetPopupMenus;
      changeManager.Changed2.Advise(lifetime, Handler);
      lifetime.AddAction(Close);
      var expandAction = actionManager.Defs.TryGetActionDefById(GotoDeclarationAction.ACTION_ID);
      if (expandAction != null)
      {
        var postfixHandler = new GotoDeclarationHandler(lifetime, shellLocks, commandProcessor, changeUnitFactory, this);

        lifetime.AddBracket(
          FOpening: () => actionManager.Handlers.AddHandler(expandAction, postfixHandler),
          FClosing: () => actionManager.Handlers.RemoveHandler(expandAction, postfixHandler));
      }
      
      var findUsagesAction = actionManager.Defs.GetActionDef<FindUsagesAction>();
      var findUsagesHandler = new FindUsagesHandler(lifetime, shellLocks, commandProcessor, changeUnitFactory, this);

      lifetime.AddBracket(
        FOpening: () => actionManager.Handlers.AddHandler(findUsagesAction, findUsagesHandler),
        FClosing: () => actionManager.Handlers.RemoveHandler(findUsagesAction, findUsagesHandler));
    }
开发者ID:derigel23,项目名称:Nitra,代码行数:26,代码来源:Solution.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LiftExportAsFragmentTestSession类代码示例发布时间:2022-05-24
下一篇:
C# Lifestyle类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap