Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (48 sloc) 1.643 kb
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
public partial class Processor
{
public List<WeaverEntry> Weavers;
public void ReadProjectWeavers()
{
if (Weavers != null)
{
return;
}
Weavers = new List<WeaverEntry>();
foreach (var configFile in ConfigFiles)
{
var xDocument = GetDocument(configFile);
foreach (var element in xDocument.Root.Elements())
{
var assemblyName = element.Name.LocalName;
var existing = Weavers.FirstOrDefault(x => x.AssemblyName == assemblyName);
var index = Weavers.Count;
if (existing != null)
{
index = Weavers.IndexOf(existing);
Weavers.Remove(existing);
}
var weaverEntry = new WeaverEntry
{
Element = element.ToString(SaveOptions.OmitDuplicateNamespaces),
AssemblyName = assemblyName
};
Weavers.Insert(index, weaverEntry);
}
}
}
static XDocument GetDocument(string configFilePath)
{
try
{
return XDocument.Load(configFilePath);
}
catch (XmlException exception)
{
throw new WeavingException(string.Format("Could not read '{0}' because it has invalid xml. Message: '{1}'.", "FodyWeavers.xml", exception.Message));
}
}
}
Jump to Line
Something went wrong with that request. Please try again.