MonoGame.Extended icon indicating copy to clipboard operation
MonoGame.Extended copied to clipboard

Change ExtendedContentManager method accessors

Open Harunx9 opened this issue 10 months ago • 0 comments

Hi. I’m not sure if it would be possible to change the accessor to protected in the following methods of the ExtendedContentManager class.

  private FileStream GetStream(string path)
    {
        if (Path.IsPathRooted(path))
        {
            return File.OpenRead(path);
        }

        return (FileStream)TitleContainer.OpenStream(path);
    }

    private void CacheAsset(string name, object obj)
    {
        LoadedAssets.Add(name, obj);
        if (obj is IDisposable disposable)
        {
            DisposeableAssets.Add(disposable);
        }
    }

    private bool NoExtension(string name) => string.IsNullOrEmpty(Path.GetExtension(name));
    private bool TryGetCachedAsset<T>(string name, out T asset)
    {
        asset = default;

        if (LoadedAssets.TryGetValue(name, out object value))
        {
            if (value is T)
            {
                asset = (T)value;
                return true;
            }
        }

        return false;
    }

This would help in creating derived classes without unnecessary code duplication.

Harunx9 avatar Feb 15 '25 13:02 Harunx9