« first day (4422 days earlier)      last day (518 days later) » 

mr5
5:16 AM
RIP
I wish I still have access to my first written app in CLI
 
 
2 hours later…
7:33 AM
Good moaning
 
 
2 hours later…
mr5
9:05 AM
@CaptainObvious do you know if you can exchange access token for cookie?
 
 
1 hour later…
10:26 AM
I am using AspNetCore Identity to manage users, and I am trying to "flatten" an array of errors returned from creating a user with a password that doesnt meet the criteria, this is what I have at the moment but ideally I would like a oneliner
var result = await userManager.CreateAsync(user, registerDto.Password);
if(!result.Succeeded){
    string errorDesc = "";
    foreach (var error in result.Errors)
    {
        errorDesc += error.Description;
    }
    return BadRequest(errorDesc);
}
something like this would be nice return BadRequest(String.Join(", ",result.Errors)); but this doesn't work as the errors are objects with a code and a description
 
BadRequest(String.Join(", ", results.Errors.ToList().Select(x=>x.Description)) maybe?
 
The ToList() is probably not even needed.
 
Probably
 
Thanks, this worked, and yes it works without the tolist as well
 
this probably could be even more "onelinered" like return !result.Succeded ? BadRequest(String.Join(", ", results.Errors.Select(x=>x.Description)) : Ok(result);
 
10:40 AM
I'm not actually returning an Ok(), I am returning a instance of a new object, so it is probably better to leave it as is
 
They do be like that
 
 
1 hour later…
12:08 PM
[Captain Obvious] @mr5 who said it was my first app
[Captain Obvious] Also what access token/cookie?
 
 
1 hour later…
1:13 PM
Hey guys, I'm trying to convert a tree structure to a hierarchial list (I think its that at least).

so for instance this:
-1
-1.1
-1.2
-2
-2.1
-2.2

To this:
1, 1.1
1, 1.2
2, 2,1
2, 2,2

So parents essentially get duplicated
The depth can in theory be infinite and ive been wrapping my head around how I would do this recursively
I got a small test project with an input and expected output (small and simple project) if anyone wants to take a look that'd be great. :)
 
How is the first part a "tree structure"?
 
The chat threw away my spaces
1 contains 1.1 and 1.2
 
Try Ctrl+K when posting
 
and 1.1 could conain 1.1.1 etc.
 
Well what would the result be for 1.1.1?
 
1:22 PM
make 1 new "hierarchy item" for each deepest node if that makes sense. So the deeper nodes share their parents.
This is just an example irl its an acutal hierarchial tree
 
ah, I wrote this function a while back, lemme see if i can find it
 
dotnetfiddle.net/NbEYJM this is my test project to illustrate what I want
It shows a simplified input and expected output
 
wait, isnt the input and output swapped in the fiddle?
that looks like you want to flatten it to a single list
 
1:42 PM
Yes but the parent is duplicated for each item... its hard for me to explain thus to search. I think I might have to solution now, I'm gonna test it then change to fiddle so I can show you what I wanted :)
 
Meanwhile
Praise wpf
for it is amazing
That's entirely just a default CheckBox control
I know it's simple but it's so nice working with something that works nicely again
 
@EpicKip can you write a unit test explaining the input and output?
 
2:05 PM
It would require me to overwrite equals etc. in the test project. It would just be the example in and output I have now in the fiddle. Give me a sec ok
@Wietlol Wait explain the in and output...? ehm maybe we should just go to a prive chat and I'll explain roughly what the in and output is. But the input is always A thing with itself as children (so infinitely deep)
 
ah nvm, I thought your fiddle was the inverse of your earlier explanation
 
2:20 PM
In computer science, tree traversal (also known as tree search and walking the tree) is a form of graph traversal and refers to the process of visiting (e.g. retrieving, updating, or deleting) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited. The following algorithms are described for a binary tree, but they may be generalized to other trees as well. == Types == Unlike linked lists, one-dimensional arrays and other linear data structures, which are canonically traversed in linear order, trees may be traversed in multiple...
basically, you want to traverse your tree in depth-first pre-order
public static IEnumerable<T> SelectRecursivePreOrder<T>(this IEnumerable<T> elements, Func<T, IEnumerable<T>> selector)
{
    foreach (T element in elements)
    {
        yield return element;
        foreach (T child in selector(element).SelectRecursivePreOrder(selector))
            yield return child;
    }
}
the enumerable that you get back from this function will iterate over the tree in the order you want
after that, you could collect the results into a list
in your case, the usage would be something like this:
var output = (new [] {input}).SelectRecursivePreOrder(item => item.Children).ToList();
 
 
7 hours later…
9:43 PM
"The last message was posted 7 hours ago"
Well shit I should probably stop then
 
stop what?
 
Developing shit
 

« first day (4422 days earlier)      last day (518 days later) »