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


C# Snapshot类代码示例

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


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

示例1: ListChangedCommand

 public ListChangedCommand(CollectionObserver collection, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
     {
         foreach (var item in e.NewItems)
         {
             snapshot = new Snapshot()
             {
                 Collection = collection,
                 NewState = DataState.Created,
                 NewValue = item,
                 Index = e.NewStartingIndex
             };
         }
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
     {
         foreach (var item in e.OldItems)
         {
             snapshot = new Snapshot()
             {
                 Collection = collection,
                 NewState = DataState.Deleted,
                 OldValue = item,
                 Index = e.OldStartingIndex
             };
         }
     }
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:29,代码来源:ListChangedCommand.cs

示例2: Save

 public void Save(Snapshot snapshot)
 {
     if(snapshot.Version == 0)
         FirstSaved = true;
     SavedVersion = snapshot.Version;
     _snapshot = snapshot;
 }
开发者ID:rjygraham,项目名称:CQRSlite,代码行数:7,代码来源:TestInMemorySnapshotStore.cs

示例3: ChainBuilderContinuesIfYouAskForAStoreOrSinkThatDoesntExist

        public void ChainBuilderContinuesIfYouAskForAStoreOrSinkThatDoesntExist()
        {
            var snapshot = new Snapshot { new MetricData(0.5, DateTime.Parse("12 Aug 2008"), new List<string> { "value" }) };

            var configs = new List<ChainElement>
                {
                    new ChainElement("id", "storageChain", "testSourceId", "testBufferId", ""),
                };

            var source = MockRepository.GenerateMock<ISnapshotProvider>();
            source.Expect(s => s.Snapshot()).Return(snapshot).Repeat.Any();
            source.Expect(s => s.Name).Return("testSource").Repeat.Any();
            source.Expect(s => s.Id).Return("testSourceId").Repeat.Any();

            var sources = new HashSet<ISnapshotProvider> { source };

            var sourceChains = ChainBuilder.Build(sources, new HashSet<ISnapshotConsumer>(), new HashSet<IMultipleSnapshotConsumer>(), configs);

            Assert.AreEqual(0, sourceChains.Count());

            var buffer = MockRepository.GenerateMock<ISnapshotConsumer>();
            buffer.Expect(b => b.Update(snapshot));
            buffer.Expect(s => s.Name).Return("testBuffer").Repeat.Any();
            buffer.Expect(s => s.Id).Return("testBufferId").Repeat.Any();

            var sinks = new HashSet<ISnapshotConsumer> { buffer };

            var sinkChains = ChainBuilder.Build(new HashSet<ISnapshotProvider>(), sinks, new HashSet<IMultipleSnapshotConsumer>(), configs);

            Assert.AreEqual(0, sinkChains.Count());
        }
开发者ID:timbarrass,项目名称:Alembic.Metrics,代码行数:31,代码来源:ChainBuilderTests.cs

示例4: SetRight

        public void SetRight(Snapshot right)
        {
            Right = new Snapshot(right);

            Debug.Assert(Left != null);
            CalculateDiff();
        }
开发者ID:dakahler,项目名称:alloclave,代码行数:7,代码来源:Diff.cs

示例5: CollectionChangedCommand

 public CollectionChangedCommand(IStatefulCollection collection, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
     {
         foreach (StatefulObject obj in e.NewItems)
         {
             snapshot = new Snapshot()
             {
                 Collection = collection,
                 OldState = obj.DataState,
                 NewState = DataState.Created,
                 NewValue = obj
             };
         }
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
     {
         foreach (StatefulObject obj in e.OldItems)
         {
             snapshot = new Snapshot()
             {
                 Collection = collection,
                 OldState = obj.DataState,
                 NewState = DataState.Deleted,
                 OldValue = obj
             };
         }
     }
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:29,代码来源:CollectionChangedCommand.cs

示例6: TryLoadFromSnapshot

        public bool TryLoadFromSnapshot(Type aggregateRootType, Snapshot snapshot, CommittedEventStream committedEventStream, out AggregateRoot aggregateRoot)
        {
            aggregateRoot = null;

            if (snapshot == null) return false;

            if (AggregateSupportsSnapshot(aggregateRootType, snapshot.Payload.GetType()))
            {
                Log.DebugFormat("Reconstructing aggregate root {0}[{1}] from snapshot", aggregateRootType.FullName,
                                snapshot.EventSourceId.ToString("D"));
                aggregateRoot = _aggregateRootCreator.CreateAggregateRoot(aggregateRootType);
                aggregateRoot.InitializeFromSnapshot(snapshot);

                var memType = aggregateRoot.GetType().GetSnapshotInterfaceType();
                var restoreMethod = memType.GetMethod("RestoreFromSnapshot");

                restoreMethod.Invoke(aggregateRoot, new[] { snapshot.Payload });

                Log.DebugFormat("Applying remaining historic event to reconstructed aggregate root {0}[{1}]",
                    aggregateRootType.FullName, snapshot.EventSourceId.ToString("D"));
                aggregateRoot.InitializeFromHistory(committedEventStream);

                return true;
            }

            return false;
        }
开发者ID:VincentSchippefilt,项目名称:ncqrs,代码行数:27,代码来源:DefaultAggregateSnapshotter.cs

示例7: ChainCanBeConfiguredWithASingleSourceAndMultipleSinks

        public void ChainCanBeConfiguredWithASingleSourceAndMultipleSinks()
        {
            var snapshot = new Snapshot { new MetricData(0.5, DateTime.Parse("12 Aug 2008"), new List<string>()) };

            var name = "testChain";

            var source = MockRepository.GenerateMock<ISnapshotProvider>();
            source.Expect(s => s.Snapshot()).Return(snapshot);

            var buffer = MockRepository.GenerateMock<ISnapshotConsumer>();
            buffer.Expect(b => b.Update(snapshot));

            var store = MockRepository.GenerateMock<ISnapshotConsumer>();
            store.Expect(s => s.Update(snapshot));

            var chain = new MultipleSinkChain("id", name, source, buffer, store);

            chain.Update();

            store.VerifyAllExpectations();

            buffer.VerifyAllExpectations();

            source.VerifyAllExpectations();
        }
开发者ID:timbarrass,项目名称:Alembic.Metrics,代码行数:25,代码来源:ChainTests.cs

示例8: Main

    static void Main(string[] args)
    {
      // Null-conditional operator.

      string name = null;
      var nameLength = name?.Length;
      List<string> names = null;
      nameLength = names?[0].Length;

      var notifier = new Notifier();
      notifier.ChangeState();
      notifier.StateChanged += (sender, e) => WriteLine("StateChanged notification received...");
      notifier.ChangeState();

      // await in catch/finally blocks.
      notifier.ChangeStateAsync().Wait();

      // Auto-property initializers + expression-bodied members + string interpolation.
      var snapshot = new Snapshot();
      WriteLine(snapshot);
      WriteLine($"{snapshot.UserName} created on {snapshot.Timestamp} with name length of {name?.Length ?? 0}");

      // nameof expressions.
      WriteLine(nameof(args));
      WriteLine(nameof(notifier));
      WriteLine(nameof(Main));
      WriteLine(nameof(Program));

      ReadLine();
    }
开发者ID:PaloMraz,项目名称:CSharp6LanguageFeatures,代码行数:30,代码来源:Program.cs

示例9: CanBeReset

        public void CanBeReset()
        {
            var firstSnapshot = new Snapshot { Name = "first" };
            firstSnapshot.Add(new MetricData(10, DateTime.Now.AddMinutes(-2), new List<string> { "value" }));
            firstSnapshot.Add(new MetricData(11, DateTime.Now.AddMinutes(-1.5), new List<string> { "value" }));
            firstSnapshot.Add(new MetricData(15, DateTime.Now.AddMinutes(-1), new List<string> { "value" }));

            var secondSnapshot = new Snapshot { Name = "second" };
            secondSnapshot.Add(new MetricData(10, DateTime.Now.AddMinutes(-2), new List<string> { "value2" }));
            secondSnapshot.Add(new MetricData(5, DateTime.Now.AddMinutes(-1.5), new List<string> { "value2" }));
            secondSnapshot.Add(new MetricData(6, DateTime.Now.AddMinutes(-1), new List<string> { "value2" }));

            var name = "testPlotter";

            var config = new PlotterElement("id", name, ".", 0, 15, 1, "");

            var sink = new MultiPlotter(config);

            sink.ResetWith(new [] { firstSnapshot, secondSnapshot });

            var plotFile = Path.Combine(".", Path.ChangeExtension(name, "png"));

            Assert.IsTrue(File.Exists(plotFile));

            File.Delete(plotFile);
        }
开发者ID:timbarrass,项目名称:Alembic.Metrics,代码行数:26,代码来源:MultiPlotterTests.cs

示例10: GetSnapshotVersionNumber

        /// <summary>
        /// 
        /// </summary>
        /// <param name="snapshot"></param>
        /// <returns></returns>
        public static String GetSnapshotVersionNumber(Snapshot snapshot)
        {
            if (snapshot != null  && snapshot.Annotation != null && snapshot.Annotation.Version != null)
                return snapshot.Annotation.Version;

            return null;
        }
开发者ID:samadm,项目名称:ReportGenerator,代码行数:12,代码来源:SnapshotUtility.cs

示例11: TryLoadFromSnapshot

        public bool TryLoadFromSnapshot(Type aggregateRootType, Snapshot snapshot, CommittedEventStream committedEventStream, out Domain.AggregateRoot aggregateRoot)
        {
            aggregateRoot = null;

            if (snapshot == null) return false;

            if (AggregateSupportsSnapshot(aggregateRootType, snapshot.Payload.GetType()))
            {
                try
                {
                    Log.DebugFormat("Reconstructing aggregate root {0}[{1}] from snapshot", aggregateRootType.FullName,
                                    snapshot.EventSourceId.ToString("D"));
                    aggregateRoot = _aggregateRootCreator.CreateAggregateRoot(aggregateRootType);
                    aggregateRoot.InitializeFromSnapshot(snapshot);
                    aggregateRoot.RestoreFromSnapshot(snapshot.Payload);

                    Log.DebugFormat("Applying remaining historic event to reconstructed aggregate root {0}[{1}]",
                        aggregateRootType.FullName, snapshot.EventSourceId.ToString("D"));
                    aggregateRoot.InitializeFromHistory(committedEventStream);
                }
                catch (Exception ex)
                {
                    Log.ErrorFormat("Cannot load snapshot for '{0}' aggregate. {1}",
                        aggregateRoot.GetType().FullName, ex.Message);
                    aggregateRoot = null;
                    return false;
                }

                return true;
            }

            return false;
        }
开发者ID:VincentSchippefilt,项目名称:ncqrs,代码行数:33,代码来源:AggregateDynamicSnapshotter.cs

示例12: GetCostComplexityName

        /// <summary>
        /// 
        /// </summary>
        /// <param name="snapshot"></param>
        /// <param name="CategorieIndex"></param>
        /// <param name="Metricindex"></param>
        /// <returns></returns>
        public static string GetCostComplexityName(Snapshot snapshot, int categorieId)
        {
            var result = snapshot.CostComplexityResults.Where(_ => _.Reference.Key == categorieId)
                                                       .FirstOrDefault();

            return (result != null && result.Reference!=null) ? result.Reference.Name : null;
        }
开发者ID:samadm,项目名称:ReportGenerator,代码行数:14,代码来源:CastComplexityUtility.cs

示例13: stats_should_be_zero_for_empty_snapshot

 public void stats_should_be_zero_for_empty_snapshot() {
   var snapshot = new Snapshot(new long[] {});
   Assert.That(snapshot.Min, Is.EqualTo(0));
   Assert.That(snapshot.Max, Is.EqualTo(0));
   Assert.That(snapshot.Mean, Is.EqualTo(0));
   Assert.That(snapshot.StdDev, Is.EqualTo(0));
 }
开发者ID:joethinh,项目名称:nohros-must,代码行数:7,代码来源:SnapshotTests.cs

示例14: ScheduleBuilderCanBuildAScheduleForMultipleChains

        // ChainWorkerBuilder -> ChainThreadBuilder -> ChainTaskBuilder -> SnapshotUpdaterBuilder
        // -> TimedSnapshotUpdaterBuilder -> SnapshotScheduleBuilder -> DelayedScheduleBuilder
        // -> ScheduleBuilder
        public void ScheduleBuilderCanBuildAScheduleForMultipleChains()
        {
            var scheduleName = "testSchedule";
            var delay = 10;

            var snapshot = new Snapshot { new MetricData(0.5, DateTime.Parse("12 Aug 2008"), new List<string>()) };

            var configs = new List<ChainElement>
                {
                    new ChainElement("id1", "firstTestChain", "testSourceId", "testBufferId", ""),
                    new ChainElement("id2", "secondTestChain", "testSourceId", "testBufferId", "")
                };                   

            var source = MockRepository.GenerateMock<ISnapshotProvider>();
            source.Expect(s => s.Snapshot()).Return(snapshot).Repeat.Any();
            source.Expect(s => s.Name).Return("testSource").Repeat.Any();
            source.Expect(s => s.Id).Return("testSourceId").Repeat.Any();

            var buffer = MockRepository.GenerateMock<ISnapshotConsumer>();
            buffer.Expect(b => b.Update(snapshot));
            buffer.Expect(s => s.Name).Return("testBuffer").Repeat.Any();
            buffer.Expect(s => s.Id).Return("testBufferId").Repeat.Any();

            var sources = new HashSet<ISnapshotProvider> { source };

            var sinks = new HashSet<ISnapshotConsumer> { buffer };

            var chains = ChainBuilder.Build(sources, sinks, new HashSet<IMultipleSnapshotConsumer>(), configs);

            var schedule = ScheduleBuilder.Build(scheduleName, delay, chains);

            Assert.IsInstanceOf<ISchedule>(schedule);
            Assert.AreEqual(scheduleName, schedule.Name);
            Assert.AreEqual(2, schedule.Chains.Count());
        }
开发者ID:timbarrass,项目名称:Alembic.Metrics,代码行数:38,代码来源:ScheduleBuilderTests.cs

示例15: GetBusinessCriteriaGradesModules

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static List<BusinessCriteriaDTO> GetBusinessCriteriaGradesModules(Snapshot snapshot, bool Round)
        {
            if (snapshot != null && snapshot.BusinessCriteriaResults != null)
            {
                List<BusinessCriteriaDTO> result = new List<BusinessCriteriaDTO>();

                var modules = snapshot.BusinessCriteriaResults.SelectMany(_ => _.ModulesResult).Select(_ => _.Module).Distinct();

                result = modules.Select(module => new BusinessCriteriaDTO
                                                {
                                                        Name = module.Name,

                                                        TQI = GetBusinessCriteriaModuleGrade(snapshot, module.Href, Constants.BusinessCriteria.TechnicalQualityIndex, Round),

                                                        Robustness = GetBusinessCriteriaModuleGrade(snapshot, module.Href, Constants.BusinessCriteria.Robustness, Round),

                                                        Performance = GetBusinessCriteriaModuleGrade(snapshot, module.Href, Constants.BusinessCriteria.Performance, Round),

                                                        Security = GetBusinessCriteriaModuleGrade(snapshot, module.Href, Constants.BusinessCriteria.Security, Round),

                                                        Changeability = GetBusinessCriteriaModuleGrade(snapshot, module.Href, Constants.BusinessCriteria.Changeability, Round),

                                                        Transferability = GetBusinessCriteriaModuleGrade(snapshot, module.Href, Constants.BusinessCriteria.Transferability, Round),
                                                                                    })
                                .ToList();

                return result;
            }
            return null;
        }
开发者ID:samadm,项目名称:ReportGenerator,代码行数:34,代码来源:BusinessCriteriaUtility.cs


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