public Type GetType(string fullName, bool throwOnError) { #if XB1 // XB1_ALLINONEASSEMBLY Type type; if ((type = MyAssembly.GetType(fullName, false)) != null) { return(type); } #else // !XB1 foreach (var assembly in m_assemblies) { Type type; if ((type = assembly.GetType(fullName, false)) != null) { return(type); } } #endif // !XB1 if (throwOnError) { throw new TypeLoadException(string.Format("Type {0} was not found in any registered assembly!", fullName)); } return(null); }
/// <summary> /// Register an activity documentation component component factory /// </summary> /// <param name="componentFactory">the activity documentation component factory</param> /// <exception cref="Exception">throws, when the target assembly is not loaded or the /// registry class or methods cannot be found</exception> public void Register(IActivityDocumentationComponentFactory componentFactory) { try { Type componentRegistryType = MyAssembly.GetType(ComponentRegistryClassName); PropertyInfo theInstanceProperty = componentRegistryType.GetProperty("TheInstance"); MethodInfo registerMethod = componentRegistryType.GetMethod("Register", new Type[] { typeof(object) }); object componentRegistry = theInstanceProperty.GetValue(null, null); registerMethod.Invoke(componentRegistry, new object[] { componentFactory }); } catch (Exception e) { // If AD is not installed, this should not cause Gear Chart to error //throw new InvalidOperationException("Cannot register component", e); } }