コード例 #1
0
        private static uint UploadEntries <TFileSystemEntry, TFileTableIndex>(FixedSizeCollection <TFileSystemEntry> fileSystemTable, IEnumerable <TFileTableIndex> entryIndexes, UploadDataOperationData uploadOpData)
            where TFileSystemEntry : class, IGlobalFileSystemEntry
        {
            var data        = uploadOpData.TaskData;
            var device      = data.Device;
            var crc         = 0u; // TODO : ELIMINATE THIS
            var numUploaded = 0;
            var numToUpload = entryIndexes.Count();
            var succeeded   = false;

            foreach (var entryIndex in entryIndexes)
            {
                if (data.AcceptCancelIfRequested())
                {
                    break;
                }
                var entry = fileSystemTable[Convert.ToInt32(entryIndex)];
                if (uploadOpData.ShouldUpdateProgress(entry))
                {
                    uploadOpData.UpdateTitle();
                    uploadOpData.UpdateStatus(entry.Name, numToUpload, ref numUploaded);
                }
                var serializableEntry = uploadOpData.GetSerializer(entry);
                uploadOpData.CreateCommand(uploadOpData.Address, serializableEntry, crc).Execute(device.Port, data, out succeeded);
                uploadOpData.Address += (uint)serializableEntry.SerializeByteCount;
            }

            return(uploadOpData.Address);
        }
コード例 #2
0
 protected override void SetItem(int index, FixedSizeCollection <T> item)
 {
     if (item.Count != Size)
     {
         throw new InvalidOperationException("Changing size is not supported.");
     }
     base.SetItem(index, item);
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of GatherDifferencesDescriptor.
 /// </summary>
 /// <param name="entityType">The type of the file system entities this descriptor works with.</param>
 /// <param name="targetFileSystemTable">The LFS file system table to be compared against a reference version.</param>
 /// <param name="comparer">The comparison function to use to determine if a reference and target file system entity are different.</param>
 /// <param name="validator">The validation function to use to determine if an entry is valid.</param>
 /// <param name="ignorer">The function to use to determine whether to ignore an entry for computing differences.</param>
 public GatherDifferencesDescriptor(LfsEntityType entityType, FixedSizeCollection <T> targetFileSystemTable, FileSystemEntryComparer <T> comparer, FileSystemEntryValidator <T> validator, Predicate <T> ignorer)
 {
     TargetFileSystemTable = targetFileSystemTable;
     Compare    = comparer;
     Validate   = validator ?? AlwaysValid;
     Ignore     = ignorer ?? NeverIgnore;
     EntityType = entityType;
 }
コード例 #4
0
 protected override void Init()
 {
     _initializing = true;
     for (int i = 0; i < Size; i++)
     {
         FixedSizeCollection <T> row = new FixedSizeCollection <T>(Size);
         Add(row);
     }
     _initializing = false;
 }
コード例 #5
0
 public static void Main() {
   FixedSizeCollection < string > gC = new FixedSizeCollection < string > (5);
   Console.WriteLine(gC);
   string s1 = "s1";
   string s2 = "s1";
   string s3 = "s1";
   int i1 = 1;
   gC.AddItem(s1);
   gC.AddItem(s2);
   gC.AddItem(s3);
   gC.AddItem(i1);
 }
コード例 #6
0
    public static void main()
    {
        // Generic class
        FixedSizeCollection <string> gC = new FixedSizeCollection <string>(5);

        Console.WriteLine(gC);

        string s1 = "s1";
        string s2 = "s1";
        string s3 = "s1";
        int    i1 = 1;

        gC.AddItem(s1);
        gC.AddItem(s2);
        gC.AddItem(s3);

        gC.AddItem(i1.ToString());
    }
コード例 #7
0
 public void CannotRemoveTest()
 {
     // if the size of the collection is fixed, we are not allowed to add items to it.
     FixedSizeCollection<TestClass> fixedSizeCollection = new FixedSizeCollection<TestClass>();
     PagedCollectionView pcv = new PagedCollectionView(fixedSizeCollection);
     Assert.IsFalse(pcv.CanRemove);
 }
コード例 #8
0
        public void CannotAddNewTest()
        {
            // if the size of the collection is fixed, we are not allowed to add items to it.
            FixedSizeCollection<TestClass> fixedSizeCollection = new FixedSizeCollection<TestClass>();
            PagedCollectionView pcv1 = new PagedCollectionView(fixedSizeCollection);
            Assert.IsFalse(pcv1.CanAddNew);

            // if the item type does not have a constructor, we are not allowed to call AddNew.
            List<int> intList = new List<int>();
            PagedCollectionView pcv2 = new PagedCollectionView(intList);
            Assert.IsFalse(pcv2.CanAddNew);

            PagedCollectionViewTest.AssertExpectedException(
                new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedForView, "AddNew")),
                delegate
                {
                    pcv2.AddNew();
                });
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of GatherDifferencesDescriptor.
 /// </summary>
 /// <param name="entityType">The type of the file system entities this descriptor works with.</param>
 /// <param name="targetFileSystemTable">The LFS file system table to be compared against a reference version.</param>
 /// <param name="comparer">The comparison function to use to determine if a reference and target file system entity are different.</param>
 /// <param name="validator">The validation function to use to determine if an entry is valid.</param>
 public GatherDifferencesDescriptor(LfsEntityType entityType, FixedSizeCollection <T> targetFileSystemTable, FileSystemEntryComparer <T> comparer, FileSystemEntryValidator <T> validator)
     : this(entityType, targetFileSystemTable, comparer, validator, NeverIgnore)
 {
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of GatherDifferencesDescriptor.
 /// </summary>
 /// <param name="entityType">The type of the file system entities this descriptor works with.</param>
 /// <param name="targetFileSystemTable">The LFS file system table to be compared against a reference version.</param>
 /// <param name="comparer">The comparison function to use to determine if a reference and target file system entity are different.</param>
 public GatherDifferencesDescriptor(LfsEntityType entityType, FixedSizeCollection <T> targetFileSystemTable, FileSystemEntryComparer <T> comparer)
     : this(entityType, targetFileSystemTable, comparer, AlwaysValid)
 {
 }