using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Reflection.Emit; using Microsoft.Dynamics.Ax.Xpp.AxShared;
namespaceMicrosoft.Dynamics.Ax.Xpp { publicstaticclassTrueFalseHelper { publicstaticboolTrueFalse(object x) { if (x != null) { global::System.Type type = x.GetType(); if (!type.IsInterface) { if (x isglobal::System.Enum) { type = type.GetEnumUnderlyingType(); if (type == typeof(ulong)) { x = (ulong)x; } elseif (type == typeof(long)) { x = (long)x; } elseif (type == typeof(uint)) { x = (uint)x; } else { x = global::System.Convert.ToInt32((global::System.Enum)x, global::System.Globalization.CultureInfo.InvariantCulture); type = typeof(int); } } global::Microsoft.Dynamics.Ax.Xpp.TrueFalseHelper.TrueFalseDelegate trueFalseDelegate = null; if (!global::Microsoft.Dynamics.Ax.Xpp.TrueFalseHelper.trueFalseCaching.TryGetValue(type, out trueFalseDelegate)) { global::System.Reflection.MethodInfo method = typeof(global::Microsoft.Dynamics.Ax.Xpp.TrueFalseHelper).GetMethod("TrueFalse", newglobal::System.Type[] { type }); global::System.Reflection.Emit.DynamicMethod dynamicMethod = newglobal::System.Reflection.Emit.DynamicMethod("TrueFalseHelper::TrueFalse", typeof(bool), newglobal::System.Type[] { typeof(object) }); global::System.Reflection.Emit.ILGenerator ilgenerator = dynamicMethod.GetILGenerator(); if (method.GetParameters()[0].ParameterType == typeof(object)) { ilgenerator.Emit(global::System.Reflection.Emit.OpCodes.Ldc_I4_1); } else { ilgenerator.Emit(global::System.Reflection.Emit.OpCodes.Ldarg_0); if (type.IsValueType) { ilgenerator.Emit(global::System.Reflection.Emit.OpCodes.Unbox_Any, type); } else { ilgenerator.Emit(global::System.Reflection.Emit.OpCodes.Castclass, type); } ilgenerator.Emit(global::System.Reflection.Emit.OpCodes.Call, method); } ilgenerator.Emit(global::System.Reflection.Emit.OpCodes.Ret); trueFalseDelegate = (global::Microsoft.Dynamics.Ax.Xpp.TrueFalseHelper.TrueFalseDelegate)dynamicMethod.CreateDelegate(typeof(global::Microsoft.Dynamics.Ax.Xpp.TrueFalseHelper.TrueFalseDelegate)); global::Microsoft.Dynamics.Ax.Xpp.TrueFalseHelper.trueFalseCaching.TryAdd(type, trueFalseDelegate); } return trueFalseDelegate(x); } } return x != null; }
publicstaticboolTrueFalse(object[] x) { return x != null && x.Length != 0 && x != global::Microsoft.Dynamics.Ax.Xpp.ContainerHelper.connull; }