-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
107 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System; | ||
|
||
namespace AssetManagementBase | ||
{ | ||
internal class AssetManagerCore | ||
{ | ||
private readonly AssetOpener _assetOpener; | ||
|
||
public Dictionary<string, object> Cache { get; } = new Dictionary<string, object>(); | ||
|
||
public AssetManagerCore(AssetOpener assetOpener) | ||
{ | ||
_assetOpener = assetOpener ?? throw new ArgumentNullException(nameof(assetOpener)); | ||
} | ||
|
||
public Stream OpenAssetStream(string assetName) => _assetOpener(assetName); | ||
|
||
/// <summary> | ||
/// Reads asset stream as string | ||
/// </summary> | ||
/// <returns></returns> | ||
public string ReadAssetAsString(string assetName) | ||
{ | ||
string result; | ||
|
||
using (var stream = OpenAssetStream(assetName)) | ||
using (var textReader = new StreamReader(stream)) | ||
{ | ||
result = textReader.ReadToEnd(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
/// <summary> | ||
/// Reads asset stream as byte array | ||
/// </summary> | ||
/// <returns></returns> | ||
public byte[] ReadAssetAsByteArray(string assetName) | ||
{ | ||
using (var stream = OpenAssetStream(assetName)) | ||
using (var ms = new MemoryStream()) | ||
{ | ||
stream.CopyTo(ms); | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Test |