Skip to content

Commit

Permalink
buffix: delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Mar 20, 2022
1 parent f331003 commit 8cf6ef3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
13 changes: 1 addition & 12 deletions UnifiedUILib/Helpers/UUIHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ internal static TDelegate CreateDelegate<TDelegate>(Type type, string name) wher
return (TDelegate)Delegate.CreateDelegate(typeof(TDelegate), method);
}

internal static TDelegate CreateClosedDelegate<TDelegate>(object instance, string name) where TDelegate : Delegate {
try {
var type = instance.GetType();
var method = type.GetMethod<TDelegate>(name);
if (method == null) return null;
return (TDelegate)Delegate.CreateDelegate(type: typeof(TDelegate), firstArgument: instance, method: method);
} catch (Exception ex) {
throw new Exception($"CreateClosedDelegate<{typeof(TDelegate).Name}>({instance.GetType().Name},{name}) failed!", ex);
}
}

internal static IEnumerable<PluginManager.PluginInfo> Plugins => PluginManager.instance.GetPluginsInfo();

internal static PluginManager.PluginInfo GetUUIPlugin() =>
Expand Down Expand Up @@ -474,7 +463,7 @@ internal static KeyActivatedDelegate GetKeyActivatedDelegate() {
return keyActivatedDelegate_; // return cached uui_
}

keyActivatedDelegate_ = CreateClosedDelegate<KeyActivatedDelegate>(GetUUI(), "KeyActivated");
keyActivatedDelegate_ = CreateDelegate<KeyActivatedDelegate>(GetUUI(), "KeyActivated");

if (keyActivatedDelegate_ != null) {
// if uui_ is cached, then reset it if something changed.
Expand Down
16 changes: 8 additions & 8 deletions UnifiedUILib/UnifiedUILib.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Version.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<AssemblyVersion>2.2.7.*</AssemblyVersion>
<FileVersion>2.2.7</FileVersion>
<AssemblyVersion>2.2.8.*</AssemblyVersion>
<FileVersion>2.2.8</FileVersion>
</PropertyGroup>
</Project>

0 comments on commit 8cf6ef3

Please sign in to comment.