@@ -64,8 +64,9 @@ public static bool Is64BitProcess()
6464 /// <summary>
6565 /// Gets a content of the embedded resource as string
6666 /// </summary>
67- /// <param name="resourceName">Resource name</param>
68- /// <param name="type">Type from assembly that containing an embedded resource</param>
67+ /// <param name="resourceName">The case-sensitive resource name without the namespace of the specified type</param>
68+ /// <param name="type">The type, that determines the assembly and whose namespace is used to scope
69+ /// the resource name</param>
6970 /// <returns>Сontent of the embedded resource as string</returns>
7071 public static string GetResourceAsString ( string resourceName , Type type )
7172 {
@@ -89,26 +90,16 @@ public static string GetResourceAsString(string resourceName, Type type)
8990
9091 Assembly assembly = type . GetTypeInfo ( ) . Assembly ;
9192 string nameSpace = type . Namespace ;
93+ string resourceFullName = nameSpace != null ? nameSpace + "." + resourceName : resourceName ;
9294
93- if ( nameSpace != null && resourceName . StartsWith ( nameSpace , StringComparison . Ordinal ) )
94- {
95- using ( Stream stream = assembly . GetManifestResourceStream ( resourceName ) )
96- {
97- return ReadResourceAsString ( resourceName , stream ) ;
98- }
99- }
100-
101- using ( Stream stream = assembly . GetManifestResourceStream ( type , resourceName ) )
102- {
103- return ReadResourceAsString ( resourceName , stream ) ;
104- }
95+ return InnerGetResourceAsString ( resourceFullName , assembly ) ;
10596 }
10697
10798 /// <summary>
10899 /// Gets a content of the embedded resource as string
109100 /// </summary>
110- /// <param name="resourceName">Resource name</param>
111- /// <param name="assembly">Assembly that containing an embedded resource</param>
101+ /// <param name="resourceName">The case-sensitive resource name</param>
102+ /// <param name="assembly">The assembly, which contains the embedded resource</param>
112103 /// <returns>Сontent of the embedded resource as string</returns>
113104 public static string GetResourceAsString ( string resourceName , Assembly assembly )
114105 {
@@ -130,23 +121,23 @@ public static string GetResourceAsString(string resourceName, Assembly assembly)
130121 string . Format ( Strings . Common_ArgumentIsEmpty , "resourceName" ) , "resourceName" ) ;
131122 }
132123
133- using ( Stream stream = assembly . GetManifestResourceStream ( resourceName ) )
134- {
135- return ReadResourceAsString ( resourceName , stream ) ;
136- }
124+ return InnerGetResourceAsString ( resourceName , assembly ) ;
137125 }
138126
139- private static string ReadResourceAsString ( string resourceName , Stream stream )
127+ private static string InnerGetResourceAsString ( string resourceName , Assembly assembly )
140128 {
141- if ( stream == null )
129+ using ( Stream stream = assembly . GetManifestResourceStream ( resourceName ) )
142130 {
143- throw new NullReferenceException (
144- string . Format ( Strings . Resources_ResourceIsNull , resourceName ) ) ;
145- }
131+ if ( stream == null )
132+ {
133+ throw new NullReferenceException (
134+ string . Format ( Strings . Resources_ResourceIsNull , resourceName ) ) ;
135+ }
146136
147- using ( var reader = new StreamReader ( stream ) )
148- {
149- return reader . ReadToEnd ( ) ;
137+ using ( var reader = new StreamReader ( stream ) )
138+ {
139+ return reader . ReadToEnd ( ) ;
140+ }
150141 }
151142 }
152143
0 commit comments