本文整理汇总了C#中Dictionary.SafeAdd方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.SafeAdd方法的具体用法?C# Dictionary.SafeAdd怎么用?C# Dictionary.SafeAdd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary
的用法示例。
在下文中一共展示了Dictionary.SafeAdd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyFilter
public static IDictionary<string, object> ApplyFilter(IFilterDescriptor filter)
{
IDictionary<string, object> parameters = new Dictionary<string, object>();
string filerMessage = string.Empty;
List<string> convertValue = new List<string>();
string filerOperators = string.Empty;
if (filter is CompositeFilterDescriptor)
{
foreach (IFilterDescriptor childFilter in ((CompositeFilterDescriptor)filter).FilterDescriptors)
{
parameters.SafeAdd(ApplyFilter(childFilter));
}
}
else
{
FilterDescriptor filterDescriptor = (FilterDescriptor)filter;
filerMessage = filterDescriptor.Member;
convertValue.Add(filterDescriptor.Value.ToSafeString());
switch (filterDescriptor.Operator)
{
case FilterOperator.IsEqualTo:
parameters.SafeAdd(filerMessage, filterDescriptor.Value);
break;
case FilterOperator.IsNotEqualTo:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0}<>'{1}'", filerMessage, filterDescriptor.Value)));
break;
case FilterOperator.StartsWith:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0} like '{1}%'", filerMessage, filterDescriptor.Value)));
break;
case FilterOperator.Contains:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0} like '%{1}%'", filerMessage, filterDescriptor.Value)));
break;
case FilterOperator.EndsWith:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0} like '%{1}'", filerMessage, filterDescriptor.Value)));
break;
case FilterOperator.IsLessThanOrEqualTo:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0} <='{1}'", filerMessage, filterDescriptor.Value)));
break;
case FilterOperator.IsLessThan:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0}<'{1}'", filerMessage, filterDescriptor.Value)));
break;
case FilterOperator.IsGreaterThanOrEqualTo:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0}>='{1}'", filerMessage, filterDescriptor.Value)));
break;
case FilterOperator.IsGreaterThan:
parameters.SafeAdd(IdGenerator.NewComb().ToSafeString(), new Condition(string.Format("{0}>'{1}'", filerMessage, filterDescriptor.Value)));
break;
}
}
return parameters;
}
示例2: Delete
public void Delete(string id)
{
string errorMsg = string.Empty;
DoResult actionResult = DoResult.Failed;
string actionMessage = string.Empty;
try
{
string processDefID = Request.Form["ProcessDefID"];
string activityID = id;
ProcessDefine processDefine = wfEngine.GetProcessDefine(ProcessDefID);
Activity activity = processDefine.Activities.FirstOrDefault(a => a.ID == activityID);
processDefine.Activities.Remove(activity);
foreach (var transition in processDefine.Transitions.Where(t => t.DestActivity == activityID || t.SrcActivity == activityID).ToList())
{
processDefine.Transitions.Remove(transition);
}
// ProcessDefService processDefService = new ProcessDefService();
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.SafeAdd("Name", processDefine.ID);
parameters.SafeAdd("Version", processDefine.Version);
ProcessDef processDef = repository.FindOne<ProcessDef>(parameters);
processDef.Content = processDefine.ToXml();
repository.SaveOrUpdate(processDef);
wfEngine.ClearProcessCache();
actionResult = DoResult.Success;
//获取提示信息
actionMessage = RemarkAttribute.GetEnumRemark(actionResult);
//显示提示信息
WebUtil.PromptMsg(actionMessage);
//刷新页面
Refresh();
}
catch (Exception ex)
{
//获取提示信息
actionMessage = RemarkAttribute.GetEnumRemark(actionResult);
log.Error(ex);
}
}
示例3: FindSameStrings
private Dictionary<string, List<int>> FindSameStrings(string text, int length, Dictionary<string, List<int>> indexes)
{
for (int startIndex = 0; startIndex < text.Length - length; startIndex++)
{
string cutString = text.Substring(startIndex, length);
indexes.SafeAdd(cutString, startIndex);
}
indexes = indexes.Where(x => x.Value.Count > 1).ToDictionary(x => x.Key, x => x.Value);
return indexes;
}
示例4: DeleteTreeNode
/// <summary>
/// 删除节点
/// </summary>
/// <param name="argument"></param>
public string DeleteTreeNode(string argument)
{
AjaxResult ajaxResult = new AjaxResult();
DoResult doResult = DoResult.Failed;
string actionMessage = string.Empty;
try
{
Organization org = repository.GetDomain<Organization>(argument);
if (org != null)
{
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.SafeAdd("OrgID", org.ID);
IList<EmployeeOrg> employeeOrgList = repository.FindAll<EmployeeOrg>(parameters);
if (employeeOrgList.Count == 0)
{
repository.Delete<Organization>(org.ID);
doResult = DoResult.Success;
}
else
{
doResult = DoResult.Failed;
actionMessage = "请先删除该部门下面的操作员!";
}
}
else
{
doResult = DoResult.Failed;
}
//获取提示信息
actionMessage = string.Format("删除组织{0}", org.Name);
//记录操作日志
AddActionLog(org, doResult, actionMessage);
ajaxResult.Result = doResult;
ajaxResult.RetValue = org.ParentID;
ajaxResult.PromptMsg = actionMessage;
}
catch (Exception ex)
{
log.Error(actionMessage, ex);
AddActionLog<Organization>(actionMessage, DoResult.Failed);
}
return JsonConvert.SerializeObject(ajaxResult);
}
示例5: GetMatchSubs
public Dictionary<Dictionary<char, char>, List<Dictionary<char, char>>> GetMatchSubs(Dictionary<char, char>[] substitutions)
{
Dictionary<Dictionary<char, char>, List<Dictionary<char, char>>> matchSubs = new Dictionary<Dictionary<char, char>, List<Dictionary<char, char>>>();
foreach (var subs1 in substitutions)
{
foreach (var subs2 in substitutions)
{
if (TextAnalysis.AreSubstMatch(subs1, subs2))
{
matchSubs.SafeAdd(subs1, subs2);
}
}
}
return matchSubs;
}
示例6: Delete
public string Delete(string argument)
{
AjaxResult ajaxResult = new AjaxResult();
string errorMsg = string.Empty;
DoResult doResult = DoResult.Failed;
string actionMessage = string.Empty;
try
{
if (!string.IsNullOrWhiteSpace(argument))
{
string roleID = argument;
IRepository<string> repository = new Repository<string>();
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.SafeAdd("RoleID", roleID);
IList<ObjectRole> objectRoleList = repository.FindAll<ObjectRole>(parameters);
if (objectRoleList.Count == 0)
{
repository.Delete<Role>(roleID);
repository.ExecuteSql<RolePrivilege>(string.Format("Delete from AC_RolePrivilege where RoleID='{0}'", roleID));
doResult = DoResult.Success;
actionMessage = RemarkAttribute.GetEnumRemark(doResult);
}
else
{
doResult = DoResult.Failed;
actionMessage = "请先解除该角色与操作员的关联!";
}
ajaxResult.RetValue = CurrentId;
ajaxResult.PromptMsg = actionMessage;
}
ajaxResult.Result = doResult;
}
catch (Exception ex)
{
actionMessage = RemarkAttribute.GetEnumRemark(doResult);
log.Error(actionMessage, ex);
}
return JsonConvert.SerializeObject(ajaxResult);
}
示例7: Initilize
/// <summary>
/// 初始化对象
/// </summary>
/// <param name="xElem"></param>
public override void Initilize(XElement xElem)
{
Attibutes = new Dictionary<string, object>();
Properties = new Dictionary<string, object>();
XElement basic = xElem.Element("basic");
xElem.Attributes()
.ForEach(e => { if (!string.IsNullOrEmpty(e.Name.LocalName) && !string.IsNullOrEmpty(e.Value))Attibutes.SafeAdd(e.Name.LocalName, e.Value.Trim()); });
basic.Elements()
.Where(e => e.Elements().Count() == 0)
.ForEach(e => { if (!string.IsNullOrEmpty(e.Name.LocalName) && !string.IsNullOrEmpty(e.Value)) Properties.SafeAdd(e.Name.LocalName, e.Value.Trim()); });
TimeLimit = new TimeLimit(this, basic.Element("timeLimit"));
var xInitiator = basic.Element("initiator");
StarterType = xInitiator.Element("starterType").Value;
Initiators = xInitiator.Elements("participantor").Select(o => new Participantor(this, o)).ToList();
TriggerEvents = basic.Element("triggerEvents").Elements("triggerEvent").Select(o => new TriggerEvent(this, o)).ToList();
Activities = xElem.Element("activities").Elements("activity").Select(e => ObejectFactory.CreateActivity(this, e)).ToList();
Transitions = xElem.Element("transitions").Elements("transition").Select(e => new Transition(this, e)).ToList();
XElement xResource = xElem.Element("resource");
BizVariables = xResource.Element("bizVariables").Elements("bizVariable").Select(e => new BizVariable(this, e)).ToList();
Notes = xResource.Element("notes").Elements("note").Select(e => new Note(this, e)).ToList();
}
示例8: GetActiveWorkItems
/// <summary>
/// 获取当前流程实例待执行工作项及参与者字典
/// </summary>
/// <param name="processInstID">流程实例ID</param>
/// <returns></returns>
public IDictionary<WorkItem, IList<Operator>> GetActiveWorkItems(string processInstID)
{
IDictionary<WorkItem, IList<Operator>> result = new Dictionary<WorkItem, IList<Operator>>();
var activeWorkItems = repository.Query<WorkItem>().Where(o => o.ProcessInstID == processInstID && o.CurrentState == (short)WorkItemStatus.WaitExecute);
foreach (var item in activeWorkItems)
{
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("WorkItemID", item.ID);
var participants = repository.ExecuteDataTable<WorkItem>(@"select * from AC_Operator where ID in (select ParticipantID from WF_Participant where WorkItemID=$WorkItemID and ParticipantType=1)
union
select * from AC_Operator where ID in (select ObjectID from OM_ObjectRole where RoleID in (select ParticipantID from WF_Participant where WorkItemID=$WorkItemID and ParticipantType=2))
union
select * from AC_Operator where ID in (select EmployeeID from OM_EmployeeOrg where OrgID in( select ParticipantID from WF_Participant where WorkItemID=$WorkItemID and ParticipantType=3))
", parameters).ToList<Operator>();
result.SafeAdd(item, participants);
}
return result;
}
示例9: GetPersonParticipantors
/// <summary>
/// 获取某参与者类型下的所有参与者
/// </summary>
/// <param name="parentType">父参与者类型</param>
/// <param name="parentID">父参与者ID</param>
/// <returns></returns>
public IList<Participantor> GetPersonParticipantors(ParticipantorType parentType, string parentID)
{
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.SafeAdd("ID", "none");
if (parentType == ParticipantorType.Role)
{
parameters.SafeAdd("ID", new AgileEAP.Core.Data.Condition(string.Format("ID in (select b.ObjectID from OM_ObjectRole b where b.RoleID='{0}')", parentID)));
}
else if (parentType == ParticipantorType.Org)
{
parameters.SafeAdd("ID", new AgileEAP.Core.Data.Condition(string.Format("ID in (select b.EmployeeID from OM_EmployeeOrg b where b.OrgID='{0}')", parentID)));
}
int index = 0;
return repository.FindAll<Employee>(parameters).Select(o => new Participantor()
{
ID = o.ID,
Name = o.Name,
ParticipantorType = ParticipantorType.Person,
SortOrder = ++index,
ParentID = parentID
}).ToList();
}
示例10: SaveResource
/// <summary>
/// 保存资源
/// </summary>
/// <param name="entity">资源实体</param>
public void SaveResource(Resource entity)
{
using (ITransaction trans = UnitOfWork.BeginTransaction(typeof(Resource)))
{
repository.Clear<Resource>();
repository.SaveOrUpdate(entity);
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("ResourceID", entity.ID);
parameters.Add("OperateID", string.Empty);
Privilege privilege = repository.FindOne<Privilege>(parameters);
if (privilege == null)
{
repository.SaveOrUpdate(new Privilege()
{
ID = IdGenerator.NewComb().ToString(),
MetaDataID = string.Empty,
Name = entity.Text,
OperateID = string.Empty,
//AppID = entity.AppID,
//OwnerOrg = entity.OwnerOrg,
//ModuleID = entity.ModuleID,
//Description = entity.Description,
ResourceID = entity.ID,
SortOrder = entity.SortOrder,
Type = entity.Type,
CreateTime = DateTime.Now,
Creator = entity.Creator,
});
}
if (entity.Operates != null)
{
string idList = "";
foreach (var operate in entity.Operates)
{
idList += string.Format(" '{0}',", operate.ID);
}
string sWhere = string.IsNullOrEmpty(idList.TrimEnd(',')) ? "" : string.Format(" and OperateID not in ({0}) ", idList.TrimEnd(','));
repository.ExecuteSql<Resource>(string.Format("delete from AC_Operate where id in (select OperateID from AC_Privilege where ResourceID='{0}' and (OperateID is not null and OperateID<>'') {1})", entity.ID, sWhere));
repository.ExecuteSql<Resource>(string.Format("delete from AC_Privilege where ResourceID='{0}' and (OperateID is not null and OperateID<>'') {1}", entity.ID, sWhere));
foreach (var operate in entity.Operates)
{
repository.SaveOrUpdate(operate);
parameters.Clear();
parameters.SafeAdd("ResourceID", entity.ID);
parameters.SafeAdd("OperateID", operate.ID);
IList<Privilege> privilegeList = repository.FindAll<Privilege>(parameters);
if (privilegeList.Count == 0)
{
repository.SaveOrUpdate(new Privilege()
{
ID = IdGenerator.NewComb().ToString(),
//AppID = entity.AppID,
MetaDataID = string.Empty,
Name = operate.OperateName,
OperateID = operate.ID,
//ModuleID = entity.ModuleID,
//OwnerOrg = entity.OwnerOrg,
//Description = entity.Description,
ResourceID = entity.ID,
SortOrder = operate.SortOrder,
Type = 3,
CreateTime = DateTime.Now,
Creator = entity.Creator,
});
}
}
}
trans.Commit();
}
repository.ClearCache<Resource>();
repository.ClearCache<Privilege>();
repository.ClearCache<Operate>();
}
示例11: SafeReturn
public static Dictionary<uint, Client.GameState> SafeReturn()
{
Dictionary<uint, Client.GameState> toReturn = new Dictionary<uint, Client.GameState>();
try
{
lock (Kernel.GamePool)
{
foreach (Client.GameState c in Kernel.GamePool.Values)
if (c != null)
if (c.Entity != null)
toReturn.SafeAdd(c.Entity.UID, c);
}
}
catch { Console.WriteLine("Error at safe return"); }
return toReturn;
}
示例12: Delete
public string Delete(string operatorID)
{
AjaxResult ajaxResult = new AjaxResult();
string errorMsg = string.Empty;
DoResult doResult = DoResult.Failed;
string actionMessage = string.Empty;
try
{
if (!string.IsNullOrWhiteSpace(operatorID))
{
IRepository<string> repository = new Repository<string>();
UnitOfWork.ExecuteWithTrans<Operator>(() =>
{
repository.Delete<Operator>(operatorID);
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.SafeAdd("OperatorID", operatorID);
Employee employee = repository.FindOne<Employee>(parameters);
repository.Delete<Employee>(parameters);
parameters.Clear();
parameters.SafeAdd("EmployeeID", employee.ID);
repository.Delete<EmployeeOrg>(parameters);
parameters.Clear();
parameters.SafeAdd("ObjectID", operatorID);
repository.Delete<ObjectRole>(parameters);
});
doResult = DoResult.Success;
//获取提示信息
actionMessage = RemarkAttribute.GetEnumRemark(doResult);
ajaxResult.RetValue = CurrentId;
ajaxResult.PromptMsg = actionMessage;
}
ajaxResult.Result = doResult;
}
catch (Exception ex)
{
actionMessage = RemarkAttribute.GetEnumRemark(doResult);
log.Error(actionMessage, ex);
}
return JsonConvert.SerializeObject(ajaxResult);
}
示例13: GetOrgNameByUserID
/// <summary>
/// 获取员工所在部门名称
/// </summary>
/// <param name="orgID">组织ID</param>
/// <returns></returns>
public IList<Organization> GetOrgNameByUserID(string userID)
{
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.SafeAdd("ID", new Condition(string.Format("ID in (select b.OrgID from OM_EmployeeOrg b where b.EmployeeID='{0}')", userID)));
return repository.FindAll<Organization>(parameters);
}
示例14: OnProcessPositions
private void OnProcessPositions(long transactionId, string[] data)
{
var f = Wrapper.FieldsPositions;
var portfChangeMessages = new Dictionary<string, PortfolioChangeMessage>();
foreach (var str in data)
{
var cols = str.ToColumns();
var portfolioName = GetPortfolioName(f.AccCode.GetValue(cols), this.GetBoardCode(f.PlaceCode.GetValue(cols)));
var secCode = f.PaperCode.GetValue(cols);
if (secCode == "money")
{
var changesMsg = portfChangeMessages.SafeAdd(portfolioName, this.CreatePortfolioChangeMessage);
changesMsg.Add(PositionChangeTypes.RealizedPnL, f.PnL.GetValue(cols));
changesMsg.Add(PositionChangeTypes.UnrealizedPnL, f.ProfitVol.GetValue(cols));
changesMsg.Add(PositionChangeTypes.CurrentPrice, f.RealVol.GetValue(cols));
changesMsg.Add(PositionChangeTypes.BeginValue, f.IncomeRest.GetValue(cols));
changesMsg.Add(PositionChangeTypes.CurrentValue, f.RealRest.GetValue(cols));
}
else
{
var secId = new SecurityId { Native = f.PaperNo.GetValue(cols) };
SendOutMessage(new PositionMessage
{
PortfolioName = portfolioName,
SecurityId = secId
});
var changesMsg = this.CreatePositionChangeMessage(portfolioName, secId);
changesMsg.Add(PositionChangeTypes.RealizedPnL, f.PnL.GetValue(cols));
changesMsg.Add(PositionChangeTypes.UnrealizedPnL, f.ProfitVol.GetValue(cols));
changesMsg.Add(PositionChangeTypes.CurrentPrice, f.RealVol.GetValue(cols));
changesMsg.Add(PositionChangeTypes.CurrentValue, f.ForwordRest.GetValue(cols));
changesMsg.Add(PositionChangeTypes.AveragePrice, f.BalancePrice.GetValue(cols));
var varMargin = f.VarMargin.GetValue(cols);
changesMsg.Add(PositionChangeTypes.VariationMargin, varMargin);
if (varMargin != 0)
{
var portfChangesMsg = portfChangeMessages.SafeAdd(portfolioName, this.CreatePortfolioChangeMessage);
var oldVm = portfChangesMsg.Changes.TryGetValue(PositionChangeTypes.VariationMargin);
if(oldVm == null)
portfChangesMsg.Changes[PositionChangeTypes.VariationMargin] = varMargin;
else
portfChangesMsg.Changes[PositionChangeTypes.VariationMargin] = (decimal)oldVm + varMargin;
}
SendOutMessage(changesMsg);
}
}
portfChangeMessages.Values.ForEach(SendOutMessage);
if (transactionId > 0)
{
SendOutMessage(new PortfolioLookupResultMessage
{
OriginalTransactionId = transactionId,
});
}
}
示例15: ShowList
/// <summary>
/// 显示列表信息
/// </summary>
/// <param name="gvList">GridView对象</param>
/// <param name="pageInfo">分页信息</param>
public void ShowList(PagedGridView gvList, PageInfo pageInfo)
{
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.SafeAdd("CatalogID", CurrentId);
parameters.SafeAdd("dataFilter", new Condition(GetFilterString()));
IPageOfList<UploadFile> result = uploadFileService.FindAll(parameters, "Order By FileName", pageInfo);
gvList.ItemCount = result.PageInfo.ItemCount;
gvList.DataSource = result;
gvList.DataBind();
}