|
I've got a list of items, and I wish to configure sub-lists of of these items based on users configurations. I've got this idea for the moment, but I'd like an opinion on it. This will have to run when generating an ASP.NET page, and I'm worried that it'll get slow as more and more predicates are added.code:
|
# ¿ Jun 26, 2014 15:04 |
|
|
# ¿ May 2, 2024 15:37 |
|
EkardNT posted:
I had realized the first part of your post more or less immediately after posting. The return line above though is what I was really missing though - I was sure that it was possible to syntax my way out of writing the nested loops. I'm a little impressed that it went all the way down to one line though! Thanks edit: Here's a followup that I maybe should have considered beforehand. Is it possible now to serialize instances of my CustomList class? At first glance, it doesn't look trivial to serialize predicates that are defined in run-time. But since my predicates are relatively simple, I could probably wrap them in a class that is easily serializable. eg, code:
Newf fucked around with this message at 19:46 on Jun 26, 2014 |
# ¿ Jun 26, 2014 19:02 |
|
Here's a real easy ASP.NET question for everyone. I'm trying to display a list of strings in a ListView, but the examples I'm working from all work from all bind to properties of the bound objects rather than the objects themselves. EG, the //what goes here line is expressed using something like <% #Eval("PropertyX") %>. How do I display the bound object itself (they're just strings!).code:
Newf fucked around with this message at 17:50 on Jun 27, 2014 |
# ¿ Jun 27, 2014 17:38 |
|
More trouble in ASP land. I think that my goal should be obvious from the code, but I'm having a lot of trouble googling the right answers. I'm working with a ListView, and States is an (incomplete) array of two letter State abbreviations.code:
Suggestions? Newf fucked around with this message at 19:13 on Jul 9, 2014 |
# ¿ Jul 9, 2014 19:09 |
|
It's perhaps not clear, but I am in a databound control (note that the first <%# Eval("States.Length") %> works). The problem is that the control is bound to an object which has a number of arrays as members, including the present States array. The solution then, I guess, is to bind more specifically to the States array rather than its parent object.
|
# ¿ Jul 9, 2014 19:21 |
|
wwb posted:You have a few issues in this code. First thing, don't try and convert int to strings and then do int things to them (error #1). Response.Write() is also an abomination that should generally be avoided in ASP.NET webforms as it really screws with the page lifecycle. Holy poo poo, this is great. The whole webforms thing is really still a mindfuck to me. The way that you can mix markup and code is kinda magical. Also, being able change this code on the fly and having it reflected on the next page load. I guess the c# is compiled on the fly when there's a page request? Thanks all. I did end up binding directly to the States list (and then did the same for the other lists I wanted on the page).
|
# ¿ Jul 10, 2014 02:15 |
|
Ithaqua posted:Or, better yet, don't use webforms if you don't have to. To follow up on this... The context here is that I'm making a web front-end that interfaces with a windows service which exposes a bunch of controls exposed via [ServiceContract] class and [OperationContract] methods. I'm using svcutil.exe to generate the client class for the webapp. I understand that webforms are maybe on the way out, but they do seem like the simplest tool that's adequate for the job. Nothing super fancy will be going on - mostly CRUD interaction and configuring the windows service. Am I wrong about this? Are there reasons that I'd be better off going for an MVC2 app? (VS2010)
|
# ¿ Jul 10, 2014 13:20 |
|
I cannot help, but you have my sympathy. These are the parts of development that make me want to jump out of a plane.
|
# ¿ Jul 11, 2014 12:51 |
|
What method does HashSet<> use in order to determine whether an element is already a member of the set? I've got a set of bean objects, but I'd like only one field in the bean to be the 'key' for insertion. Eg, I want to prevent the insertion of new objects into the set if it's key is already contained in the set. I has assumed from the name that it was checking hashes as a unique ID, but the following doesn't work: code:
|
# ¿ Jul 16, 2014 14:35 |
|
That had occurred to me, but wouldn't a dictionary's default action be to overwrite the data associated with an existing key with the new data? (edit: it throws an exception.) I want to keep the original. In particular, the only thing that changes with the new inserts is a timestamp, but I'm only interested in knowing the earliest timestamp. Semantically, it's a set of these objects, and the 'Key' here is itself data, so I don't like splitting the object into Key / Value. Newf fucked around with this message at 15:43 on Jul 16, 2014 |
# ¿ Jul 16, 2014 15:06 |
|
Bognar posted:This is correct. HashSet first checks the hash, then checks for equality using the specified equality comparer (which will most likely be EqualityComparer<T>.Default which uses .Equals()). Ah, that clarifies. Overriding Equals did work (thanks Betjeman!), but I was confused because I knew that Add (and Contains) were supposed to be O(1), so I figured that it had to be checking with GetHashCode(). Makes sense that it's done as a first pass. Thanks all.
|
# ¿ Jul 16, 2014 15:10 |
|
Ithaqua posted:Can you describe the initial problem in a little bit more detail? I'm always wary of the XY Problem rearing its head. It's really not a complicated issue, and either implementation works, I think. I've left it as it because the Equals override was only a couple of lines and I'd rather not have to wrap my Adds in Try/Catch blocks. The initial problem is to keep a list of objects (they're boats, incidentally) who have requested a service. Each boat, after requesting service, will receive a default service until the service is configured (server side) for them by an administrator. I just want to keep a list of boats who have requested service but remain unconfigured. I also want the dates at which they first requested service. So the bean is just a unique identifier for the boat (the key in my problem), the boat's "common name", and the date of the service request. It's possible for a boat to make several service requests before the administrator configures them, but I don't want double/triple/ ect records of that.
|
# ¿ Jul 16, 2014 15:53 |
|
Ithaqua, Bognar posted:Stuff My prejudice towards sets here probably comes from my math background. I do recognize that it's better practice to use a dictionary, specifically for the reason Ithaqua mentioned of constructing lovely hash codes. In this case though, the hash code is just inheriting from String.GetHashCode(), so there's no chance that it's bad...
|
# ¿ Jul 16, 2014 18:06 |
|
I've thrown a bootstrap tarp over a .net webforms app. I used this starter template and things have gone peachy with one little hickup. The markup for the navbar is in my WebApp.master markup file, which is then followed by a ContentPlaceHolder for my pages to go. The problem is that I'm not sure how best to go about altering the nav element that's tagged as 'active' when clicking from one page to the next.code:
edit: Ok, that worked. I gave each <li> an id and runat="server" and something along the lines of code:
Newf fucked around with this message at 19:26 on Jul 17, 2014 |
# ¿ Jul 17, 2014 19:13 |
|
I'd like to know what gets spit out by Path.GetInvalidFileNameChars(). Is there a more reasonable thing for me to do than boot up a new console app and print them to screen? I feel like Visual Studio should have some sort of console that I can type commands like this into.
|
# ¿ Jul 25, 2014 14:46 |
|
That's great! Thanks! Ctrl+alt+F opens this console in VS 2010 and up, for anyone who's wondering. My knowledge of F# has now increased from nothing to "it's like C# except you use two semicolons". I'm confident that this is accurate.
|
# ¿ Jul 25, 2014 14:57 |
|
All very useful suggestions. Thanks!ljw1004 posted:(1) Launch VS. You have to load a project -- any old project will do. Not quite, I'm afraid! Apparently: msdn posted:You cannot use design time expression evaluation in project types that require starting up an execution environment, including Visual Studio Tools for Office projects, Web projects, Smart Device projects, and SQL projects.
|
# ¿ Jul 25, 2014 16:43 |
|
I'll second that. I'm a complete rear end whenever it comes to deciding things like typography and colors, but I'm currently having a good deal of success with a work project that I essentially threw a Bootstrap tarp over the top of.
|
# ¿ Jul 25, 2014 18:01 |
|
Bognar posted:complete lack of syntax support (even through plugins) in Visual Studio for JSX. .NET devs who want to +1 in the name of progress on this front can do so here: http://webessentials.uservoice.com/forums/140520-general/suggestions/4935998-add-reactjs-jsx-support
|
# ¿ Jul 29, 2014 00:44 |
|
Volte posted:There is strong reason to believe that Xamarin will be part of Visual Studio in the not too distant future, so there's still hope. Looking forward to a $1600 VS 2015! Side note, someone in the oldie thread seems to want to quit his job because they've decided to move to xamarin. If you people like it he may benefit from hearing so.
|
# ¿ Jul 30, 2014 16:19 |
|
gently caress them posted:The users like a "walk along search", that is, as you type, every lift of your key makes the current string in the searchbox fire a search event. Right now this is done with an incomprehensible mishmash of codebehind, <%eval%> magic, and $get() from the ajaxtoolkit I confused with jQuery for a long time. And their own custom gridview that was opaque and undocumented. And reams of commented out code. I'm currently enjoying great success with this sort of thing via selectize. I'm using it as a configuration tool, and it was really easy to attach ajax events to the menu so that it updates my model on the fly. The below attaches to a <select id="AvailablePortfolios"> element that gets populated server-side by an ASP:ListView, and makes a real nice, user-friendly menu for selecting the different portfolios. JavaScript code:
|
# ¿ Jul 31, 2014 18:02 |
|
For that level of responsiveness I think client-side solutions are worth checking out. tinysort is a pretty rad js library for sorting dom elements via custom search functions (which can be attached to the keyup event of your favorite search box). Bottom of the page there has it working with a table.
|
# ¿ Jul 31, 2014 18:37 |
|
Is there a way to instantiate automatic properties without having to put it in the constructor itself? Or is ClassC (no automatic properties) the most graceful answer?C# code:
|
# ¿ Aug 1, 2014 17:20 |
|
More of my low priority idle wishes need to come true like this.
|
# ¿ Aug 1, 2014 18:39 |
|
I've got a class with some static and some non-static methods, and I'd like to lazily check the existence of system setup / default configurations whenever the class is referenced. Is the following a bad idea for any reason?C# code:
|
# ¿ Aug 8, 2014 14:42 |
|
gariig posted:InitClass will be called at startup because the runtime wants to create the variable initialized. It sounds like you want Lazy<T>. Without a better sample it's hard to say if this is good or bad. I'd lean toward not doing it because it's hard to mock out or hide static anything during a unit test. Lazy<T> would be the way to go except that the project is 3.5. I've run this code though, and it didn't run at startup - the class itself isn't static, so that's probably the difference.
|
# ¿ Aug 8, 2014 17:56 |
|
A visual studio question. I'm used to being able to edit code in c++ projects while the program is running in a debugger, and when I'm at a suitable point I ctrl-alt-break to pause, and F5 to spark an edit-and-continue rebuild. In .NET, I haven't been able to figure out how to do this. Open source files for running projects are decorated with a little lock icon, and attempts to edit them are met withEdit and Continue posted:Changes are not allowed while code is running or if the option 'Break all processes when one process breaks' is disabled. The option can be enabled in Tools, Options, Debugging. Any way to get around this?
|
# ¿ Aug 28, 2014 13:41 |
|
It's VS 2010, but I'm debugging in x86 and I'm able to edit and continue if I break the running process - it just won't let me do any typing (editing) while the process is running.
|
# ¿ Aug 28, 2014 14:10 |
|
Malcolm XML posted:This would break source mapping if you e.g. deleted a method with a breakpoint in it. I get that, and I get it as a reason to disallow it, but when doing it in C++ my breakpoints just change from solid red dots to little hollow dots and life goes on until the next build. One totally queer thing that I've just found is that if I edit a file OUTSIDE of VS, it asks if I'd like it reloaded, and then the 'locks' disappear from every file other than the one that I edited / reloaded. I'm then able to edit all of these in the way I wanted, complete with the edit and continue specific compiler warnings (can't alter types, etc).
|
# ¿ Aug 28, 2014 14:24 |
|
Wait - do solved cases count as negative?
|
# ¿ Sep 8, 2014 18:24 |
|
If someone calls SomeClass SomeClassInstance = SomeClass.Load(key); with an invalid key, should the method return null or throw an exception or log some swear words or what? As far as I can tell I could go either route without much headache but I'm sure that this is something that has lots of established best practices. fake edit: Please, look inside your mercy file... File Not Found.
|
# ¿ Sep 17, 2014 17:07 |
|
GrumpyDoctor posted:With that little contextual information, I think the only advice anyone can reasonably give you is "All of those options are fine, as long as whatever you do is consistent with the rest of your codebase." Logging swear words it is, then.
|
# ¿ Sep 17, 2014 17:11 |
|
I've just come across something I don't understand.C# code:
What gives?
|
# ¿ Sep 18, 2014 15:08 |
|
zokie posted:It has to be the fully qualified type names or missing usings. Does it work with just foreach(SettingsProperty p in ...)? If I stick in the using System.Configuration; then I can use foreach(SettingsProperty p ...), but still not var. Ithaqua posted:You'll see that kind of thing a lot with pre-generic collections. It implements IEnumerable, not IEnumerable<T>. Even if all of the stuff in the collection is of the same type, the compiler has no way to know that. Just put a .Cast<Type>() in there. Ahh, this makes sense. But my confusion has shifted to why I'm able to declare the inner variable type at all - having just tried, I'm able to compile and run C# code:
Isn't the whole point of strong static typed languages to avoid this sort of problem? Is this an edge case wart that was a side effect of the introduction of generics which we're happy enough to suffer? (Or an edge case that appeared after the introduction of both generics and the var keyword?) Newf fucked around with this message at 16:36 on Sep 18, 2014 |
# ¿ Sep 18, 2014 16:32 |
|
GrumpyDoctor posted:This is the problem that generics solved, but the collection you're iterating over doesn't have a generic interface, which is why var's type inference isn't working. I get that, but I don't get why I'm able to declare the type of a variable when the compiler doesn't know it ahead of time. It feels like a stricter version would force me to expect only objects from an IEnumerable and then cast them myself - at least in this case the cast becomes explicit. Had I gone with foreach(SettingsProperty ... instead of var in the first place I would never have noticed that any cast was taking place - that's bad, isn't it?
|
# ¿ Sep 18, 2014 16:49 |
|
GrumpyDoctor posted:http://stackoverflow.com/questions/3917129/foreachderived-obj-in-new-listbase is your exact question with the answer (tldr it's a special thing that foreach does for historial reasons) ljw1004 posted:Basically the C#/VB languages consider foreach loops to be explicit casts. Thanks both, and all. I think at least that the quality of my confusions is rising.
|
# ¿ Sep 18, 2014 19:16 |
|
Silvah posted:Does EF work properly with interfaces? So instead of using the abstract BaseClass, you could just compose your derived classes by implementing various interfaces, then maybe use some master interface from the context to add the query conditions? EssOEss posted:I tried using a subclassing structure for modeling my database once and I will never try it again. This is just one of the headaches you will encounter. My recommendation is to not try to make any fancy entity model - just treat your entity classes as database rows and you'll have a happy life. This sounds more or less exactly like what I'm currently attempting to do. I'm working on a math-tutoring app that's got a pile of different question classes which have a shared inheritance structure blah blah. It's code-first with the current MVC5 / EF6 / VS2013. Haven't run into any problems yet but I'm always nervous that I might sneeze in the wrong direction and then my program will never compile again.
|
# ¿ Sep 21, 2014 13:27 |
|
Here's a question to slot into inheritance/EF chat. I've been working on something with MVC but I'm starting to doubt whether it's the tool for the job. The short of it is that I've got some slowly growing (as the system matures) number of hand-made classes each of which have ~100 instances stored in the DB. Each class also has associated with it at least one but potentially any number of views. My first look tells me that it's going to be a pain to store the views themselves in the DB, since the framework wants to be loading them from Views/ClassName/ActionName (or whatever, but it wants to be loading physical .cshtml files). In practice, I expect classes to be static, but the views (including the number of them assigned to each class) will be in flux in a partially automated, partially user driver way. Moreover, the system itself needs to be 'aware' of the coming and going of the views. This is why I prefer to have them persisted as DB objects rather than as physical files. Does anyone have experience with VirtualPathProvider to do this sort of thing? And on a related note, how inconvenient would it become to be editing razor views in VS in order to then persist them to the DB? Probably just a matter of setting up an alternate project to store all of that? This is total greenfield and it's my first time looking at MVC, so it's possible that I'm missing a better route to take with MVC, and it's also possible for me to ditch and move to another framework if something is a more natural fit with my intention. Would appreciate any feedback.
|
# ¿ Sep 25, 2014 22:40 |
|
Ithaqua posted:It sounds like you're doing something really, really fishy. I think we may have an XY problem. What's the goal of the system that's requiring hundreds of views? The views are alternative representations of math problems. EG, your basic multiplication problem can be put to people several obvious ways: quote:4x5=__ quote:How many dots are there? quote:There are 4 cookies in each box. [picture of five boxes]. How many cookies are there? The idea is to feed this to children, "do big data stuff" to gain information about the relative merits of different question/view schemes, feed a better refined diet of it to children, and so on. edit: It's not necessarily the case that '100s of views' are required for a particular question at a particular time, but the idea is to be running generalized A/B/C... testing against the existing stockpile in order to find the most useful ones and toss the least useful. Newf fucked around with this message at 23:04 on Sep 25, 2014 |
# ¿ Sep 25, 2014 23:01 |
|
|
# ¿ May 2, 2024 15:37 |
|
EssOEss posted:I recommend a change of viewpoint. What you are calling views here are not actually views - they are different ways to model some entities. Views are a purely UI layer thing. Think of the different representations as parts of the model and orient your views around showing these different representations. I think I understand your meaning here, but the point of having a single model displayed via different views is to help students discern the equivalence for themselves. A numerate person will instantly and thoughtlessly use multiplication in order to count the square tiles on a floor, but a young kid won't necessarily do that without first giving it some thought. The idea is to give them the experience to internalize the equivalence for themselves, rather than 'telling' them about it, and a way to measure for it is to measure their relative performance with "different views" of the same "model". It simplifies some of the logistics if there's a hard-wired relationship between these different views. Still considering options here though - more plumbing work is ongoing. ljw1004 posted:(1) Don't do any more coding until you've met with your data-scientist and he's done the first run through of data. 1) This is a one-man show I'm afraid. On the plus side, it keeps me from designing a CMS / ViewModel that's incompatible with what the data-scientist wants the data to look like! I'm not actually learned in anything like 'data-science' (honestly I'm not even sure what that refers to) but I've done a bit of evolutionary programming and I've got a ton of experience working with low-numeracy students and I have a scheme in mind that I think can work. The short of it is that it's an evolutionary scheme where a bunch of software objects have 'opinions' on how different skills are related to one another, and are continually gambling on the performance of the users. The objects with better opinions about the relationships between skills will be better able to predict student performance, and be selected for. (They all have access to the students' prior performance records). I built a version of this scheme for arbitrary binary data for a course a year or so ago and it was extremely successful (if a little slow) at learning the relationships between the individual bits of a stream of bitstrings I threw at it 2-3) That's something to think about. I'm going to plow forward for the moment because I'm nearing the point of actually loosing my data scheme against the existing model, at which point I guess I'll step back and try to figure out whether the model will work (well) going forward. 4) You mean cultural / language wise? My intended audience for this is a few dozen kids who are part of an after-school program around the corner. I think that internationalization is maybe a ways off Your app sounds neat. Thanks for all of the feedback everyone.
|
# ¿ Sep 28, 2014 19:35 |