/// <summary> /// Tries to get the filename that declared the given type /// </summary> /// <param name="ExistingType"></param> /// <param name="File"></param> /// <returns>True if the type was found, false otherwise</returns> public bool TryGetFileNameFromType(Type ExistingType, out FileReference File) { if (ExistingType.Assembly == CompiledAssembly) { string Name = ExistingType.Name; if (ModuleNameToModuleFile.TryGetValue(Name, out File)) { return(true); } string NameWithoutTarget = Name; if (NameWithoutTarget.EndsWith("Target")) { NameWithoutTarget = NameWithoutTarget.Substring(0, NameWithoutTarget.Length - 6); } if (TargetNameToTargetFile.TryGetValue(NameWithoutTarget, out File)) { return(true); } } else { if (Parent != null && Parent.TryGetFileNameFromType(ExistingType, out File)) { return(true); } } File = null; return(false); }
/// <summary> /// Gets the filename that declares the given type. /// </summary> /// <param name="ExistingType">The type to search for.</param> /// <returns>The filename that declared the given type, or null</returns> public static string GetFileNameFromType(Type ExistingType) { FileReference FileName; if (EngineRulesAssembly != null && EngineRulesAssembly.TryGetFileNameFromType(ExistingType, out FileName)) { return(FileName.FullName); } foreach (RulesAssembly RulesAssembly in LoadedAssemblyMap.Values) { if (RulesAssembly.TryGetFileNameFromType(ExistingType, out FileName)) { return(FileName.FullName); } } return(null); }