Example #1
0
 public virtual void SetByteArrayValue(byte[] bytes)
 {
     if (bytes != null)
     {
         if (byteArrayId != null && ResourceEntity != null)
         {
             byteArrayValue.Bytes = bytes;
         }
         else
         {
             DeleteByteArrayValue();
             //TODO 每次新建ResourceEntity?
             if (Context.CommandContext != null)
             {
                 byteArrayValue = new ResourceEntity(NameProvider.Name, bytes);
                 Context.CommandContext.ByteArrayManager.Add(byteArrayValue);
                 byteArrayId = byteArrayValue.Id;
             }
             else//TODO 不在cmd中
             {
                 using (IScope scope = ObjectContainer.BeginLifetimeScope())
                 {
                     IByteArrayManager manager = scope.Resolve <IByteArrayManager>();
                     byteArrayValue = new ResourceEntity(NameProvider.Name, bytes);
                     var bytearr = manager.Add(byteArrayValue);
                     byteArrayId = byteArrayValue.Id;
                 }
                 //throw new System.NotImplementedException("CommandContext is null");
             }
         }
     }
     else
     {
         DeleteByteArrayValue();
     }
 }