~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/ResourceToolkit/Project/Src/ResourceFileContent/DefaultBclResourceFileContentFactory.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.IO;
 
6
 
 
7
namespace Hornung.ResourceToolkit.ResourceFileContent
 
8
{
 
9
        /// <summary>
 
10
        /// Creates resource file contents for .resources and .resx files.
 
11
        /// </summary>
 
12
        public class DefaultBclResourceFileContentFactory : IResourceFileContentFactory
 
13
        {
 
14
                /// <summary>
 
15
                /// Determines whether this factory can create a resource file content
 
16
                /// for the specified file.
 
17
                /// </summary>
 
18
                /// <param name="fileName">The file name to examine.</param>
 
19
                /// <returns><c>true</c>, if this factory can create a resource file content for the specified file, otherwise <c>false</c>.</returns>
 
20
                public bool CanCreateContentForFile(string fileName)
 
21
                {
 
22
                        string ext = Path.GetExtension(fileName);
 
23
                        
 
24
                        if (ext.Equals(".resources", StringComparison.OrdinalIgnoreCase) ||
 
25
                            ext.Equals(".resx", StringComparison.OrdinalIgnoreCase)) {
 
26
                                return true;
 
27
                        }
 
28
                        
 
29
                        return false;
 
30
                }
 
31
                
 
32
                /// <summary>
 
33
                /// Creates a resource file content for the specified file.
 
34
                /// </summary>
 
35
                /// <param name="fileName">The name of the file to create the resource file content for.</param>
 
36
                /// <returns>A new instance of a class that implements <see cref="IResourceFileContent"/> and represents the content of the specified file, or <c>null</c>, if this class cannot handle the file format.</returns>
 
37
                public IResourceFileContent CreateContentForFile(string fileName)
 
38
                {
 
39
                        string ext = Path.GetExtension(fileName);
 
40
                        
 
41
                        if (ext.Equals(".resources", StringComparison.OrdinalIgnoreCase)) {
 
42
                                return new ResourcesResourceFileContent(fileName);
 
43
                        } else if (ext.Equals(".resx", StringComparison.OrdinalIgnoreCase)) {
 
44
                                return new ResXResourceFileContent(fileName);
 
45
                        }
 
46
                        
 
47
                        return null;
 
48
                }
 
49
                
 
50
                // ********************************************************************************************************************************
 
51
                
 
52
                /// <summary>
 
53
                /// Initializes a new instance of the <see cref="DefaultBclResourceFileContentFactory"/> class.
 
54
                /// </summary>
 
55
                public DefaultBclResourceFileContentFactory()
 
56
                {
 
57
                }
 
58
        }
 
59
}