Esempio n. 1
0
        public ProjRef[] Change(ProjRef[] changes)
        {
            XDocument doc = null;
            List<ProjRef> allRefs = new List<ProjRef>();

            foreach (var projRef in changes)
            {
                if (!CheckExistance(projRef.ProjectName, projRef.NewRef))
                {
                    Log.Debug("Path not found skipping " + projRef);
                    allRefs.Add(projRef);
                    continue;
                }
                Log.Debug("handling "+projRef);
                doc = XDocument.Load(projRef.ProjectName);
                var referenceName = Path.GetFileNameWithoutExtension(projRef.Ref);
                IEnumerable<XElement> result =  FindExistingReference(doc, referenceName);
                if(result.Count()!=1)
                {
                    Log.Info("Found " + result.Count() + " result, which was unexepcted");
                    throw new Exception("Expected exactly one match "+projRef) ;
                }

                var xmlRef = result.SingleOrDefault();
                Log.Debug("value before "+xmlRef.Value);
                xmlRef.Value = projRef.NewRef;
                Log.Debug("value after "+xmlRef.Value);

                allRefs.Add(CreateResult(projRef.ProjectName, xmlRef.Value));

                doc.Save(projRef.ProjectName);

            }
            return allRefs.ToArray();
        }
Esempio n. 2
0
        public ProjRef[] Add(ProjRef[] newRefs)
        {
            XDocument doc = null;
            List<ProjRef> addedRefs = new List<ProjRef>();

            foreach (var projRef in newRefs)
            {
                if (!CheckExistance(projRef.ProjectName, projRef.Ref))
                {
                    Log.Debug("Path not found skipping " + projRef);
                    continue;
                }
                Log.Debug("handling " + projRef);
                doc = XDocument.Load(projRef.ProjectName);

                var refName = Path.GetFileNameWithoutExtension(projRef.Ref);

               if (FindExistingReference(doc, refName).Any())
               {
                   Log.Debug("ref (name) already exists "+refName +" in "+projRef.ProjectName);
                   continue;
               }

               var refGroup = doc.Root.Descendants(_ns + "Reference").FirstOrDefault().Parent;

                var hintPath = new XElement(_ns + "HintPath", projRef.Ref);
                refGroup.AddFirst(new XElement(_ns + "Reference",new XAttribute("Include",refName),
                                          hintPath
                                      ));

                Log.Debug(refGroup);

                addedRefs.Add(CreateResult(projRef.ProjectName, hintPath.Value));

                doc.Save(projRef.ProjectName);

            }
            return addedRefs.ToArray();
        }
Esempio n. 3
0
 public ProjRef[] GetRefs(ProjRef[] updates)
 {
     var projFiles= new List<string>();
     foreach (var projRef in updates)
     {
         projFiles.Add(projRef.ProjectName);
     }
     return GetRefsInternal(projFiles.ToArray());
 }
Esempio n. 4
0
 private static ProjRef CreateResult(string projFile, string referenceHintPath)
 {
     var fileExists = CheckExistance(projFile, referenceHintPath);
     var projRef = new ProjRef {ProjectName = projFile, Ref = referenceHintPath, FileExists = fileExists};
     return projRef;
 }
Esempio n. 5
0
        public void Delete(ProjRef deleteMe)
        {
            XDocument doc = XDocument.Load(deleteMe.ProjectName);

            IEnumerable<XElement> result = FindExistingReferenceByHint(doc, deleteMe.Ref);
            if (result.Count() != 1)
            {
                Log.Info("Found " + result.Count() + " result, which was unexepcted");
                throw new Exception("Expected exactly one match " + deleteMe.Ref);
            }

            var xmlRef = result.SingleOrDefault();
            var theRef = xmlRef.Parent;
            theRef.Remove();

            doc.Save(deleteMe.ProjectName);
        }