Implemented rest of profile methods for IPC
This commit is contained in:
23
CustomizePlus/Profiles/Exceptions/ActorNotFoundException.cs
Normal file
23
CustomizePlus/Profiles/Exceptions/ActorNotFoundException.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace CustomizePlus.Profiles.Exceptions;
|
||||
|
||||
internal class ActorNotFoundException : ProfileException
|
||||
{
|
||||
public ActorNotFoundException()
|
||||
{
|
||||
}
|
||||
|
||||
public ActorNotFoundException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ActorNotFoundException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected ActorNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
23
CustomizePlus/Profiles/Exceptions/ProfileException.cs
Normal file
23
CustomizePlus/Profiles/Exceptions/ProfileException.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace CustomizePlus.Profiles.Exceptions;
|
||||
|
||||
internal class ProfileException : Exception
|
||||
{
|
||||
public ProfileException()
|
||||
{
|
||||
}
|
||||
|
||||
public ProfileException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ProfileException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected ProfileException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CustomizePlus.Profiles.Exceptions;
|
||||
internal class ProfileNotFoundException : ProfileException
|
||||
{
|
||||
public ProfileNotFoundException()
|
||||
{
|
||||
}
|
||||
|
||||
public ProfileNotFoundException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ProfileNotFoundException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected ProfileNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ using CustomizePlus.GameData.Services;
|
||||
using CustomizePlus.GameData.Extensions;
|
||||
using CustomizePlus.Profiles.Enums;
|
||||
using Penumbra.GameData.Enums;
|
||||
using CustomizePlus.Profiles.Exceptions;
|
||||
|
||||
namespace CustomizePlus.Profiles;
|
||||
|
||||
@@ -299,6 +300,8 @@ public class ProfileManager : IDisposable
|
||||
{
|
||||
SetEnabled(profile, value);
|
||||
}
|
||||
else
|
||||
throw new ProfileNotFoundException();
|
||||
}
|
||||
|
||||
public void SetLimitLookupToOwned(Profile profile, bool value)
|
||||
@@ -390,7 +393,7 @@ public class ProfileManager : IDisposable
|
||||
public void AddTemporaryProfile(Profile profile, Actor actor/*, Template template*/)
|
||||
{
|
||||
if (!actor.Identifier(_actorManager, out var identifier))
|
||||
return;
|
||||
throw new ActorNotFoundException();
|
||||
|
||||
profile.Enabled = true;
|
||||
profile.ProfileType = ProfileType.Temporary;
|
||||
@@ -418,21 +421,30 @@ public class ProfileManager : IDisposable
|
||||
public void RemoveTemporaryProfile(Profile profile)
|
||||
{
|
||||
if (!Profiles.Remove(profile))
|
||||
return;
|
||||
throw new ProfileNotFoundException();
|
||||
|
||||
_logger.Debug($"Removed temporary profile for {profile.CharacterName}");
|
||||
|
||||
_event.Invoke(ProfileChanged.Type.TemporaryProfileDeleted, profile, null);
|
||||
}
|
||||
|
||||
public void RemoveTemporaryProfile(Guid profileId)
|
||||
{
|
||||
var profile = Profiles.FirstOrDefault(x => x.UniqueId == profileId && x.IsTemporary);
|
||||
if (profile == null)
|
||||
throw new ProfileNotFoundException();
|
||||
|
||||
RemoveTemporaryProfile(profile);
|
||||
}
|
||||
|
||||
public void RemoveTemporaryProfile(Actor actor)
|
||||
{
|
||||
if (!actor.Identifier(_actorManager, out var identifier))
|
||||
return;
|
||||
throw new ActorNotFoundException();
|
||||
|
||||
var profile = Profiles.FirstOrDefault(x => x.TemporaryActor == identifier && x.IsTemporary);
|
||||
if (profile == null)
|
||||
return;
|
||||
throw new ProfileNotFoundException();
|
||||
|
||||
RemoveTemporaryProfile(profile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user