Ole (ping please)
Ole (ping please)
CC#
Created by Ole (ping please) on 6/6/2024 in #help
Unable to determine reason for publish error
ok, I managed to track it down. There is a warning, saying that there is different processing architectures between some projects. That causes the publish to fail
10 replies
CC#
Created by Ole (ping please) on 6/6/2024 in #help
Unable to determine reason for publish error
Yeah, its an old project. Lots of things to clean up
10 replies
CC#
Created by Ole (ping please) on 6/6/2024 in #help
Unable to determine reason for publish error
If someone could help me see where it goes wrong, that would be greatly appreciated
10 replies
CC#
Created by Ole (ping please) on 11/15/2023 in #help
Deserializing binary data
This is my current approach:
public class PluginPropertyValue
{
public uint propertyId { get; set; }
public byte rtpcAccum { get; set; }
public float fValue { get; set; }

public static PluginPropertyValue Create(ByteChunk chunk)
{
var instance = new PluginPropertyValue();

instance.propertyId = chunk.ReadUInt32();
instance.rtpcAccum = chunk.ReadByte();
instance.fValue = chunk.ReadSingle();

return instance;
}
}
public class PluginPropertyValue
{
public uint propertyId { get; set; }
public byte rtpcAccum { get; set; }
public float fValue { get; set; }

public static PluginPropertyValue Create(ByteChunk chunk)
{
var instance = new PluginPropertyValue();

instance.propertyId = chunk.ReadUInt32();
instance.rtpcAccum = chunk.ReadByte();
instance.fValue = chunk.ReadSingle();

return instance;
}
}
Where chunk is a helper around a memory stream
16 replies
CC#
Created by Ole (ping please) on 11/15/2023 in #help
Deserializing binary data
I just trying to explain the data layout. Its a custom format that there is no real documentation or name for. I have made a parser which basically reads ffield by field, but I am wondering if there is a "smarter" way of doing this. I have a lot of binary structures to serialize and deserialize so I am looking for improvments 🙂
16 replies
CC#
Created by Ole (ping please) on 9/7/2023 in #help
❔ Selecting child tables using EF Core
The dbContext only has the enterprise attribute. The other tables are added implecitly
10 replies
CC#
Created by Ole (ping please) on 7/30/2023 in #help
❔ Getting all instances from a IServiceScope
Because it requires me to store the variable. It means I would have to write something like this:
class MyClass : IDisposable
{
EventHub _hub;

public MyClass(EventHub hub)
{
_hub = hub;
_hub.Subscribe<ItemSaved>(this, OnSaved);
}

public void Dispose() => _hub.Remove(this);
}
class MyClass : IDisposable
{
EventHub _hub;

public MyClass(EventHub hub)
{
_hub = hub;
_hub.Subscribe<ItemSaved>(this, OnSaved);
}

public void Dispose() => _hub.Remove(this);
}
but what I really want is the following, as I never need the hub outside of create/delete
class MyClass : IDisposable
{
public MyClass(EventHub hub)
{
hub.Subscribe<ItemSaved>(this, OnSaved);
}

public void Unsub(EventHub hub) => hub.Remove(this);
}
class MyClass : IDisposable
{
public MyClass(EventHub hub)
{
hub.Subscribe<ItemSaved>(this, OnSaved);
}

public void Unsub(EventHub hub) => hub.Remove(this);
}
29 replies
CC#
Created by Ole (ping please) on 7/30/2023 in #help
❔ Getting all instances from a IServiceScope
I cant find a way of doing it, which is a bit strange. I agree its a bit of a corner case but it cant be that unusual. Would be good for some logging cases as well I would assume
29 replies
CC#
Created by Ole (ping please) on 7/30/2023 in #help
❔ Getting all instances from a IServiceScope
But that has the potential to be very inefficient? For a given scope there might be 500 potential classes, but depending on the incomming request, the path taken might only instanciate 5. Doing it that way will force the instanciation of all.
29 replies
CC#
Created by Ole (ping please) on 7/30/2023 in #help
❔ Getting all instances from a IServiceScope
That was my frist thought, but then I need to store the event subscriber class so I can call it from dispose. I never need it outside of dispose and the construtor so it would be kind of neat to have a void Unregister(EventHub hub) function in a interface
29 replies
CC#
Created by Ole (ping please) on 7/3/2023 in #help
❔ Help with Action syntax for event handler system
I feared so, thanks for clarifying. I dont deal with generics all that much and the rules for when things can be implied or not is still a bit of a mystery to me 🙂
7 replies
CC#
Created by Ole (ping please) on 7/3/2023 in #help
❔ Help with Action syntax for event handler system
I see I messed up my post a bit: This is working:
RegisterEventHandler<EventHandler, MyEvent>((x, e) => x.Process(e));
RegisterEventHandler<EventHandler, MyEvent>((x, e) => x.Process(e));
But the (x,e) syntax is not all that clean. So I would love doing x.Process and have the e implied
7 replies
CC#
Created by Ole (ping please) on 6/17/2023 in #help
❔ Getting the last data registration time for multiple locations
sorry for being unprecise and thanks a lot for explaining.
15 replies
CC#
Created by Ole (ping please) on 6/17/2023 in #help
❔ Getting the last data registration time for multiple locations
so OrderBy(x=>x.prop) and Max(x=>x.prop) would both point to a base sql type
15 replies
CC#
Created by Ole (ping please) on 6/17/2023 in #help
❔ Getting the last data registration time for multiple locations
But all SQL types have a comparor right?
15 replies
CC#
Created by Ole (ping please) on 6/17/2023 in #help
❔ Getting the last data registration time for multiple locations
what is the difference between using orderByDec().First over Max() in this case?
15 replies
CC#
Created by Ole (ping please) on 6/17/2023 in #help
❔ Getting the last data registration time for multiple locations
Yeah, that sounds like a way more resonable approach. Thanks!
15 replies
CC#
Created by Ole (ping please) on 5/16/2023 in #help
❔ Sorting a list of objects into a tree structure
I feared so
8 replies
CC#
Created by Ole (ping please) on 5/16/2023 in #help
❔ Sorting a list of objects into a tree structure
The actual visualization is not important, I was mostly interested in finding out if there was a somewhat built in way in c# to turn a flat structure into a tree. I do this a fair bit for different data structures and it would be nice to learn a 'trick' if there is one. I threw this together:
var rootItems = new List<TreeBusItem>();
var roots = busses.Where(x => x.OverrideBusId == 0).ToList();
roots.ForEach(x => rootItems.Add(new TreeBusItem(x, audioRepo)));

foreach (var item in roots)
busses.Remove(item);

while (busses.Count != 0)
{
var toDelete = new List<CAkBus_v136>();
foreach(var bus in busses)
{
var parent = FindParent(rootItems, bus.OverrideBusId);
if(parent != null)
toDelete.Add(bus);

parent.Children.Add(new TreeBusItem(bus, audioRepo));
}

foreach (var item in toDelete)
busses.Remove(item);
}
var rootItems = new List<TreeBusItem>();
var roots = busses.Where(x => x.OverrideBusId == 0).ToList();
roots.ForEach(x => rootItems.Add(new TreeBusItem(x, audioRepo)));

foreach (var item in roots)
busses.Remove(item);

while (busses.Count != 0)
{
var toDelete = new List<CAkBus_v136>();
foreach(var bus in busses)
{
var parent = FindParent(rootItems, bus.OverrideBusId);
if(parent != null)
toDelete.Add(bus);

parent.Children.Add(new TreeBusItem(bus, audioRepo));
}

foreach (var item in toDelete)
busses.Remove(item);
}
I am not really interested in feedback on this as the code will just be thrown out again, but if there is a clever linq way to do something like this let me know 🙂 With the temp data class TreeBusItem and the FindParent its about 100 lines which is a lot of wasted time for something like this.
8 replies
CC#
Created by Ole (ping please) on 4/5/2023 in #help
❔ How to handle migration with column changes in Ef Core code first?
That is a bummer, as my SQL skills are way lower then C#
7 replies