Even better objects #39
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Xunit;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler.Tests
|
||||
namespace MatFileHandler.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Data used in reading/writing tests.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Xunit;
|
||||
using Xunit;
|
||||
|
||||
namespace MatFileHandler.Tests
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler.Tests;
|
||||
namespace MatFileHandler.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Method of reading .mat files for testing.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using Xunit;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler.Tests;
|
||||
namespace MatFileHandler.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Method of writing .mat files for testing.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MatFileHandler.Tests
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MatFileHandler.Tests
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,92 +1,92 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// A stream that calculates Adler32 checksum of everything
|
||||
/// written to it before passing to another stream.
|
||||
/// </summary>
|
||||
internal class ChecksumCalculatingStream : Stream
|
||||
{
|
||||
private const uint BigPrime = 0xFFF1;
|
||||
private readonly Stream _stream;
|
||||
private uint s1;
|
||||
private uint s2;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChecksumCalculatingStream"/> class.
|
||||
/// </summary>
|
||||
/// <param name="stream">Wrapped stream.</param>
|
||||
public ChecksumCalculatingStream(Stream stream)
|
||||
{
|
||||
_stream = stream;
|
||||
s1 = 1;
|
||||
s2 = 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanRead => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanSeek => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanWrite => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Length => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Position
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Flush()
|
||||
{
|
||||
_stream.Flush();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
for (var i = offset; i < offset + count; i++)
|
||||
{
|
||||
s1 = (s1 + buffer[i]) % BigPrime;
|
||||
s2 = (s2 + s1) % BigPrime;
|
||||
}
|
||||
|
||||
_stream.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the checksum of everything written to the stream so far.
|
||||
/// </summary>
|
||||
/// <returns>Checksum of everything written to the stream so far.</returns>
|
||||
public uint GetCrc()
|
||||
{
|
||||
return (s2 << 16) | s1;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// A stream that calculates Adler32 checksum of everything
|
||||
/// written to it before passing to another stream.
|
||||
/// </summary>
|
||||
internal class ChecksumCalculatingStream : Stream
|
||||
{
|
||||
private const uint BigPrime = 0xFFF1;
|
||||
private readonly Stream _stream;
|
||||
private uint s1;
|
||||
private uint s2;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChecksumCalculatingStream"/> class.
|
||||
/// </summary>
|
||||
/// <param name="stream">Wrapped stream.</param>
|
||||
public ChecksumCalculatingStream(Stream stream)
|
||||
{
|
||||
_stream = stream;
|
||||
s1 = 1;
|
||||
s2 = 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanRead => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanSeek => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanWrite => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Length => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Position
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Flush()
|
||||
{
|
||||
_stream.Flush();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
for (var i = offset; i < offset + count; i++)
|
||||
{
|
||||
s1 = (s1 + buffer[i]) % BigPrime;
|
||||
s2 = (s2 + s1) % BigPrime;
|
||||
}
|
||||
|
||||
_stream.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the checksum of everything written to the stream so far.
|
||||
/// </summary>
|
||||
/// <returns>Checksum of everything written to the stream so far.</returns>
|
||||
public uint GetCrc()
|
||||
{
|
||||
return (s2 << 16) | s1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes compression usage strategy for writing files.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all data elements in .mat files.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// A better interface for using enum adapter.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface providing access to array's contents.
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Matlab's cell array.
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Matlab's character array.
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for accessing the contents of .mat files.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for accessing the variable contents.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Character array.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for writing .mat files.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <inheritdoc />
|
||||
internal class MatVariable : IVariable
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// A matrix of type T.
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MatFileHandler;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace MatFileHandler
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatFileHandler
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace MatFileHandler
|
||||
namespace MatFileHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of the data attached to the tag.
|
||||
|
Loading…
x
Reference in New Issue
Block a user