Skip to content

Commit

Permalink
Added start of show aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
danesparza committed Oct 14, 2013
1 parent 054f214 commit 1dda5ce
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ShowInfo.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@

<!-- TheTVDB API information -->
<add key="TheTVDB_APIKey" value=""/>

<add key="AliasFile" value="showalias.json"/>
</appSettings>
</configuration>
19 changes: 19 additions & 0 deletions ShowInfo/ShowAlias.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace ShowInfo
{
[DataContract]
public class ShowAlias
{
[DataMember]
public string Show { get; set; }

[DataMember]
public string Alias { get; set; }
}
}
11 changes: 11 additions & 0 deletions ShowInfo/ShowInfo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<AssemblyName>ShowInfo</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -30,17 +32,22 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ServiceStack.Text">
<HintPath>..\packages\ServiceStack.Text.3.9.66\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ShowAlias.cs" />
<Compile Include="ShowInformation.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand All @@ -50,7 +57,11 @@
<Name>ShowInfoProvider</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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">
Expand Down
41 changes: 41 additions & 0 deletions ShowInfo/ShowInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
Expand Down Expand Up @@ -39,11 +41,50 @@ private void Compose()

#endregion

private string currentPath = string.Empty;

/// <summary>
/// Our list of customizable show 'aliases'
/// </summary>
private List<ShowAlias> showAliases = new List<ShowAlias>();

/// <summary>
/// Loads the aliases from the alias file. This allows us to map
/// one TVshow name to another -- like 'Castle' to 'Castle (2009)'
/// </summary>
private void LoadAliases()
{
// If the show alias file exists, load it up:
currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

try
{
string aliasFile = ConfigurationManager.AppSettings["AliasFile"];
if(string.IsNullOrEmpty(aliasFile))
aliasFile = "showalias.json";

// If the alias file exists, open it:
if(File.Exists(Path.Combine(currentPath, aliasFile)))
{
// TODO: Open the file and laod the aliases

}
}
catch(Exception ex)
{
/* Silently fail */
}
}

/// <summary>
/// Default constructor
/// </summary>
public ShowInformationManager()
{
// Load our aliases
LoadAliases();

// Load our provider plugins
Compose();
}

Expand Down
4 changes: 4 additions & 0 deletions ShowInfo/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="3.9.66" targetFramework="net45" />
</packages>

0 comments on commit 1dda5ce

Please sign in to comment.