// Find binding-redirects with linq-to-xml from a .config file. // This might be useful for then parsing config-changes e.g. by System.Linq.Enumerable.Except#r @"System.Xml.Linq.dll"openSystem.Xml.LinqletparseBindingRedirects(filename:string)=letxns=XName.Get(s,"urn:schemas-microsoft-com:asm.v1")letxml=XDocument.LoadfilenameletdepAssemblies=xml.Descendants(xn"dependentAssembly")seq{fordependentAssemblyindepAssembliesdoletname=dependentAssembly.Elements()|>Seq.tryFind(fune->e.Name.LocalName="assemblyIdentity")|>Option.map(fune->e.Attributes()|>Seq.tryFind(funa->a.Name.LocalName="name")|>Option.map(funv->v.Value))|>Option.flattenletbd=dependentAssembly.Elements()|>Seq.tryFind(fune->e.Name.LocalName="bindingRedirect")letoldVersion=bd|>Option.map(funb->b.Attributes()|>Seq.tryFind(funa->a.Name.LocalName="oldVersion")|>Option.map(funv->v.Value))|>Option.flattenletnewVersion=bd|>Option.map(funb->b.Attributes()|>Seq.tryFind(funa->a.Name.LocalName="newVersion")|>Option.map(funv->v.Value))|>Option.flattenmatchname,oldVersion,newVersionwith|Somen,Someov,Somenv->yieldn,ov,nv|_->()}|>Seq.distinct|>Seq.toList
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.