Created
December 26, 2016 01:20
-
-
Save aschuhardt/fd0635fa83e378c071b5cb11c078418f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
internal abstract class AssetBase : IAsset { | |
protected string _fileName; | |
protected string _canonicalName; | |
protected string _filePath; | |
private Guid _id; | |
public AssetType assetType { | |
get { | |
return getAssetType(); | |
} | |
} | |
public string canonicalName { | |
get { | |
return _canonicalName; | |
} | |
} | |
public string fileName { | |
get { | |
return _fileName; | |
} | |
} | |
public string filePath { | |
get { | |
return _filePath; | |
} | |
} | |
public Guid id { | |
get { | |
return _id; | |
} | |
} | |
public AssetBase(string filePath) { | |
if (File.Exists(filePath)) { | |
_filePath = filePath; | |
_fileName = Path.GetFileName(_filePath); | |
_canonicalName = Path.GetFileNameWithoutExtension(_filePath); | |
_id = Guid.NewGuid(); | |
} else { | |
string msg = $"Could not find asset \"{filePath}\""; | |
throw new AssetFileNotFoundException(msg); | |
} | |
} | |
public override int GetHashCode() { | |
return _id.GetHashCode(); | |
} | |
public override bool Equals(object obj) { | |
if (obj is AssetBase) { | |
return ((AssetBase)obj).id.Equals(_id); | |
} else { | |
return false; | |
} | |
} | |
protected abstract AssetType getAssetType(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment