예제 #1
0
        public PayloadStreamAssembler GetPayloadAssembler(Guid id)
        {
            if (!_activeAssemblers.TryGetValue(id, out var assembler))
            {
                // a new id has come in, start a new task to process it
                assembler = new PayloadStreamAssembler(this, id);
                if (!_activeAssemblers.TryAdd(id, assembler))
                {
                    // Don't need to dispose the assembler because it was never used
                    // Get the one that is in use
                    _activeAssemblers.TryGetValue(id, out assembler);
                }
            }

            return(assembler);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PayloadStream"/> class.
 /// </summary>
 /// <param name="assembler">The <see cref="PayloadStreamAssembler"/> to use when constructing this stream.</param>
 public PayloadStream(PayloadStreamAssembler assembler)
 {
     _assembler = assembler;
 }
예제 #3
0
 public ContentStream(Guid id, PayloadStreamAssembler assembler)
 {
     Id         = id;
     _assembler = assembler ?? throw new ArgumentNullException();
     Stream     = _assembler.GetPayloadAsStream();
 }