Skip to content

Commit bcf789f

Browse files
committed
Simplified delegate handle tracking
1 parent ef2983b commit bcf789f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

Source/ExcelDna.Loader/XlRegistration.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static void RegisterMethods(List<MethodInfo> methods)
3737
public static void RegisterMethodsWithAttributes(List<MethodInfo> methods, List<object> methodAttributes, List<List<object>> argumentAttributes)
3838
{
3939
List<XlMethodInfo> xlMethods = XlMethodInfo.ConvertToXlMethodInfos(methods, null, null, methodAttributes, argumentAttributes);
40-
xlMethods.ForEach(i => delegateHandles.Add(i.DelegateHandle));
4140
RegisterXlMethods(xlMethods);
4241
}
4342

@@ -57,14 +56,12 @@ public static void RegisterDelegatesWithAttributes(List<Delegate> delegates, Lis
5756
targets.Add(del);
5857
}
5958
List<XlMethodInfo> xlMethods = XlMethodInfo.ConvertToXlMethodInfos(methods, targets, null, methodAttributes, argumentAttributes);
60-
xlMethods.ForEach(i => delegateHandles.Add(i.DelegateHandle));
6159
RegisterXlMethods(xlMethods);
6260
}
6361

6462
public static void RegisterLambdaExpressionsWithAttributes(List<LambdaExpression> lambdaExpressions, List<object> methodAttributes, List<List<object>> argumentAttributes)
6563
{
6664
List<XlMethodInfo> xlMethods = XlMethodInfo.ConvertToXlMethodInfos(null, null, lambdaExpressions, methodAttributes, argumentAttributes);
67-
xlMethods.ForEach(i => delegateHandles.Add(i.DelegateHandle));
6865
RegisterXlMethods(xlMethods);
6966
}
7067

@@ -89,7 +86,6 @@ public static void RegisterRtdWrapper(string progId, object rtdWrapperOptions, o
8986
null,
9087
new List<object> { functionAttribute },
9188
new List<List<object>> { argumentAttributes });
92-
xlMethods.ForEach(i => delegateHandles.Add(i.DelegateHandle));
9389
RegisterXlMethods(xlMethods);
9490
}
9591

@@ -143,6 +139,8 @@ static void RegisterXlMethods(List<XlMethodInfo> xlMethods)
143139

144140
static void RegisterXlMethod(XlMethodInfo mi)
145141
{
142+
delegateHandles.Add(mi.DelegateHandle);
143+
146144
int index = registeredMethods.Count;
147145
XlAddIn.SetJump(index, mi.FunctionPointer);
148146
string exportedProcName = string.Format("f{0}", index);

0 commit comments

Comments
 (0)