-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented hot reload of configuration
When a config is changed and saved by an entity framework context: * it will forward these changes to a IConfigurationChangeListener which is specific to the Persistence.EntityFramework. * The implementation of that will * update the cached configuration objects and their parent objects, in case it's an collection * notify an instance of a ConfigurationChangeHandler which also existed before * The change handler will notify the change mediator (game logic), on which several logic objects will subscribe for changes To make this work, especially updating the cached objects, I had to implement something like ICloneable<T> and Assignable<T>. I did this by implementing a code generator and a CloneableAttribute. The referencing of it might need some adaptions as it's probably only working in debug build right now.
- Loading branch information
Showing
248 changed files
with
3,547 additions
and
298 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// <copyright file="CloneableAttribute.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.Annotations; | ||
|
||
/// <summary> | ||
/// Classes marked with this attribute will get a generic Clonable-Interface | ||
/// implemented by a code generator. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] | ||
public sealed class CloneableAttribute : Attribute | ||
{ | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<WarningsAsErrors>nullable;CS4014;VSTHRD110;VSTHRD100</WarningsAsErrors> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// <copyright file="AssignableExtensions.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.DataModel; | ||
|
||
using MUnique.OpenMU.DataModel.Configuration; | ||
|
||
/// <summary> | ||
/// Extensions for <see cref="IAssignable{T}"/>. | ||
/// </summary> | ||
public static class AssignableExtensions | ||
{ | ||
/// <summary> | ||
/// Assigns a collection to another one, resolving the objects to the ones | ||
/// which are contained in the given <see cref="GameConfiguration"/>. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the collection elements.</typeparam> | ||
/// <param name="collection">The target collection.</param> | ||
/// <param name="other">The other collection.</param> | ||
/// <param name="gameConfiguration">The game configuration.</param> | ||
public static void AssignCollection<T>(this ICollection<T> collection, ICollection<T> other, GameConfiguration gameConfiguration) | ||
where T : class | ||
{ | ||
var newItems = collection.Except(other).ToList(); | ||
var oldItems = other.Except(collection).ToList(); | ||
|
||
oldItems.ForEach(i => collection.Remove(i)); | ||
newItems.ForEach(i => collection.Add( | ||
gameConfiguration.GetObjectOfConfig(i) | ||
?? (i as ICloneable<T>)?.Clone(gameConfiguration) | ||
?? (i as ICloneable)?.Clone() as T | ||
?? i)); | ||
} | ||
|
||
/// <summary> | ||
/// Assigns a collection to another one. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the collection values.</typeparam> | ||
/// <param name="collection">The target collection.</param> | ||
/// <param name="other">The other collection.</param> | ||
public static void AssignCollection<T>(this ICollection<T> collection, ICollection<T> other) | ||
where T : struct | ||
{ | ||
var newItems = collection.Except(other).ToList(); | ||
var oldItems = other.Except(collection).ToList(); | ||
|
||
oldItems.ForEach(i => collection.Remove(i)); | ||
newItems.ForEach(collection.Add); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.