Created
June 5, 2014 16:58
-
-
Save jacobmendoza/4597e14c052b7a650e35 to your computer and use it in GitHub Desktop.
UndefRec.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class ST | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
} | |
public void ProcessChildCategories(XElement categoriesNode, Category parentNode) | |
{ | |
var xmlCategories = categoriesNode.Elements("Category"); | |
foreach (var categoryNode in xmlCategories) | |
{ | |
//var properties = typeof(Category).GetProperties(); | |
var categoryId = categoryNode.Element("Id").Value; | |
var categoryName = categoryNode.Element("Name").Value; | |
var category = GetExistingCategory(categoryName, parentNode); | |
var loopParentNode = category; | |
var hierarchy = new List<ST>(); | |
if (loopParentNode != null) | |
{ | |
while (loopParentNode != null) | |
{ | |
hierarchy.Insert(0, new ST { Id = loopParentNode.Id, Name = loopParentNode.Name }); | |
loopParentNode = _existingCategories.FirstOrDefault(c => c.Id == loopParentNode.ParentCategoryId); | |
} | |
} | |
var joinedString = string.Join("/", hierarchy.Select(h => string.Format("{0} ({1})", h.Name, h.Id))); | |
using (var stream = File.AppendText(@"E:\Git\text.txt")) | |
{ | |
stream.WriteLine(joinedString); | |
} | |
Debug.WriteLine(joinedString); | |
//_propertiesProcessorService.ProcessBasicTypes(properties, categoryNode.Elements().ToList(), category); | |
//UpdateCategory(category, parentNode); | |
var subCategoriesNode = categoryNode.Element("SubCategories"); | |
ProcessChildCategories(subCategoriesNode, category); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment