Skip to content

Commit

Permalink
ICU4N.Support: Factored out AssemblyExtensions and TypeExtensions in …
Browse files Browse the repository at this point in the history
…favor of J2N's implementation
  • Loading branch information
NightOwl888 committed Feb 7, 2020
1 parent ebbdca6 commit 0e44d1f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 316 deletions.
8 changes: 5 additions & 3 deletions src/ICU4N/Impl/ICUData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using ICU4N.Logging;
using ICU4N.Support;
using ICU4N.Support.Globalization;
using ICU4N.Util;
using J2N;
using System;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -81,13 +83,13 @@ public sealed class ICUData

public static bool Exists(string resourceName)
{
return typeof(ICUData).FindAndGetManifestResourceStream(resourceName) != null;
return typeof(ICUData).FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName)) != null;
}

private static Stream GetStream(Type root, string resourceName, bool required)
{
Stream i;
i = root.FindAndGetManifestResourceStream(resourceName);
i = root.FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName));
if (i == null && required)
{
throw new MissingManifestResourceException("could not locate data " + resourceName +
Expand All @@ -103,7 +105,7 @@ private static Stream GetStream(Type root, string resourceName, bool required)
internal static Stream GetStream(Assembly loader, string resourceName, bool required)
{
Stream i = null;
i = loader.FindAndGetManifestResourceStream(resourceName);
i = loader.FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(resourceName));
if (i == null && required)
{
throw new MissingManifestResourceException("could not locate data " + loader.ToString() + " Resource: " + resourceName);
Expand Down
8 changes: 4 additions & 4 deletions src/ICU4N/Impl/ICUResourceBundle.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ICU4N.Support;
using ICU4N.Support.Collections;
using ICU4N.Support.Collections;
using ICU4N.Support.Globalization;
using ICU4N.Util;
using J2N.Collections;
using J2N;
using J2N.Collections.Generic.Extensions;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -708,7 +708,7 @@ private static void AddLocaleIDsFromListFile(string bn, Assembly root, ISet<stri
{
try
{
using (Stream s = root.FindAndGetManifestResourceStream(bn + FULL_LOCALE_NAMES_LIST))
using (Stream s = root.FindAndGetManifestResourceStream(ResourceUtil.ConvertResourceName(bn + FULL_LOCALE_NAMES_LIST)))
{
if (s != null)
{
Expand Down
268 changes: 0 additions & 268 deletions src/ICU4N/Support/AssemblyExtensions.cs

This file was deleted.

15 changes: 15 additions & 0 deletions src/ICU4N/Support/Globalization/ResourceUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace ICU4N.Support.Globalization
{
internal static class ResourceUtil
{
/// <summary>
/// Change from JDK-style resource path (Impl/Data/icudt60b/brkitr) to .NET style (Impl.Data.brkitr).
/// This method also removes the version number from the path so we don't have to change it internally
/// from one release to the next.
/// </summary>
public static string ConvertResourceName(string name)
{
return name.Replace('/', '.').Replace("." + ICU4N.Impl.ICUData.PackageName, "");
}
}
}
41 changes: 0 additions & 41 deletions src/ICU4N/Support/TypeExtensions.cs

This file was deleted.

0 comments on commit 0e44d1f

Please sign in to comment.