本文整理汇总了C#中WorkItem类的典型用法代码示例。如果您正苦于以下问题:C# WorkItem类的具体用法?C# WorkItem怎么用?C# WorkItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkItem类属于命名空间,在下文中一共展示了WorkItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildItem
/// <summary>
/// 构建插件单元
/// </summary>
/// <param name="caller">调用者</param>
/// <param name="context">上下文,用于存放在构建时需要的组件</param>
/// <param name="element">插件单元</param>
/// <param name="subItems">被构建的子对象列表</param>
/// <returns>构建好的插件单元</returns>
public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
{
if (element.Configuration.Attributes["label"] == null)
throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
element.ClassName, element.Id));
string label = element.Configuration.Attributes["label"];
NavBarItem item = new NavBarItem(BuilderUtility.GetStringRES(context, label));
item.Name = element.Name;
if (element.Configuration.Attributes["tooltip"] != null)
item.Hint = element.Configuration.Attributes["tooltip"];
if (element.Configuration.Attributes["largeimage"] != null) {
string largeImage = element.Configuration.Attributes["largeimage"];
item.LargeImage = BuilderUtility.GetBitmap(context, largeImage, 32, 32);
}
if (element.Configuration.Attributes["imagefile"] != null) {
string image = element.Configuration.Attributes["imagefile"];
item.SmallImage = BuilderUtility.GetBitmap(context, image, 16, 16);
}
if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
context.UIExtensionSites[element.Path].Add(item);
Command cmd = BuilderUtility.GetCommand(context, element.Command);
if (cmd != null)
cmd.AddInvoker(item, "LinkClicked");
return item;
}
开发者ID:wuyingyou,项目名称:uniframework,代码行数:36,代码来源:XtraNavBarItemBuilder.cs
示例2: Cancel
/// <summary>
/// Cancels the specified Queue workitem.
/// </summary>
/// <param name="item">The item to cancel in thread pool.</param>
/// <param name="allowAbort">if set to <see langword="true"/> [allow abort].</param>
/// <returns>Status of item queue</returns>
public static WorkItemStatus Cancel(WorkItem item, bool allowAbort)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
lock (CallbacksList)
{
LinkedListNode<WorkItem> node = CallbacksList.Find(item);
if (node != null)
{
CallbacksList.Remove(node);
return WorkItemStatus.Queued;
}
else if (ThreadList.ContainsKey(item))
{
if (allowAbort)
{
ThreadList[item].Abort();
ThreadList.Remove(item);
return WorkItemStatus.Aborted;
}
else
{
return WorkItemStatus.Executing;
}
}
else
{
return WorkItemStatus.Completed;
}
}
}
开发者ID:Andy-Yin,项目名称:MY_OA_RM,代码行数:41,代码来源:AbortableThreadPool.cs
示例3: GetStatus
/// <summary>
/// Get the status the specified Queue workitem.
/// </summary>
/// <param name="item">The item to get status in thread pool.</param>
/// <returns>Status of item queue</returns>
public static WorkItemStatus GetStatus(WorkItem item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
lock (CallbacksList)
{
LinkedListNode<WorkItem> node = CallbacksList.Find(item);
if (node != null)
{
return WorkItemStatus.Queued;
}
else if (ThreadList.ContainsKey(item))
{
return WorkItemStatus.Executing;
}
else
{
return WorkItemStatus.Completed;
}
}
}
开发者ID:Andy-Yin,项目名称:MY_OA_RM,代码行数:30,代码来源:AbortableThreadPool.cs
示例4: NewLink_succeeds
public void NewLink_succeeds()
{
// prepare
this.fixture.PushPolicies("NewObjects");
string workItemTypeName = "Product Backlog Item";
var targetType = this.fixture.Project.WorkItemTypes[workItemTypeName];
var wiPBI = new WorkItem(targetType);
wiPBI.Title = workItemTypeName + " NewLink_succeeds";
wiPBI.Save();
workItemTypeName = "Task";
targetType = this.fixture.Project.WorkItemTypes[workItemTypeName];
var wiTask = new WorkItem(targetType);
wiTask.Title = workItemTypeName + " NewLink_succeeds";
// trigger
wiTask.Save();
Thread.Sleep(3000);
wiPBI.SyncToLatest();
wiTask.SyncToLatest();
// validate
var hierarchyRelationship = this.fixture.WorkItemStore.WorkItemLinkTypes["System.LinkTypes.Hierarchy"];
Assert.Equal(1, wiTask.WorkItemLinks.Count);
var actualLink = wiTask.WorkItemLinks[0];
Assert.Equal(hierarchyRelationship.ReverseEnd.ImmutableName, actualLink.LinkTypeEnd.ImmutableName);
Assert.Equal(wiTask.Id, actualLink.SourceId);
Assert.Equal(1, actualLink.TargetId);
}
开发者ID:veredflis,项目名称:tfsaggregator,代码行数:30,代码来源:NewObjectsTests.cs
示例5: NewTask_succeeds
public void NewTask_succeeds()
{
// prepare
this.fixture.PushPolicies("NewObjects");
string workItemTypeName = "Bug";
var targetType = this.fixture.Project.WorkItemTypes[workItemTypeName];
var wiBug = new WorkItem(targetType);
wiBug.Title = workItemTypeName + " NewLink_succeeds";
// trigger
wiBug.Save();
Thread.Sleep(4000);
wiBug.SyncToLatest();
// validate
var hierarchyRelationship = this.fixture.WorkItemStore.WorkItemLinkTypes["System.LinkTypes.Hierarchy"];
Assert.Equal(1, wiBug.WorkItemLinks.Count);
var actualLink = wiBug.WorkItemLinks[0];
Assert.Equal(hierarchyRelationship.ForwardEnd.ImmutableName, actualLink.LinkTypeEnd.ImmutableName);
Assert.Equal(wiBug.Id, actualLink.SourceId);
var wiTask = fixture.WorkItemStore.GetWorkItem(actualLink.TargetId);
Assert.NotNull(wiTask);
Assert.Equal("Task", wiTask.Type.Name);
Assert.Equal("Task auto-generated for " + wiBug.Title, wiTask.Title);
}
开发者ID:veredflis,项目名称:tfsaggregator,代码行数:26,代码来源:NewObjectsTests.cs
示例6: WorkItemVisualizer
public WorkItemVisualizer(WorkItem rootWorkItem, IVisualizer visualizer)
: this()
{
_visualizer = visualizer;
WorkItemAdded(this, new DataEventArgs<WorkItem>(visualizer.CabRootWorkItem));
rootWorkItem.Workspaces["MainWorkspace"].Show(this, new SmartPartInfo("WorkItems", string.Empty));
}
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:7,代码来源:WorkItemVisualizer.xaml.cs
示例7: Print
public void Print(WorkItem wi)
{
Console.WriteLine(" Id: {0}", wi.Id);
Console.WriteLine("State: {0}", wi.State);
Console.WriteLine("Title: {0}", wi.Title);
Console.WriteLine(" Desc: {0}", wi.Description);
}
开发者ID:fm107,项目名称:Shared,代码行数:7,代码来源:BaseState.cs
示例8: Complete
public override void Complete(WorkItem workItem, WorkflowProvider provider)
{
completed.Add(workItem);
started.Remove(workItem);
processing.Remove(workItem);
provider.EndWorkItem(this, workItem);
}
开发者ID:johnfelipe,项目名称:inn690,代码行数:7,代码来源:YAWLAgent.cs
示例9: EnqueueWorkItem
/// <summary>
/// Enqueue a work item to the queue.
/// </summary>
public bool EnqueueWorkItem(WorkItem workItem) {
// A work item cannot be null, since null is used in the WaitForWorkItem() method to indicate timeout or cancel
if (workItem == null)
throw new ArgumentNullException("workItem");
bool enqueue = true;
// First check if there is a wait entry waiting for work item. During
// the check, timed out waiters are ignored. If there is no waiter then the work item is queued.
lock (this) {
CheckDisposed();
if (!_isWorkItemsQueueActive)
return false;
while (_waitersCount > 0) {
// Dequeue a waiter.
WaitEntry waitEntry = PopWaiter();
// Signal the waiter. On success break the loop
if (waitEntry.Signal(workItem)) {
enqueue = false;
break;
}
}
if (enqueue) {
// Enqueue the work item
_workItems.Enqueue(workItem);
}
}
return true;
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:35,代码来源:WorkItemsQueue.cs
示例10: GetPivotalIdFromTFSWorkItem
private static int GetPivotalIdFromTFSWorkItem(WorkItem item)
{
int num;
var originalValue = (string) item.Fields["History"].Value;
if (originalValue == string.Empty)
{
originalValue = (string) item.Fields["History"].OriginalValue;
}
if ((!string.IsNullOrEmpty(originalValue) && originalValue.Contains(PIVOTALID)) &&
int.TryParse(
originalValue.Substring(originalValue.IndexOf(PIVOTALID) + PIVOTALID.Length).Replace(":", ""), out num))
{
return num;
}
var url = GetPivotalUrlFromTFSWorkItem(item);
if (url == null)
return -1;
if (int.TryParse(url.Substring(url.LastIndexOf("/") + 1), out num))
return num;
return -1;
}
开发者ID:ricred,项目名称:PivotalTFS,代码行数:26,代码来源:frmMain.cs
示例11: Cancel
public WorkItemStatus Cancel(WorkItem item, bool allowAbort)
{
if (item == null)
throw new ArgumentNullException("item");
lock (_callbacks)
{
LinkedListNode<WorkItem> node = _callbacks.Find(item);
if (node != null)
{
_callbacks.Remove(node);
return WorkItemStatus.Queued;
}
else if (_threads.ContainsKey(item))
{
if (allowAbort)
{
_threads[item].Abort();
_threads.Remove(item);
return WorkItemStatus.Aborted;
}
else
return WorkItemStatus.Executing;
}
else
return WorkItemStatus.Completed;
}
}
开发者ID:CamWiseOwl,项目名称:flashdevelop,代码行数:27,代码来源:AbortableThreadPool.cs
示例12: BuildItem
/// <summary>
/// 构建插件单元
/// </summary>
/// <param name="caller">调用者</param>
/// <param name="context">上下文,用于存放在构建时需要的组件</param>
/// <param name="element">插件单元</param>
/// <param name="subItems">被构建的子对象列表</param>
/// <returns>构建好的插件单元</returns>
public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
{
if (element.Configuration.Attributes["label"] == null)
throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
element.ClassName, element.Id));
string label = element.Configuration.Attributes["label"];
BarManager barManager = context.Items.Get<BarManager>(UIExtensionSiteNames.Shell_Bar_Manager);
if (barManager == null)
throw new UniframeworkException("未定义框架外壳的工具条管理器。");
Bar item = new Bar(barManager, label);
item.BarName = element.Name;
item.DockStyle = BarDockStyle.Top; // 默认停靠在顶部
if (element.Configuration.Attributes["dockstyle"] != null) {
string dockStyle = element.Configuration.Attributes["dockstyle"];
item.DockStyle = (BarDockStyle)Enum.Parse(typeof(BarDockStyle), dockStyle);
}
// 是否让工具栏显示整行
if (element.Configuration.Attributes["wholerow"] != null)
item.OptionsBar.UseWholeRow = bool.Parse(element.Configuration.Attributes["wholerow"]);
if (element.Configuration.Attributes["allowcustomization"] != null)
item.OptionsBar.AllowQuickCustomization = bool.Parse(element.Configuration.Attributes["allowcustomization"]);
if (element.Configuration.Attributes["register"] != null) {
bool register = bool.Parse(element.Configuration.Attributes["register"]);
if (register)
context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item); // 此处可能抛出异常
}
return item;
}
开发者ID:wuyingyou,项目名称:uniframework,代码行数:40,代码来源:XtraBarBuilder.cs
示例13: LauncherService
public LauncherService()
{
rootWorkItemService = SpringUtil.GetObject<IRootWorkItemService>("RootWorkItemService");
workItem = rootWorkItemService.RootWorkItem;
coordinator = workItem.Services.Get<ICoordinator>();
}
开发者ID:choruspapa,项目名称:GBFW,代码行数:7,代码来源:LauncherService.cs
示例14: Abort
/// <summary>
/// Aborts a previously queued work item.
/// </summary>
/// <param name="item">The work item to abort.</param>
/// <param name="unconditionalAbort">If <c>true</c> then abort will commence
/// unconditionally. If <c>false</c> then the task will only be
/// aborted if it hasn't started execution yet.</param>
/// <returns>The status of the work item as it was before aborting.</returns>
public static WorkItemStatus Abort(WorkItem item, bool unconditionalAbort)
{
if (item == null) throw new ArgumentNullException("item");
Thread joiningThread = null;
WorkItemStatus returnValue;
lock (_callbacks)
{
LinkedListNode<WorkItem> node = _callbacks.Find(item);
if (node != null)
{
_callbacks.Remove(node);
returnValue = WorkItemStatus.Queued;
}
else if (_threads.ContainsKey(item))
{
if (unconditionalAbort)
{
_threads[item].Abort();
joiningThread = _threads[item];
_threads.Remove(item);
returnValue = WorkItemStatus.Aborted;
}
else
returnValue = WorkItemStatus.Executing;
}
else
returnValue = WorkItemStatus.Completed;
}
if (joiningThread != null)
joiningThread.Join(1000);
return returnValue;
}
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:41,代码来源:AbortableThreadPool.cs
示例15: AssignOperands
/// <summary>
/// Assigns the operands.
/// </summary>
/// <param name="workItem">The work item.</param>
private void AssignOperands(WorkItem workItem)
{
var operandStack = workItem.IncomingStack;
var block = workItem.Block;
operandStack = CreateMovesForIncomingStack(block, operandStack);
//System.Diagnostics.Debug.WriteLine("IN: Block: " + block.Label + " Operand Stack Count: " + operandStack.Count);
AssignOperands(block, operandStack);
//System.Diagnostics.Debug.WriteLine("AFTER: Block: " + block.Label + " Operand Stack Count: " + operandStack.Count);
operandStack = CreateScheduledMoves(block, operandStack);
outgoingStack[block.Sequence] = operandStack;
processed.Set(block.Sequence, true);
foreach (var b in block.NextBlocks)
{
if (enqueued.Get(b.Sequence))
continue;
workList.Enqueue(new WorkItem(b, new Stack<Operand>(operandStack)));
enqueued.Set(b.Sequence, true);
}
}
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:29,代码来源:OperandAssignmentStage.cs
示例16: BuildItem
/// <summary>
/// 构建插件单元
/// </summary>
/// <param name="caller">调用者</param>
/// <param name="context">上下文,用于存放在构建时需要的组件</param>
/// <param name="element">插件单元</param>
/// <param name="subItems">被构建的子对象列表</param>
/// <returns>构建好的插件单元</returns>
public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
{
Guard.ArgumentNotNull(context, "插件构建上下文对象");
if (element.Configuration.Attributes["label"] == null)
throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
element.ClassName, element.Id));
string label = element.Configuration.Attributes["label"];
Form shell = context.Items.Get<Form>(UIExtensionSiteNames.Shell);
Bar bar = context.Items.Get<Bar>(UIExtensionSiteNames.Shell_Bar_Mainmenu);
XtraTabbedMdiManager mdiManager = context.Items.Get<XtraTabbedMdiManager>(UIExtensionSiteNames.Shell_Manager_TabbedMdiManager);
Guard.ArgumentNotNull(bar, "Main menu bar.");
Guard.ArgumentNotNull(shell, "Shell");
Guard.ArgumentNotNull(mdiManager, "Tabbed mdi manager.");
XtraWindowMenu item = new XtraWindowMenu(bar, mdiManager, shell);
item.Caption = label;
item.Name = element.Name;
BarManager barManager = BuilderUtility.GetBarManager(context);
if (barManager != null)
item.Id = barManager.GetNewItemId(); // 为BarItem设置Id方便正确的保存和恢复其状态
if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
context.UIExtensionSites[element.Path].Add(item);
// 注册插件单元
if (element.Configuration.Attributes["register"] != null) {
bool register = bool.Parse(element.Configuration.Attributes["register"]);
if (register)
context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item);
}
return item;
}
开发者ID:wuyingyou,项目名称:uniframework,代码行数:41,代码来源:XtraWindowMenuBuilder.cs
示例17: AbstractCTIDriver
/// <summary>
/// ���캯��
/// </summary>
/// <param name="workItem">�������</param>
public AbstractCTIDriver(WorkItem workItem)
{
this.workItem = workItem;
this.logger = this.workItem.Services.Get<ILog>();
channels = null;
confGroups = new Dictionary<int, List<int>>();
}
开发者ID:wuyingyou,项目名称:uniframework,代码行数:11,代码来源:AbstractCTIDriver.cs
示例18: BuildItem
/// <summary>
/// 构建插件单元
/// </summary>
/// <param name="caller">调用者</param>
/// <param name="context">上下文,用于存放在构建时需要的组件</param>
/// <param name="element">插件单元</param>
/// <param name="subItems">被构建的子对象列表</param>
/// <returns>构建好的插件单元</returns>
public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
{
IContentMenuService cmbService = context.Services.Get<IContentMenuService>();
if (cmbService == null)
throw new UniframeworkException(String.Format("未注册IContentMenuBarService无法创建上下文菜单 \"{0}\"。", element.Name));
BarSubItem item = new BarSubItem();
item.Name = element.Name;
item.Tag = element.Path;
item.Manager = BuilderUtility.GetBarManager(context); // 设置工具栏管理器
string exPath = BuilderUtility.CombinPath(element.Path, element.Id);
cmbService.RegisterContentMenu(exPath, item);
// 添加插件单元到系统中
if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
context.UIExtensionSites[element.Path].Add(item);
if (!String.IsNullOrEmpty(element.Command))
{
Command cmd = BuilderUtility.GetCommand(context, element.Command);
if (cmd != null)
cmd.AddInvoker(item, "Popup");
}
context.UIExtensionSites.RegisterSite(exPath, item);
return item;
}
开发者ID:wuyingyou,项目名称:uniframework,代码行数:34,代码来源:XtraContentMenuBuilder.cs
示例19: BuildItem
/// <summary>
/// 构建插件单元
/// </summary>
/// <param name="caller">调用者</param>
/// <param name="context">上下文,用于存放在构建时需要的组件</param>
/// <param name="element">插件单元</param>
/// <param name="subItems">被构建的子对象列表</param>
/// <returns>构建好的插件单元</returns>
public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
{
Guard.ArgumentNotNull(context, "插件构建上下文对象");
if (element.Configuration.Attributes["label"] == null)
throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
element.ClassName, element.Id));
string label = element.Configuration.Attributes["label"];
Bar bar = context.Items.Get<Bar>(UIExtensionSiteNames.Shell_Bar_Mainmenu);
if (bar == null)
throw new UniframeworkException("没有定义系统主菜单条无法创建系统皮肤菜单项。");
XtraSkinMenu item = new XtraSkinMenu(bar);
item.Caption = label;
item.Name = element.Name;
BarManager barManager = BuilderUtility.GetBarManager(context);
if (barManager != null)
item.Id = barManager.GetNewItemId(); // 为BarItem设置Id方便正确的保存和恢复其状态
BarItemExtend extend = new BarItemExtend();
if (element.Configuration.Attributes["begingroup"] != null)
{
bool beginGroup = bool.Parse(element.Configuration.Attributes["begingroup"]);
extend.BeginGroup = beginGroup;
}
if (element.Configuration.Attributes["insertbefore"] != null)
extend.InsertBefore = element.Configuration.Attributes["insertbefore"];
item.Tag = extend;
if (!String.IsNullOrEmpty(element.Path) && context.UIExtensionSites.Contains(element.Path))
context.UIExtensionSites[element.Path].Add(item);
return item;
}
开发者ID:wuyingyou,项目名称:uniframework,代码行数:42,代码来源:XtraSkinMenuBuilder.cs
示例20: GetBarManager
/// <summary>
/// 获取工具条管理器
/// </summary>
/// <param name="workItem">工作项</param>
/// <returns>返回系统外壳定义的工具条管理器</returns>
public static BarManager GetBarManager(WorkItem workItem)
{
Guard.ArgumentNotNull(workItem, "workItem");
BarManager barManager = workItem.Items.Get<BarManager>(UIExtensionSiteNames.Shell_Bar_Manager);
return barManager;
}
开发者ID:wuyingyou,项目名称:uniframework,代码行数:12,代码来源:BuilderUtility.cs
注:本文中的WorkItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论