/// <summary> /// Utilities routine to get class methods. /// </summary> /// <param name="IncludeParent">if false then just returns methods defined in the passed class type /// if true then this routine makes a list of all methods in the class including any parent classes /// </param> /// <param name="Info">type of the class to check</param> /// <returns></returns> // helper for FIlterClasses callback - checks if the TypeData contaisn the iFormat Specs private bool FilterClassesCheck_Routines(TypeInfo Data) { int VerifyCheck = 0; ParameterInfo[] ArgInfo; List <MethodInfo> Info = InstancedPluginContainer.GetClassMethods(true, Data); foreach (MethodInfo RoutineInfo in Info) { switch (RoutineInfo.Name) { case "ReadData": if (!RoutineInfo.IsPublic) { continue; } if (RoutineInfo.ReturnType != typeof(void)) { continue; } if (RoutineInfo.IsStatic == true) { continue; } ArgInfo = RoutineInfo.GetParameters(); if (ArgInfo.Length != 3) { continue; } if (ArgInfo[0].ParameterType != typeof(StreamReader)) { continue; } if (ArgInfo[1].ParameterType != typeof(StreamWriter)) { continue; } // TODO: Check argument for reference bool /* * if (ArgInfo[2].ParameterType != Boolean.get) * { * continue; * }*/ VerifyCheck++; break; case "GetPreferredExtension": if (!RoutineInfo.IsPublic) { continue; } if (RoutineInfo.IsStatic) { continue; } if (RoutineInfo.ReturnType != typeof(string)) { continue; } ArgInfo = RoutineInfo.GetParameters(); if (ArgInfo.Length != 0) { continue; } VerifyCheck++; break; case "WriteData": if (!RoutineInfo.IsPublic) { continue; } if (RoutineInfo.IsStatic) { continue; } if (RoutineInfo.ReturnType != typeof(void)) { continue; } ArgInfo = RoutineInfo.GetParameters(); if (ArgInfo.Length != 2) { continue; } if (ArgInfo[0].ParameterType != typeof(StreamReader)) { continue; } if (ArgInfo[1].ParameterType != typeof(StreamWriter)) { continue; } VerifyCheck++; break; case "GetDialogBoxExt": if (RoutineInfo.IsPublic) { if (RoutineInfo.ReturnType == typeof(string)) { VerifyCheck++; } } break; case "GetShortName": if (RoutineInfo.IsPublic) { if (RoutineInfo.ReturnType == typeof(string)) { VerifyCheck++; } } break; case "GetFriendlyName": if (RoutineInfo.IsPublic) { if (RoutineInfo.ReturnType == typeof(string)) { VerifyCheck++; } } break; } } if (VerifyCheck >= 5) { return(true); } return(false); }
private bool SimpleToolTypeCheck(string name, TypeInfo Data) { name = name.ToUpper(CultureInfo.InvariantCulture); if (name.Contains("NOEXPORT")) { return(false); } if (Data.Name.StartsWith("SIMPLETOOL", StringComparison.InvariantCultureIgnoreCase) == false) { return(false); } if (Data.IsGenericType) { return(false); } if (Data.IsAbstract) { return(false); } if (Data.IsEnum) { return(false); } var Methods = InstancedPluginContainer.GetClassMethods(false, Data); { /* * * * The protocal requres the class to export these two routines. * public string GetMenuItemName(); * public string GetMenuItemCommand(); * * * The protocal may optionally export this routine. ReturnType should be named PreferredLocation and it will need to * match the values containng with *this* modules enum of the same name. * public PreferredLocation GetMenuPreferedLocation() * */ int match = 0; foreach (MethodInfo Routine in Methods) { if (Routine.Name.Equals("GetMenuItemCommand", StringComparison.InvariantCultureIgnoreCase)) { if (Routine.ReturnType.Name.Equals("string", StringComparison.InvariantCultureIgnoreCase)) { if (Routine.IsPublic) { if (Routine.IsStatic == false) { if (Routine.GetParameters().Length == 0) { match++; } } } } } if (Routine.Name.Equals("GetMenuItemName", StringComparison.InvariantCultureIgnoreCase)) { if (Routine.ReturnType.Name.Equals("string", StringComparison.InvariantCultureIgnoreCase)) { if (Routine.IsPublic) { if (Routine.IsStatic == false) { if (Routine.GetParameters().Length == 0) { match++; } } } } } if (Routine.Name.Equals("GetMenuPreferedLocation", StringComparison.InvariantCultureIgnoreCase)) { if (Routine.ReturnType.Name.Equals("PreferedLocation", StringComparison.InvariantCultureIgnoreCase)) { if (Routine.IsPublic) { if (Routine.IsStatic == false) { if (Routine.GetParameters().Length == 0) { // match++; optional. The instancedplugin handler returns default if this routine is not defined. } } } } } } if (match != 2) { return(false); } } return(true); }