Recreate extension or make other methods for create TreeStructure C#

Preklicano Objavljeno pred 4 letoma/leti Plačilo ob prevzemu
Preklicano Plačilo ob prevzemu

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]

C# programiranje Arhitektura porgramske opreme

ID projekta: #19049380

Več o projektu

9 predlogov Oddaljen projekt Aktiven pred 4 letoma/leti

9 freelancerjev ponuja v povprečju za €28 na tem delu

carlosperezit

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

€24 EUR v 1 dnevu
(33 ocen)
5.2
harshdaga

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?

€25 EUR v 1 dnevu
(45 ocen)
5.1
yoyo09

Hello,I am ready to start right away,i am an expert in web development with experience of 5 years,so i assure you that I can help you in your venture and do a good job. Please feel free to discuss with me. best rega Več

€20 EUR v 4 dneh
(0 ocen)
0.0
omarkamoon

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

€24 EUR v 2 dneh
(0 ocen)
0.0
juampavilla

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 Več

€19 EUR v 5 dneh
(0 ocen)
0.0
vlkadiya

Hi, I go through the job description and i am very confident to make this requirement complete. I have 7+ years of professional experience in Microsoft technology. You may come on chat and let's discuss in details. He Več

€39 EUR v 3 dneh
(0 ocen)
0.0