Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

GrumpyDoctor posted:

I think you could have just used Seq.collect. (Also check out the Array.Parallel module.)

e: Actually the solution you posted shouldn't be compiling for a couple of reasons so I'm not sure what you're doing.
How would I have used Seq.collect?
I'm not sure what I'm doing either, this is my first attempt at f# and functional programming in general. However, my code does compile and returns correct results in the dataformat I'm expecting. I went from a ~6sec response going the synchronous route and with my current approach I'm at ~1.9sec.

Adbot
ADBOT LOVES YOU

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Uziel posted:

How would I have used Seq.collect?
I'm not sure what I'm doing either, this is my first attempt at f# and functional programming in general. However, my code does compile and returns correct results in the dataformat I'm expecting. I went from a ~6sec response going the synchronous route and with my current approach I'm at ~1.9sec.
I'm wrong. While it compiles I'm still not getting the datatype I want. I just want a single sequence of string arrays!
Current code that returns seq<string[]> []:
code:
 let asyncScrape url allParameters =
        allParameters
        |> Seq.map(fun v ->
            yearAndClassResultsAsync url v)
            |> Async.Parallel
            |> Async.RunSynchronously
            |> Array.mapi (fun s -> resultsBody)
So for every item in the parameters collection (which is 4 right now), I'm getting a collection of 4 items, each of which contain a sequence of string[]s. I want those 4 outer collection items combined.

raminasi
Jan 25, 2005

a last drink with no ice
Your solution with cleaned-up formatting:
code:
let asyncScrape url allParameters =
    allParameters
    |> Seq.map (fun v -> yearAndClassResultsAsync url v)
    |> Async.Parallel
    |> Async.RunSynchronously
    |> Array.mapi (fun s -> resultsBody)
There's no reason to use Array.mapi if you just ignore the index:
code:
let asyncScrape url allParameters =
    allParameters
    |> Seq.map (fun v -> yearAndClassResultsAsync url v)
    |> Async.Parallel
    |> Async.RunSynchronously
    |> Array.map resultsBody
What I think you want:
code:
let asyncScrape url allParameters =
    allParameters
    |> Seq.map (fun v -> yearAndClassResultsAsync url v)
    |> Async.Parallel
    |> Async.RunSynchronously
    |> Array.map resultsBody
    |> Array.concat
Which can just be written:
code:
let asyncScrape url allParameters =
    allParameters
    |> Seq.map (fun v -> yearAndClassResultsAsync url v)
    |> Async.Parallel
    |> Async.RunSynchronously
    |> Array.collect resultsBody
More functional programming dork cred :kheldragar::
code:
let asyncScrape url =
    Seq.map (yearAndClassResultsAsync url)
    >> Async.Parallel
    >> Async.RunSynchronously
    >> Array.collect resultsBody

raminasi fucked around with this message at 18:53 on Jun 6, 2014

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Thanks, I switched to this per your formatting:
code:
let asyncScrape url allParameters =
        allParameters
        |> Seq.map(fun v -> yearAndClassResultsAsync url v)
        |> Async.Parallel
        |> Async.RunSynchronously
        |> Array.map resultsBody
        |> Array.concat
It works fine without the Array.concat, but Array.concat gives a type mismatch:


Without the array.concat, this is what I have:

raminasi
Jan 25, 2005

a last drink with no ice
Oh, I misremembered the Array.concat signature. It should be Seq.concat, which you can then combine with the previous Array.map into a Seq.collect.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

I have an class called Server with a method called Start that takes a delegate(delegate void Callback(int)).

I want to use it to start a thread, passing in a method that matches the delegate.

code:
public void Callback(int i)
{
return;
}

...

Thread t = new Thread( new ParameterizedThreadStart(Server.Start));
t.Start(Callback);
It didn't like this, I assumed because it took an int instead of an object, so I changed int to object everywhere and still got nowhere.

I ended up calling Start without a thread, and making Start make a new thread instead, but I'm wondering how I should have gotten it to work.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

GrumpyDoctor posted:

Oh, I misremembered the Array.concat signature. It should be Seq.concat, which you can then combine with the previous Array.map into a Seq.collect.
Thanks for your help. A Seq.concat gives me exactly what I'm looking for, a sequence of string[]s!

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

bobua posted:

I have an class called Server with a method called Start that takes a delegate(delegate void Callback(int)).

I want to use it to start a thread, passing in a method that matches the delegate.

etc...

I'm a bit confused by what you've got there, could you show more code? Also, if my limited understanding of this is correct, you may want to consider using Action<int> instead of delegate to pass your callback.

EDIT:

Just use the lambda syntax to define the method to start the thread, then you don't have to deal with ThreadStart at all (and the lack of type-safety that comes with it):

https://dotnetfiddle.net/nxgsWg

C# code:
public static void Main()
{
	var server = new Server();
	var thread = new Thread(() => server.Start(Callback));
	thread.Start();
	thread.Join();
}

public static void Callback(int val){
	Console.WriteLine(val.ToString());
}

public class Server {
	public void Start(Action<int> callback)
	{
		callback(123);
	}
}

Bognar fucked around with this message at 20:27 on Jun 6, 2014

bobua
Mar 23, 2003
I'd trade it all for just a little more.

Bognar posted:

I'm a bit confused by what you've got there, could you show more code? Also, if my limited understanding of this is correct, you may want to consider using Action<int> instead of delegate to pass your callback.

I've already trashed the code I was trying to use but I'll try and rewrite it a bit...
code:
class Server
{

	public delegate void Receiver(object);

	public void Start(Receiver receiver)
	{
		//infinite loop here
	}
}

class Form1
{

	public void StartServer()
	{
		Server server = new Server();
		Thread t = new Thread(new ParameterizedThreadStart(server.Start));
		t.Start(ReceivedHandler);
	}

	public void ReceivedHandler(object i)
	{
		//do stuff
	}

}

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Don't use Threads directly. Use the TPL to create tasks, and let the framework handle the threads.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
I edited my above post, you should try using anonymous lambda syntax to start your thread.

Regarding the TPL, if he's actually building a "Server" then you might need a thread devoted to handling network requests. If you know a way to do that with Tasks, let me know because I'd find that interesting. Then again, any server you might be building has probably been built better by someone else.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

The 'server' is just a zmq listener that listens for a network request from a c++ app and fires an event(and sends the contents of the request) off. I've never really messed with the tpl(hell this is the first time I've even had to use a delegate) but none of the examples I saw made it look attractive for this.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Bognar posted:

Regarding the TPL, if he's actually building a "Server" then you might need a thread devoted to handling network requests. If you know a way to do that with Tasks, let me know because I'd find that interesting. Then again, any server you might be building has probably been built better by someone else.

I could be missing something, but I don't see why you couldn't use tasks for that. What's the thread doing that the task isn't (or vice versa) in the scenario you're thinking of?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Huh, yeah that's true. I guess I always think about Tasks only in terms of using them to do asynchronous work that will eventually complete. It seems so wrong to me to use a Task to do something like loop indefinitely, but there's no reason you couldn't.

Sedro
Dec 31, 2008

Bognar posted:

Regarding the TPL, if he's actually building a "Server" then you might need a thread devoted to handling network requests. If you know a way to do that with Tasks, let me know because I'd find that interesting. Then again, any server you might be building has probably been built better by someone else.
TPL has a LongRunning flag which, in practice, creates a dedicated thread. If they ever change that behavior you could still implement a custom TaskScheduler to do the same. So no reason not to take advantage of the nicer APIs and language integration.

spiderlemur
Nov 6, 2010

Horn posted:

What you're looking for is to use some kind of ajax calls to pull new data down from the server. This post gives a pretty basic example.

Yep, this is exactly what I want and it seems pretty simple to do, too. Thanks!

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick
I'm not sure if this is something straightforward or not. If you're developing a large MVC site, is it possible to break that up into separate projects? I don't mind if the sub-projects get included into the main site at compile time or run time... it's basically to potentially solve two problems in my head (that may not even be problems, or may be solved better in other ways):

1. reuse of code across different sites via a shared library, so you just maintain one set of code
2. easy/standard way of adding functionality to a site via a sort-of plugin type of design, where new functionality can follow some sort of predefined interface or design pattern, and then the resulting DLLs and Views can just be dropped onto the web server (maybe with some updates to the web.config as necessary) without having to add it to the main project, rebuild and redeploy the entire thing.

This sounds like it should be a solved problem, but all my searching hasn't turned up anything useful.

Calidus
Oct 31, 2011

Stand back I'm going to try science!
1. Yes, you can use multiple projects on a MVC site, for example I have a project that does barcode decoding and encoding for some manufacturing software and I also include the project on my MVC site so I place barcodes on files printed from the website.

2. I think you need to at a look at IIS because it sounds like you want to make Sub Applications for a default website?

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

beuges posted:

I'm not sure if this is something straightforward or not. If you're developing a large MVC site, is it possible to break that up into separate projects? I don't mind if the sub-projects get included into the main site at compile time or run time... it's basically to potentially solve two problems in my head (that may not even be problems, or may be solved better in other ways):

1. reuse of code across different sites via a shared library, so you just maintain one set of code
2. easy/standard way of adding functionality to a site via a sort-of plugin type of design, where new functionality can follow some sort of predefined interface or design pattern, and then the resulting DLLs and Views can just be dropped onto the web server (maybe with some updates to the web.config as necessary) without having to add it to the main project, rebuild and redeploy the entire thing.

This sounds like it should be a solved problem, but all my searching hasn't turned up anything useful.

Check out nopCommerce (.net mvc). If you're asking what I think you're asking, then they organize their solution in that manner.

https://nopcommerce.codeplex.com/SourceControl/latest

It's probably easier to download the source and run it from Visual Studio to get a good idea of how they do it, as opposed to that web interface though.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

beuges posted:

I'm not sure if this is something straightforward or not. If you're developing a large MVC site, is it possible to break that up into separate projects? I don't mind if the sub-projects get included into the main site at compile time or run time... it's basically to potentially solve two problems in my head (that may not even be problems, or may be solved better in other ways):

1. reuse of code across different sites via a shared library, so you just maintain one set of code
2. easy/standard way of adding functionality to a site via a sort-of plugin type of design, where new functionality can follow some sort of predefined interface or design pattern, and then the resulting DLLs and Views can just be dropped onto the web server (maybe with some updates to the web.config as necessary) without having to add it to the main project, rebuild and redeploy the entire thing.

This sounds like it should be a solved problem, but all my searching hasn't turned up anything useful.

Your MVC project should contain very little logic. The controllers should be extremely lightweight, and it's common (and a good practice!) to totally isolate the web application from the business logic via a RESTful service. If you have the bulk of your application isolated behind a series of appropriate services, you can just deploy those individual services as necessary.

Calidus
Oct 31, 2011

Stand back I'm going to try science!
Anyone have tips for porting a Windows Form Application to a MVC site? I imagine this is going to be a rather painful experience. The application is your basic business app, input data, run SQL queries, do some calculations, then output data in a user friendly medium(tables or images). I think I am going to end up turning each Form into 2 or 3 Views to cut down the complexity.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Calidus posted:

Anyone have tips for porting a Windows Form Application to a MVC site? I imagine this is going to be a rather painful experience. The application is your basic business app, input data, run SQL queries, do some calculations, then output data in a user friendly medium(tables or images). I think I am going to end up turning each Form into 2 or 3 Views to cut down the complexity.

That's such a broad topic, there's really no way to give you constructive advice. UI paradigms between desktop and web are very different. Also consider that the web is stateless, whereas your existing WinForms application is stateful.

Like I said before, make the core application logic into a service and just consume the service via the site. If the existing application is absolutely business-critical and just has a horrible mishmash of tightly-coupled presentation/business logic and no unit tests or anything to give you any confidence that you're porting the functionality correctly, you could start by making the service and refactoring the existing application to consume the service. Once that's done and the existing application is presentation-only, writing a web interface to it probably won't be that painful.

I actually took exactly that approach, albeit with porting a monster of a classic ASP site to an ASP .NET site. The logic in the existing page was byzantine, incredibly complex, and well-understood by maybe 2 or 3 people in the company. We stripped the page down to presentation-only, rewrote the business logic as a service, wrote SpecFlow tests so that the business users could actually help us generate appropriate unit tests, and once the service-backed Classic ASP site was stable and reliable, we just plopped a new UI on top of it in ASP .NET, then retired the Classic ASP version.

New Yorp New Yorp fucked around with this message at 07:12 on Jun 8, 2014

Funking Giblet
Jun 28, 2004

Jiglightful!

Knyteguy posted:

Check out nopCommerce (.net mvc). If you're asking what I think you're asking, then they organize their solution in that manner.

https://nopcommerce.codeplex.com/SourceControl/latest

It's probably easier to download the source and run it from Visual Studio to get a good idea of how they do it, as opposed to that web interface though.

I probably wouldn't copy nopCommerce, I mean, have you seen their controllers?

I've used MEF in the past to import controllers and views via a DLL, but there's no reason a standard IOC container couldn't do the same.

I use the mediator pattern to lighten controllers to the point that could essentially be created dynamically and their methods dispatched within an ActionInvoker. The mediator pattern just requires you to know the type of command or query for a given action, and return a result or issue a command. Which library this happens in is up to you. I wouldn't go down this route until I've encountered enough complexity within the app though. If your controllers look like this
https://nopcommerce.codeplex.com/SourceControl/latest#src/Presentation/Nop.Web/Controllers/CatalogController.cs then it's time to consider something better. (Also their dependency graph and start up time for each controller must be horrid!)

Funking Giblet fucked around with this message at 09:25 on Jun 8, 2014

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Funking Giblet posted:

I probably wouldn't copy nopCommerce, I mean, have you seen their controllers?

I've used MEF in the past to import controllers and views via a DLL, but there's no reason a standard IOC container couldn't do the same.

I use the mediator pattern to lighten controllers to the point that could essentially be created dynamically and their methods dispatched within an ActionInvoker. The mediator pattern just requires you to know the type of command or query for a given action, and return a result or issue a command. Which library this happens in is up to you. I wouldn't go down this route until I've encountered enough complexity within the app though. If your controllers look like this
https://nopcommerce.codeplex.com/SourceControl/latest#src/Presentation/Nop.Web/Controllers/CatalogController.cs then it's time to consider something better. (Also their dependency graph and start up time for each controller must be horrid!)

Unfortunately yes. I have to work with their controllers nearly daily (it's awful and makes me hate my job sometimes). We have a custom eCommerce package based off their source at work. They do some stuff right and really well though. I still kind of copy their layout tree on personal projects. Maybe I'm just familiar with it though.

I am going to look into this mediator pattern though. I might be able to convince the owner of the company we should spend some time on this. He's a developer so he should understand. Of course he might say "Clients don't care if the code looks pretty. We don't need to spend any time refactoring." and then we'll have to work on it later and not know what the gently caress. I think the last time he said that he also said we shouldn't add the project to source control because we can keep the project on our dropbox. [/rant] (sorry)

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Funking Giblet posted:

I've used MEF in the past to import controllers and views via a DLL, but there's no reason a standard IOC container couldn't do the same.

I like MEF for plugin discovery because it's explicitly designed with that in mind and nothing else.

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick

Knyteguy posted:

Check out nopCommerce (.net mvc). If you're asking what I think you're asking, then they organize their solution in that manner.

https://nopcommerce.codeplex.com/SourceControl/latest

It's probably easier to download the source and run it from Visual Studio to get a good idea of how they do it, as opposed to that web interface though.

From looking at the structure of the solution there, it does look like what I'm thinking of. I'm downloading the source to look at it in more detail. But yes, what I was after was to have a bunch of related controllers and views in their own projects - I wasn't sure how to import those into a "framework" website though, so I'll see how nopCommerce does it (at least the plugin loading parts).

Ithaqua posted:

Your MVC project should contain very little logic. The controllers should be extremely lightweight, and it's common (and a good practice!) to totally isolate the web application from the business logic via a RESTful service. If you have the bulk of your application isolated behind a series of appropriate services, you can just deploy those individual services as necessary.

Yes that's how I do things already :) The controllers are basically just wrappers around either a web service call or a business logic manager object. Even so, I want to be able to deploy and test different parts of this overall solution separately or together - the idea is to have a "framework" site that hosts a couple of independent but related products - an end user could subscribe to any one of them individually if they chose, but if they subscribed to a bunch of them, they can integrate nicely with each other to provide a nice seamless overall experience. Different teams may be working on different products eventually, and I also want a nice standardised way of adding new products to the system. Since the end users can subscribe to just a single product as a standalone service, I want to take the extreme stance of being able to develop it on its own in its own project (with the necessary hook point interfaces as well) to develop and test easier, and then being able to just drop it into the framework site and have the new product available with minimal changes to the framework site.

Funking Giblet posted:

I've used MEF in the past to import controllers and views via a DLL, but there's no reason a standard IOC container couldn't do the same.

I took a look at http://mef.codeplex.com/documentation and I honestly have no idea where to start looking at how to use this thing. Is there any better documentation or tutorials available anywhere?

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

Knyteguy posted:

Check out nopCommerce (.net mvc). If you're asking what I think you're asking, then they organize their solution in that manner.

https://nopcommerce.codeplex.com/SourceControl/latest

It's probably easier to download the source and run it from Visual Studio to get a good idea of how they do it, as opposed to that web interface though.

Orchard also does this well.

Calidus posted:

Anyone have tips for porting a Windows Form Application to a MVC site? I imagine this is going to be a rather painful experience. The application is your basic business app, input data, run SQL queries, do some calculations, then output data in a user friendly medium(tables or images). I think I am going to end up turning each Form into 2 or 3 Views to cut down the complexity.

Devil's advocate: recompile it for the web.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Totally uninformed, kneejerk reaction to that company's products based on the information on their site: It looks like a bunch of snake oil bullshit.

Funking Giblet
Jun 28, 2004

Jiglightful!

Ithaqua posted:

I like MEF for plugin discovery because it's explicitly designed with that in mind and nothing else.

The only issue I have with MEF is managing the creation of an AppDomain to allow shadow copying (which would allow dynamic loading and removal of plugins). It's fine for standalone apps, but it's a pain in the rear end for Web.

Calidus
Oct 31, 2011

Stand back I'm going to try science!

Ithaqua posted:

Totally uninformed, kneejerk reaction to that company's products based on the information on their site: It looks like a bunch of snake oil bullshit.

Yea I am just going to stick with MVC, Bootstrap and JQuery.

SirViver
Oct 22, 2008

Ithaqua posted:

Totally uninformed, kneejerk reaction to that company's products based on the information on their site: It looks like a bunch of snake oil bullshit.
From what I've seen it actually works surprisingly well, though admittedly my first reaction to "we're going to convert this 15-year-old Gupta application to .NET and then make it web-deployable using Visual Web GUI" was very similar.

I haven't worked directly with it, but from what I've seen of the application's prototype conversions it really is Windows Forms in your browser. Of course, depending on how your application is designed and what it does then there will be a few problem areas, like dealing with static variables, multiple exe files, local file access, printing, etc. Overall it performed much better than I'd ever have anticipated, though. AFAIK it works by having a JS "desktop OS" framework running on the client, which communicates with the server using AJAX/JSON callbacks. The server doesn't actually render any HTML, but just sends the form/control properties down to the client "OS", which then constructs the HTML to render the actual UI. That way the web traffic ends up being much smaller than you'd think as well (also since applications are 99.9% intended to be intranet only, latency isn't much of a problem in practice).

That said, I'm still glad I don't have to work with it. But if you do, it probably actually works better than your gut reaction would tell you.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

Hoping someone here has some knowledge of opencv\emgu. I have a decent understanding of the opencv image structure cv::mat, but I'm trying to rewrite something in c#(emgu) which generally uses an Image<> type instead.

In c++, I can take a regular image and 'carve out' a sub image by creating a new cv::mat from a region of the old. The important part being that the new cv::mat is just a pointer to that region, it doesn't actually do an expensive data copy. I want to do the same thing in c#... create hundreds of Image<>'s which are just regions of one underlying image, without duplicating all that data.

Here's the documentation on the Image<>
http://www.emgu.com/wiki/files/2.4.2/document/html/a8929aab-99c5-79cf-385c-dcec7769fea1.htm

wwb
Aug 17, 2004

beuges posted:

From looking at the structure of the solution there, it does look like what I'm thinking of. I'm downloading the source to look at it in more detail. But yes, what I was after was to have a bunch of related controllers and views in their own projects - I wasn't sure how to import those into a "framework" website though, so I'll see how nopCommerce does it (at least the plugin loading parts).


Yes that's how I do things already :) The controllers are basically just wrappers around either a web service call or a business logic manager object. Even so, I want to be able to deploy and test different parts of this overall solution separately or together - the idea is to have a "framework" site that hosts a couple of independent but related products - an end user could subscribe to any one of them individually if they chose, but if they subscribed to a bunch of them, they can integrate nicely with each other to provide a nice seamless overall experience. Different teams may be working on different products eventually, and I also want a nice standardised way of adding new products to the system. Since the end users can subscribe to just a single product as a standalone service, I want to take the extreme stance of being able to develop it on its own in its own project (with the necessary hook point interfaces as well) to develop and test easier, and then being able to just drop it into the framework site and have the new product available with minimal changes to the framework site.


I took a look at http://mef.codeplex.com/documentation and I honestly have no idea where to start looking at how to use this thing. Is there any better documentation or tutorials available anywhere?

I would just let these end up being independent services perhaps talking to each other where it makes sense -- especially some common core services that might provide the main building blocks of the app here.

ljw1004
Jan 18, 2005

rum

bobua posted:

Hoping someone here has some knowledge of opencv\emgu. I have a decent understanding of the opencv image structure cv::mat, but I'm trying to rewrite something in c#(emgu) which generally uses an Image<> type instead.

(Sorry I don't know your answer but...)

Q1. Why did you go for Emgu rather than "OpenCVSharp"? I'm not sure which one to pick.

Q2. Has anyone managed to get either wrapper to work in Windows8.1 or WindowsPhone8.1 projects?

RichardA
Sep 1, 2006
.
Dinosaur Gum

bobua posted:

Hoping someone here has some knowledge of opencv\emgu. I have a decent understanding of the opencv image structure cv::mat, but I'm trying to rewrite something in c#(emgu) which generally uses an Image<> type instead.

Here's the documentation on the Image<>
http://www.emgu.com/wiki/files/2.4.2/document/html/a8929aab-99c5-79cf-385c-dcec7769fea1.htm

Looking at the docs the method GetSubRect does what you want.

Drythe
Aug 26, 2012


 
You are able to have a web.config in a subfolder for only that folder and those under it with connectionstrings in it, correct? I am trying to do that and want the server to appear in the server explorer.

Drythe fucked around with this message at 16:18 on Jun 10, 2014

Geisladisk
Sep 15, 2007

I posted a question over on stackoverflow about an issue I'm growing incredibly frustrated with: http://stackoverflow.com/questions/24143964/could-not-load-file-or-assembly-jsonfx-json-or-one-of-its-dependencies-an-att

If you guys could take a look at it, that'd be swell. :)

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Per the SO question, it looks like you were able to fix it by redownloading the DLL. Were you able to see what the differences were between the two files?

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
I feel like I'm in bizarro world right now. "knockout is just like WPF so easy!" was the selling point, and I did me a knockout. Now I'm back to wpf (WOO!!!) or really "anything that's .NET and makes a windows app."

Is it just me or is it really, really loving wordy? Or am I just using an old-hat style and there are newer features that are less wordy and a pain in the rear end? I'll give an example:

code:
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="380" Width="600">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="200" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Label Grid.Row="0" Grid.Column="0" Content="Name:"/>
        <Label Grid.Row="1" Grid.Column="0" Content="Pass:"/>
        <Label Grid.Row="2" Grid.Column="0" Content="DLN:"/>
        <TextBox Grid.Column="1" Grid.Row="0" Margin="3,3,-530,3" Text="{Binding Path=UserName, 
            RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"/>
        <TextBox Grid.Column="1" Grid.Row="1" Margin="3,3,-530,3" Text="{Binding Path=UserPass, 
            RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
        <TextBox Grid.Column="1" Grid.Row="2" Margin="3,3,-530,0" Grid.RowSpan="2"   Text="{Binding Path=DLNList, 
            RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
              
         TextWrapping="Wrap"  AcceptsReturn="True"  VerticalScrollBarVisibility="Visible"/>
        <Button Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" 
            MinWidth="80"  Content="Search" Margin="0,5,-530,-5"  Click="Button_Click" />
    </Grid>
</Window>
Class MainWindow
    Public Shared Property UserNameProperty As DependencyProperty = DependencyProperty.Register("UserName", GetType(String), GetType(MainWindow))
    Public Shared Property UserPassProperty As DependencyProperty = DependencyProperty.Register("UserPass", GetType(String), GetType(MainWindow))
    Public Shared Property DLNListProperty As DependencyProperty = DependencyProperty.Register("DLNList", GetType(String), GetType(MainWindow))

    Public Property UserName As String
        Get
            Return GetValue(UserNameProperty)
        End Get
        Set(value As String)
            SetValue(UserNameProperty, value)
        End Set
    End Property
    Public Property UserPass As String
        Get
            Return GetValue(UserPassProperty)
        End Get
        Set(value As String)
            SetValue(UserPassProperty, value)
        End Set
    End Property
    Public Property DLNList As String
        Get
            Return GetValue(DLNListProperty)
        End Get
        Set(value As String)
            SetValue(DLNListProperty, value)
        End Set
    End Property

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
        // DO THINGS HERE
    End Sub

End Class

Does it HAVE to be so damned wordy to just bind some text boxes to some data in the code behind? It honestly felt cleaner and easier doing this poo poo in knockout. Maybe the web-programming just leaked into my brain and hasn't drained completely yet.

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Well, part of the problem is that you're not doing MVVM. Not that MVVM is going to make it less verbose, but you're setting yourself up for pain down the line.

  • Locked thread