static fsConverterRegistrar() { Converters = new List <Type>(); foreach (FieldInfo field in typeof(fsConverterRegistrar).GetDeclaredFields()) { if (field.Name.StartsWith("Register_")) { Converters.Add(field.FieldType); } } foreach (MethodInfo method in typeof(fsConverterRegistrar).GetDeclaredMethods()) { if (method.Name.StartsWith("Register_")) { method.Invoke(null, null); } } // Make sure we do not use any AOT Models which are out of date. List <Type> finalResult = new List <Type>(Converters); foreach (Type t in Converters) { object instance = null; try { instance = Activator.CreateInstance(t); } catch (Exception) { } fsIAotConverter aotConverter = instance as fsIAotConverter; if (aotConverter != null) { fsMetaType modelMetaType = fsMetaType.Get(new fsConfig(), aotConverter.ModelType); if (fsAotCompilationManager.IsAotModelUpToDate(modelMetaType, aotConverter) == false) { finalResult.Remove(t); } } } Converters = finalResult; }
/// <summary> /// Returns true if the given aotModel can be used. Returns false if it needs to /// be recompiled. /// </summary> public static bool IsAotModelUpToDate(fsMetaType currentModel, fsIAotConverter aotModel) { if (currentModel.IsDefaultConstructorPublic != aotModel.VersionInfo.IsConstructorPublic) { return(false); } if (currentModel.Properties.Length != aotModel.VersionInfo.Members.Length) { return(false); } foreach (fsMetaProperty property in currentModel.Properties) { if (HasMember(aotModel.VersionInfo, new fsAotVersionInfo.Member(property)) == false) { return(false); } } return(true); }