Пример #1
0
        /// <summary>
        /// Constructor to support serialization required for storing the task.
        /// </summary>
        /// <param name="info">The serialization information.</param>
        /// <param name="context">The serialization context.</param>
        protected DownloadTask(SerializationInfo info, StreamingContext context)
        {
            var reader = new SerializationInfoReader(info, context);

            DownloadItem    = reader.Get("_manifest", (DownloadItem)null);
            _state          = reader.Get("_state", DownloadTaskState.None);
            _id             = reader.Get("_id", Guid.Empty);
            JobId           = reader.Get("_jobId", (Guid?)null);
            TransferredSize = reader.Get("_transferSize", 0);
            FileSize        = reader.Get("_fileSize", 0);
            _createDate     = TimeZoneInfo.ConvertTime(reader.Get("_createDate", DateTime.Now), TimeZoneInfo.Local);
            _fileName       = reader.Get("_fileName", (string)null);
            _errorText      = reader.Get("_errorText", (string)null);
            _supportsBITS   = reader.Get("_supportsBITS", false);

            if (reader.Contains("_downloadFilesBase"))
            {
                DownloadFilesBase = reader.Get("_downloadFilesBase", (string)null);
            }
            else /* there used to be a typo in the field name */
            {
                DownloadFilesBase = reader.Get("_donwnloadFilesBase", (string)null);
            }
            if (reader.Contains("_downloadErrorResumeCount"))
            {
                _downloadErrorResumeCount = reader.Get("_downloadErrorResumeCount", 0);
            }
        }
Пример #2
0
 /// <summary>
 /// Runs when the entire object graph has been deserialized.
 /// </summary>
 /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
 public virtual void OnDeserialization(object sender)
 {
     if (reader != null)
     {
         int version = reader.Get(SerialVersion, DefaultVersion);
         switch (version)
         {
         case Version_1:
             items     = reader.GetGenericList(Serialitems, Defaultitems);
             positions = reader.GetGenericDictionary(Serialpositions, Defaultpositions);
             if (reader.Context.State != StreamingContextStates.Persistence)
             {
                 positions.OnDeserialization(sender);
             }
             break;
         }
         if (items == null)
         {
             items = new List <Object>();
         }
         if (positions == null)
         {
             positions = new Dictionary <Key, int>();
         }
         reader = null;
     }
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyItemCollection&lt;Key, Object&gt;"/> class.
 /// </summary>
 /// <param name="info">The info.</param>
 /// <param name="context">The context.</param>
 protected KeyItemCollection(SerializationInfo info, StreamingContext context)
 {
     reader = new SerializationInfoReader(info, context);
 }
Пример #4
0
 /// <summary>
 /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
 /// </summary>
 /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
 /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
 public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     info.AddValue(SerialVersion, Version_1, typeof(int));
     SerializationInfoReader.AddGenericList(context, info, Serialitems, items);
     SerializationInfoReader.AddGenericDictionary(context, info, Serialpositions, positions);
 }