Recreate extension or make other methods for create TreeStructure C#
€8-24 EUR
ชำระเงินเมื่อจัดส่ง
Welcome,
I have a problem with creating a tree structure on the basis of a split string, now it returns to me a class object e.g. Node<string> with filled in Name and Children properties, I would like it to fill in all properties and preferably instead of an extension it should concern a ready class e.g. Player. Below is how it looks like now:
I have a Player class on the basis of which I would like to create a tree system with all fields filled in:
public class Player
{
public string Name { get; set; }
public int Age { get; set; }
public string Description { get; set; }
public string MainName { get; set; } // e.g. "Player_1_here_is" and this thong will be divided into pieces and a tree structure will be created based on it.
public IEnumerable<Player> Players { get; set; }
public Player Parent { get; set; }
}
// an example collection, the problem is to divide 'MainName' names by the '_' character and create a tree structure:
List<Player> Players = new List<Player>()
{
new Player(){ Name = "Name", Age = 20, Description = "Description", MainName = "Player" },
new Player(){ Name = "Name 2", Age = 20, Description = "Description 2", MainName = "Player_2" },
new Player(){ Name = "Name 3", Age = 30, Description = "Description 3", MainName = "Player_spoko" },
new Player(){ Name = "Name 4", Age = 40, Description = "Description 4", MainName = "Player_2_dobre" },
new Player(){ Name = "Name 5", Age = 25, Description = "Description 5", MainName = "Player_spoko2" },
new Player(){ Name = "Name 6", Age = 30, Description = "Description 6", MainName = "Player_spoko2_dobre" }
}
// where we create structures on the basis of 'MainName' divided into pieces.
var test = [login to view URL](x => [login to view URL]('_').AsEnumerable()).GroupToTree();
// The result looks like this:
//- Player
//--- 2
//------ good
//--- calm
//--- calm2
//------ good
//where there is a good structure, only to it I would like to assign the remaining fields e.g. for 'Value = good (Name = Name 6)':
//- Name = First name 6
//- Age = 30
//- Description = Description 6
//- MainName - Player_spoko2_dobre
//- Parent = calm2 // where Parent would be set when creating a tree, currently null
// something in this pattern:). Below is an extension to create a tree (GroupToTree)
public class Node<T>
{
public Node(T value, IEnumerable<Node<T>>> children)
{
Value = value;
Children = children;
}
public Node(T value, IEnumerable<Node<T>>> children, Player player)
{
Value = value;
Children = children;
[login to view URL] = player;
}
public T Value { get; set; }
public [login to view URL] Player { get; set; }
public string Test { get; set; }
public IEnumerable<Node<T>>> Children { get; set; }
}
public static IList<Node<T>>> GroupToTree<T>(this IEnumerable<IEnumerable<T>>> source)
{
return GroupToTree([login to view URL](sequence => [login to view URL]()));
}
private static IList<Node<T>>> GroupToTree<T>(IEnumerable<IEnumerator<T>>> source)
{
return [login to view URL]()
.GroupBy(iterator => [login to view URL])
Select(group => new Node<T>([login to view URL], GroupToTree(group)))
ToList();
}
Further part of the description in the link (in polish) because it didn't fit and in general the whole thing is here. I can give 25 EUR for the task. Payment after completing the order, if someone manages to do it, let's record a short video showing how this tree structure looks like for him, whether it's during debugging or the example of DevExpress TreeList. I need this structure just to attach it under TreeList WPF in DevExpress.
OPTIONALY:
- Add method for update tree structure when I will change MainName from collection or when I remove some element from collection then will be nice updated treelist
[login to view URL]
หมายเลขโปรเจค: #19049380
เกี่ยวกับโปรเจกต์
freelancer 9 คน กำลังเสนอราคาในงานนี้ โดยมีราคาเฉลี่ยอยู่ที่ €28
Hi there My name is Carlos and I'm an expert in .Net and sql server. I have been working in software developement for the last 20 years. I have many experience in desktop and web development. Regards
Hi, I've got quite some experience with Collections in C# and I'm sure I can help you out here. May I get some more details over the chat?
I have a experience in c# and tree and I will do my best to finish it as faster as I can ... maybe less than 2 days
Hello, I'm a Software Engineer from Argentina, Sr. C# Developer, I could help you with your project, but I need more info. Do you code this? There are syntax mistakes Is it an exercice college project? bes เพิ่มเติม