Changeset 3

Show
Ignore:
Timestamp:
10/26/08 15:59:45 (4 weeks ago)
Author:
Jeremy
Message:

Added tag model

Location:
trunk
Files:
8 added
14 modified
10 moved

Legend:

Unmodified
Added
Removed
  • trunk/AddInViews/AudioModel.AddInViews/AudioInvalidException.cs

    r2 r3  
    2424{ 
    2525    [Serializable] 
    26     public class InvalidAudioException : Exception 
     26    public class AudioInvalidException : Exception 
    2727    { 
    28         public InvalidAudioException() 
     28        public AudioInvalidException() 
    2929            : base() 
    3030        { 
    3131        } 
    3232 
    33         public InvalidAudioException(string message) 
     33        public AudioInvalidException(string message) 
    3434            : base(message) 
    3535        { 
    3636        } 
    3737 
    38         public InvalidAudioException(string message, Exception innerException) 
     38        public AudioInvalidException(string message, Exception innerException) 
    3939            : base(message, innerException) 
    4040        { 
    4141        } 
    4242 
    43         protected InvalidAudioException(SerializationInfo info, StreamingContext context) 
     43        protected AudioInvalidException(SerializationInfo info, StreamingContext context) 
    4444            : base(info, context) 
    4545        { 
  • trunk/AddInViews/AudioModel.AddInViews/AudioModel.AddInViews.csproj

    r2 r3  
    5656    <Compile Include="IAudioFormat.cs" /> 
    5757    <Compile Include="IAudio.cs" /> 
    58     <Compile Include="InvalidAudioException.cs" /> 
     58    <Compile Include="AudioInvalidException.cs" /> 
    5959    <Compile Include="Properties\AssemblyInfo.cs" /> 
    60     <Compile Include="UnsupportedAudioException.cs" /> 
     60    <Compile Include="AudioUnsupportedException.cs" /> 
    6161  </ItemGroup> 
    6262  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 
  • trunk/AddInViews/AudioModel.AddInViews/AudioUnsupportedException.cs

    r2 r3  
    2424{ 
    2525    [Serializable] 
    26     public class UnsupportedAudioException : Exception 
     26    public class AudioUnsupportedException : Exception 
    2727    { 
    28         public UnsupportedAudioException() 
     28        public AudioUnsupportedException() 
    2929            : base() 
    3030        { 
    3131        } 
    3232 
    33         public UnsupportedAudioException(string message) 
     33        public AudioUnsupportedException(string message) 
    3434            : base(message) 
    3535        { 
    3636        } 
    3737 
    38         public UnsupportedAudioException(string message, Exception innerException) 
     38        public AudioUnsupportedException(string message, Exception innerException) 
    3939            : base(message, innerException) 
    4040        { 
    4141        } 
    4242 
    43         protected UnsupportedAudioException(SerializationInfo info, StreamingContext context) 
     43        protected AudioUnsupportedException(SerializationInfo info, StreamingContext context) 
    4444            : base(info, context) 
    4545        { 
  • trunk/AddIns/WaveAudio/WaveAudio.cs

    r2 r3  
    4949                    break; 
    5050                default: 
    51                     throw new UnsupportedAudioException("The Wave format '0x" + waveFormatEx.FormatTag.ToString("X", CultureInfo.CurrentCulture) + "' is not supported."); 
     51                    throw new AudioUnsupportedException("The Wave format '0x" + waveFormatEx.FormatTag.ToString("X", CultureInfo.CurrentCulture) + "' is not supported."); 
    5252            } 
    5353 
     
    5555                channels = waveFormatEx.Channels; 
    5656            else 
    57                 throw new UnsupportedAudioException(waveFormatEx.Channels + "-channel Wave files are not supported."); 
     57                throw new AudioUnsupportedException(waveFormatEx.Channels + "-channel Wave files are not supported."); 
    5858 
    5959            bitrate = (int)(waveFormatEx.AvgBytesPerSec * 8); 
  • trunk/AddIns/WaveAudio/WaveReader.cs

    r2 r3  
    3636            { 
    3737                if (new string(reader.ReadChars(4)) != "RIFF") 
    38                     throw new InvalidAudioException("The file '" + fileName + "' does not contain a RIFF header."); 
     38                    throw new AudioInvalidException("The file '" + fileName + "' does not contain a RIFF header."); 
    3939 
    4040                reader.BaseStream.Seek(4, SeekOrigin.Current); 
    4141 
    4242                if (new string(reader.ReadChars(4)) != "WAVE") 
    43                     throw new InvalidAudioException("The file '" + fileName + "' is not a Wave file."); 
     43                    throw new AudioInvalidException("The file '" + fileName + "' is not a Wave file."); 
    4444            } 
    4545            catch (EndOfStreamException e) 
    4646            { 
    47                 throw new InvalidAudioException("The file '" + fileName + "' is missing data.", e); 
     47                throw new AudioInvalidException("The file '" + fileName + "' is missing data.", e); 
    4848            } 
    4949        } 
  • trunk/AudioModel/AudioInvalidException.cs

    r2 r3  
    2424{ 
    2525    [Serializable] 
    26     public class InvalidAudioException : Exception 
     26    public class AudioInvalidException : Exception 
    2727    { 
    28         public InvalidAudioException() 
     28        public AudioInvalidException() 
    2929            : base() 
    3030        { 
    3131        } 
    3232 
    33         public InvalidAudioException(string message) 
     33        public AudioInvalidException(string message) 
    3434            : base(message) 
    3535        { 
    3636        } 
    3737 
    38         public InvalidAudioException(string message, Exception innerException) 
     38        public AudioInvalidException(string message, Exception innerException) 
    3939            : base(message, innerException) 
    4040        { 
    4141        } 
    4242 
    43         protected InvalidAudioException(SerializationInfo info, StreamingContext context) 
     43        protected AudioInvalidException(SerializationInfo info, StreamingContext context) 
    4444            : base(info, context) 
    4545        { 
  • trunk/AudioModel/AudioModel.csproj

    r2 r3  
    5454    <Compile Include="IAudioFormat.cs" /> 
    5555    <Compile Include="IAudio.cs" /> 
    56     <Compile Include="InvalidAudioException.cs" /> 
     56    <Compile Include="AudioInvalidException.cs" /> 
    5757    <Compile Include="Properties\AssemblyInfo.cs" /> 
    58     <Compile Include="UnsupportedAudioException.cs" /> 
     58    <Compile Include="AudioUnsupportedException.cs" /> 
    5959  </ItemGroup> 
    6060  <ItemGroup> 
  • trunk/AudioModel/AudioUnsupportedException.cs

    r2 r3  
    2424{ 
    2525    [Serializable] 
    26     public class UnsupportedAudioException : Exception 
     26    public class AudioUnsupportedException : Exception 
    2727    { 
    28         public UnsupportedAudioException() 
     28        public AudioUnsupportedException() 
    2929            : base() 
    3030        { 
    3131        } 
    3232 
    33         public UnsupportedAudioException(string message) 
     33        public AudioUnsupportedException(string message) 
    3434            : base(message) 
    3535        { 
    3636        } 
    3737 
    38         public UnsupportedAudioException(string message, Exception innerException) 
     38        public AudioUnsupportedException(string message, Exception innerException) 
    3939            : base(message, innerException) 
    4040        { 
    4141        } 
    4242 
    43         protected UnsupportedAudioException(SerializationInfo info, StreamingContext context) 
     43        protected AudioUnsupportedException(SerializationInfo info, StreamingContext context) 
    4444            : base(info, context) 
    4545        { 
  • trunk/AudioModel/CompositeAudioFormat.cs

    r2 r3  
    3737                List<string> result = new List<string>(); 
    3838 
    39                 foreach (IAudioFormat container in manager.AddIns) 
    40                     foreach (string extension in container.Extensions) 
     39                foreach (IAudioFormat format in manager.AddIns) 
     40                    foreach (string extension in format.Extensions) 
    4141                        if (!result.Contains(extension)) 
    4242                            result.Add(extension); 
     
    5050            string fileExtension = Path.GetExtension(fileName).ToUpperInvariant(); 
    5151 
    52             UnsupportedAudioException priorException = null; 
     52            AudioUnsupportedException priorException = null; 
    5353 
    54             foreach (IAudioFormat container in manager.AddIns) 
    55                 if (container.Extensions.Contains(fileExtension)) 
     54            foreach (IAudioFormat format in manager.AddIns) 
     55                if (format.Extensions.Contains(fileExtension)) 
    5656                { 
    5757                    try 
    5858                    { 
    59                         return container.GetAudio(fileName); 
     59                        return format.GetAudio(fileName); 
    6060                    } 
    61                     catch (UnsupportedAudioException e) 
     61                    catch (AudioUnsupportedException e) 
    6262                    { 
    6363                        priorException = e; 
     
    6969                throw priorException; 
    7070            else 
    71                 throw new UnsupportedAudioException("The file '" + fileName + "' is not in a supported audio format."); 
     71                throw new AudioUnsupportedException("The file '" + fileName + "' is not in a supported audio format."); 
    7272        } 
    7373 
  • trunk/DataModel.UnitTests/AddTrackTests.cs

    r2 r3  
    9292 
    9393        [TestMethod] 
    94         [DataSource("SupportedFiles")] 
    95         public void AddTracksForSupportedFiles() 
     94        [DataSource("AudioSupportedFiles")] 
     95        public void AddTracksForFilesWithSupportedAudio() 
    9696        { 
    9797            string fileName = testContextInstance.DataRow["FileName"].ToString(); 
     
    102102            TimeSpan length = new TimeSpan(0, 0, Convert.ToInt32(testContextInstance.DataRow["Length"])); 
    103103 
     104            // Execute the command. 
    104105            AddTrackCommand command = new AddTrackCommand(fileName); 
    105106            command.Execute(); 
     107            Track track = TrackCollection.Instance[fileName]; 
    106108 
    107             Track track = TrackCollection.Instance[fileName]; 
     109            // Compare. 
    108110            Assert.IsNotNull(track, "The file '" + fileName + "' was not found in the track collection."); 
    109             Assert.IsNotNull(track.AudioInfo, "The file '" + fileName + "' has a null AudioInfo property."); 
    110             Assert.AreEqual<string>(format, track.AudioInfo.Format); 
    111             Assert.AreEqual<int>(channels, track.AudioInfo.Channels); 
    112             Assert.AreEqual<int>(bitRate, track.AudioInfo.Bitrate); 
    113             Assert.AreEqual<int>(sampleRate, track.AudioInfo.SampleRate); 
    114             Assert.AreEqual<TimeSpan>(length, track.AudioInfo.Length); 
     111            Assert.IsNotNull(track.Audio, "The file '" + fileName + "' has a null AudioInfo property."); 
     112            Assert.AreEqual<string>(format, track.Audio.Format); 
     113            Assert.AreEqual<int>(channels, track.Audio.Channels); 
     114            Assert.AreEqual<int>(bitRate, track.Audio.Bitrate); 
     115            Assert.AreEqual<int>(sampleRate, track.Audio.SampleRate); 
     116            Assert.AreEqual<TimeSpan>(length, track.Audio.Length); 
    115117        } 
    116118 
    117119        [TestMethod] 
    118         [DataSource("UnsupportedFiles")] 
    119         [ExpectedException(typeof(UnsupportedAudioException))] 
    120         public void AddTracksForUnsupportedFiles() 
     120        [DataSource("AudioUnsupportedFiles")] 
     121        [ExpectedException(typeof(AudioUnsupportedException))] 
     122        public void AddTracksForFilesWithUnsupportedAudio() 
    121123        { 
    122124            string fileName = testContextInstance.DataRow["FileName"].ToString(); 
     
    126128 
    127129        [TestMethod] 
    128         [DataSource("InvalidFiles")] 
    129         [ExpectedException(typeof(InvalidAudioException))] 
    130         public void AddTracksForInvalidFiles() 
     130        [DataSource("AudioInvalidFiles")] 
     131        [ExpectedException(typeof(AudioInvalidException))] 
     132        public void AddTracksForFilesWithInvalidAudio() 
    131133        { 
    132134            string fileName = testContextInstance.DataRow["FileName"].ToString(); 
     
    134136            command.Execute(); 
    135137        } 
     138 
     139        [TestMethod] 
     140        [DataSource("TagSupportedFiles")] 
     141        public void AddTracksForFilesWithSupportedTags() 
     142        { 
     143            string fileName = testContextInstance.DataRow["FileName"].ToString(); 
     144            string trackNumber = testContextInstance.DataRow["TrackNumber"].ToString(); 
     145 
     146            AddTrackCommand command = new AddTrackCommand(fileName); 
     147            command.Execute(); 
     148 
     149            Track track = TrackCollection.Instance[fileName]; 
     150            Assert.IsNotNull(track.Tag, "The file '" + fileName + "' has a null Tag property."); 
     151            Assert.AreEqual<int>(Convert.ToInt32(trackNumber), (int)track.Tag["TrackNumber"]); 
     152        } 
    136153    } 
    137154} 
  • trunk/DataModel.UnitTests/App.config

    r2 r3  
    1010  <microsoft.visualstudio.testtools> 
    1111    <dataSources> 
    12       <add name="SupportedFiles" connectionString="FileListConnection" dataTableName="Supported$" dataAccessMethod="Sequential"/> 
    13       <add name="UnsupportedFiles" connectionString="FileListConnection" dataTableName="Unsupported$" dataAccessMethod="Sequential"/> 
    14       <add name="InvalidFiles" connectionString="FileListConnection" dataTableName="Invalid$" dataAccessMethod="Sequential"/> 
     12      <add name="AudioSupportedFiles" connectionString="FileListConnection" dataTableName="AudioSupported$" dataAccessMethod="Sequential"/> 
     13      <add name="AudioUnsupportedFiles" connectionString="FileListConnection" dataTableName="AudioUnsupported$" dataAccessMethod="Sequential"/> 
     14      <add name="AudioInvalidFiles" connectionString="FileListConnection" dataTableName="AudioInvalid$" dataAccessMethod="Sequential"/> 
     15      <add name="TagSupportedFiles" connectionString="FileListConnection" dataTableName="TagSupported$" dataAccessMethod="Sequential"/> 
    1516    </dataSources> 
    1617  </microsoft.visualstudio.testtools> 
  • trunk/DataModel.UnitTests/DataModel.UnitTests.csproj

    r2 r3  
    5353      <Project>{08D4BF3C-24E5-4D2D-BE7C-5C09F3DA7D88}</Project> 
    5454      <Name>AddInModel</Name> 
     55      <Private>False</Private> 
    5556    </ProjectReference> 
    5657    <ProjectReference Include="..\AudioModel\AudioModel.csproj"> 
    5758      <Project>{1EFE00B7-0B55-4A02-9C7B-78C8049016F9}</Project> 
    5859      <Name>AudioModel</Name> 
     60      <Private>False</Private> 
    5961    </ProjectReference> 
    6062    <ProjectReference Include="..\DataModel\DataModel.csproj"> 
    6163      <Project>{DDE1CDD5-8D83-4A63-A6E3-DD0863C0FE70}</Project> 
    6264      <Name>DataModel</Name> 
     65      <Private>False</Private> 
     66    </ProjectReference> 
     67    <ProjectReference Include="..\TagModel\TagModel.csproj"> 
     68      <Project>{06D79C17-FC18-4F59-A115-6B1E01E5E32A}</Project> 
     69      <Name>TagModel</Name> 
     70      <Private>False</Private> 
    6371    </ProjectReference> 
    6472  </ItemGroup> 
  • trunk/DataModel/DataModel.csproj

    r2 r3  
    6464      <Private>False</Private> 
    6565    </ProjectReference> 
     66    <ProjectReference Include="..\TagModel\TagModel.csproj"> 
     67      <Project>{06D79C17-FC18-4F59-A115-6B1E01E5E32A}</Project> 
     68      <Name>TagModel</Name> 
     69      <Private>False</Private> 
     70    </ProjectReference> 
    6671  </ItemGroup> 
    6772  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 
  • trunk/DataModel/Track.cs

    r2 r3  
    1919 
    2020using OmniEncoder.AudioModel; 
     21using OmniEncoder.TagModel; 
    2122 
    2223namespace OmniEncoder.DataModel 
     
    2526    { 
    2627        readonly string fileName; 
    27         readonly IAudio audioInfo; 
     28        readonly IAudio audio; 
     29        readonly ITag tag; 
    2830 
    29         internal Track(string fileName, IAudio audioInfo) 
     31        internal Track(string fileName, IAudio audio, ITag tag) 
    3032        { 
    3133            this.fileName = fileName; 
    32             this.audioInfo = audioInfo; 
     34            this.audio = audio; 
     35            this.tag = tag; 
    3336        } 
    3437 
     
    3841        } 
    3942 
    40         public IAudio AudioInfo 
     43        public IAudio Audio 
    4144        { 
    42             get { return audioInfo; } 
     45            get { return audio; } 
     46        } 
     47 
     48        public ITag Tag 
     49        { 
     50            get { return tag; } 
    4351        } 
    4452    } 
  • trunk/DataModel/TrackFactory.cs

    r2 r3  
    1919 
    2020using OmniEncoder.AudioModel; 
     21using OmniEncoder.TagModel; 
    2122 
    2223namespace OmniEncoder.DataModel 
     
    2627        internal static Track MakeTrack(string fileName) 
    2728        { 
    28             IAudio audioInfo = new CompositeAudioFormat().GetAudio(fileName); 
    29             return new Track(fileName, audioInfo); 
     29            IAudio audio = new CompositeAudioFormat().GetAudio(fileName); 
     30            ITag tag = new CompositeTagFormat().GetTag(fileName); 
     31            return new Track(fileName, audio, tag); 
    3032        } 
    3133    } 
  • trunk/HostSideAdapters/AudioModel.HostSideAdapters/AudioFormatContractToViewAdapter.cs

    r2 r3  
    6666                { 
    6767                    // Custom exceptions don't have contracts, so re-throw based on the name. 
    68                     case "OmniEncoder.AudioModel.AddInViews.UnsupportedAudioException": 
    69                         throw new UnsupportedAudioException(e.Message, e); 
    70                     case "OmniEncoder.AudioModel.AddInViews.InvalidAudioException": 
    71                         throw new InvalidAudioException(e.Message, e); 
     68                    case "OmniEncoder.AudioModel.AddInViews.AudioUnsupportedException": 
     69                        throw new AudioUnsupportedException(e.Message, e); 
     70                    case "OmniEncoder.AudioModel.AddInViews.AudioInvalidException": 
     71                        throw new AudioInvalidException(e.Message, e); 
    7272 
    7373                    // All other exceptions indicate add-in failure. 
  • trunk/OmniEncoder.sln

    r2 r3  
    1414Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestFiles", "TestFiles", "{57261C29-B3B2-4FD0-9C0C-F2B41F6634D6}" 
    1515        ProjectSection(SolutionItems) = preProject 
     16                TestFiles\AudioInvalid00.wav = TestFiles\AudioInvalid00.wav 
     17                TestFiles\AudioSupported00.wav = TestFiles\AudioSupported00.wav 
     18                TestFiles\AudioSupported01.wav = TestFiles\AudioSupported01.wav 
     19                TestFiles\AudioSupported02.wav = TestFiles\AudioSupported02.wav 
     20                TestFiles\AudioUnsupported00.txt = TestFiles\AudioUnsupported00.txt 
     21                TestFiles\AudioUnsupported00.wav = TestFiles\AudioUnsupported00.wav 
    1622                TestFiles\FileList.xlsx = TestFiles\FileList.xlsx 
    17                 TestFiles\Invalid00.wav = TestFiles\Invalid00.wav 
    18                 TestFiles\Supported00.wav = TestFiles\Supported00.wav 
    19                 TestFiles\Supported01.wav = TestFiles\Supported01.wav 
    20                 TestFiles\Supported02.wav = TestFiles\Supported02.wav 
    21                 TestFiles\Unsupported00.txt = TestFiles\Unsupported00.txt 
    22                 TestFiles\Unsupported00.wav = TestFiles\Unsupported00.wav 
     23                TestFiles\TagSupported00.wav = TestFiles\TagSupported00.wav 
    2324        EndProjectSection 
    2425EndProject 
     
    4849EndProject 
    4950Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaveAudio", "AddIns\WaveAudio\WaveAudio.csproj", "{60743B1C-8EC7-4278-B940-EEB22EAA961D}" 
     51EndProject 
     52Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagModel", "TagModel\TagModel.csproj", "{06D79C17-FC18-4F59-A115-6B1E01E5E32A}" 
    5053EndProject 
    5154Global 
     
    99102                {60743B1C-8EC7-4278-B940-EEB22EAA961D}.Release|Any CPU.ActiveCfg = Release|Any CPU 
    100103                {60743B1C-8EC7-4278-B940-EEB22EAA961D}.Release|Any CPU.Build.0 = Release|Any CPU 
     104                {06D79C17-FC18-4F59-A115-6B1E01E5E32A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 
     105                {06D79C17-FC18-4F59-A115-6B1E01E5E32A}.Debug|Any CPU.Build.0 = Debug|Any CPU 
     106                {06D79C17-FC18-4F59-A115-6B1E01E5E32A}.Release|Any CPU.ActiveCfg = Release|Any CPU 
     107                {06D79C17-FC18-4F59-A115-6B1E01E5E32A}.Release|Any CPU.Build.0 = Release|Any CPU 
    101108        EndGlobalSection 
    102109        GlobalSection(SolutionProperties) = preSolution 
  • trunk/TestFiles/AudioInvalid00.wav

  • trunk/TestFiles/AudioSupported00.wav

  • trunk/TestFiles/AudioSupported01.wav

  • trunk/TestFiles/AudioSupported02.wav

  • trunk/TestFiles/AudioUnsupported00.txt

  • trunk/TestFiles/AudioUnsupported00.wav