Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractContentManager - Cleanup #156

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions Content/AbstractContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ public AbstractContentManager AddGroup(ContentGroupConfigVO configVO)
/// <exception cref="ArgumentException">Occurs when the passed in ID is not found. <see cref="HasGroup"/> to check beforehand.</exception>
public AbstractContentManager RemoveGroup(string contentGroupID)
{
if (!m_ContentGroups.ContainsKey(contentGroupID))
if (!m_ContentGroups.TryGetValue(contentGroupID, out AbstractContentGroup contentGroup))
{
throw new ArgumentException($"Tried to remove Content Group with ID {contentGroupID} but none exists!");
}

AbstractContentGroup contentGroup = m_ContentGroups[contentGroupID];
m_ContentGroups.Remove(contentGroupID);
contentGroup.Dispose();

Expand All @@ -120,12 +119,12 @@ public AbstractContentManager RemoveGroup(string contentGroupID)
/// <exception cref="ArgumentException">Occurs when the passed in ID is not found. <see cref="HasGroup"/> to check beforehand.</exception>
public AbstractContentGroup GetGroup(string contentGroupID)
{
if (!m_ContentGroups.ContainsKey(contentGroupID))
if (!m_ContentGroups.TryGetValue(contentGroupID, out AbstractContentGroup group))
{
throw new ArgumentException($"Tried to get Content Group with ID {contentGroupID} but none exists!");
}

return m_ContentGroups[contentGroupID];
return group;
}

/// <summary>
Expand All @@ -148,12 +147,11 @@ public void Show(AbstractContentController contentController)
{
string contentGroupID = contentController.ContentGroupID;

if (!m_ContentGroups.ContainsKey(contentGroupID))
if (!m_ContentGroups.TryGetValue(contentGroupID, out AbstractContentGroup contentGroup))
{
throw new ArgumentException($"ContentGroupID of {contentGroupID} does not exist in the Content Manager. Did you add the Content Group?");
}

AbstractContentGroup contentGroup = m_ContentGroups[contentGroupID];
contentGroup.Show(contentController);
}

Expand All @@ -164,13 +162,12 @@ public void Show(AbstractContentController contentController)
/// <returns>true if found and cleared, false if not found. A warning will be logged</returns>
public bool ClearGroup(string contentGroupID)
{
if (!m_ContentGroups.ContainsKey(contentGroupID))
if (!m_ContentGroups.TryGetValue(contentGroupID, out AbstractContentGroup contentGroup))
{
Logger.Warning($"ContentGroupID of {contentGroupID} does not exist in the Content Manager. Did you add the Content Group?");
return false;
}

AbstractContentGroup contentGroup = m_ContentGroups[contentGroupID];
contentGroup.Clear();

return true;
Expand Down
Loading