|
CapnAndy posted:So I'm playing with .NET 5 now that it's out, and you can make .dbml files again, but there's no System.Data.Linq, so as far as I can tell, they don't frigging do anything.
|
# ? Dec 10, 2020 20:16 |
|
|
# ? Jun 8, 2024 12:47 |
|
mystes posted:Isn't that LINQ to SQL which has been deprecated for years (for some reason)?
|
# ? Dec 10, 2020 22:22 |
|
Say I have an ASP.NET WebAPI server, with a handful of WPF clients. When a user opens a record and saves it, after the save operation is completed successfully, the server broadcasts "record with id=42 updated!" to all the clients. The clients then all request the latest copy of record with id=42. This is turning out to be a bit "bursty". With a small number clients it's fine, but when the number of clients is high, and one saves a record, 20 or 40 or 60 other clients all request the latest copy of that record, at the same time, and basically DOS the server. The EF query to get the record is pretty quick (a few ms). The network is fast (a few ms). We've played with RabbitMQ, and SignalR, we're not married to a particular message queue system. In a pub/sub environment like this, how does one avoid these bursts? We're considering a few things. 1. Spacing out the broadcast so they don't all ask at the same moment 2. Caching the record we know everyone is about to ask for, in memory on the server 3. Sending the whole object with the broadcast, but this seems wasteful because not all clients necessarily need it Any advice?
|
# ? Dec 11, 2020 03:28 |
|
epalm posted:Say I have an ASP.NET WebAPI server, with a handful of WPF clients. Can you add a small amount of randomness to when the clients request the record? I know you can do that with a retry policy using Polly. Decent MS doc on the idea: https://docs.microsoft.com/en-us/do...l-backoff-polly
|
# ? Dec 11, 2020 03:55 |
|
WPF continues. I'm now trying to switch between "screens." Each screen is its own UserControl. I've been working on them in separate WPF windows for development but they'd ultimately be manipulated through a common control. I figured I needed a control with it's own view model containing which control to currently present., but it seems like a perversion to use a view model to represent literal GUI controls. I also can't figure out how to plumb it. What I saw was to add a mention of each of my different screen user controls into my resource dictionary under data templates. I can extract the templates from the dictionary in code but I can't extract the actual user control because I don't know what to feed DataTemplate.FindName's templated parent argument. I'm not entirely convinced I even what a template because it sounds like it's not actually an instance. I think I want to actually instantiate some of this stuff at launch. My main use case here is to gray out loading a game if I don't have any saves, and to gray out or hide saving a game from the main menu if a game hasn't started yet. Assuming I get past this, all of the screens I'm switching between having some notion of going back (main menu goes back to game, others go back to main menu). What's an appropriate way pass each of these some reference so that it knows how to change the screen? Edit: I still don't know what the answer really is, but I'm trying something using a template selector attached to a content template selector properly on a content control. I'm not at the point where I got to start switching it in and out so we'll see if that's actually the thing to do or not. Rocko Bonaparte fucked around with this message at 09:31 on Dec 14, 2020 |
# ? Dec 11, 2020 17:47 |
|
Eldred posted:Can you add a small amount of randomness to when the clients request the record? I know you can do that with a retry policy using Polly. Decent MS doc on the idea: https://docs.microsoft.com/en-us/do...l-backoff-polly +1 for Polly. You can also protect on the server side with Polly to allow only a few requests at a time to enter critical parts, and having everything else wait it's turn. https://github.com/App-vNext/Polly E: Hell from your use case, it sounds like server side Bulkhead Isolation+cache policywrap with a relatively short lifetime may do exactly what you need.
|
# ? Dec 16, 2020 15:18 |
|
So its possible to build a project for multiple target frameworks now, but there's no way to build a project with two or more SDKs right? Is the best way to achieve this to have two .csproj files?
|
# ? Dec 16, 2020 19:11 |
|
Mata posted:So its possible to build a project for multiple target frameworks now, but there's no way to build a project with two or more SDKs right? Is the best way to achieve this to have two .csproj files? This smells a lot like an X-Y problem. What do you need to achieve by building with multiple asks?
|
# ? Dec 16, 2020 22:03 |
|
Is there a general way in WPF to tell where a view model of mine is actually getting decided to be constructed? The specific issue is that I'm creating an instance of the view model in question as part of the navigation for my main window. I had to define the view model as a data template in the main window's xaml. I have a content control using a template selector that determines the current bound view model and returns that data template. I think that process creates its own instance of the view model I care about. I can kind of see it happening with breakpoints. I can see it returning the data template I want to use, and the next thing along the way is creating that view model. I guess I should also add that this generally does work. The initial menu does get shown correctly but that's with the defaults. The problem is the new one I want to show needs a little more information to work correctly. In particular, it needs a reference back to the main window to tell it to show itself. Alternately, the main window needs to know to do the change instead. Since this view model instance that came from an anonymous default constructor is the one the runtime actually has, it finds this back reference is null. I suppose if anybody has any general idea how I might plumb this, then I'd like to know. Architecturally, I have a view model for the overall presentation of the screen. It basically just contains which view model is currently active. This parent view model is aware of the children and vice versa... if I can actually introduce them in the code. Right now, the children are getting independently created by the framework. I don't know how I can get them in touch with each other. I sense that some of you deal with these view model relationships a lot and have been talking about dependency injection for this kind of situation.
|
# ? Dec 17, 2020 09:27 |
|
NihilCredo posted:This smells a lot like an X-Y problem. What do you need to achieve by building with multiple asks? Yeah it does, doesn't it? Specifically I got a Monogame passion project (Yes I'm using .NET recreationally) which can be built to target DirectX or OpenGL. The GL one is cool because it uses SDL to handle window creation and input, the only issue is poor GL support on older radeon cards, and for this reason I want to also build a version of my game using the DirectX DLL, but the DX version of Monogame uses System.Windows.Forms for windows and input. Using System.windows.forms in .NET5 means I have to use the net5.0-windows SDK (and set a few properties in the .csproj, but this can be done conditionally. The SDK can not). There's a few different approaches I could use to tackle the X problem, such as trying to generate radeon-compatible GLSL shaders, or simply using the SDL window to host the DirectX context as well. But building out two separate versions (of which one references System.Windows.Forms) seemed like the easiest way forward. Mata fucked around with this message at 12:16 on Dec 17, 2020 |
# ? Dec 17, 2020 12:13 |
|
Rocko Bonaparte posted:Is there a general way in WPF to tell where a view model of mine is actually getting decided to be constructed? The specific issue is that I'm creating an instance of the view model in question as part of the navigation for my main window. I would recommend defining all viewModels in code rather than the view itself. I like to disable startup in app.xaml and override a method to do it from app.xaml.cs where I can load my mainViewModel using a DialogService to open the window. This service is also used to open any other windows I may need. This is the key method: code:
|
# ? Dec 18, 2020 00:09 |
|
GoodCleanFun posted:I would recommend defining all viewModels in code rather than the view itself. I'm nonetheless still trying to figure out how I could use a manually created view models to get around these phantom ones that are getting created in the stead. I am actually getting thwarted throwing them in the resource dictionary; they're not resolving when I try to look them up and I don't see anything like them in the application's resource dictionary. It's a mystery. I'm still trying stuff though so I'm not totally lost again.
|
# ? Dec 19, 2020 00:45 |
|
Rocko Bonaparte posted:Is that "define" or "declare?" I'm trying to shove instances of view models into my resources, so I would guess that counts as a declaration instead of definition. But that only matters based on what you meant. Declare, thanks for catching that. Stop setting DataContext in xaml and do it in C# as mentioned. If you create and control all the viewModels in code there should not be confusion.
|
# ? Dec 19, 2020 04:42 |
|
Mata posted:Yeah it does, doesn't it? code:
code:
code:
code:
|
# ? Dec 23, 2020 01:14 |
|
What is the best way to take HTML and transform it into valid XML? I have some web pages I want to scrape and turn into something I can use System.Xml.Linq on but it doesn't start out in a form that XElement.Parse() will tolerate, loads of stuff that's not valid in XML. Stack Overflow has a question about this but the answers are mostly dead links. This seems like the most "alive" project linked from the SO post: https://html-agility-pack.net/ Has anyone used that?
|
# ? Dec 25, 2020 11:57 |
|
I've used HTML Agility Pack for a cursed module that converts rich text back and forth between XAML and HTML. It worked well for me, but I can trust the input HTML to be well-formed and have a very simple structure, so I can't say how good it is at handling nonconformant markup and whatnot. The project is definitely alive, judging by how often they release new versions.
|
# ? Dec 25, 2020 12:16 |
|
Hammerite posted:What is the best way to take HTML and transform it into valid XML? I have some web pages I want to scrape and turn into something I can use System.Xml.Linq on but it doesn't start out in a form that XElement.Parse() will tolerate, loads of stuff that's not valid in XML. Stack Overflow has a question about this but the answers are mostly dead links. This seems like the most "alive" project linked from the SO post: https://html-agility-pack.net/ Has anyone used that? Do you actually need well-formed XML, or are you just trying to scrape a page? Because if you’re just trying to scrape HTML, adding a step where you generate XML is probably unnecessary, and you can just use that library directly. (The last time I checked it was the go-to .NET scraping library.)
|
# ? Dec 25, 2020 16:36 |
|
If you need to do HTML parsing, use Anglesharp. IMO it's so much better than HTML Agility Pack: Its API makes way more sense and easier to set up and use, it's fast, it's easy to run Javascript commands on the parsed HTML, and it supports DOM querySelector. So you can test selecting elements inside the browser and pluck them out much easier than what you would have to do in HTML Agility Pack.
|
# ? Dec 25, 2020 17:18 |
|
Drastic Actions posted:If you need to do HTML parsing, use Anglesharp. IMO it's so much better than HTML Agility Pack: Its API makes way more sense and easier to set up and use, it's fast, it's easy to run Javascript commands on the parsed HTML, and it supports DOM querySelector. So you can test selecting elements inside the browser and pluck them out much easier than what you would have to do in HTML Agility Pack. This looks awesome. I’ve never used it but I’d recommend it anyway. Agility pack was a hot mess to use the last time I tried it a few years back.
|
# ? Dec 25, 2020 17:44 |
|
Drastic Actions posted:If you need to do HTML parsing, use Anglesharp. IMO it's so much better than HTML Agility Pack: Its API makes way more sense and easier to set up and use, it's fast, it's easy to run Javascript commands on the parsed HTML, and it supports DOM querySelector. So you can test selecting elements inside the browser and pluck them out much easier than what you would have to do in HTML Agility Pack. I don't want to run JavaScript on it, and I don't care what a browser would make of the HTML I download. The pages contain tables of data. I want to read some data out of the tables and then further transform the data. I want to do that using the tools provided in the System.Xml.Linq namespace, because I'm comfortable with those tools.
|
# ? Dec 25, 2020 22:11 |
|
HAP exposes the DOM via IEnumerable<HtmlElement>, so you can write LINQ against that. It will be regular LINQ-to-Objects, but I don't know if that's missing anything that System.Xml.Linq has.
|
# ? Dec 25, 2020 23:10 |
|
Hammerite posted:I don't want to run JavaScript on it, and I don't care what a browser would make of the HTML I download. The pages contain tables of data. I want to read some data out of the tables and then further transform the data. I want to do that using the tools provided in the System.Xml.Linq namespace, because I'm comfortable with those tools. I just realised this came across really arsey, which I didn't mean for it to. Sorry. I actually ended up making my own little class that fucks around with the HTML to turn it into something the XML parser will accept. There are about half a dozen faults that the HTML can have as XML, and I'm just manually fixing them*. But I appreciate the suggestions and I know about them for the future now. * "fixing" usually means changing the HTML into something not equivalent to the original, because it's in a part of the page I know I don't care about.
|
# ? Dec 26, 2020 11:42 |
|
Since people in this thread like AngleSharp so much, could someone give an example of how you're supposed to use the default configuration but set headers in the current version? The documentation seems to be astonishingly bad. Or does everyone just make the requests separately and feed the result to AngleSharp because it's not worth the trouble to use the built in functionality? Edit: If I google it looks like there should be a Configuration.WithRequestors method which seems like it should be an extension method defined in AngleSharp.Io but it doesn't seem to exist in the version of AngleSharp I'm getting from nuget? Edit 2: Oh my god there's a separate AngleSharp.Io package even though the AngleSharp.Io namespace is also defined in the main AngleSharp package just to be confusing jesus christ. Why the heck isn't this documented on https://anglesharp.github.io/ which just links to the main nuget package? Edit 3: I'm still just getting null from OpenAsync whatever I do with no error message, lol. mystes fucked around with this message at 17:24 on Dec 27, 2020 |
# ? Dec 27, 2020 16:54 |
|
mystes posted:Since people in this thread like AngleSharp so much, could someone give an example of how you're supposed to use the default configuration but set headers in the current version? The documentation seems to be astonishingly bad. This is how I have it set up: 1. Handle all requests myself through HttpClient. 2. Create a new AngleSharp.Html.Parser.HtmlParser 3. Parse the HttpClient results with HtmlParser.ParseDocumentAsync, keeping the IHtmlDocument it creates. 4. Handle that document in other classes.
|
# ? Dec 27, 2020 19:52 |
|
Oh man I found out the NoesisGUI theme is a default that highlights defaults in hot pink to compel you to use your own theme. So I'm supposed to actually define a theme for all the controls I'm using. My brain melts.
|
# ? Dec 28, 2020 08:16 |
|
Drastic Actions posted:This is how I have it set up:
|
# ? Dec 28, 2020 14:59 |
|
Does anyone know why System.Drawing.Graphics.CopyFromScreen would run slow in the current (or close to - 6.8.0.105) version of Mono on linux? It's 10-100 times slower than it should be. Normal time to capture a frame should be a few milliseconds, increasing slightly with resolution. Easily fast enough for real time video capture when run in Windows on the .NET runtime (not Mono), and through an old version of Unity with whatever really old version of the Mono runtime that ships with. Using the new Mono runtime: Running in Monodevelop takes 435 ms to capture 1 frame at 1920x1080. Running in Godot gets about this speed too. Unuseable for real time. Running the exe of the same code takes 38 ms to capture 1 frame at 1920x1080. Better but still too slow. Using .NET runtime on a Windows machine, windows virtual machine, or through Unity with the old Mono runtime: 3.75ms to capture 1 frame at 1920x1080. It's really annoying that the performance of a basic old function would get worse like that.
|
# ? Dec 28, 2020 16:19 |
|
Rocko Bonaparte posted:Oh man I found out the NoesisGUI theme is a default that highlights defaults in hot pink to compel you to use your own theme. So I'm supposed to actually define a theme for all the controls I'm using. My brain melts. Counterpoint: lean into it and have your app be Barbie-mode by default.
|
# ? Dec 28, 2020 19:52 |
|
Nth Doctor posted:Counterpoint: lean into it and have your app be Barbie-mode by default. Unfortunately, not everything has that color or I would really be pondering that right now!
|
# ? Dec 29, 2020 07:26 |
|
So baby's first foray into styles. I think the typical thing grown-ups do is define them completely as resources, but I believe I should also be able to define a style with the component I'm creating. This seems to work in my standalone WPF application but not in Noesis GUI in Unity. I'm checking with them on their forums, but I wanted a sanity check from the regular .NET side. Is something like this a normally okay thing to do?code:
|
# ? Dec 30, 2020 00:59 |
|
Rocko Bonaparte posted:So baby's first foray into styles. I think the typical thing grown-ups do is define them completely as resources, but I believe I should also be able to define a style with the component I'm creating. This seems to work in my standalone WPF application but not in Noesis GUI in Unity. I'm checking with them on their forums, but I wanted a sanity check from the regular .NET side. Is something like this a normally okay thing to do? From https://www.noesisengine.com/docs/Gui.Core.StylingTutorial.html quote:Controls can only have one style set in its Style property, so if a few properties need to be locally overridden remember to define BasedOn in local style to inherit the rest of properties from the style defined in application dictionary. If BasedOn is omitted, property values will fallback to the debug default style defined by Noesis theme. WPF controls can only have one style - the styles don't cascade out of the box (to get that effect, there's a property 'basedOn'). So I think if you don't define BaseOn property, it'll just use the debug style and ignore what you put inline. The documentation for noesis seems to be strongly encouraging you to put some kind of style in the app dictionary, and then override it inline using based-on property. (I've never used noessis I just googled this)
|
# ? Dec 30, 2020 17:28 |
|
Bruegels Fuckbooks posted:(I've never used noessis I just googled this) Do you remember what you googled to get that? I wasn't getting anything and I want to figure out the magic words. I would not be surprised that's the thing since all their examples looked like resource dictionary stuff. So I guess I'll toy around with it in Visual Studio to get the effect using a resource dictionary and then transplant it over. Edit: Apparently they came to me in a post in their own forum about it. I have to set the Template property for anything to actually take effect. Well, I'll be trying that and then moving to the resource dictionary since it seems like the hip thing to do. Rocko Bonaparte fucked around with this message at 17:49 on Dec 30, 2020 |
# ? Dec 30, 2020 17:47 |
|
Rocko Bonaparte posted:Do you remember what you googled to get that? I wasn't getting anything and I want to figure out the magic words. I would not be surprised that's the thing since all their examples looked like resource dictionary stuff. So I guess I'll toy around with it in Visual Studio to get the effect using a resource dictionary and then transplant it over. I started off googling "inline style wpf" just to get a refresher on how that worked - then I remembered you mentioning something about that hot pink theme, wondered how that would work, and googled "multiple style wpf" because I didn't know which would win, resource style or "inline" style (I didn't remember it was called "local" style, I should've looked that up). This led to a stackoverflow article about "how to apply multiple styles in WPF", which said https://stackoverflow.com/questions/16096/how-to-apply-multiple-styles-in-wpf quote:I think the simple answer is that you can't do (at least in this version of WPF) what you are trying to do. Remembering that stuff about the hot pink theme, it occurred to me that since last style applied wins, if they were applying that style programmatically, it would blow out the inline style. So this led me to think this problem was related to the handling in noesis somehow. I then thought "hey, you know, this Noesis gui thing probably has some kind of documentation." So I googled "noesisgui style" - and that lead to the article I linked, which gave an overview of how the styling worked. I figured that whatever was going on with the styles was something done by the framework, so I did a control-F for "pink" - and it showed up in that document. I found the stuff about the local styles (I didn't remember it was called "local style") by reading around the places that mentioned how that theme worked.
|
# ? Dec 30, 2020 18:20 |
|
I was feeling better about myself until "noesisgui style" because I was trying that search term too and probably saw that page as well, but I wouldn't have been able to tell the significance of it. Regardless, setting the template is what got it to take effect, but I think I should move it into my resources. I can't put that directly in an App.xaml due to how it integrates with Unity. NoesisGUI does have an App.xaml for standalone usage but not for Unity integration. I have a separate resources XAML that I've been using and merging into my various controls. Is the normal thing here to create a dedicated "theme" XAML that merge in as a part of my resources? Do people normally keep that decoupled from resource XAML that does structural stuff?
|
# ? Dec 30, 2020 20:15 |
|
Can anyone recommend a markdown -> HTML renderer? e: I'm assuming that anything decent offers separate parsing and rendering operations, but if not, I need one that does. raminasi fucked around with this message at 22:44 on Jan 2, 2021 |
# ? Jan 2, 2021 22:41 |
I am so unhappy with the resources I have available to me. I have been poking around with ASP.Net stuff, entity framework, and all of that, but the course that was guiding me is so garbage that I just can't deal with it anymore, and the resources that come up from my googling (microsoft tutorials, stuff like https://www.learnentityframeworkcore.com) are very general. They help a bit, like hey it's neat that I can write a basic context class on my own now. I wasn't getting that poo poo at all before. But I guess I'm looking for freely available course-level stuff, if anything like that is out there. I simply lack enough of a knowledge base to be able to say, "I want to make x project" and then just sort of consume whatever I need to get there. I have a book on C# 8.0 by Ian Griffiths, and it's an okay resource, but again not really useful by itself it seems. I really wish I could just afford proper paid courses GDI Anyway if any of y'all have those kinds of recommendations or resources to share, I'd love to get my hands on them.
|
|
# ? Jan 3, 2021 04:29 |
|
Riot Bimbo posted:I am so unhappy with the resources I have available to me. There's definitely a lot of mediocre (or just outdated) material out there. Are you learning just to learn, or are you working on a project? "Learning just to learn" is a bit like learning music notation without actually playing an instrument. I can learn what all these symbols mean, in depth, but unless I actually make some noises with an instrument (and fail a lot, and stick with it, and slowly get better) I'm not getting any meaningful work done.
|
# ? Jan 3, 2021 04:45 |
|
Riot Bimbo posted:I am so unhappy with the resources I have available to me. Might want to check out IAmTimCorey on YouTube. He’s got a ton of C# material, and while I’m not a fan of some elements - his use of Dapper for database access, and Caliburn Micro for MVVM in particular - he’s got a lot of (IMHO) decent content.
|
# ? Jan 4, 2021 01:11 |
|
dapper is real good how dare you
|
# ? Jan 4, 2021 01:52 |
|
|
# ? Jun 8, 2024 12:47 |
|
Seconding Tim Corey. He has a ton of great free content.
|
# ? Jan 4, 2021 02:54 |