public static IgnoredMemberReferencesIncludeLoader Serialize( IgnoredMemberReferencesIncludeLoader instance, SimpleXmlSerializerBase serializer ) { instance = instance ?? new IgnoredMemberReferencesIncludeLoader(); FileIncludeLoader <IIgnoredMemberReference> .Serialize(instance, serializer); return(instance); }
private ResolvedInjecteeAssembly GetInjecteeAssembly(InjecteeAssembly sourceInjecteeAssembly) { List <IgnoredMemberReference> ignoredMemberReferences = new List <IgnoredMemberReference>(); List <AllowedAssemblyReference> allowedAssemblyReferences = new List <AllowedAssemblyReference>(); void LoadIgnoredMemberReferences(IEnumerable <IIgnoredMemberReference> items) { foreach (IIgnoredMemberReference item in items) { if (item is IgnoredMemberReference ignoredMemberReference) { ignoredMemberReferences.Add(ignoredMemberReference); continue; } if (item is IgnoredMemberReferenceInclude ignoredMemberReferenceInclude) { try { Log.DebugFormat("Loading ignored member references list include at '{0}'", ignoredMemberReferenceInclude.Path); string includeXml = File.ReadAllText(ignoredMemberReferenceInclude.Path); IgnoredMemberReferencesIncludeLoader ignoredMemberReferencesIncludeLoader = SimpleXmlSerializationUtility.XmlDeserializeFromString <IgnoredMemberReferencesIncludeLoader>(includeXml); LoadIgnoredMemberReferences(ignoredMemberReferencesIncludeLoader.Items); } catch (Exception e) { Console.WriteLine(e); throw new MethodInlineInjectorException( $"Unable to load ignored member references list include at '{ignoredMemberReferenceInclude.Path}'", e ); } } } } void LoadAllowedAssemblyReferences(IEnumerable <IAllowedAssemblyReference> items) { foreach (IAllowedAssemblyReference item in items) { if (item is AllowedAssemblyReference allowedAssemblyReference) { allowedAssemblyReferences.Add(allowedAssemblyReference); continue; } if (item is AllowedAssemblyReferenceInclude allowedAssemblyReferenceInclude) { Log.DebugFormat("Loading allowed assembly references list include at '{0}'", allowedAssemblyReferenceInclude.Path); try { string includeXml = File.ReadAllText(allowedAssemblyReferenceInclude.Path); AllowedAssemblyReferenceIncludeLoader allowedAssemblyReferencesLoader = SimpleXmlSerializationUtility.XmlDeserializeFromString <AllowedAssemblyReferenceIncludeLoader>(includeXml); LoadAllowedAssemblyReferences(allowedAssemblyReferencesLoader.Items); } catch (Exception e) { throw new MethodInlineInjectorException( $"Unable to load allowed assembly references list include at '{allowedAssemblyReferenceInclude.Path}'", e ); } } } } LoadIgnoredMemberReferences(sourceInjecteeAssembly.IgnoredMemberReferences); LoadAllowedAssemblyReferences(sourceInjecteeAssembly.AllowedAssemblyReferences); List <ResolvedAllowedAssemblyReference> resolvedAllowedAssemblyReferences = allowedAssemblyReferences .Select(item => new ResolvedAllowedAssemblyReference(AssemblyNameReference.Parse(item.Name), item.Path, item.StrictNameCheck)) .ToList(); // Configure assembly resolver for this assembly IgnoringExceptionsAssemblyResolver assemblyResolver = CreateAssemblyResolver(resolvedAllowedAssemblyReferences); AssemblyDefinitionCachedData assemblyDefinitionCachedData = GetAssemblyDefinitionCachedData(sourceInjecteeAssembly.AssemblyPath, assemblyResolver); Log.DebugFormat( "Calculating injectee methods in assembly '{0}'", assemblyDefinitionCachedData.AssemblyDefinition.MainModule.FullyQualifiedName); List <MethodDefinition> filteredInjecteeMethods = GetFilteredInjecteeMethods(assemblyDefinitionCachedData, ignoredMemberReferences); ResolvedInjecteeAssembly resolvedInjecteeAssembly = new ResolvedInjecteeAssembly( assemblyDefinitionCachedData.AssemblyDefinition, filteredInjecteeMethods, resolvedAllowedAssemblyReferences, assemblyResolver ); return(resolvedInjecteeAssembly); }