Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…lysis

Original hash: 5824951
  • Loading branch information
YvonneP committed Feb 28, 2017
2 parents ea1fe1c + 1b4a54e commit 137d5ce
Show file tree
Hide file tree
Showing 214 changed files with 925 additions and 433 deletions.
3 changes: 3 additions & 0 deletions Acoustics/Acoustics.Shared/Acoustics.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<CodeContractsSuggestAssumptionsForCallees>False</CodeContractsSuggestAssumptionsForCallees>
<CodeContractsNecessaryEnsures>True</CodeContractsNecessaryEnsures>
<CodeContractsSkipAnalysisIfCannotConnectToCache>False</CodeContractsSkipAnalysisIfCannotConnectToCache>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -138,6 +139,7 @@
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsSkipAnalysisIfCannotConnectToCache>False</CodeContractsSkipAnalysisIfCannotConnectToCache>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CsvHelper, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
Expand Down Expand Up @@ -229,6 +231,7 @@
<Compile Include="Range.cs" />
<Compile Include="ResultProperty.cs" />
<Compile Include="SegmentPolicy.cs" />
<Compile Include="Span.cs" />
<Compile Include="SqlServerTypes\Loader.cs" />
<Compile Include="StatDescriptive.cs" />
<Compile Include="StringKeyValueStore.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/AppConfigHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AppConfigHelper.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the AppConfigHelper type.
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/ConfigFile/ConfigFile.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ConfigFile.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the ConfigFile type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ConfigFileException.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the ConfigFileException type.
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Csv/Csv.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Csv.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Generic methods for reading and writing Csv file.
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Csv/CsvExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AnalysisProgramsClassMapper.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the AnalysisProgramsClassMapper type.
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Csv/ISetPointConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SetPointConverter.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the ISetPointConverter type.
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Csv/MatrixMapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MatrixMapper.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the TwoDimensionalArray type.
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Debugging/AutoAttachVs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AutoAttachVs.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Example taken from this gist.
Expand Down
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Extensions/ArrayExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ArrayExtensions.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the ArrayExtensions type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ExtensionsDateTime.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
//
Expand Down Expand Up @@ -303,5 +303,25 @@ public static TimeSpan Multiply(this TimeSpan multiplicand, double multiplier)
{
return TimeSpan.FromTicks((long)(multiplicand.Ticks * multiplier));
}

// https://github.com/exceptionless/Exceptionless.DateTimeExtensions/blob/master/src/Exceptionless.DateTimeExtensions/DateTimeOffsetExtensions.cs#L222
public static DateTimeOffset Floor(this DateTimeOffset date, TimeSpan interval)
{
return date.AddTicks(-(date.Ticks % interval.Ticks));
}

// https://github.com/exceptionless/Exceptionless.DateTimeExtensions/blob/master/src/Exceptionless.DateTimeExtensions/DateTimeOffsetExtensions.cs#L226
public static DateTimeOffset Ceiling(this DateTimeOffset date, TimeSpan interval)
{
return date.AddTicks(interval.Ticks - (date.Ticks % interval.Ticks));
}

// https://github.com/exceptionless/Exceptionless.DateTimeExtensions/blob/master/src/Exceptionless.DateTimeExtensions/DateTimeOffsetExtensions.cs#L230
public static DateTimeOffset Round(this DateTimeOffset date, TimeSpan roundingInterval)
{
var halfIntervalTicks = ((roundingInterval.Ticks + 1) >> 1);
return date.AddTicks(halfIntervalTicks - ((date.Ticks + halfIntervalTicks) % roundingInterval.Ticks));
}

}
}
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Extensions/DoubleExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DoubleExtensions.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the DoubleExtensions type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DoubleSquareArrayExtensions.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EnumerableExtensions.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FileInfoExtensions.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the FileInfoExtensions type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ReSharper disable once CheckNamespace
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ReflectionExtensions.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the ReflectionExtensions type.
Expand Down
38 changes: 22 additions & 16 deletions Acoustics/Acoustics.Shared/FileDateHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FileDateHelpers.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the FileDateHelpers type.
Expand All @@ -23,6 +23,15 @@ namespace Acoustics.Shared

public class FileDateHelpers
{
private static readonly string[] AcceptedFormatsNoTimeZone = {
"yyyyMMdd[-|T|_]HHmmss (if timezone offset hint provided)",
"yyyyMMdd[-|T|_]HHmmssZ"
};

private static readonly string[] AcceptedFormatsTimeZone = {
"yyyyMMdd[-|T|_]HHmmss[+|-]HH",
"yyyyMMdd[-|T|_]HHmmss[+|-]HHmm"
};

internal static readonly DateVariants[] PossibleFormats =
{
Expand All @@ -32,7 +41,8 @@ public class FileDateHelpers
new DateVariants(
@"^(.*)(?<date>(\d{4})(\d{2})(\d{2})(?<separator>T|-|_)(\d{2})(\d{2})(\d{2})(?![+-][\d:]{2,5}|Z)).*\.([a-zA-Z0-9]+)$",
AppConfigHelper.StandardDateFormatNoTimeZone,
false),
false,
AcceptedFormatsNoTimeZone),

// valid: prefix_20140101-235959+10.mp3, a_00000000-000000+00.a, a_99999999-999999+9999.dnsb48364JSFDSD
// valid: prefix_20140101_235959+10.mp3, a_00000000_000000+00.a, a_99999999_999999+9999.dnsb48364JSFDSD
Expand All @@ -41,7 +51,7 @@ public class FileDateHelpers
new DateVariants(
@"^(.*)(?<date>(\d{4})(\d{2})(\d{2})(?<separator>T|-|_)(\d{2})(\d{2})(\d{2})(?![+-][:]{2,5})(?<offset>([+-](?!\d{0,5}:)(\d{4}|\d{2}))|Z)).*\.([a-zA-Z0-9]+)",
AppConfigHelper.StandardDateFormat,
true),
true, AcceptedFormatsTimeZone),
};

private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
Expand Down Expand Up @@ -205,18 +215,21 @@ private static bool ParseFileDateTimeBase(

internal class DateVariants
{
public DateVariants(string regex, string parseFormat, bool parseTimeZone)
public DateVariants(string regex, string parseFormat, bool parseTimeZone, string[] acceptedFormats)
{
this.Regex = regex;
this.ParseFormat = parseFormat;
this.ParseTimeZone = parseTimeZone;
this.AcceptedFormats = acceptedFormats;
}

public string Regex { get; set; }
public string Regex { get; }

public string ParseFormat { get; }

public string ParseFormat { get; set; }
public bool ParseTimeZone{ get; }

public bool ParseTimeZone{ get; set; }
public string[] AcceptedFormats { get; }

}
}
Expand All @@ -229,17 +242,10 @@ public InvalidFileDateException(string message)
: base(message)
{
this.options = "\n Valid formats include: \n"
+ FileDateHelpers.PossibleFormats.Select(x => x.ParseFormat)
.Distinct()
+ FileDateHelpers.PossibleFormats.SelectMany(x => x.AcceptedFormats)
.Aggregate(string.Empty, (s, x) => s += "\t - " + x + "\n");
}

public override string Message
{
get
{
return base.Message + this.options;
}
}
public override string Message => base.Message + this.options;
}
}
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Json.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Json.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the Json type.
Expand Down
40 changes: 40 additions & 0 deletions Acoustics/Acoustics.Shared/Span.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Acoustics.Shared
{
public struct Span<T> : IEquatable<Span<T>>, IComparable<Span<T>> where T : struct, IComparable<T>
{
public Span(T lower, T upper)
{
this.Lower = lower;
this.Upper = upper;
}

public T Lower { get; }
public T Upper { get; }

public bool Equals(Span<T> other)
{
return this.Lower.Equals(other.Lower) && this.Upper.Equals(other.Upper);
}

public int CompareTo(Span<T> other)
{
var lower = this.Lower.CompareTo(other.Lower);
var upper = this.Upper.CompareTo(other.Upper);

return lower == 0 ? upper : lower;
}
}

public static class Span
{
public static Span<T> Create<T>(T minimum, T maximum) where T : struct, IComparable<T>
{
return new Span<T>(minimum, maximum);
}
}
}
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/Yaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Yaml.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Defines the Yaml type.
Expand Down
8 changes: 4 additions & 4 deletions Acoustics/Acoustics.Shared/app.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="YamlDotNet" publicKeyToken="2b53052c5884d7a1" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.21004" newVersion="2.0.1.21004" />
<assemblyIdentity name="YamlDotNet" publicKeyToken="2b53052c5884d7a1" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.1.21004" newVersion="2.0.1.21004"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Shared/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="fasterflect" version="2.1.3" targetFramework="net4" />
<package id="log4net" version="2.0.3" targetFramework="net4" />
<package id="Microsoft.SqlServer.Types" version="11.0.2" targetFramework="net4" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net4" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net40" />
<package id="YamlDotNet" version="3.9.0" targetFramework="net40" />
<package id="YamlDotNet.Dynamic" version="3.2.3" targetFramework="net40" />
</packages>
2 changes: 1 addition & 1 deletion Acoustics/Acoustics.Test/ArrayExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ArrayExtensionsTests.cs" company="QutBioacoustics">
// All code in this file and all associated files are the copyright of the QUT Bioacoustics Research Group (formally MQUTeR).
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
// Summary description for ArrayExtensionsTests
Expand Down
Loading

0 comments on commit 137d5ce

Please sign in to comment.