From e2ea849211305ef9f276b29717d409402381d8fd Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 7 Mar 2018 09:34:23 +0100 Subject: [PATCH] Cleanup --- src/Umbraco.Core/Models/Entities/EntityBase.cs | 4 ---- src/Umbraco.Core/ReflectionUtilities.cs | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Models/Entities/EntityBase.cs b/src/Umbraco.Core/Models/Entities/EntityBase.cs index 4d0c2f74d9..ab57d57ab6 100644 --- a/src/Umbraco.Core/Models/Entities/EntityBase.cs +++ b/src/Umbraco.Core/Models/Entities/EntityBase.cs @@ -38,10 +38,6 @@ namespace Umbraco.Core.Models.Entities set { SetPropertyValueAndDetectChanges(value, ref _id, Ps.Value.IdSelector); - - // fixme - this is a problem w/ user 'admin' having ID 'zero' - // in v7 _hasIdentity becomes true soon as an ID is set, which is... weird - // we should NOT have 'admin' have ID 'zero' _hasIdentity = value != 0; } } diff --git a/src/Umbraco.Core/ReflectionUtilities.cs b/src/Umbraco.Core/ReflectionUtilities.cs index cb8a52cdad..db0cde87db 100644 --- a/src/Umbraco.Core/ReflectionUtilities.cs +++ b/src/Umbraco.Core/ReflectionUtilities.cs @@ -672,10 +672,16 @@ namespace Umbraco.Core // return o is T t ? t : (T) System.Convert.ChangeType(o, typeof(T)); //} + private static MethodInfo _convertMethod; + private static void Convert(this ILGenerator ilgen, Type type) { ilgen.Emit(OpCodes.Ldtoken, type); - ilgen.CallMethod(typeof(Convert).GetMethod("ChangeType", BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(object), typeof(Type)}, null)); // fixme cache + + if (_convertMethod == null) + _convertMethod = typeof(Convert).GetMethod("ChangeType", BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(object), typeof(Type) }, null); + + ilgen.CallMethod(_convertMethod); } // emits adapter code before OpCodes.Ret