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


C# Lifetime类代码示例

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


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


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