static List <WorkspaceTreeNode> GetLockableCandidates( List <WorkspaceTreeNode> candidates, LockRule lockRule) { List <WorkspaceTreeNode> result = new List <WorkspaceTreeNode>(); LockedFilesFilter filter = new LockedFilesFilter(lockRule.Rules); foreach (WorkspaceTreeNode candidate in candidates) { string cmPath = WorkspaceNodeOperations.GetCmPath(candidate); if (cmPath == null) { //The node could not be on the head tree (like copied items) so when we //cannot calculate the path we assume that it's lockable. result.Add(candidate); continue; } if (filter.IsLockable(cmPath)) { result.Add(candidate); } } return(result); }
static void FillRepositoryLocks( WorkspaceInfo wkInfo, RepositorySpec repSpec, List <WorkspaceTreeNode> candidates, Dictionary <string, Dictionary <Guid, LockInfo> > locksByItemByServer, Dictionary <WorkspaceTreeNode, LockInfo> locks) { if (candidates.Count == 0) { return; } LockRule lockRule = ServerLocks.GetLockRule(repSpec); if (lockRule == null) { return; } candidates = GetLockableCandidates(candidates, lockRule); if (candidates.Count == 0) { return; } string lockServer = string.IsNullOrEmpty(lockRule.LockServer) ? repSpec.Server : lockRule.LockServer; Dictionary <Guid, LockInfo> serverlocksByItem = ServerLocks.GetServerLocksByItem( lockServer, locksByItemByServer); if (serverlocksByItem == null || serverlocksByItem.Count == 0) { return; } IList <Guid> candidatesGuids = GetCandidatesGuids( wkInfo, repSpec, candidates); for (int index = 0; index < candidates.Count; index++) { LockInfo serverLock; if (!serverlocksByItem.TryGetValue( candidatesGuids[index], out serverLock)) { continue; } locks[candidates[index]] = serverLock; } }
public FieldUnit(OperationRegion operationRegion, int startBitIndex, int numBits, AccessType accessType, AccessAttrib accessAttrib, LockRule lockRule, UpdateRule updateRule) { if (startBitIndex < 0 || (startBitIndex + numBits + 7) / 8 > (int)operationRegion.Length) { throw new ArgumentException("Field unit not in bounds of operation region"); } this.operationRegion = operationRegion; this.startBitIndex = startBitIndex; this.numBits = numBits; this.accessType = accessType; this.accessAttrib = accessAttrib; this.lockRule = lockRule; this.updateRule = updateRule; }
// SortedList will be Dictionary<string, FieldUnit> when generics are available public static SortedList CreateFromFieldList(OperationRegion operationRegionNode, FieldElement[] fieldList, AccessType initialAccessType, AccessAttrib initialAccessAttrib, LockRule lockRule, UpdateRule updateRule ) { SortedList result = new SortedList(); // = new Dictionary<string, FieldUnit>(); AccessType accessType = initialAccessType; AccessAttrib accessAttrib = initialAccessAttrib; int bitIndex = 0; foreach (FieldElement fieldElement in fieldList) { switch (fieldElement.Tag) { case FieldElement.TagValue.NamedField: AmlParser.NamedField namedField = fieldElement.GetAsNamedField(); result.Add(namedField.nameSeg.data, new FieldUnit(operationRegionNode, bitIndex, namedField.bitWidth, accessType, accessAttrib, lockRule, updateRule)); bitIndex += namedField.bitWidth; break; case FieldElement.TagValue.ReservedField: AmlParser.ReservedField reservedField = fieldElement.GetAsReservedField(); bitIndex += reservedField.bitWidth; break; case FieldElement.TagValue.AccessField: AmlParser.AccessField accessField = fieldElement.GetAsAccessField(); accessType = accessField.accessType; accessAttrib = accessField.accessAttrib; break; default: throw new LoadException("Unhandled alternative in switch over 'FieldElement'"); } } return(result); }