1
0
mirror of https://github.com/chylex/Code-Statistics.git synced 2025-05-24 06:34:08 +02:00

Refactor abstract classes, interfaces, and utils to a separate project CodeStatisticsCore

This commit is contained in:
chylex 2016-06-23 02:05:37 +02:00
parent c8390b8639
commit 02dfe82204
62 changed files with 247 additions and 115 deletions

View File

@ -6,10 +6,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeStatistics", "CodeStati
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeStatisticsTests", "CodeStatisticsTests\CodeStatisticsTests.csproj", "{BD148062-5858-49E7-B11B-20FC6E7114DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeStatisticsCore", "CodeStatisticsCore\CodeStatisticsCore.csproj", "{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Mono|Any CPU = Mono|Any CPU
Release|Any CPU = Release|Any CPU
Windows|Any CPU = Windows|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
@ -17,12 +20,24 @@ Global
{B1BC156C-AAA8-40EB-B90B-AEE950870D62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1BC156C-AAA8-40EB-B90B-AEE950870D62}.Mono|Any CPU.ActiveCfg = Mono|Any CPU
{B1BC156C-AAA8-40EB-B90B-AEE950870D62}.Mono|Any CPU.Build.0 = Mono|Any CPU
{B1BC156C-AAA8-40EB-B90B-AEE950870D62}.Release|Any CPU.ActiveCfg = Windows|Any CPU
{B1BC156C-AAA8-40EB-B90B-AEE950870D62}.Release|Any CPU.Build.0 = Windows|Any CPU
{B1BC156C-AAA8-40EB-B90B-AEE950870D62}.Windows|Any CPU.ActiveCfg = Windows|Any CPU
{B1BC156C-AAA8-40EB-B90B-AEE950870D62}.Windows|Any CPU.Build.0 = Windows|Any CPU
{BD148062-5858-49E7-B11B-20FC6E7114DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD148062-5858-49E7-B11B-20FC6E7114DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD148062-5858-49E7-B11B-20FC6E7114DD}.Mono|Any CPU.ActiveCfg = Mono|Any CPU
{BD148062-5858-49E7-B11B-20FC6E7114DD}.Release|Any CPU.ActiveCfg = Windows|Any CPU
{BD148062-5858-49E7-B11B-20FC6E7114DD}.Release|Any CPU.Build.0 = Windows|Any CPU
{BD148062-5858-49E7-B11B-20FC6E7114DD}.Windows|Any CPU.ActiveCfg = Windows|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Mono|Any CPU.ActiveCfg = Release|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Mono|Any CPU.Build.0 = Release|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Release|Any CPU.Build.0 = Release|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Windows|Any CPU.ActiveCfg = Release|Any CPU
{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}.Windows|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -66,12 +66,6 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Collections\AnonymousDictionary.cs" />
<Compile Include="Collections\BiDictionary.cs" />
<Compile Include="Collections\CharacterRangeSet.cs" />
<Compile Include="Collections\CounterDictionary.cs" />
<Compile Include="Collections\EnumDictionary.cs" />
<Compile Include="Collections\TopElementList.cs" />
<Compile Include="Data\Lang.cs" />
<Compile Include="Forms\AboutForm.cs">
<SubType>Form</SubType>
@ -79,7 +73,6 @@
<Compile Include="Forms\AboutForm.Designer.cs">
<DependentUpon>AboutForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\FormUtils.cs" />
<Compile Include="Forms\GitHubForm.cs">
<SubType>Form</SubType>
</Compile>
@ -92,12 +85,9 @@
<Compile Include="Forms\ProjectDebugForm.Designer.cs">
<DependentUpon>ProjectDebugForm.cs</DependentUpon>
</Compile>
<Compile Include="Handling\General\AbstractFileHandler.cs" />
<Compile Include="Handling\IFolderHandler.cs" />
<Compile Include="Handling\General\AssetHandler.cs" />
<Compile Include="Handling\General\FolderHandler.cs" />
<Compile Include="Handling\General\UnknownHandler.cs" />
<Compile Include="Handling\Languages\AbstractLanguageFileHandler.cs" />
<Compile Include="Handling\Languages\JavaHandler.cs" />
<Compile Include="Handling\Languages\Java\Elements\Annotation.cs" />
<Compile Include="Handling\Languages\Java\Elements\Field.cs" />
@ -117,20 +107,10 @@
<Compile Include="Handling\Languages\Java\JavaFileInfo.cs" />
<Compile Include="Handling\Languages\Java\Utils\JavaParseUtils.cs" />
<Compile Include="Handling\Languages\Java\JavaState.cs" />
<Compile Include="Handling\Utils\CodeParser.cs" />
<Compile Include="Handling\Utils\FileIntValue.cs" />
<Compile Include="Handling\Utils\ParseUtils.cs" />
<Compile Include="Handling\Utils\StringUtils.cs" />
<Compile Include="Handling\IFileHandler.cs" />
<Compile Include="Handling\HandlerList.cs" />
<Compile Include="Handling\Project.cs" />
<Compile Include="Handling\Utils\VariableUtils.cs" />
<Compile Include="Handling\Variables.cs" />
<Compile Include="Input\File.cs" />
<Compile Include="Input\FileSearch.cs" />
<Compile Include="Input\FileSearchData.cs" />
<Compile Include="Input\IOEntry.cs" />
<Compile Include="Input\IOUtils.cs" />
<Compile Include="Input\Methods\ArchiveExtraction.cs" />
<Compile Include="Input\Methods\DummyInputMethod.cs" />
<Compile Include="Input\Methods\GitHub.cs" />
@ -205,6 +185,12 @@
<ItemGroup>
<None Include="Resources\about.rtf" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodeStatisticsCore\CodeStatisticsCore.csproj">
<Project>{6e9bf33e-c035-4a44-ae11-6c2cfb029c0b}</Project>
<Name>CodeStatisticsCore</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Mono xbuild.bat /p:Configuration=Mono /p:PostBuildEvent= "$(SolutionPath)"</PostBuildEvent>

View File

@ -23,9 +23,6 @@ namespace CodeStatistics.Data{
{ "ErrorInvalidArgsFolderNotFound", "Folder not found: $1" },
{ "ErrorInvalidArgsGitHub", "Invalid GitHub repository, correct format is <username/repo[/branch]>: $1" },
{ "ErrorArgumentEqualLargerOne", "Argument must be equal to or larger than 1." },
{ "ErrorArgumentArrayAtLeastOne", "Array must contain at least one element." },
{ "MenuProjectFromFolder", "Project From Folder" },
{ "MenuProjectFromGitHub", "Project From GitHub" },
{ "MenuProjectFromArchive", "Project From Archive" },

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
using System;
namespace CodeStatistics.Forms{
public sealed partial class AboutForm : Form{
sealed partial class AboutForm : Form{
private static Dictionary<string,string> AboutFormData{
get{
return new Dictionary<string,string>{

View File

@ -2,9 +2,10 @@
using CodeStatistics.Input.Methods;
using System;
using System.Windows.Forms;
using CodeStatisticsCore.Forms;
namespace CodeStatistics.Forms{
public sealed partial class GitHubForm : Form{
sealed partial class GitHubForm : Form{
public GitHub GitHub { get; private set; }
private readonly Timer timer = new Timer{

View File

@ -6,10 +6,11 @@ using CodeStatistics.Input.Methods;
using CodeStatistics.Input;
using CodeStatistics.Input.Helpers;
using System.Drawing;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Forms{
public sealed partial class MainForm : Form{
public IInputMethod InputMethod{ get; private set; }
sealed partial class MainForm : Form{
public IInputMethod InputMethod { get; private set; }
public MainForm(){
InitializeComponent();

View File

@ -1,16 +1,17 @@
using CodeStatistics.Handling;
using System.Windows.Forms;
using CodeStatistics.Input;
using System;
using System.Runtime.InteropServices;
using CodeStatistics.Handling.Languages;
using PathIO = System.IO.Path;
using CodeStatistics.Data;
using System.Diagnostics;
using System.Collections.Generic;
using CodeStatisticsCore.Handling;
using CodeStatisticsCore.Handling.Files;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Forms{
sealed partial class ProjectDebugForm : Form{
partial class ProjectDebugForm : Form{
#if WINDOWS
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr handle, int message, IntPtr wParam, int[] lParam);

View File

@ -9,9 +9,11 @@ using System.Globalization;
using CodeStatistics.Data;
using CodeStatistics.Input.Methods;
using System.IO;
using CodeStatisticsCore.Forms;
using CodeStatisticsCore.Handling;
namespace CodeStatistics.Forms{
public sealed partial class ProjectLoadForm : Form{
sealed partial class ProjectLoadForm : Form{
private readonly IInputMethod inputMethod;
private FileSearch search;
private Project project;

View File

@ -1,6 +1,8 @@
using CodeStatistics.Input;
using System;
using System;
using System.Collections.Generic;
using CodeStatisticsCore.Handling;
using CodeStatisticsCore.Handling.Files;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Handling.General{
class AssetHandler : AbstractFileHandler{

View File

@ -1,4 +1,6 @@
namespace CodeStatistics.Handling.General{
using CodeStatisticsCore.Handling;
namespace CodeStatistics.Handling.General{
class FolderHandler : IFolderHandler{
public int Weight{
get { return 1; }

View File

@ -1,4 +1,6 @@
using CodeStatistics.Input;
using CodeStatisticsCore.Handling;
using CodeStatisticsCore.Handling.Files;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Handling.General{
class UnknownHandler : AbstractFileHandler{

View File

@ -3,13 +3,11 @@ using CodeStatistics.Handling.Languages;
using CodeStatistics.Input;
using System.Collections.Generic;
using System.Linq;
using CodeStatisticsCore.Handling;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Handling{
static class HandlerList{
public interface IWeightedEntry{
int Weight { get; }
}
private static readonly Dictionary<string,IFileHandler> FileHandlers = new Dictionary<string,IFileHandler>(8);
private static readonly IFileHandler UnknownFileHandler;

View File

@ -1,5 +0,0 @@
namespace CodeStatistics.Handling{
interface IFolderHandler : HandlerList.IWeightedEntry{
void Process(string folder, Variables.Root variables);
}
}

View File

@ -1,6 +1,6 @@
using System;
using CodeStatistics.Collections;
using System.Collections.Generic;
using CodeStatisticsCore.Collections;
namespace CodeStatistics.Handling.Languages.Java.Elements{
[Flags]

View File

@ -1,5 +1,5 @@
using System.Collections.Generic;
using CodeStatistics.Collections;
using CodeStatisticsCore.Collections;
namespace CodeStatistics.Handling.Languages.Java.Elements{
public enum Primitives{

View File

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using CodeStatistics.Handling.Languages.Java.Utils;
using CodeStatistics.Handling.Utils;
using System.Linq;
using CodeStatisticsCore.Handling.Utils;
namespace CodeStatistics.Handling.Languages.Java{
public class JavaCodeBlockParser : CodeParser{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using CodeStatistics.Handling.Languages.Java.Elements;
using CodeStatistics.Handling.Utils;
using System.Text;
using CodeStatistics.Handling.Languages.Java.Utils;
using CodeStatisticsCore.Handling.Utils;
namespace CodeStatistics.Handling.Languages.Java{
public class JavaCodeParser : CodeParser{

View File

@ -1,6 +1,6 @@
using System.Collections.Generic;
using CodeStatistics.Collections;
using CodeStatistics.Handling.Languages.Java.Elements;
using CodeStatisticsCore.Collections;
namespace CodeStatistics.Handling.Languages.Java{
class JavaGlobalInfo{

View File

@ -1,7 +1,7 @@
using CodeStatistics.Input;
using System.Collections.Generic;
using System.Collections.Generic;
using CodeStatistics.Handling.Languages.Java.Elements;
using CodeStatistics.Handling.Languages.Java.Utils;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Handling.Languages.Java{
class JavaState{

View File

@ -1,5 +1,5 @@
using System.Collections.Generic;
using CodeStatistics.Collections;
using CodeStatisticsCore.Collections;
namespace CodeStatistics.Handling.Languages.Java.Utils{
static class JavaCharacters{

View File

@ -1,14 +1,16 @@
using System;
using System.IO;
using System.Linq;
using CodeStatistics.Handling.Utils;
using File = CodeStatistics.Input.File;
using File = CodeStatisticsCore.Input.File;
using CodeStatistics.Handling.Languages.Java;
using CodeStatistics.Handling.Languages.Java.Utils;
using Type = CodeStatistics.Handling.Languages.Java.Elements.Type;
using CodeStatistics.Handling.Languages.Java.Elements;
using System.Collections.Generic;
using System.Windows.Forms;
using CodeStatisticsCore.Handling;
using CodeStatisticsCore.Handling.Utils;
using CodeStatisticsCore.Handling.Files;
namespace CodeStatistics.Handling.Languages{
class JavaHandler : AbstractLanguageFileHandler{

View File

@ -4,6 +4,8 @@ using System.Threading.Tasks;
using System.Linq;
using System.Collections.Generic;
using System;
using CodeStatisticsCore.Handling;
using CodeStatisticsCore.Input;
// ReSharper disable AccessToModifiedClosure
namespace CodeStatistics.Handling{

View File

@ -7,9 +7,10 @@ using FileIO = System.IO.File;
using DirectoryIO = System.IO.Directory;
using CodeStatistics.Input.Methods;
using CodeStatistics.Forms;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Input{
public class FileSearch : IInputMethod{
class FileSearch : IInputMethod{
public delegate void RefreshEventHandler(int entriesFound);
public delegate void FinishEventHandler(FileSearchData searchData);
public delegate void FailureEventHandler(Exception ex);

View File

@ -1,7 +1,8 @@
using System.Collections.Generic;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Input{
public class FileSearchData{
class FileSearchData{
private readonly HashSet<File> files = new HashSet<File>();
private readonly HashSet<string> folders = new HashSet<string>();

View File

@ -5,6 +5,7 @@ using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Input.Helpers{
class ZipArchive : IDisposable{

View File

@ -11,9 +11,10 @@ using System.IO;
using System.Text.RegularExpressions;
using CodeStatistics.Data;
using CodeStatistics.Input.Helpers;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Input.Methods{
public class GitHub : IInputMethod, IDisposable{
class GitHub : IInputMethod, IDisposable{
public const string DefaultBranch = "master";
private static readonly Regex RepositoryRegexCustom = new Regex(@"^([a-zA-Z0-9\-]+)/([\w\-\. ]+)(?:/([^\\[?^:~ ]+))?$",RegexOptions.CultureInvariant);

View File

@ -2,7 +2,7 @@
using CodeStatistics.Forms;
namespace CodeStatistics.Input.Methods{
public interface IInputMethod{
interface IInputMethod{
void BeginProcess(ProjectLoadForm.UpdateCallbacks callbacks);
void CancelProcess(Action onCancelFinish);
}

View File

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using CodeStatistics.Handling;
using System.IO;
using System.Text;
using CodeStatisticsCore.Handling;
namespace CodeStatistics.Output{
class GenerateHtml{

View File

@ -1,5 +1,5 @@
using CodeStatistics.Handling;
using System.Collections.Generic;
using System.Collections.Generic;
using CodeStatisticsCore.Handling;
namespace CodeStatistics.Output{
abstract class Template{

View File

@ -1,6 +1,6 @@
using CodeStatistics.Handling;
using System.Collections.Generic;
using System.Collections.Generic;
using CodeStatistics.Data;
using CodeStatisticsCore.Handling;
namespace CodeStatistics.Output{
class TemplateList{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using CodeStatistics.Handling;
using System.Text;
using CodeStatistics.Data;
using CodeStatisticsCore.Handling;
namespace CodeStatistics.Output{
abstract class TemplateToken{

View File

@ -1,11 +1,10 @@
using System;
using System.Windows.Forms;
using CodeStatistics.Forms;
using CodeStatistics.Input;
using CodeStatistics.Data;
using CodeStatistics.Input.Methods;
using CodeStatisticsCore.Input;
[assembly:CLSCompliant(true)]
namespace CodeStatistics{
static class Program{
public static ProgramConfiguration Config { get; private set; }

View File

@ -8,6 +8,7 @@ using CodeStatistics.Data;
using DirectoryIO = System.IO.Directory;
using FileIO = System.IO.File;
using CodeStatistics.Input.Methods;
using CodeStatisticsCore.Input;
namespace CodeStatistics{
class ProgramConfiguration{

View File

@ -1,4 +1,5 @@
using System.Reflection;
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@ -33,3 +34,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]
[assembly:CLSCompliant(true)]

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6E9BF33E-C035-4A44-AE11-6C2CFB029C0B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CodeStatisticsCore</RootNamespace>
<AssemblyName>Core</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Collections\AnonymousDictionary.cs" />
<Compile Include="Collections\BiDictionary.cs" />
<Compile Include="Collections\CharacterRangeSet.cs" />
<Compile Include="Collections\CounterDictionary.cs" />
<Compile Include="Collections\EnumDictionary.cs" />
<Compile Include="Collections\TopElementList.cs" />
<Compile Include="Forms\FormUtils.cs" />
<Compile Include="Handling\Files\AbstractFileHandler.cs" />
<Compile Include="Handling\Files\AbstractLanguageFileHandler.cs" />
<Compile Include="Handling\IFileHandler.cs" />
<Compile Include="Handling\IFolderHandler.cs" />
<Compile Include="Handling\Utils\CodeParser.cs" />
<Compile Include="Handling\Utils\FileIntValue.cs" />
<Compile Include="Handling\Utils\ParseUtils.cs" />
<Compile Include="Handling\Utils\StringUtils.cs" />
<Compile Include="Handling\Utils\VariableUtils.cs" />
<Compile Include="Handling\Variables.cs" />
<Compile Include="Input\File.cs" />
<Compile Include="Input\IOEntry.cs" />
<Compile Include="Input\IOUtils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.ComponentModel;
namespace CodeStatistics.Collections{
static class AnonymousDictionary{
namespace CodeStatisticsCore.Collections{
public static class AnonymousDictionary{
public delegate string ToStringFunction(object obj);
public static Dictionary<string,TValue> Create<TValue>(object obj){

View File

@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;
namespace CodeStatistics.Collections{
namespace CodeStatisticsCore.Collections{
public class BiDictionary<TKey,TValue> : IEnumerable<KeyValuePair<TKey,TValue>>{
private readonly Dictionary<TKey,TValue> kv;
private readonly Dictionary<TValue,TKey> vk;

View File

@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;
namespace CodeStatistics.Collections{
namespace CodeStatisticsCore.Collections{
public class CharacterRangeSet : IEnumerable<KeyValuePair<int,int>>{
private readonly List<KeyValuePair<int,int>> innerList = new List<KeyValuePair<int,int>>();

View File

@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Linq;
namespace CodeStatistics.Collections{
class CounterDictionary<TKey> : IEnumerable<KeyValuePair<TKey,int>>{
namespace CodeStatisticsCore.Collections{
public class CounterDictionary<TKey> : IEnumerable<KeyValuePair<TKey,int>>{
private readonly Dictionary<TKey,int> innerDict;
public int Count { get { return innerDict.Count; } }

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace CodeStatistics.Collections{
namespace CodeStatisticsCore.Collections{
public static class EnumDictionary{
/// <summary>
/// Creates a Dictionary&lt;Enum,TValue&gt; and prefills it with <paramref name="initializeTo"/> assigned to each element of the Enum.

View File

@ -2,8 +2,8 @@
using System.Collections;
using System.Collections.Generic;
namespace CodeStatistics.Collections {
class TopElementList<T> : IList<T>{
namespace CodeStatisticsCore.Collections {
public class TopElementList<T> : IList<T>{
private readonly List<T> internalList;
private readonly Comparison<T> sorter;
private readonly int maxSize;

View File

@ -1,7 +1,7 @@
using System;
using System.Windows.Forms;
namespace CodeStatistics.Forms{
namespace CodeStatisticsCore.Forms{
public static class FormUtils{
public static void InvokeOnUIThread(this Form form, Action func){
if (form.InvokeRequired)form.Invoke(func);

View File

@ -1,7 +1,7 @@
using CodeStatistics.Input;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Handling.General{
abstract class AbstractFileHandler : IFileHandler{
namespace CodeStatisticsCore.Handling.Files{
public abstract class AbstractFileHandler : IFileHandler{
public abstract int Weight { get; }
public virtual void SetupProject(Variables.Root variables){}

View File

@ -2,13 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using CodeStatistics.Collections;
using CodeStatistics.Handling.General;
using CodeStatistics.Handling.Utils;
using CodeStatistics.Input;
using CodeStatisticsCore.Collections;
using CodeStatisticsCore.Handling.Utils;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Handling.Languages{
abstract class AbstractLanguageFileHandler : AbstractFileHandler{
namespace CodeStatisticsCore.Handling.Files{
public abstract class AbstractLanguageFileHandler : AbstractFileHandler{
protected abstract string Key { get; }
private readonly object stateOwner = new object();

View File

@ -1,7 +1,9 @@
using CodeStatistics.Input;
using CodeStatisticsCore.Input;
namespace CodeStatisticsCore.Handling{
public interface IFileHandler{
int Weight { get; }
namespace CodeStatistics.Handling{
interface IFileHandler : HandlerList.IWeightedEntry{
void SetupProject(Variables.Root variables);
void Process(File file, Variables.Root variables);
void FinalizeProject(Variables.Root variables);

View File

@ -0,0 +1,7 @@
namespace CodeStatisticsCore.Handling{
public interface IFolderHandler{
int Weight { get; }
void Process(string folder, Variables.Root variables);
}
}

View File

@ -1,6 +1,6 @@
using System;
namespace CodeStatistics.Handling.Utils{
namespace CodeStatisticsCore.Handling.Utils{
public class CodeParser{
protected readonly string code;
protected readonly int length;

View File

@ -1,8 +1,8 @@
using System;
using CodeStatistics.Input;
using CodeStatisticsCore.Input;
namespace CodeStatistics.Handling.Utils{
struct FileIntValue{
namespace CodeStatisticsCore.Handling.Utils{
public struct FileIntValue{
public static readonly Comparison<FileIntValue> SortMax = (x, y) => y.Value-x.Value;
public static readonly Comparison<FileIntValue> SortMin = (x, y) => x.Value-y.Value;

View File

@ -1,14 +1,13 @@
using CodeStatistics.Data;
using System;
using System;
using System.Linq;
namespace CodeStatistics.Handling.Utils{
namespace CodeStatisticsCore.Handling.Utils{
public static class ParseUtils{
/// <summary>
/// Returns the amount of characters in a string after converting leading spaces to tabs. Amount of spaces per tab has to be equal to or larger than 1.
/// </summary>
public static int CountCharacters(string line, int spacesPerTab = 4){
if (spacesPerTab < 1)throw new ArgumentException(Lang.Get["ErrorArgumentEqualLargerOne"],"spacesPerTab");
if (spacesPerTab < 1)throw new ArgumentException("Argument must be equal to or larger than 1.","spacesPerTab");
int spaces = line.Length-line.SkipWhile(chr => chr == ' ').Count();
return line.Length-spaces*(spacesPerTab-1)/spacesPerTab;

View File

@ -1,4 +1,4 @@
namespace CodeStatistics.Handling.Utils{
namespace CodeStatisticsCore.Handling.Utils{
public static class StringUtils{
/// <summary>
/// Capitalizes the first character of a string and leaves the rest intact.

View File

@ -1,7 +1,7 @@
using System;
namespace CodeStatistics.Handling.Utils{
static class VariableUtils{
namespace CodeStatisticsCore.Handling.Utils{
public static class VariableUtils{
public static void Average(this Variables.Root variables, string targetName, string totalValueName, string unitValueName, int roundingThreshold = 10){
float avg = (float)variables.GetVariable(totalValueName,0)/Math.Max(1,variables.GetVariable(unitValueName,1));
variables.SetVariable(targetName,avg >= roundingThreshold ? (int)Math.Round(avg) : avg);

View File

@ -1,11 +1,11 @@
using CodeStatistics.Collections;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using CodeStatisticsCore.Collections;
namespace CodeStatistics.Handling{
abstract class Variables{
namespace CodeStatisticsCore.Handling{
public abstract class Variables{
private static readonly NumberFormatInfo NumberFormat = new NumberFormatInfo{
NumberGroupSeparator = " ",
NumberDecimalSeparator = ".",

View File

@ -2,7 +2,7 @@
using System.IO;
using System.Text;
namespace CodeStatistics.Input{
namespace CodeStatisticsCore.Input{
public struct File{
public readonly string FullPath;
public readonly string Ext;

View File

@ -1,4 +1,4 @@
namespace CodeStatistics.Input{
namespace CodeStatisticsCore.Input{
public struct IOEntry{
public enum Type{
File, Folder

View File

@ -2,12 +2,11 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CodeStatistics.Data;
using FileIO = System.IO.File;
namespace CodeStatistics.Input{
namespace CodeStatisticsCore.Input{
public static class IOUtils{
private readonly static string[] FileSizeSuffixes = { "B", "kB", "MB", "GB", "TB", "PB", "EB" };
private static readonly string[] FileSizeSuffixes = { "B", "kB", "MB", "GB", "TB", "PB", "EB" };
/// <summary>
/// Finds the longest common path in an array. Does not include the trailing path separator, except when only the drive letter is returned. <para/>
@ -16,7 +15,7 @@ namespace CodeStatistics.Input{
/// For example, <code>FindRootPath({ "C:\Projects\One", "C:\Projects\Two" })</code> returns C:\Projects
/// </summary>
public static string FindRootPath(string[] paths){
if (paths.Length == 0)throw new ArgumentException(Lang.Get["ErrorArgumentArrayAtLeastOne"],"paths");
if (paths.Length == 0)throw new ArgumentException("Array must contain at least one element.","paths");
if (paths.Length == 1)return paths[0];
List<string[]> split = paths.Select(path => path.Split(new []{ Path.DirectorySeparatorChar },StringSplitOptions.RemoveEmptyEntries)).ToList();

View File

@ -0,0 +1,38 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Code Statistics Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Code Statistics Core")]
[assembly: AssemblyCopyright("chylex")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b1eb504e-19f3-4b3d-be85-ab8722886967")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: CLSCompliant(true)]

View File

@ -1,4 +1,4 @@
using CodeStatistics.Handling.Utils;
using CodeStatisticsCore.Handling.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CodeStatisticsTests{

View File

@ -75,6 +75,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodeStatisticsCore\CodeStatisticsCore.csproj">
<Project>{6e9bf33e-c035-4a44-ae11-6c2cfb029c0b}</Project>
<Name>CodeStatisticsCore</Name>
</ProjectReference>
<ProjectReference Include="..\CodeStatistics\CodeStatistics.csproj">
<Project>{b1bc156c-aaa8-40eb-b90b-aee950870d62}</Project>
<Name>CodeStatistics</Name>

View File

@ -1,4 +1,4 @@
using CodeStatistics.Collections;
using CodeStatisticsCore.Collections;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CodeStatisticsTests{

View File

@ -1,4 +1,4 @@
using CodeStatistics.Input;
using CodeStatisticsCore.Input;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CodeStatisticsTests{

View File

@ -1,4 +1,4 @@
using CodeStatistics.Handling.Utils;
using CodeStatisticsCore.Handling.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CodeStatisticsTests{

View File

@ -1,4 +1,4 @@
using CodeStatistics.Handling.Utils;
using CodeStatisticsCore.Handling.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CodeStatisticsTests{