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


C# TrackingCollection类代码示例

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


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

示例1: RepositoryCloneViewModel

        public RepositoryCloneViewModel(
            IRepositoryHost repositoryHost,
            IRepositoryCloneService cloneService,
            IOperatingSystem operatingSystem,
            INotificationService notificationService,
            IUsageTracker usageTracker)
        {
            this.repositoryHost = repositoryHost;
            this.cloneService = cloneService;
            this.operatingSystem = operatingSystem;
            this.notificationService = notificationService;
            this.usageTracker = usageTracker;

            Title = string.Format(CultureInfo.CurrentCulture, Resources.CloneTitle, repositoryHost.Title);

            Repositories = new TrackingCollection<IRemoteRepositoryModel>();
            repositories.ProcessingDelay = TimeSpan.Zero;
            repositories.Comparer = OrderedComparer<IRemoteRepositoryModel>.OrderBy(x => x.Owner).ThenBy(x => x.Name).Compare;
            repositories.Filter = FilterRepository;
            repositories.NewerComparer = OrderedComparer<IRemoteRepositoryModel>.OrderByDescending(x => x.UpdatedAt).Compare;

            filterTextIsEnabled = this.WhenAny(x => x.IsLoading,
                loading => loading.Value || repositories.UnfilteredCount > 0 && !LoadingFailed)
                .ToProperty(this, x => x.FilterTextIsEnabled);

            this.WhenAny(x => x.IsLoading, x => x.LoadingFailed,
                (loading, failed) => !loading.Value && !failed.Value && repositories.UnfilteredCount == 0)
                .Subscribe(x => NoRepositoriesFound = x);

            this.WhenAny(x => x.FilterText, x => x.Value)
                .DistinctUntilChanged(StringComparer.OrdinalIgnoreCase)
                .Throttle(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler)
                .Subscribe(_ => repositories.Filter = FilterRepository);

            var baseRepositoryPath = this.WhenAny(
                x => x.BaseRepositoryPath,
                x => x.SelectedRepository,
                (x, y) => x.Value);

            BaseRepositoryPathValidator = ReactivePropertyValidator.ForObservable(baseRepositoryPath)
                .IfNullOrEmpty(Resources.RepositoryCreationClonePathEmpty)
                .IfTrue(x => x.Length > 200, Resources.RepositoryCreationClonePathTooLong)
                .IfContainsInvalidPathChars(Resources.RepositoryCreationClonePathInvalidCharacters)
                .IfPathNotRooted(Resources.RepositoryCreationClonePathInvalid)
                .IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists);

            var canCloneObservable = this.WhenAny(
                x => x.SelectedRepository,
                x => x.BaseRepositoryPathValidator.ValidationResult.IsValid,
                (x, y) => x.Value != null && y.Value);
            canClone = canCloneObservable.ToProperty(this, x => x.CanClone);
            CloneCommand = ReactiveCommand.CreateAsyncObservable(canCloneObservable, OnCloneRepository);

            browseForDirectoryCommand.Subscribe(_ => ShowBrowseForDirectoryDialog());
            this.WhenAny(x => x.BaseRepositoryPathValidator.ValidationResult, x => x.Value)
                .Subscribe();
            BaseRepositoryPath = cloneService.DefaultClonePath;
            NoRepositoriesFound = true;
        }
开发者ID:github,项目名称:VisualStudio,代码行数:59,代码来源:RepositoryCloneViewModel.cs

示例2: ParticlePlugin

 /// <summary>
 /// Initializes a new instance of the <see cref="ParticlePlugin" /> class.
 /// </summary>
 /// <param name="name">Name of this particle manager</param>
 public ParticlePlugin(string name) : base(name)
 {
     meshesToRender = new RenderPassListEnumerator();
     Updaters = new TrackingCollection<ParticleEmitterComponent>();
     currentUpdaters = new List<ParticleUpdaterState>();
     updatersToRemove = new List<ParticleUpdaterState>();
     Updaters.CollectionChanged += UpdatersOnCollectionChanged;
     EnableSorting = true;
 }
开发者ID:cg123,项目名称:xenko,代码行数:13,代码来源:ParticlePlugin.cs

示例3: PhysicsElementBase

        protected PhysicsElementBase()
        {
            CanScaleShape = true;

            ColliderShapes = new TrackingCollection<IInlineColliderShapeDesc>();
            ColliderShapes.CollectionChanged += (sender, args) =>
            {
                ColliderShapeChanged = true;
            };
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:10,代码来源:PhysicsElementBase.cs

示例4: When_Item_Added_Raises_ItemAdded

		public void When_Item_Added_Raises_ItemAdded() {
			string addedItem = null;
			var items = new TrackingCollection<string>();

			using(items.OnItemAdded(x => addedItem = x)) {
				items.Add("foo");
			}

			addedItem.ShouldEqual("foo");
		}
开发者ID:jango2015,项目名称:FluentValidation,代码行数:10,代码来源:TrackingCollectionTests.cs

示例5: SceneInstance

        /// <summary>
        /// Initializes a new instance of the <see cref="SceneInstance" /> class.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <param name="sceneEntityRoot">The scene entity root.</param>
        /// <param name="enableScripting">if set to <c>true</c> [enable scripting].</param>
        /// <exception cref="System.ArgumentNullException">services
        /// or
        /// sceneEntityRoot</exception>
        public SceneInstance(IServiceRegistry services, Scene sceneEntityRoot, ExecutionMode executionMode = ExecutionMode.Runtime) : base(services)
        {
            if (services == null) throw new ArgumentNullException("services");

            ExecutionMode = executionMode;
            VisibilityGroups = new TrackingCollection<VisibilityGroup>();
            VisibilityGroups.CollectionChanged += VisibilityGroups_CollectionChanged;
            Scene = sceneEntityRoot;
            Load();
        }
开发者ID:cg123,项目名称:xenko,代码行数:19,代码来源:SceneInstance.cs

示例6: PullRequestListViewModel

        public PullRequestListViewModel(
            IRepositoryHost repositoryHost,
            ILocalRepositoryModel repository,
            IPackageSettings settings)
        {
            this.repositoryHost = repositoryHost;
            this.repository = repository;
            this.settings = settings;

            Title = Resources.PullRequestsNavigationItemText;

            this.listSettings = settings.UIState
                .GetOrCreateRepositoryState(repository.CloneUrl)
                .PullRequests;

            openPullRequestCommand = ReactiveCommand.Create();
            openPullRequestCommand.Subscribe(_ =>
            {
                VisualStudio.Services.DefaultExportProvider.GetExportedValue<IVisualStudioBrowser>().OpenUrl(repositoryHost.Address.WebUri);
            });

            States = new List<PullRequestState> {
                new PullRequestState { IsOpen = true, Name = "Open" },
                new PullRequestState { IsOpen = false, Name = "Closed" },
                new PullRequestState { Name = "All" }
            };

            trackingAuthors = new TrackingCollection<IAccount>(Observable.Empty<IAccount>(),
                OrderedComparer<IAccount>.OrderByDescending(x => x.Login).Compare);
            trackingAssignees = new TrackingCollection<IAccount>(Observable.Empty<IAccount>(),
                OrderedComparer<IAccount>.OrderByDescending(x => x.Login).Compare);
            trackingAuthors.Subscribe();
            trackingAssignees.Subscribe();

            Authors = trackingAuthors.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAuthor));
            Assignees = trackingAssignees.CreateListenerCollection(EmptyUser, this.WhenAnyValue(x => x.SelectedAssignee));

            PullRequests = new TrackingCollection<IPullRequestModel>();
            pullRequests.Comparer = OrderedComparer<IPullRequestModel>.OrderByDescending(x => x.UpdatedAt).Compare;
            pullRequests.NewerComparer = OrderedComparer<IPullRequestModel>.OrderByDescending(x => x.UpdatedAt).Compare;

            this.WhenAny(x => x.SelectedState, x => x.Value)
                .Where(x => PullRequests != null)
                .Subscribe(s => UpdateFilter(s, SelectedAssignee, SelectedAuthor));

            this.WhenAny(x => x.SelectedAssignee, x => x.Value)
                .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
                .Subscribe(a => UpdateFilter(SelectedState, a, SelectedAuthor));

            this.WhenAny(x => x.SelectedAuthor, x => x.Value)
                .Where(x => PullRequests != null && x != EmptyUser && IsLoaded)
                .Subscribe(a => UpdateFilter(SelectedState, SelectedAssignee, a));

            SelectedState = States.FirstOrDefault(x => x.Name == listSettings.SelectedState) ?? States[0];
        }
开发者ID:github,项目名称:VisualStudio,代码行数:55,代码来源:PullRequestListViewModel.cs

示例7: TransformComponent

        /// <summary>
        /// Initializes a new instance of the <see cref="TransformComponent" /> class.
        /// </summary>
        public TransformComponent()
        {
            var children = new TrackingCollection<TransformComponent>();
            children.CollectionChanged += ChildrenCollectionChanged;

            Children = children;

            UseTRS = true;
            Scale = Vector3.One;
            Rotation = Quaternion.Identity;
        }
开发者ID:releed,项目名称:paradox,代码行数:14,代码来源:TransformComponent.cs

示例8: Should_not_raise_event_once_handler_detached

		public void Should_not_raise_event_once_handler_detached() {
			var addedItems = new List<string>();
			var items = new TrackingCollection<string>();
			
			using(items.OnItemAdded(addedItems.Add)) {
				items.Add("foo");
			}
			items.Add("bar");

			addedItems.Count.ShouldEqual(1);
		}
开发者ID:jango2015,项目名称:FluentValidation,代码行数:11,代码来源:TrackingCollectionTests.cs

示例9: ViewModel

 public ViewModel()
 {
     _selectedView = View.vwOpsChecklistLoad;
     //_selectedView = View.vwDueToday | View.vwAssignedTasks;//this sets the initial View
     _tasks = new TrackingCollection();
     Refreshing = false;
     IsUpdating = false;
     regionalSettings = new RegionalSetting(this);
     LoggedInUserInfo = new UserInfo();
     memberOfGroups = new ObservableCollection<string>();
     MemberOfGroups.CollectionChanged += MemberOfGroups_CollectionChanged;
 }
开发者ID:nilavghosh,项目名称:VChk,代码行数:12,代码来源:ViewModel.cs

示例10: PhysicsComponent

        protected PhysicsComponent()
        {
            CanScaleShape = true;

            ColliderShapes = new TrackingCollection<IInlineColliderShapeDesc>();
            ColliderShapes.CollectionChanged += (sender, args) =>
            {
                ColliderShapeChanged = true;
            };

            NewPairChannel = new Channel<Collision> { Preference = ChannelPreference.PreferSender };
            PairEndedChannel = new Channel<Collision> { Preference = ChannelPreference.PreferSender };
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:13,代码来源:PhysicsComponent.cs

示例11: OrderByUpdatedFilter

    public void OrderByUpdatedFilter()
    {
        var count = 3;
        ITrackingCollection<Thing> col = new TrackingCollection<Thing>(
            Observable.Never<Thing>(),
            OrderedComparer<Thing>.OrderBy(x => x.UpdatedAt).Compare,
            (item, position, list) => true,
            OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare);
        col.ProcessingDelay = TimeSpan.Zero;

        var list1 = new List<Thing>(Enumerable.Range(1, count).Select(i => GetThing(i, i, count - i, "Run 1")).ToList());
        var list2 = new List<Thing>(Enumerable.Range(1, count).Select(i => GetThing(i, i, i + count, "Run 2")).ToList());

        var evt = new ManualResetEvent(false);
        col.Subscribe(t =>
        {
            if (++count == list1.Count)
                evt.Set();
        }, () => { });

        count = 0;
        // add first items
        foreach (var l in list1)
            col.AddItem(l);

        evt.WaitOne();
        evt.Reset();

        Assert.AreEqual(list1.Count, col.Count);
        list1.Sort(new LambdaComparer<Thing>(OrderedComparer<Thing>.OrderByDescending(x => x.CreatedAt).Compare));
        CollectionAssert.AreEqual(col, list1);

        count = 0;
        // replace items
        foreach (var l in list2)
            col.AddItem(l);

        evt.WaitOne();
        evt.Reset();

        Assert.AreEqual(list2.Count, col.Count);
        CollectionAssert.AreEqual(col, list2);

        col.Dispose();
    }
开发者ID:shana,项目名称:handy-things,代码行数:45,代码来源:TrackingCollectionTests.cs

示例12: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            /*
            stuff.CollectionChanged += (s, e) => {
                Console.WriteLine(e.Action);
                e.NewItems?.OfType<Thing>().All(thing => { Console.WriteLine("{0} {1}:{2}", e.Action, thing.Number, thing.UpdatedAt); return true; });
            };
            */

            Activated += (s, e) =>
            {
            };

            col = new TrackingCollection<Thing>(
            OrderedComparer<Thing>.OrderByDescending(x => x.UpdatedAt).Compare);
            col.ProcessingDelay = TimeSpan.FromMilliseconds(30);
        }
开发者ID:shana,项目名称:handy-things,代码行数:21,代码来源:MainWindow.xaml.cs

示例13: Removing

    public void Removing()
    {
        var source = new Subject<Thing>();

        var col = new TrackingCollection<Thing>(
            source,
            OrderedComparer<Thing>.OrderBy(x => x.UpdatedAt).Compare,
            (item, position, list) => (position > 2 && position < 5) || (position > 6 && position < 8))
            { ProcessingDelay = TimeSpan.Zero };

        var count = 0;
        var expectedCount = 0;
        var evt = new ManualResetEvent(false);

        col.Subscribe(t =>
        {
            if (++count == expectedCount)
                evt.Set();
        }, () => { });

        expectedCount = 11;
        Add(source, GetThing(0, 0));
        Add(source, GetThing(1, 1));
        Add(source, GetThing(2, 2));
        Add(source, GetThing(3, 3));
        Add(source, GetThing(4, 4));
        Add(source, GetThing(5, 5));
        Add(source, GetThing(6, 6));
        Add(source, GetThing(7, 7));
        Add(source, GetThing(8, 8));
        Add(source, GetThing(9, 9));
        Add(source, GetThing(10, 10));
        evt.WaitOne();
        evt.Reset();
        CollectionAssert.AreEqual(col, new List<Thing> {
            GetThing(3, 3),
            GetThing(4, 4),
            GetThing(7, 7),
        });

        expectedCount = 12;
        col.RemoveItem(GetThing(2));
        evt.WaitOne();
        evt.Reset();
        CollectionAssert.AreEqual(col, new List<Thing> {
            GetThing(4, 4),
            GetThing(5, 5),
            GetThing(8, 8),
        });

        expectedCount = 13;
        col.RemoveItem(GetThing(5));
        evt.WaitOne();
        evt.Reset();
        CollectionAssert.AreEqual(col, new List<Thing> {
            GetThing(4, 4),
            GetThing(6, 6),
            GetThing(9, 9),
        });

        col.SetFilter(null);

        expectedCount = 14;
        col.RemoveItem(GetThing(100)); // this one won't result in a new element from the observable
        col.RemoveItem(GetThing(10));
        evt.WaitOne();
        evt.Reset();

        Assert.AreEqual(8, col.Count);
        CollectionAssert.AreEqual(col, new List<Thing> {
            GetThing(0, 0),
            GetThing(1, 1),
            GetThing(3, 3),
            GetThing(4, 4),
            GetThing(6, 6),
            GetThing(7, 7),
            GetThing(8, 8),
            GetThing(9, 9),
        });
        col.Dispose();
    }
开发者ID:chris134pravin,项目名称:VisualStudio,代码行数:81,代码来源:TrackingCollectionTests.cs

示例14: ChangingComparers

    public void ChangingComparers()
    {
        var source = new Subject<Thing>();

        var col = new TrackingCollection<Thing>(source, OrderedComparer<Thing>.OrderBy(x => x.CreatedAt).Compare) { ProcessingDelay = TimeSpan.Zero };

        var count = 0;
        var evt = new ManualResetEvent(false);
        var list1 = new List<Thing> {
            GetThing(1, 1, 9),
            GetThing(2, 2, 8),
            GetThing(3, 3, 7),
            GetThing(4, 4, 6),
            GetThing(5, 5, 5),
            GetThing(6, 6, 4),
            GetThing(7, 7, 3),
            GetThing(8, 8, 2),
            GetThing(9, 9, 1),
        };

        col.Subscribe(t =>
        {
            if (++count == list1.Count)
                evt.Set();
        }, () => { });

        foreach (var l in list1)
            Add(source, l);

        evt.WaitOne();
        evt.Reset();
        CollectionAssert.AreEqual(col, list1);
        col.SetComparer(null);
        CollectionAssert.AreEqual(col, list1.Reverse<Thing>().ToArray());
        col.Dispose();
    }
开发者ID:chris134pravin,项目名称:VisualStudio,代码行数:36,代码来源:TrackingCollectionTests.cs

示例15: RemovingItemsFromCollectionManuallyThrows2

    public void RemovingItemsFromCollectionManuallyThrows2()
    {
        var source = new Subject<Thing>();
        var col = new TrackingCollection<Thing>(source) { ProcessingDelay = TimeSpan.Zero };
        var count = 0;
        var expectedCount = 2;
        var evt = new ManualResetEvent(false);

        col.Subscribe(t =>
        {
            if (++count == expectedCount)
                evt.Set();
        }, () => { });

        Add(source, GetThing(1, 1));
        Add(source, GetThing(2, 2));
        evt.WaitOne();
        evt.Reset();
        Assert.Throws<InvalidOperationException>(() => col.RemoveAt(0));
        col.Dispose();
    }
开发者ID:chris134pravin,项目名称:VisualStudio,代码行数:21,代码来源:TrackingCollectionTests.cs


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