Commit c0a777d1 authored by Wacton's avatar Wacton

Embedded JMdict now zip compressed

+ small example project
parent 66980b33
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{943713F4-ED72-49B1-ACCE-433FA9E55B8A}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wacton.Desu.Example</RootNamespace>
<AssemblyName>Wacton.Desu.Example</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Desu\Desu.csproj">
<Project>{2d36dfd4-8fe3-4166-846d-4a8efcb0178c}</Project>
<Name>Desu</Name>
</ProjectReference>
</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>
\ No newline at end of file
namespace Wacton.Desu.Example
{
using System;
using System.Diagnostics;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
var dictionary = new JapaneseDictionary();
var entries = dictionary.GetEntries().ToList();
var index = new Random().Next(0, entries.Count);
var entry = entries[index];
Debug.WriteLine(entry);
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
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("Wacton.Desu.Example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Wacton")]
[assembly: AssemblyProduct("Wacton.Desu.Example")]
[assembly: AssemblyCopyright("Copyright © Wacton 2016")]
[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("943713f4-ed72-49b1-acce-433fa9e55b8a")]
// 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")]
......@@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desu", "Desu\Desu.csproj", "{2D36DFD4-8FE3-4166-846D-4A8EFCB0178C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desu.Example", "Desu.Example\Desu.Example.csproj", "{943713F4-ED72-49B1-ACCE-433FA9E55B8A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -15,6 +17,10 @@ Global
{2D36DFD4-8FE3-4166-846D-4A8EFCB0178C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D36DFD4-8FE3-4166-846D-4A8EFCB0178C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D36DFD4-8FE3-4166-846D-4A8EFCB0178C}.Release|Any CPU.Build.0 = Release|Any CPU
{943713F4-ED72-49B1-ACCE-433FA9E55B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{943713F4-ED72-49B1-ACCE-433FA9E55B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{943713F4-ED72-49B1-ACCE-433FA9E55B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943713F4-ED72-49B1-ACCE-433FA9E55B8A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -34,6 +34,10 @@
<DocumentationFile>bin\Release\Wacton.Desu.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ionic.Zip, Version=1.9.8.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.9.8\lib\net20\Ionic.Zip.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -71,14 +75,12 @@
<Compile Include="Language.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\JMdict" />
</ItemGroup>
<ItemGroup>
<Content Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<EmbeddedResource Include="Resources\JMdict.zip" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.1.28.3\build\Fody.targets" Condition="Exists('..\packages\Fody.1.28.3\build\Fody.targets')" />
......
......@@ -18,7 +18,7 @@
public static readonly EntryElement Reading = new EntryElement("Reading", "r_ele", (entry, data) => entry.StartNewReading(), false);
public static readonly EntryElement ReadingText = new EntryElement("ReadingText", "reb", (entry, data) => entry.GetReading().Text = data.Content);
public static readonly EntryElement ReadingNoKanji = new EntryElement("ReadingNoKanji", "re_nokanji", (entry, data) => entry.GetReading().IsTrueKanjiReading = false);
public static readonly EntryElement ReadingRestriction = new EntryElement("ReadingRestriction", "re_restr", (entry, data) => AddContent(entry.GetReading().GetRestricted(), data));
public static readonly EntryElement ReadingRestriction = new EntryElement("ReadingRestriction", "re_restr", (entry, data) => AddContent(entry.GetReading().GetRestriction(), data));
public static readonly EntryElement ReadingInformation = new EntryElement("ReadingInformation", "re_inf", (entry, data) => AddContent(entry.GetReading().GetInformations(), data, ReadingInformations));
public static readonly EntryElement ReadingPriority = new EntryElement("ReadingPriority", "re_pri", (entry, data) => AddContent(entry.GetReading().GetPriorities(), data, Priorities));
......
......@@ -6,7 +6,7 @@
{
string Text { get; }
bool IsTrueKanjiReading { get; }
IEnumerable<string> Restricted { get; }
IEnumerable<string> Restriction { get; }
IEnumerable<ReadingInformation> Informations { get; }
IEnumerable<Priority> Priorities { get; }
}
......
namespace Wacton.Desu
using Ionic.Zip;
namespace Wacton.Desu
{
using System;
using System.Collections.Generic;
......@@ -56,7 +58,8 @@
var assembly = Assembly.GetExecutingAssembly();
var resourceNames = assembly.GetManifestResourceNames();
var resourceName = resourceNames.Single(resource => resource.Contains(DictionaryName));
return assembly.GetManifestResourceStream(resourceName);
var resourceStream = assembly.GetManifestResourceStream(resourceName);
return ZipFile.Read(resourceStream).Single().OpenReader();
}
private static IEnumerable<IJapaneseDictionaryEntry> ParseDictionary(Func<Stream> openStreamFunction)
......
......@@ -33,6 +33,6 @@ using System.Runtime.InteropServices;
// 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.*")]
[assembly: AssemblyVersion("2.0.0.*")]
[assembly: NeutralResourcesLanguage("en-US")]
......@@ -8,9 +8,9 @@
public bool IsTrueKanjiReading { get; set; } = true;
private readonly List<string> restricted = new List<string>();
internal List<string> GetRestricted() => this.restricted;
public IEnumerable<string> Restricted => this.GetRestricted();
private readonly List<string> restriction = new List<string>();
internal List<string> GetRestriction() => this.restriction;
public IEnumerable<string> Restriction => this.GetRestriction();
private readonly List<ReadingInformation> informations = new List<ReadingInformation>();
internal List<ReadingInformation> GetInformations() => this.informations;
......
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net46" developmentDependency="true" />
<package id="DotNetZip" version="1.9.8" targetFramework="net46" />
<package id="Fody" version="1.28.3" targetFramework="net46" developmentDependency="true" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment