Commits

Bozydar Sobczak  committed 8268402

Refactor: Pascal case identifiers

  • Participants
  • Parent commits 0cfeabf

Comments (0)

Files changed (7)

File Rdc.Wrapper.Synchronizer/Synchronizer.cs

                 foreach (var item in needList)
                 {
                     byte[] data;
-                    switch (item.blockType)
+                    switch (item.BlockType)
                     {
                         case RdcNeedType.Source:
-                            data = _rdcServiceClient.TransferDataBlock(sourcePath, (int)item.fileOffset,
-                                                                       (int)item.blockLength);
+                            data = _rdcServiceClient.TransferDataBlock(sourcePath, (int)item.FileOffset,
+                                                                       (int)item.BlockLength);
                             break;
                         case RdcNeedType.Seed:
-                            data = new byte[item.blockLength];
-                            seedFile.Seek((int)item.fileOffset, SeekOrigin.Begin);
-                            seedFile.Read(data, 0, (int)item.blockLength);
+                            data = new byte[item.BlockLength];
+                            seedFile.Seek((int)item.FileOffset, SeekOrigin.Begin);
+                            seedFile.Read(data, 0, (int)item.BlockLength);
                             break;
                         default:
                             data = null;
                     }
                     if (data != null)
                     {
-                        outputFile.Write(data, 0, (int)item.blockLength);
+                        outputFile.Write(data, 0, (int)item.BlockLength);
                     }
                 }
             }

File Rdc.Wrapper.Test/NeedListGeneratorTest.cs

         private readonly ISignatureRepository _signatureRepository = new SimpleSignatureRepository();
 
         [TestFixtureSetUp]
-        public void Initi()
+        public void Init()
         {
 
-            using (Stream file = File.Create("source.txt"))
+            using (Stream file = File.Create("source.bin"))
             {
-                new RandomStream(1024*1024*1024, 1).CopyTo(file);
+                new RandomStream(1024*1024*200, 1).CopyTo(file);
             }
 
-            using (Stream file = File.Create("seed.txt"))
+            using (Stream file = File.Create("seed.bin"))
             {
-                new RandomlyModifiedStream(new RandomStream(1024*1024*1024, 1), 0.001, 1).CopyTo(file);
+                new RandomlyModifiedStream(new RandomStream(1024*1024*200, 1), 0.001, 1).CopyTo(file);
             }
         }
 
             IList<SignatureInfo> sourceSignatureInfos;
             IList<SignatureInfo> seedSignatureInfos;
             long sourceSize;
-            using (Stream file = File.OpenRead("seed.txt"))
+            using (Stream file = File.OpenRead("seed.bin"))
             {
                 using (var generator = new SigGenerator(_signatureRepository))
                 {
                     seedSignatureInfos = generator.GenerateSignatures(file);
                 }
             }
-            using (Stream file = File.OpenRead("source.txt"))
+            using (Stream file = File.OpenRead("source.bin"))
             {
                 using (var generator = new SigGenerator(_signatureRepository))
                 {
                 var result = tested.CreateNeedsList(seedSignatureInfos.Last(), sourceSignatureInfos.Last());
                 Assert.IsNotNull(result);
 
-                Assert.AreEqual(0, sourceSize - result.Sum(x => Convert.ToInt32(x.blockLength)));
+                Assert.AreEqual(0, sourceSize - result.Sum(x => Convert.ToInt32(x.BlockLength)));
             }
         }
     }

File Rdc.Wrapper/NeedListGenerator.cs

     {
         private readonly ReaderWriterLockSlim _disposerLock = new ReaderWriterLockSlim();
         private bool _disposed;
-        private ISignatureRepository _seedSignatureRepository;
+        private readonly ISignatureRepository _seedSignatureRepository;
         private readonly ISignatureRepository _sourceSignatureRepository;
 
         private readonly IRdcLibrary _rdcLibrary;
                 _rdcLibrary.CreateComparator(fileReader, ComparatorBufferSize, out comparator);
 
                 var inputBuffer = new RdcBufferPointer();
-                inputBuffer.size = 0;
-                inputBuffer.used = 0;
-                inputBuffer.data = Marshal.AllocCoTaskMem(InputBufferSize + 16); // Completely don't know why 16
+                inputBuffer.Size = 0;
+                inputBuffer.Used = 0;
+                inputBuffer.Data = Marshal.AllocCoTaskMem(InputBufferSize + 16); // Completely don't know why 16
 
                 var outputBuffer = Marshal.AllocCoTaskMem(
                     Marshal.SizeOf(typeof(RdcNeed)) * 256);
 
                     while (!eofOutput)
                     {
-                        if (inputBuffer.size == inputBuffer.used && !eof)
+                        if (inputBuffer.Size == inputBuffer.Used && !eof)
                         {
                             var bytesRead = 0;
                             try
                             {
-                                bytesRead = RdcBufferTools.IntPtrCopy(sourceStream, inputBuffer.data, 0, InputBufferSize);
+                                bytesRead = RdcBufferTools.IntPtrCopy(sourceStream, inputBuffer.Data, 0, InputBufferSize);
                             }
                             catch (Exception ex)
                             {
                                 throw new RdcException("Failed to read from the source stream.", ex);
                             }
 
-                            inputBuffer.size = (uint)bytesRead;
-                            inputBuffer.used = 0;
+                            inputBuffer.Size = (uint)bytesRead;
+                            inputBuffer.Used = 0;
 
                             if (bytesRead < InputBufferSize)
                             {
                         }
 
                         // Initialize our output needs array
-                        outputPointer.size = 256;
-                        outputPointer.used = 0;
-                        outputPointer.data = outputBuffer;
+                        outputPointer.Size = 256;
+                        outputPointer.Used = 0;
+                        outputPointer.Data = outputBuffer;
 
                         RdcError error;
 
                         Marshal.FreeCoTaskMem(outputBuffer);
                     }
 
-                    if (inputBuffer.data != IntPtr.Zero)
+                    if (inputBuffer.Data != IntPtr.Zero)
                     {
-                        Marshal.FreeCoTaskMem(inputBuffer.data);
+                        Marshal.FreeCoTaskMem(inputBuffer.Data);
                     }
                 }
                 return result;
 
         private RdcNeed[] GetRdcNeedList(RdcNeedPointer pointer)
         {
-            var result = new RdcNeed[pointer.used];
+            var result = new RdcNeed[pointer.Used];
 
-            var ptr = pointer.data;
+            var ptr = pointer.Data;
             var needSize = Marshal.SizeOf(typeof(RdcNeed));
 
             // Get our native needs pointer 

File Rdc.Wrapper/RdcBufferTools.cs

     {
         public static RdcBufferPointer GetInputBuffer(Stream source, int inputBufferSize, RdcBufferPointer inputBuffer, ref bool eof)
         {
-            if (inputBuffer.size == inputBuffer.used)
+            if (inputBuffer.Size == inputBuffer.Used)
                 if (true)
             {
                 if (eof)
                 {
-                    inputBuffer.size = 0;
-                    inputBuffer.used = 0;
+                    inputBuffer.Size = 0;
+                    inputBuffer.Used = 0;
                 }
                 else
                 {
                     var bytesRead = 0;
                     try
                     {
-                        bytesRead = IntPtrCopy(source, inputBuffer.data, 0, inputBufferSize);
+                        bytesRead = IntPtrCopy(source, inputBuffer.Data, 0, inputBufferSize);
                     }
                     catch (Exception ex)
                     {
                         throw new RdcException("Failed to read from the source stream.", ex);
                     }
 
-                    inputBuffer.size = (uint)bytesRead;
-                    inputBuffer.used = 0;
+                    inputBuffer.Size = (uint)bytesRead;
+                    inputBuffer.Used = 0;
 
                     if (bytesRead < inputBufferSize)
                     {

File Rdc.Wrapper/RdcComInterop.cs

     [StructLayout(LayoutKind.Sequential, Pack = 8)]
     public struct RdcNeed
     {
-        public RdcNeedType blockType;
-        public UInt64 fileOffset;
-        public UInt64 blockLength;
+        public RdcNeedType BlockType;
+        public UInt64 FileOffset;
+        public UInt64 BlockLength;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     public struct RdcBufferPointer
     {
-        public uint size;
-        public uint used;
-        public IntPtr data;
+        public uint Size;
+        public uint Used;
+        public IntPtr Data;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     internal struct RdcNeedPointer
     {
-        public uint size;
-        public uint used;
-        public IntPtr data;
+        public uint Size;
+        public uint Used;
+        public IntPtr Data;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     internal struct RdcSignature
     {
-        public IntPtr signature;
-        public ushort blockLength;
+        public IntPtr Signature;
+        public ushort BlockLength;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     internal struct RdcSignaturePointer
     {
-        public uint size;
-        public uint used;
+        public uint Size;
+        public uint Used;
         [MarshalAs(UnmanagedType.Struct)]
-        public RdcSignature data;
+        public RdcSignature Data;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     internal struct SimilarityMappedViewInfo
     {
-        public string data;
-        public uint length;
+        public string Data;
+        public uint Length;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     public struct SimilarityData
     {
-        public char[] data;     // m_Data[16]
+        public char[] Data;     // m_Data[16]
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     internal struct FindSimilarFileIndexResults
     {
-        public uint fileIndex;
-        public uint matchCount;
+        public uint FileIndex;
+        public uint MatchCount;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     internal struct SimilarityDumpData
     {
-        public uint fileIndex;
-        public SimilarityData data;
+        public uint FileIndex;
+        public SimilarityData Data;
     }
 
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     internal struct SimilarityFileId
     {
-        public byte[] fileId;   // m_FileId[32]
+        public byte[] FileId;   // m_FileId[32]
     }
 
     #endregion

File Rdc.Wrapper/SigGenerator.cs

 
             Marshal.ReleaseComObject(rdcGenerator);
 
-            if (inputBuffer.data != IntPtr.Zero)
+            if (inputBuffer.Data != IntPtr.Zero)
             {
-                Marshal.FreeCoTaskMem(inputBuffer.data);
+                Marshal.FreeCoTaskMem(inputBuffer.Data);
             }
 
             return result.Reverse().ToList();
-            // TODO: Fee memory in case of exception
-
         }
 
 
             IList<SignatureInfo> result)
         {
             var inputBuffer = new RdcBufferPointer();
-            inputBuffer.size = 0;
-            inputBuffer.used = 0;
-            inputBuffer.data = Marshal.AllocCoTaskMem((int)InputBufferSize + 16); // Completely don't know why 16
+            inputBuffer.Size = 0;
+            inputBuffer.Used = 0;
+            inputBuffer.Data = Marshal.AllocCoTaskMem((int)InputBufferSize + 16); // Completely don't know why 16
             var eof = false;
             var eofOutput = false;
             // prepare streams
 
                         // Write the signature block to the file.
                         var bytesWritten = RdcBufferTools.IntPtrCopy(
-                            rdcBufferPointers[i].data,
+                            rdcBufferPointers[i].Data,
                             resultStream,
                             0,
-                            (int)rdcBufferPointers[i].used);
+                            (int)rdcBufferPointers[i].Used);
                         result[i].Length += bytesWritten;
 
-                        if (rdcBufferPointers[i].used != bytesWritten)
+                        if (rdcBufferPointers[i].Used != bytesWritten)
                         {
                             throw new RdcException("Failed to write to the signature file.");
                         }
 
 
-                        rdcBufferPointers[i].used = 0;
+                        rdcBufferPointers[i].Used = 0;
                     }
 
                     RdcBufferTranslate(rdcBufferPointers, outputPointers);
             var result = new RdcBufferPointer[outputBuffers.Length];
             for (var i = 0; i < outputBuffers.Length; i++)
             {
-                result[i].size = OutputBufferSize;
-                result[i].data = outputBuffers[i];
-                result[i].used = 0;
+                result[i].Size = OutputBufferSize;
+                result[i].Data = outputBuffers[i];
+                result[i].Used = 0;
             }
             return result;
         }

File Rdc.Wrapper/SignatureInfo.cs

             set;
         }
 
-        public RdcNeed[] Needs
-        {
-            get;
-            set;
-        }
-
         public SignatureInfo()
         {
             Name = Guid.NewGuid().ToString();