public static IGxCollection CreateCollection(string Name, string Namespace, IGxContext context) { #if NETCORE Type type = ClassLoader.FindType(Config.CommonAssemblyName, Namespace, GxSdtNameToCsharpName(Name), Assembly.GetEntryAssembly()); #else Type type = ClassLoader.FindType(Config.CommonAssemblyName, Namespace, GxSdtNameToCsharpName(Name), Assembly.GetCallingAssembly()); #endif var listType = typeof(GXBaseCollection <>); var concreteType = listType.MakeGenericType(type); return(Activator.CreateInstance(concreteType, new object[] { context, GxSdtNameToCsharpName(Name), Namespace }) as IGxCollection); }
protected static object MakeRestType(object v) { Type vType = v.GetType(); if (vType.IsConstructedGenericType && typeof(IGxCollection).IsAssignableFrom(vType)) //Collection<SDTType> convert to GxGenericCollection<SDTType_RESTInterface> { Type itemType = v.GetType().GetGenericArguments()[0]; Type restItemType = ClassLoader.FindType(Config.CommonAssemblyName, itemType.FullName + "_RESTInterface", null); bool isWrapped = !restItemType.IsDefined(typeof(GxUnWrappedJson), false); Type genericListItemType = typeof(GxGenericCollection <>).MakeGenericType(restItemType); return(Activator.CreateInstance(genericListItemType, new object[] { v, isWrapped })); } else if (typeof(GxUserType).IsAssignableFrom(vType)) //SDTType convert to SDTType_RESTInterface { Type restItemType = ClassLoader.FindType(Config.CommonAssemblyName, vType.FullName + "_RESTInterface", null); return(Activator.CreateInstance(restItemType, new object[] { v })); } return(v); }