Determinism
❔ Is it possible to serialize this struct?
Hello,
I want to serialize this struct to json:
I'm have these methods:
Is it possible? At the moment it only returns 2 bytes (the curly braces). I'm assuming this has something to do with the marshalling because it works without it
12 replies
Avoiding 'new' in IOC
Hello,
I am learning about dependency injection and one of the things said to avoid is using
new
in the constructor. How can I avoid doing stuff like this:
where I need _sendingClient
throughout multiple methods in the class?
Thanks!151 replies
❔ Refactoring a Tag class
I have a
Tag
class that has the ability to store information about tags. Each tag has several properties associated with it. For example:
I am trying to think of a more efficient way to handle this. At the moment, each tag is stored in a json file and then loaded on startup. Therefore, I am accessing each tag with a string, and getting each property based on this file.
It works, but I think it could be better. I'm running into issues of bringing stuff back into memory with this setup. Any suggestions are welcome, thanks.33 replies
Protobuf deserialization not working after upgrade to .net 6
Hello,
I am trying to deserialize a buffer (byte array) into a model. I upgraded my solution from core 3.1 to 6 and it no longer works. I am receiving the error
My code is :
Thanks for any help in advance.
30 replies
Converting ReadOnlySequence of bytes to object
I have to convert a
ReadOnlySequence<byte>
to an object, the way I'm doing it currently is like so:
Is there a better way to handle this? BitConverter doesn't support ReadOnlySequence, so I would have to convert it to a byte array which is not ideal. I also have tons of properties on this model so it is a ton of code. Thanks in advance!59 replies
Image switching on bool change [Answered]
Hello,
I have an image in a Blazor Server app that changes as a boolean value changes. The image flip happens, but the image flickers before being rendered to the screen. This only happens sometimes, so I figure it has something to do with the rendering speed. I am rendering it like so:
TLDR: image flickering on bool value change in blazor
9 replies
TCP - The IO operation has been aborted because of either a thread exit or an application request
Hello, I am trying to implement a class that connects to a server through TCP, receives a message, opens a server, then sends a message through that server to all connected clients. This class seems to work, however, incrementally I will receive:
and then eventually:
https://hastebin.com/depiviqoci.csharp
4 replies
WriteAsync doesn't always send data to all connected clients
I am making an application that has a TCP client that listens for messages from a TCP server, then puts those messages in a queue, then sends all of the queued messages to the connected TCP clients of the server started. The application is working, but sometimes
WriteAsync
doesn't send the same amount of messages to all clients. Any ideas of what the issues is, and also what can I improve on in this code?
https://hastebin.com/fejosepufi.csharp
Thanks18 replies