Merge pull request #74 from mlavik1/assetstore-fix

Read .dic files from Resources folder instead of StreamingAssets.
This commit is contained in:
Matias Lavik 2021-11-22 20:15:27 +01:00 коммит произвёл GitHub
Родитель e6cc256c69 108383dd56
Коммит 13abae6746
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 50 добавлений и 14 удалений

Просмотреть файл

@ -434,6 +434,25 @@ namespace openDicom.Registry
if (global == null) Global = this;
}
public void LoadFromMemory(MemoryStream memStream, DictionaryFileFormat fileFormat)
{
if (!IsEmpty) Clear();
StreamReader streamReader = new StreamReader(memStream);
switch (fileFormat)
{
case DictionaryFileFormat.BinaryFile:
LoadFromBinary(streamReader); break;
case DictionaryFileFormat.PropertyFile:
LoadFromProperty(streamReader); break;
case DictionaryFileFormat.CsvFile:
LoadFromCsv(streamReader); break;
case DictionaryFileFormat.XmlFile:
LoadFromXml(streamReader); break;
}
streamReader.Close();
if (global == null) Global = this;
}
private void SaveAsBinary(StreamWriter streamWriter,
DataElementDictionaryEntry[] entryArray)
{

Просмотреть файл

@ -308,6 +308,25 @@ namespace openDicom.Registry
if (global == null) Global = this;
}
public void LoadFromMemory(MemoryStream memStream, DictionaryFileFormat fileFormat)
{
if (!IsEmpty) Clear();
StreamReader streamReader = new StreamReader(memStream);
switch (fileFormat)
{
case DictionaryFileFormat.BinaryFile:
LoadFromBinary(streamReader); break;
case DictionaryFileFormat.PropertyFile:
LoadFromProperty(streamReader); break;
case DictionaryFileFormat.CsvFile:
LoadFromCsv(streamReader); break;
case DictionaryFileFormat.XmlFile:
LoadFromXml(streamReader); break;
}
streamReader.Close();
if (global == null) Global = this;
}
private void SaveAsBinary(StreamWriter streamWriter,
UidDictionaryEntry[] entryArray)
{

Просмотреть файл

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 973e06d586332ae47bed697dfab2de3d
DefaultImporter:
guid: 995b791e7a90b494194aa1d02cedc49c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:

Просмотреть файл

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: dbc53a7688d64154eb54ec48178d29dd
DefaultImporter:
guid: 53bd64257ce5dc444ba9bc04d58de1e7
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:

Просмотреть файл

@ -54,8 +54,14 @@ namespace UnityVolumeRendering
UidDictionary uidDictionary = new UidDictionary();
try
{
dataElementDictionary.LoadFrom(Path.Combine(Application.streamingAssetsPath, "dicom-elements-2007.dic"), DictionaryFileFormat.BinaryFile);
uidDictionary.LoadFrom(Path.Combine(Application.streamingAssetsPath, "dicom-uids-2007.dic"), DictionaryFileFormat.BinaryFile);
// Load .dic files from Resources
TextAsset dcmElemAsset = (TextAsset)Resources.Load("dicom-elements-2007.dic");
Debug.Assert(dcmElemAsset != null, "dicom-elements-2007.dic is missing from the Resources folder");
TextAsset dcmUidsAsset = (TextAsset)Resources.Load("dicom-uids-2007.dic");
Debug.Assert(dcmUidsAsset != null, "dicom-uids-2007.dic is missing from the Resources folder");
dataElementDictionary.LoadFromMemory(new MemoryStream(dcmElemAsset.bytes), DictionaryFileFormat.BinaryFile);
uidDictionary.LoadFromMemory(new MemoryStream(dcmUidsAsset.bytes), DictionaryFileFormat.BinaryFile);
}
catch (Exception dictionaryException)
{

Просмотреть файл

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b11b1f848245f974ab893c35ca3aae92
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: