public object Read(IReadContext context) { int classId = context.ReadInt(); long enumValue = context.ReadLong(); return ToEnum(context, classId, enumValue); }
// #end example // #example: Read the StringBuilder public object Read(IReadContext readContext) { int length = readContext.ReadInt(); byte[] data = new byte[length]; readContext.ReadBytes(data); return new StringBuilder(Encoding.UTF8.GetString(data)); }
public override object Read(IReadContext readContext) { IInternalReadContext context = (IInternalReadContext)readContext; int payloadOffset = context.ReadInt(); if (payloadOffset == 0) { context.NotifyNullReferenceSkipped(); return null; } int savedOffSet = context.Offset(); try { ITypeHandler4 typeHandler = ReadTypeHandler(context, payloadOffset); if (typeHandler == null) { return null; } if (IsPlainObject(typeHandler)) { return ReadPlainObject(readContext); } SeekSecondaryOffset(context, typeHandler); return context.ReadAtCurrentSeekPosition(typeHandler); } finally { context.Seek(savedOffSet); } }
public override object Read(IReadContext context) { var b1 = context.ReadByte(); var b2 = context.ReadByte(); var charValue = (char) ((b1 & unchecked(0xff)) | ((b2 & unchecked(0xff)) << 8)); return charValue; }
public override object Eval(GameState state, IReadContext c) { bool l = (bool)lhs.Eval(state, c); // Lazy evaluation if (l == true) return true; return rhs.Eval(state, c); }
public override object Read(IReadContext context) { byte[] bytes = new byte[2]; context.ReadBytes(bytes); return (ushort)( bytes[1] & 255 | (bytes[0] & 255) << 8 ); }
public override object Eval(GameState state, IReadContext c) { var ret = new List<object>(); foreach (var item in set) { ret.Add(item.Eval(state, c)); } return ret; }
public override object Read(IReadContext context) { int i = context.ReadInt(); if (i == int.MaxValue) { return null; } return i; }
public override object Read(IReadContext context) { float value = (float)base.Read(context); if (float.IsNaN(value)) { return null; } return value; }
public override object Read(IReadContext context) { var value = context.ReadLong(); if (value == long.MaxValue) { return PrimitiveNull(); } return new DateTime(value); }
public override object Read(IReadContext context) { short value = (short)base.Read(context); if (value == short.MaxValue) { return null; } return value; }
public override object Read(IReadContext context) { double value = (double)base.Read(context); if (double.IsNaN(value)) { return null; } return value; }
public override object Read(IReadContext context) { long value = (long)base.Read(context); if (value == long.MaxValue) { return null; } return value; }
/// <summary> /// Initializes a new instance of the <see cref="WriteToReadRepository"/> class. /// </summary> public WriteToReadRepository(IReadContext readContext) { if (readContext == null) { throw new ArgumentNullException(nameof(readContext)); } this.readContext = readContext; }
public virtual object Read(IReadContext context) { object read = StringHandler(context).Read(context); if (null == read) { return null; } return ConvertString((string)read); }
public override object Read(IReadContext context) { ByteArrayBuffer buffer = (ByteArrayBuffer)((IInternalReadContext)context).ReadIndirectedBuffer (); if (buffer == null) { return null; } return ReadString(context, buffer); }
public override object Read(IReadContext context) { byte[] bytes = new byte[4]; context.ReadBytes(bytes); return (uint)( bytes[3] & 255 | (bytes[2] & 255) << 8 | (bytes[1] & 255) << 16 | (bytes[0] & 255) << 24 ); }
public override object Eval(GameState state, IReadContext c) { var f = (ICallable)name.Eval(state, c); if (f == null) throw new InvalidGameException("Invalid function: " + name); object[] args = new object[p.Length]; //args[0] = c; for (int i = 0; i < p.Length; i++) { args[i] = p[i].Eval(state, c); } return f.Call(state, Context.NewLocal(state), args); }
protected override void ReadElements(IReadContext context, ArrayInfo info, object array) { if (array == null) { return; } object[] objects = new object[info.ElementCount()]; ReadInto(context, info, objects); ArrayReflector(Container(context)).Shape(objects, 0, array, ((MultidimensionalArrayInfo )info).Dimensions(), 0); }
public override object Read(IReadContext context) { var bytes = new byte[8]; context.ReadBytes(bytes); return (ulong) bytes[7] & 255 | (ulong) (bytes[6] & 255) << 8 | (ulong) (bytes[5] & 255) << 16 | (ulong) (bytes[4] & 255) << 24 | (ulong) (bytes[3] & 255) << 32 | (ulong) (bytes[2] & 255) << 40 | (ulong) (bytes[1] & 255) << 48 | (ulong) (bytes[0] & 255) << 56; }
private object ReadPlainObject(IReadContext context) { int id = context.ReadInt(); Transaction transaction = context.Transaction(); object obj = transaction.ObjectForIdFromCache(id); if (obj != null) { return obj; } obj = new object(); AddReference(context, obj, id); return obj; }
public override object Read(IReadContext context) { byte ret = context.ReadByte(); if (ret == True) { return true; } if (ret == False) { return false; } return null; }
static public IList <StudyStorageLocation> FindStorageLocations(ServerEntityKey partitionKey, string studyInstanceUid) { using (IReadContext readContext = _store.OpenReadContext()) { IQueryStudyStorageLocation locQuery = readContext.GetBroker <IQueryStudyStorageLocation>(); StudyStorageLocationQueryParameters locParms = new StudyStorageLocationQueryParameters { StudyInstanceUid = studyInstanceUid, ServerPartitionKey = partitionKey }; IList <StudyStorageLocation> list = locQuery.Find(locParms); return(list); } }
private object ReadPlainObject(IReadContext context) { int id = context.ReadInt(); Transaction transaction = context.Transaction(); object obj = transaction.ObjectForIdFromCache(id); if (obj != null) { return(obj); } obj = new object(); AddReference(context, obj, id); return(obj); }
public List <T> GetList <T>(IReadContext read, string key) { var t = typeof(T); List <T> nmlis = new List <T>(); foreach (IReadContext r in read.ReadList(key)) { T nm = GetObject <T>(r);//创建对象 nmlis.Add(nm); } return(nmlis); }
public override object Read(IReadContext context) { byte ret = context.ReadByte(); if (ret == True) { return(true); } if (ret == False) { return(false); } return(null); }
public void Dispose() { if (_readContext != null) { lock (_syncRoot) { if (_readContext != null) { _readContext.Dispose(); _readContext = null; } } } }
public override object Read(IReadContext context) { byte[] bytes = new byte[8]; context.ReadBytes(bytes); return((ulong)( (ulong)bytes[7] & 255 | (ulong)(bytes[6] & 255) << 8 | (ulong)(bytes[5] & 255) << 16 | (ulong)(bytes[4] & 255) << 24 | (ulong)(bytes[3] & 255) << 32 | (ulong)(bytes[2] & 255) << 40 | (ulong)(bytes[1] & 255) << 48 | (ulong)(bytes[0] & 255) << 56 )); }
List <IReadContext> IReadContext.ReadList(string path) { List <IReadContext> lst = new List <IReadContext>(); // IReadContext red = this; var json = red.Read(path); JArray obj = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(json); for (int i = 0; i < obj.Count; i++) { lst.Add(new ReadContextByJson(obj[i].ToString())); } // return(lst); }
public override object Eval(GameState state, IReadContext c) { int[] newCoords = new int[coords.Length]; bool[] placeholder = new bool[coords.Length]; for (int i = 0; i < coords.Length; i++) { object v = coords[i].Eval(state, c); if (v is PlaceHolderValue) { placeholder[i] = true; } else { newCoords[i] = (int)v; } } return new Coords(newCoords, placeholder); }
protected override AuthorityGroupData Export(AuthorityGroup group, IReadContext context) { AuthorityGroupData data = new AuthorityGroupData(); data.Name = group.Name; data.Description = group.Description; data.DataGroup = group.DataGroup; data.Tokens = CollectionUtils.Map <AuthorityToken, string>( group.AuthorityTokens, delegate(AuthorityToken token) { return(token.Name); }); return(data); }
protected override LocationData Export(Location entity, IReadContext context) { var data = new LocationData { Deactivated = entity.Deactivated, Id = entity.Id, Name = entity.Name, Description = entity.Description, FacilityCode = entity.Facility.Code, Building = entity.Building, Floor = entity.Floor, PointOfCare = entity.PointOfCare }; return(data); }
protected override UserData Export(User user, IReadContext context) { var data = new UserData(); data.AccountType = user.AccountType.ToString(); data.UserName = user.UserName; data.DisplayName = user.DisplayName; data.ValidFrom = user.ValidFrom; data.ValidUntil = user.ValidUntil; data.Enabled = user.Enabled; data.AuthorityGroups = CollectionUtils.Map <AuthorityGroup, string>( user.AuthorityGroups, group => group.Name); return(data); }
private static ServerEntityKey GetPartitionKey(string partitionFolder) { using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IServerPartitionEntityBroker broker = ctx.GetBroker <IServerPartitionEntityBroker>(); ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria(); criteria.PartitionFolder.EqualTo(partitionFolder); ServerPartition partition = broker.FindOne(criteria); if (partition != null) { return(partition.Key); } } return(null); }
public UnitType Execute(IReadContext <UserState> context) { // retrieve the information for this user var userInfo = context.State; // if authentication fails, raise event and throw exception if (!Validate(Credentials, userInfo.InitialCredentials)) { throw new InvalidOperationException("Unauthorized"); } // TODO // escape transaction to report failed login return(UnitType.Value); }
public Study GetStudy() { if (_study == null) { lock (SyncRoot) { // TODO: Use ExecutionContext to re-use db connection if possible // This however requires breaking the Common --> Model dependency. using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { _study = LoadStudy(readContext); } } } return(_study); }
public Response Execute(IReadContext <AccountState> context) { var accountInfo = context.State; if (!accountInfo.Created.HasValue) { return(null); } else { return(new Response() { Balance = accountInfo.Balance, Owner = accountInfo.Owner }); } }
protected override UserData Export(User user, IReadContext context) { UserData data = new UserData(); data.UserName = user.UserName; data.DisplayName = user.DisplayName; data.ValidFrom = user.ValidFrom; data.ValidUntil = user.ValidUntil; data.Enabled = user.Enabled; data.AuthorityGroups = CollectionUtils.Map <AuthorityGroup, string>( user.AuthorityGroups, delegate(AuthorityGroup group) { return(group.Name); }); return(data); }
public override object Read(IReadContext context) { byte[] bytes = new byte[16]; int[] ints = new int[4]; int offset = 4; context.ReadBytes(bytes); for (int i = 0; i < 4; i++) { ints[i] = ( bytes[--offset] & 255 | (bytes[--offset] & 255) << 8 | (bytes[--offset] & 255) << 16 | (bytes[--offset] & 255) << 24 ); offset += 8; } return new Decimal(ints); }
public void SetUp() { this.readContext = Substitute.For<IReadContext>(); var regTypes = SampleRegistrationTypes.CreateRegistrationTypes().AsQueryable(); this.registrationTypes = Substitute.For<IDbSet<RegistrationType>>().Initialize(regTypes); var regs = SampleRegistrations.CreateRegistrations().AsQueryable(); this.registrations = Substitute.For<IDbSet<Registration>>().Initialize(regs); var propTypes = SamplePropertyTypes.CreatePropertyTypes().AsQueryable(); this.propertyTypes = Substitute.For<IDbSet<PropertyType>>().Initialize(propTypes); var props = SampleProperties.CreateProperties().AsQueryable(); this.properties = Substitute.For<IDbSet<Property>>().Initialize(props); SystemTime.Set(TimeStamp); }
/// <summary> /// Returns a list of the services supported by this plugin. /// </summary> /// <returns></returns> public override IList <SupportedSop> GetSupportedSopClasses() { if (!Context.AllowStorage) { return(new List <SupportedSop>()); } if (_sopList == null) { _sopList = new List <SupportedSop>(); // Get the SOP Classes using (IReadContext read = _store.OpenReadContext()) { // Get the transfer syntaxes _syntaxList = LoadTransferSyntaxes(read, Partition.GetKey(), true); } var partitionSopClassConfig = new PartitionSopClassConfiguration(); var sopClasses = partitionSopClassConfig.GetAllPartitionSopClasses(Partition); if (sopClasses != null) { // Now process the SOP Class List foreach (PartitionSopClass partitionSopClass in sopClasses) { if (partitionSopClass.Enabled && !partitionSopClass.NonImage) { var sop = new SupportedSop { SopClass = SopClass.GetSopClass(partitionSopClass.SopClassUid) }; foreach (PartitionTransferSyntax syntax in _syntaxList) { sop.SyntaxList.Add(TransferSyntax.GetTransferSyntax(syntax.Uid)); } _sopList.Add(sop); } } } } return(_sopList); }
private static Device FindServer(string retrieveAeTitle) { using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { var broker = ctx.GetBroker <IDeviceEntityBroker>(); var criteria = new DeviceSelectCriteria(); criteria.AeTitle.EqualTo(retrieveAeTitle); IList <Device> list = broker.Find(criteria); foreach (Device theDevice in list) { if (string.Compare(theDevice.AeTitle, retrieveAeTitle, false, CultureInfo.InvariantCulture) == 0) { return(theDevice); } } } return(null); }
protected override ProcedureTypeGroupData Export(ProcedureTypeGroup entity, IReadContext context) { ProcedureTypeGroupData data = new ProcedureTypeGroupData(); data.Name = entity.Name; data.Class = entity.GetClass().FullName; data.Description = entity.Description; data.ProcedureTypes = CollectionUtils.Map <ProcedureType, ProcedureTypeData>( entity.ProcedureTypes, delegate(ProcedureType pt) { ProcedureTypeData ptdata = new ProcedureTypeData(); ptdata.Id = pt.Id; return(ptdata); }); return(data); }
/// <summary> /// Log FilesystemQueue related entries. /// </summary> public void LogFilesystemQueue() { FilesystemQueueSelectCriteria criteria = new FilesystemQueueSelectCriteria(); criteria.StudyStorageKey.EqualTo(Key); using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IFilesystemQueueEntityBroker broker = read.GetBroker <IFilesystemQueueEntityBroker>(); IList <FilesystemQueue> list = broker.Find(criteria); foreach (FilesystemQueue queueItem in list) { if (queueItem.FilesystemQueueTypeEnum.Equals(FilesystemQueueTypeEnum.LosslessCompress) || queueItem.FilesystemQueueTypeEnum.Equals(FilesystemQueueTypeEnum.LossyCompress)) { XmlElement element = queueItem.QueueXml.DocumentElement; string syntax = element.Attributes["syntax"].Value; TransferSyntax compressSyntax = TransferSyntax.GetTransferSyntax(syntax); if (compressSyntax != null) { Platform.Log(LogLevel.Info, "{0}: Study {1} on partition {2} scheduled for {3} compression at {4}", queueItem.FilesystemQueueTypeEnum.Description, StudyInstanceUid, ServerPartition.AeTitle, compressSyntax.Name, queueItem.ScheduledTime); } else { Platform.Log(LogLevel.Info, "{0}: Study {1} on partition {2} scheduled for {3} compression at {4}", queueItem.FilesystemQueueTypeEnum.Description, StudyInstanceUid, ServerPartition.AeTitle, syntax, queueItem.ScheduledTime); } } else { Platform.Log(LogLevel.Info, "{0}: Study {1} on partition {2} scheduled for {3}", queueItem.FilesystemQueueTypeEnum.Description, StudyInstanceUid, ServerPartition.AeTitle, queueItem.ScheduledTime); } } } }
public override object Read(IReadContext readContext) { IInternalReadContext context = (IInternalReadContext)readContext; ByteArrayBuffer buffer = (ByteArrayBuffer)context.ReadIndirectedBuffer(); if (buffer == null) { return null; } // With the following line we ask the context to work with // a different buffer. Should this logic ever be needed by // a user handler, it should be implemented by using a Queue // in the UnmarshallingContext. // The buffer has to be set back from the outside! See below IReadBuffer contextBuffer = context.Buffer(buffer); object array = base.Read(context); // The context buffer has to be set back. context.Buffer(contextBuffer); return array; }
private bool DeviceIsBusy(Device device) { bool busy = false; if (device.ThrottleMaxConnections != UNLIMITED) { if (_tempBlackoutDevices.ContainsKey(device.Key)) { busy = true; } else { List <Model.WorkQueue> currentMoves; using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { currentMoves = device.GetAllCurrentMoveEntries(context); } if (currentMoves != null && currentMoves.Count > device.ThrottleMaxConnections) { // sort the list to see where this entry is // and postpone it if its position is greater than the ThrottleMaxConnections currentMoves.Sort(delegate(Model.WorkQueue item1, Model.WorkQueue item2) { return(item1.ScheduledTime.CompareTo(item2.ScheduledTime)); }); int index = currentMoves.FindIndex(delegate(Model.WorkQueue item) { return(item.Key.Equals(WorkQueueItem.Key)); }); if (index >= device.ThrottleMaxConnections) { Platform.Log(LogLevel.Warn, "Connection limit on device {0} has been reached. Max = {1}.", device.AeTitle, device.ThrottleMaxConnections); // blackout for 5 seconds _tempBlackoutDevices.Add(device.Key, device); busy = true; } } } } return(busy); }
public override object Read(IReadContext context) { byte[] bytes = new byte[16]; int[] ints = new int[4]; int offset = 4; context.ReadBytes(bytes); for (int i = 0; i < 4; i++) { ints[i] = ( bytes[--offset] & 255 | (bytes[--offset] & 255) << 8 | (bytes[--offset] & 255) << 16 | (bytes[--offset] & 255) << 24 ); offset += 8; } return(new Decimal(ints)); }
public override object Eval(GameState state, IReadContext c) { IEnumerable<object> set = (IEnumerable<object>)from.Eval(state, c); var newSet = new HashSet<object>(); foreach (var o in set) { ReferenceExpr refExpr = varName as ReferenceExpr; if (refExpr != null && refExpr.Name == "$") { if (where == null) { newSet.Add(o); } else { var oContext = (IReadContext)o; bool result = (bool)where.Eval(state, new MultiParentContext(state, oContext, c)); if (result) { newSet.Add(o); } } } else { var oContext = (IReadContext)o; if (where == null) { newSet.Add(varName.Eval(state, oContext)); } else { bool result = (bool)where.Eval(state, new MultiParentContext(state, oContext, c)); if (result) { newSet.Add(varName.Eval(state, oContext)); } } } } return newSet; }
public ImageServerData() { using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { TotalStudiesCount = 0; IServerPartitionEntityBroker partitionBroker = context.GetBroker <IServerPartitionEntityBroker>(); var partitions = partitionBroker.Find(new ServerPartitionSelectCriteria()); foreach (ServerPartition partition in partitions) { TotalStudiesCount += partition.StudyCount; } IDeviceEntityBroker deviceBroker = context.GetBroker <IDeviceEntityBroker>(); DeviceSelectCriteria criteria = new DeviceSelectCriteria(); criteria.Enabled.EqualTo(true); ActiveDeviceCount += deviceBroker.Count(criteria); } }
protected override bool Initialize() { if (_theProcessor == null) { // Force a read context to be opened. When developing the retry mechanism // for startup when the DB was down, there were problems when the type // initializer for enumerated values were failng first. For some reason, // when the database went back online, they would still give exceptions. // changed to force the processor to open a dummy DB connect and cause an // exception here, instead of getting to the enumerated value initializer. using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { } _theProcessor = new ServiceLockProcessor(2, ThreadStop); // 2 threads for processor } return(true); }
/// <summary> /// Method called by the connection once the bytes were read /// </summary> /// <param name="context">Current transmission</param> /// <param name="readBytes">Bytes that were read by the socket</param> /// <param name="publishCompleteMessage">Delegate to publish a complete message read from the byte stream</param> public ByteReadResult ProcessReadBytes(IReadContext context, int readBytes, Action <BinaryMessage> publishCompleteMessage) { var delimited = (DelimitedMessageContext)context; // Search for start if (!delimited.StartFound) { if (delimited.CurrentIndex + readBytes >= StartDelimiter.Length && FindStart(readBytes, delimited)) { delimited.StartFound = true; } else { delimited.CurrentIndex += readBytes; return(ByteReadResult.KeepReading); } } // Search for end var header = delimited.MessageStart + StartDelimiter.Length; var searchStart = delimited.CurrentIndex > (header + EndDelimiter.Length) ? delimited.CurrentIndex - EndDelimiter.Length : header; var searchEnd = (delimited.CurrentIndex + readBytes) - EndDelimiter.Length; for (var index = searchStart; index <= searchEnd; index++) { var segment = new ArraySegment <byte>(delimited.ReadBuffer, index, EndDelimiter.Length); if (!EndDelimiter.SequenceEqual(segment)) { continue; } // Wrap up message and publish delimited.MessageEnd = index + EndDelimiter.Length - 1; publishCompleteMessage(ToMessage(delimited)); var overlap = ResetContext(readBytes, delimited); return(ProcessReadBytes(delimited, overlap, publishCompleteMessage)); } delimited.CurrentIndex += readBytes; return(ByteReadResult.KeepReading); }
private void BeginRead(IReadContext transmission) { try { if (_disconnected) { return; } _stream.BeginRead(transmission.ReadBuffer, transmission.CurrentIndex, transmission.ReadSize, ReadCallback, transmission); } catch (ObjectDisposedException) { Disconnect(); } catch (IOException) { Disconnect(); } }
/// <summary> /// Return snapshot of all related items in the Study Integrity Queue. /// </summary> /// <returns></returns> public IList <StudyIntegrityQueue> GetRelatedStudyIntegrityQueueItems() { lock (SyncRoot) // make this thread-safe { if (_integrityQueueItems == null) { using (IReadContext ctx = _store.OpenReadContext()) { IStudyIntegrityQueueEntityBroker integrityQueueBroker = ctx.GetBroker <IStudyIntegrityQueueEntityBroker>(); StudyIntegrityQueueSelectCriteria parms = new StudyIntegrityQueueSelectCriteria(); parms.StudyStorageKey.EqualTo(GetKey()); _integrityQueueItems = integrityQueueBroker.Find(parms); } } } return(_integrityQueueItems); }
private Study GetStudyAndQueues(StudyStorageLocation location, out int integrityQueueCount, out int workQueueCount) { using (IReadContext context = _store.OpenReadContext()) { IStudyIntegrityQueueEntityBroker integrityBroker = context.GetBroker <IStudyIntegrityQueueEntityBroker>(); StudyIntegrityQueueSelectCriteria integrityCriteria = new StudyIntegrityQueueSelectCriteria(); integrityCriteria.StudyStorageKey.EqualTo(location.Key); integrityQueueCount = integrityBroker.Count(integrityCriteria); IWorkQueueEntityBroker workBroker = context.GetBroker <IWorkQueueEntityBroker>(); WorkQueueSelectCriteria workCriteria = new WorkQueueSelectCriteria(); workCriteria.StudyStorageKey.EqualTo(location.Key); workQueueCount = workBroker.Count(workCriteria); IStudyEntityBroker procedure = context.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.StudyStorageKey.EqualTo(location.Key); return(procedure.FindOne(criteria)); } }
protected override StaffGroupData Export(StaffGroup entity, IReadContext context) { StaffGroupData data = new StaffGroupData(); data.Deactivated = entity.Deactivated; data.Name = entity.Name; data.Description = entity.Description; data.Elective = entity.Elective; data.Members = CollectionUtils.Map <Staff, StaffMemberData>( entity.Members, delegate(Staff staff) { StaffMemberData s = new StaffMemberData(); s.Id = staff.Id; return(s); }); return(data); }
private void LoadRelatedEntities() { if (_study == null || _studyStorage == null) { using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { lock (SyncRoot) { if (_study == null) { _study = LoadStudy(context); } if (_studyStorage == null) { _studyStorage = LoadStudyStorage(context); } } } } }
public override object Read(IReadContext readContext) { IInternalReadContext context = (IInternalReadContext)readContext; ByteArrayBuffer buffer = (ByteArrayBuffer)context.ReadIndirectedBuffer(); if (buffer == null) { return(null); } // With the following line we ask the context to work with // a different buffer. Should this logic ever be needed by // a user handler, it should be implemented by using a Queue // in the UnmarshallingContext. // The buffer has to be set back from the outside! See below IReadBuffer contextBuffer = context.Buffer(buffer); object array = base.Read(context); // The context buffer has to be set back. context.Buffer(contextBuffer); return(array); }
/// <summary> /// Load from the database the configured transfer syntaxes /// </summary> /// <param name="read">a Read context</param> /// <param name="partitionKey">The partition to retrieve the transfer syntaxes for</param> /// <param name="encapsulated">true if searching for encapsulated syntaxes only</param> /// <returns>The list of syntaxes</returns> protected static IList<PartitionTransferSyntax> LoadTransferSyntaxes(IReadContext read, ServerEntityKey partitionKey, bool encapsulated) { var broker = read.GetBroker<IQueryServerPartitionTransferSyntaxes>(); var criteria = new PartitionTransferSyntaxQueryParameters { ServerPartitionKey = partitionKey }; IList<PartitionTransferSyntax> list = broker.Find(criteria); var returnList = new List<PartitionTransferSyntax>(); foreach (PartitionTransferSyntax syntax in list) { if (!syntax.Enabled) continue; TransferSyntax dicomSyntax = TransferSyntax.GetTransferSyntax(syntax.Uid); if (dicomSyntax.Encapsulated == encapsulated) returnList.Add(syntax); } return returnList; }
public override object Read(IReadContext context) { var value = ((context.ReadByte() & unchecked(0xff)) << 8) + (context.ReadByte () & unchecked(0xff)); return (short) value; }