/// <summary> /// 获取路径节点 /// </summary> /// <param name="IsSavePrev">ture 当前点为第一个节点时,当前点就为第一个节点</param> public PathData GetPathData(PathAccess Access, bool IsSavePrev = false) { int index = 0; if (Access == PathAccess.Prev) { index = m_Index - 1; if (index < 0 && IsSavePrev == true) { index = 0; } return(GetPathData(index)); } else if (Access == PathAccess.Cur) { index = m_Index; return(GetPathData(index)); } else if (Access == PathAccess.Next) { index = m_Index + 1; return(GetPathData(index)); } return(null); }
/// <summary> /// 获取路径节点 /// </summary> public PathData GetPathData(PathAccess Access, int index) { if (Access == PathAccess.Cur) { return(GetPathData(index)); } else if (Access == PathAccess.Prev) { return(GetPathData(index - 1)); } else if (Access == PathAccess.Next) { return(GetPathData(index + 1)); } return(null); }
protected override PathAccess FetchPathAccess(string pathName) { PathAccess access; if (!pathAccessMap.TryGetValue(pathName, out access)) { string pathTypeName; if (!pathTypes.TryGetValue(pathName, out pathTypeName)) throw new ApplicationException("Path '" + pathName + "' not found input this root service."); if (deletedPaths.Contains(pathName)) throw new ApplicationException("Path '" + pathName + "' did exist but was deleted."); access = new PathAccess(new MemoryStream(), pathName, pathTypeName); pathAccessMap[pathName] = access; } return access; }
private bool SynchronizePathInfoData(PathAccess pathFile, IServiceAddress rootServer) { // Get the last entry, PathRecordEntry lastEntry = pathFile.GetLastEntry(); long uid; DataAddress daddr; if (lastEntry == null) { uid = 0; daddr = null; } else { uid = lastEntry.Uid; daddr = lastEntry.Address; } while (true) { // Fetch a bundle for the path from the root server, MessageStream outputStream = new MessageStream(); outputStream.AddMessage(new Message("internalFetchPathDataBundle", pathFile.PathName, uid, daddr)); // Send the command IMessageProcessor processor = connector.Connect(rootServer, ServiceType.Root); IEnumerable<Message> result = processor.Process(outputStream); long[] uids = null; DataAddress[] dataAddrs = null; foreach (Message m in result) { if (m.HasError) { // If it's a connection fault, report the error and return false if (ReplicatedValueStore.IsConnectionFault(m)) { serviceTracker.ReportServiceDownClientReport(rootServer, ServiceType.Root); return false; } throw new ApplicationException(m.ErrorMessage); } uids = (long[]) m.Arguments[0].Value; dataAddrs = (DataAddress[]) m.Arguments[1].Value; } // If it's empty, we reached the end so return, if (uids == null || uids.Length == 0) { break; } // Insert the data pathFile.AddPathDataEntries(uids, dataAddrs); // The last, uid = uids[uids.Length - 1]; daddr = dataAddrs[dataAddrs.Length - 1]; } return true; }