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


C# ProjectManager.ResourcesOf方法代码示例

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


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

示例1: UnassignSpecificResource

        public void UnassignSpecificResource()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var r1 = new Task();
            var r2 = new Task();
            manager.Add(one);

            // setup: assign some resource
            manager.Assign(one, r1);
            manager.Assign(one, r2);
            Assert.IsTrue(manager.Resources.Count() == 2);
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
            Assert.IsTrue(manager.TasksOf(r1).Contains(one));
            Assert.IsTrue(manager.TasksOf(r2).Contains(one));

            // test: unassign resource
            manager.Unassign(one, r2);
            Assert.IsTrue(manager.Resources.Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
            Assert.IsTrue(!manager.ResourcesOf(one).Contains(r2));
            Assert.IsTrue(manager.TasksOf(r1).Contains(one));
            Assert.IsTrue(!manager.TasksOf(r2).Contains(one));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:25,代码来源:ProjectTest.cs

示例2: EnumerationShouldReturnEmptySet

        public void EnumerationShouldReturnEmptySet()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var alien = new Task();

            // test: Enumerators should at least return empty sets
            Assert.IsNotNull(manager.ChildrenOf(alien), "ChildrenOf is null");
            Assert.IsNotNull(manager.AncestorsOf(alien), "AncestorsOf is null");
            Assert.IsNotNull(manager.DecendantsOf(alien), "DecendantsOf is null");
            Assert.IsNotNull(manager.DependantsOf(alien), "DependantsOf is null");
            Assert.IsNotNull(manager.PrecedentsOf(alien), "PrecedentsOf is null");
            Assert.IsNotNull(manager.DirectDependantsOf(alien), "DirectDependantsOf is null");
            Assert.IsNotNull(manager.DirectPrecedentsOf(alien), "DirectPrecedentsOf is null");
            Assert.IsNotNull(manager.ResourcesOf(alien), "ResourcesOf is null");
            Assert.IsNotNull(manager.TasksOf(alien), "TasksOf is null");
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:16,代码来源:ProjectTest.cs

示例3: UnassignAllResourceFromTask

        public void UnassignAllResourceFromTask()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var two = new Task();
            var r1 = new Task();
            var r2 = new Task();
            manager.Add(one);
            manager.Add(two);

            // setup: assign some resource
            manager.Assign(one, r1);
            manager.Assign(one, r2);
            manager.Assign(two, r1);
            manager.Assign(two, r2);
            Assert.IsTrue(manager.Resources.Count() == 2);
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
            Assert.IsTrue(manager.TasksOf(r1).Contains(one));
            Assert.IsTrue(manager.TasksOf(r2).Contains(one));
            Assert.IsTrue(manager.TasksOf(r1).Contains(two));
            Assert.IsTrue(manager.TasksOf(r2).Contains(two));

            manager.Unassign(one);
            Assert.IsTrue(manager.Resources.Count() == 2);
            Assert.IsTrue(!manager.ResourcesOf(one).Contains(r1));
            Assert.IsTrue(!manager.ResourcesOf(one).Contains(r2));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
            Assert.IsTrue(!manager.TasksOf(r1).Contains(one));
            Assert.IsTrue(!manager.TasksOf(r2).Contains(one));
            Assert.IsTrue(manager.TasksOf(r1).Contains(two));
            Assert.IsTrue(manager.TasksOf(r2).Contains(two));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:36,代码来源:ProjectTest.cs

示例4: UnassignResourceFromAllTask

        public void UnassignResourceFromAllTask()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var two = new Task();
            var r1 = new object();
            var r2 = new object();
            manager.Add(one);
            manager.Add(two);

            // setup: assign some resource
            manager.Assign(one, r1);
            manager.Assign(one, r2);
            manager.Assign(two, r1);
            manager.Assign(two, r2);
            Assert.IsTrue(manager.Resources.Count() == 2);
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
            Assert.IsTrue(manager.TasksOf(r1).Contains(one));
            Assert.IsTrue(manager.TasksOf(r2).Contains(one));
            Assert.IsTrue(manager.TasksOf(r1).Contains(two));
            Assert.IsTrue(manager.TasksOf(r2).Contains(two));

            manager.Unassign(r1);
            Assert.IsTrue(manager.Resources.Count() == 1, string.Format("Expected {0} != {1}", 1, manager.Resources.Count()));
            Assert.IsTrue(!manager.ResourcesOf(one).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(r2));
            Assert.IsTrue(!manager.ResourcesOf(two).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(r2));
            Assert.IsTrue(!manager.TasksOf(r1).Contains(one));
            Assert.IsTrue(manager.TasksOf(r2).Contains(one));
            Assert.IsTrue(!manager.TasksOf(r1).Contains(two));
            Assert.IsTrue(manager.TasksOf(r2).Contains(two));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:36,代码来源:ProjectTest.cs

示例5: AssignSameResourceToSameTask

        public void AssignSameResourceToSameTask()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var res = new Task() { Name = "Resource" };
            manager.Add(one);

            // setup: assign resource
            manager.Assign(one, res);
            Assert.IsTrue(manager.Resources.Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
            Assert.IsTrue(manager.TasksOf(res).Count() == 1);
            Assert.IsTrue(manager.Resources.Contains(res));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
            Assert.IsTrue(manager.TasksOf(res).Contains(one));

            // test: assign the same resource to the same task (no effect, as resource is already assigned)
            manager.Assign(one, res);
            Assert.IsTrue(manager.Resources.Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
            Assert.IsTrue(manager.TasksOf(res).Count() == 1);
            Assert.IsTrue(manager.Resources.Contains(res));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
            Assert.IsTrue(manager.TasksOf(res).Contains(one));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:25,代码来源:ProjectTest.cs

示例6: TwoWayResourceLookup

        public void TwoWayResourceLookup()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var two = new Task();
            var r1 = new Task();
            var r2 = new Task();
            manager.Add(one);
            manager.Add(two);

            // check initializations are correct
            Assert.IsTrue(manager.ResourcesOf(one) != null);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 0);
            Assert.IsTrue(manager.ResourcesOf(two) != null);
            Assert.IsTrue(manager.ResourcesOf(two).Count() == 0);

            // assign resource
            manager.Assign(one, r1);
            Assert.IsTrue(manager.ResourcesOf(one) != null);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(one).FirstOrDefault().Equals(r1));
            Assert.IsTrue(manager.TasksOf(r1).Count() == 1);
            Assert.IsTrue(manager.TasksOf(r1).FirstOrDefault().Equals(one));

            // assign another resource
            manager.Assign(one, r2);
            Assert.IsTrue(manager.ResourcesOf(one) != null);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 2);
            Assert.IsTrue(manager.ResourcesOf(one).ElementAtOrDefault(1).Equals(r2));
            Assert.IsTrue(manager.TasksOf(r2).Count() == 1);
            Assert.IsTrue(manager.TasksOf(r2).FirstOrDefault().Equals(one));

            // assign resource to another task
            manager.Assign(two, r2);
            Assert.IsTrue(manager.ResourcesOf(two) != null);
            Assert.IsTrue(manager.ResourcesOf(two).Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(two).FirstOrDefault().Equals(r2));
            Assert.IsTrue(manager.TasksOf(r2).Count() == 2);
            Assert.IsTrue(manager.TasksOf(r2).ElementAtOrDefault(1).Equals(two));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:40,代码来源:ProjectTest.cs

示例7: AssignResourceForUnknownTasks

        public void AssignResourceForUnknownTasks()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var res = new Task() { Name = "Resource" };

            // setup: confirm there is no resource
            Assert.IsTrue(manager.Resources.Count() == 0);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 0);
            Assert.IsTrue(manager.TasksOf(res).Count() == 0);

            // test: assign resource
            manager.Assign(one, res);
            Assert.IsTrue(manager.Resources.Count() == 0);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 0);
            Assert.IsTrue(manager.TasksOf(res).Count() == 0);
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:17,代码来源:ProjectTest.cs

示例8: AssignSameResourceToDifferentTask

        public void AssignSameResourceToDifferentTask()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var two = new Task();
            var res = new Task() { Name = "Resource" };
            manager.Add(one);
            manager.Add(two);

            // setup: assign resource
            manager.Assign(one, res);
            Assert.IsTrue(manager.Resources.Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
            Assert.IsTrue(manager.TasksOf(res).Count() == 1);
            Assert.IsTrue(manager.Resources.Contains(res));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
            Assert.IsTrue(manager.TasksOf(res).Contains(one));

            // setup: assign resource. no extra resource should be created. resource reference shared by 2 tasks
            manager.Assign(two, res);
            Assert.IsTrue(manager.Resources.Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(one).Count() == 1);
            Assert.IsTrue(manager.ResourcesOf(two).Count() == 1);
            Assert.IsTrue(manager.TasksOf(res).Count() == 2);
            Assert.IsTrue(manager.Resources.Contains(res));
            Assert.IsTrue(manager.ResourcesOf(one).Contains(res));
            Assert.IsTrue(manager.ResourcesOf(two).Contains(res));
            Assert.IsTrue(manager.TasksOf(res).Contains(one));
            Assert.IsTrue(manager.TasksOf(res).Contains(two));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:30,代码来源:ProjectTest.cs

示例9: KnownTasksEnumeration

        public void KnownTasksEnumeration()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var local = new Task();
            manager.Add(local);

            Assert.IsNotNull(manager.ChildrenOf(local));
            Assert.IsNotNull(manager.AncestorsOf(local));
            Assert.IsNotNull(manager.DecendantsOf(local));
            Assert.IsNotNull(manager.DependantsOf(local));
            Assert.IsNotNull(manager.PrecedentsOf(local));
            Assert.IsNotNull(manager.DirectDependantsOf(local));
            Assert.IsNotNull(manager.DirectPrecedentsOf(local));
            Assert.IsNotNull(manager.ResourcesOf(local));
            Assert.IsNotNull(manager.TasksOf(local));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:16,代码来源:ProjectTest.cs

示例10: ExampleFull

        /// <summary>
        /// Example starts here
        /// </summary>
        public ExampleFull()
        {
            InitializeComponent();

            // Create a Project and some Tasks
            _mManager = new ProjectManager();
            var work = new MyTask(_mManager) { Name = "Prepare for Work" };
            var wake = new MyTask(_mManager) { Name = "Wake Up" };
            var teeth = new MyTask(_mManager) { Name = "Brush Teeth" };
            var shower = new MyTask(_mManager) { Name = "Shower" };
            var clothes = new MyTask(_mManager) { Name = "Change into New Clothes" };
            var hair = new MyTask(_mManager) { Name = "Blow My Hair" };
            var pack = new MyTask(_mManager) { Name = "Pack the Suitcase" };

            _mManager.Add(work);
            _mManager.Add(wake);
            _mManager.Add(teeth);
            _mManager.Add(shower);
            _mManager.Add(clothes);
            _mManager.Add(hair);
            _mManager.Add(pack);

            // Create another 1000 tasks for stress testing
            Random rand = new Random();
            for (int i = 0; i < 1000; i++)
            {
                var task = new MyTask(_mManager) { Name = string.Format("New Task {0}", i.ToString()) };
                _mManager.Add(task);
                _mManager.SetStart(task, rand.Next(300));
                _mManager.SetDuration(task, rand.Next(50));
            }

            // Set task durations, e.g. using ProjectManager methods
            _mManager.SetDuration(wake, 3);
            _mManager.SetDuration(teeth, 5);
            _mManager.SetDuration(shower, 7);
            _mManager.SetDuration(clothes, 4);
            _mManager.SetDuration(hair, 3);
            _mManager.SetDuration(pack, 5);

            // demostrate splitting a task
            _mManager.Split(pack, new MyTask(_mManager), new MyTask(_mManager), 2);

            // Set task complete status, e.g. using newly created properties
            wake.Complete = 0.9f;
            teeth.Complete = 0.5f;
            shower.Complete = 0.4f;

            // Give the Tasks some organisation, setting group and precedents
            _mManager.Group(work, wake);
            _mManager.Group(work, teeth);
            _mManager.Group(work, shower);
            _mManager.Group(work, clothes);
            _mManager.Group(work, hair);
            _mManager.Group(work, pack);
            _mManager.Relate(wake, teeth);
            _mManager.Relate(wake, shower);
            _mManager.Relate(shower, clothes);
            _mManager.Relate(shower, hair);
            _mManager.Relate(hair, pack);
            _mManager.Relate(clothes, pack);

            // Create and assign Resources.
            // MyResource is just custom user class. The API can accept any object as resource.
            var jake = new MyResource() { Name = "Jake" };
            var peter = new MyResource() { Name = "Peter" };
            var john = new MyResource() { Name = "John" };
            var lucas = new MyResource() { Name = "Lucas" };
            var james = new MyResource() { Name = "James" };
            var mary = new MyResource() { Name = "Mary" };
            // Add some resources
            _mManager.Assign(wake, jake);
            _mManager.Assign(wake, peter);
            _mManager.Assign(wake, john);
            _mManager.Assign(teeth, jake);
            _mManager.Assign(teeth, james);
            _mManager.Assign(pack, james);
            _mManager.Assign(pack, lucas);
            _mManager.Assign(shower, mary);
            _mManager.Assign(shower, lucas);
            _mManager.Assign(shower, john);

            // Initialize the Chart with our ProjectManager and CreateTaskDelegate
            _mChart.Init(_mManager);
            _mChart.CreateTaskDelegate = delegate() { return new MyTask(_mManager); };

            // Attach event listeners for events we are interested in
            _mChart.TaskMouseOver += new EventHandler<TaskMouseEventArgs>(_mChart_TaskMouseOver);
            _mChart.TaskMouseOut += new EventHandler<TaskMouseEventArgs>(_mChart_TaskMouseOut);
            _mChart.TaskSelected += new EventHandler<TaskMouseEventArgs>(_mChart_TaskSelected);
            _mChart.PaintOverlay += _mOverlay.ChartOverlayPainter;
            _mChart.AllowTaskDragDrop = true;

            // set some tooltips to show the resources in each task
            _mChart.SetToolTip(wake, string.Join(", ", _mManager.ResourcesOf(wake).Select(x => (x as MyResource).Name)));
            _mChart.SetToolTip(teeth, string.Join(", ", _mManager.ResourcesOf(teeth).Select(x => (x as MyResource).Name)));
            _mChart.SetToolTip(pack, string.Join(", ", _mManager.ResourcesOf(pack).Select(x => (x as MyResource).Name)));
//.........这里部分代码省略.........
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:101,代码来源:ExampleFull.cs

示例11: DeleteResourcesOnDeleteSplitTask

        public void DeleteResourcesOnDeleteSplitTask()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var split = new Task();
            var part1 = new Task();
            var part2 = new Task();
            var r1 = new Task();
            manager.Add(split);

            // setup: create a split task with resources on parts
            manager.Split(split, part1, part2, 1);
            manager.Assign(part1, r1);
            manager.Assign(part2, r1);
            Assert.IsTrue(!manager.TasksOf(r1).Contains(split));
            Assert.IsTrue(manager.TasksOf(r1).Contains(part1));
            Assert.IsTrue(manager.TasksOf(r1).Contains(part2));
            Assert.IsTrue(!manager.ResourcesOf(split).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(part1).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(part2).Contains(r1));
            Assert.IsTrue(manager.Resources.Count() == 1);
            Assert.IsTrue(manager.Tasks.Count() == 1);

            // test: delete the split task, everything should go
            manager.Delete(split);
            Assert.IsTrue(manager.Resources.Count() == 0);
            Assert.IsTrue(manager.Tasks.Count() == 0);
            Assert.IsTrue(!manager.TasksOf(r1).Contains(split));
            Assert.IsTrue(!manager.TasksOf(r1).Contains(part1));
            Assert.IsTrue(!manager.TasksOf(r1).Contains(part2));
            Assert.IsTrue(!manager.ResourcesOf(split).Contains(r1));
            Assert.IsTrue(!manager.ResourcesOf(part1).Contains(r1));
            Assert.IsTrue(!manager.ResourcesOf(part2).Contains(r1));

            // test: check that they are really deleted by adding them back again
            manager.Add(split);
            manager.Add(part1);
            manager.Add(part2);
            Assert.IsTrue(manager.Tasks.Count() == 3);
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:39,代码来源:TaskTest.cs

示例12: DeleteResourceOnDeleteTask

        public void DeleteResourceOnDeleteTask()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var task1 = new Task();
            var task2 = new Task();
            var r1 = new Task();
            manager.Add(task1);
            manager.Add(task2);

            // setup: assign resource
            manager.Assign(task1, r1);
            manager.Assign(task2, r1);
            Assert.IsTrue(manager.ResourcesOf(task1).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(task2).Contains(r1));
            Assert.IsTrue(manager.TasksOf(r1).Count() == 2);

            // test: delete task1
            manager.Delete(task1);
            Assert.IsTrue(!manager.ResourcesOf(task1).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(task2).Contains(r1));
            Assert.IsTrue(manager.TasksOf(r1).Count() == 1);
            Assert.IsTrue(manager.Resources.Count() == 1);
            Assert.IsTrue(manager.Resources.Contains(r1));

            // test: delete task2
            manager.Delete(task2);
            Assert.IsTrue(!manager.ResourcesOf(task1).Contains(r1));
            Assert.IsTrue(!manager.ResourcesOf(task2).Contains(r1));
            Assert.IsTrue(manager.TasksOf(r1).Count() == 0);
            Assert.IsTrue(manager.Resources.Count() == 0);
            Assert.IsTrue(!manager.Resources.Contains(r1));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:32,代码来源:TaskTest.cs

示例13: TransferResourceToSplitTaskOnMerge_ByDeleteInThisCase

        public void TransferResourceToSplitTaskOnMerge_ByDeleteInThisCase()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var split = new Task();
            var part1 = new Task();
            var part2 = new Task();
            var r1 = new Task();
            manager.Add(split);

            // setup: create a split task with resources on parts
            manager.Split(split, part1, part2, 1);
            manager.Assign(part1, r1);
            manager.Assign(part2, r1);
            Assert.IsTrue(!manager.TasksOf(r1).Contains(split));
            Assert.IsTrue(manager.TasksOf(r1).Contains(part1));
            Assert.IsTrue(manager.TasksOf(r1).Contains(part2));
            Assert.IsTrue(!manager.ResourcesOf(split).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(part1).Contains(r1));
            Assert.IsTrue(manager.ResourcesOf(part2).Contains(r1));
            Assert.IsTrue(manager.Resources.Count() == 1);

            // test: delete a part, expect a merge and resources transferred to split task
            manager.Delete(part1);
            Assert.IsTrue(manager.TasksOf(r1).Contains(split));
            Assert.IsTrue(!manager.TasksOf(r1).Contains(part1));
            Assert.IsTrue(!manager.TasksOf(r1).Contains(part2));
            Assert.IsTrue(manager.ResourcesOf(split).Contains(r1));
            Assert.IsTrue(!manager.ResourcesOf(part1).Contains(r1));
            Assert.IsTrue(!manager.ResourcesOf(part2).Contains(r1));
            Assert.IsTrue(manager.Resources.Count() == 1);
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:31,代码来源:TaskTest.cs


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