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.
 
  • Post
  • Reply
raminasi
Jan 25, 2005

a last drink with no ice
C# 6.0 will have a way to more easily match constructor arguments with auto-properties, but there's nothing like what you want yet.

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Careful Drums posted:

I have a problem: the default bundling in System.Web.Optimization is not cutting it.

I need to be able to pull down css/js/images from our own hosted CDN, bundle it up, then serve that as one minified request. I guess with System.Web.Optimization you can only pull down inidividual CDN files.

Anyone have experience or reccomendations on this?

The candidates so far are to

- use grunt and a poo poo ton of dependencies to host a static site with everything bundled already. I don't hate this but I'm hesitant to introduce node.js into our all-asp.net mvc workflow
- use this bundler library which is basically a wrapper for what i previously described
- this library called squishit which as far as i can tell looks okay. But I'm not so sure what the hell is going on with their AssetsController class in this example.

I've had good luck with RequestReduce.

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

Careful Drums posted:

I have a problem: the default bundling in System.Web.Optimization is not cutting it.

I need to be able to pull down css/js/images from our own hosted CDN, bundle it up, then serve that as one minified request. I guess with System.Web.Optimization you can only pull down inidividual CDN files.

Anyone have experience or reccomendations on this?

The candidates so far are to

- use grunt and a poo poo ton of dependencies to host a static site with everything bundled already. I don't hate this but I'm hesitant to introduce node.js into our all-asp.net mvc workflow
- use this bundler library which is basically a wrapper for what i previously described
- this library called squishit which as far as i can tell looks okay. But I'm not so sure what the hell is going on with their AssetsController class in this example.

If you go the all-static route, Microsoft has a library/tool called the Ajax Minifier and a tool which builds on it called WebGrease which you might find useful.

wwb
Aug 17, 2004

I'd admit defeat and look at the grunt option -- it really is the way forward and I suspect it will become more and more prevalent in ASP.NET as they move away from VS dependence.

I will admit that node seems like a funky dependency and there is a whole lot of stupid poo poo on the platform but there is some pretty cool or handy poo poo as well. Or at least grunt is pretty awesome -- having a pretty good build / integration tool for static stuff is pretty worthwhile. Karma -- a javascript unit testing framework -- is pretty sweet as well.

Careful Drums
Oct 30, 2007

by FactsAreUseless

chmods please posted:

If you go the all-static route, Microsoft has a library/tool called the Ajax Minifier and a tool which builds on it called WebGrease which you might find useful.

I forgot to mention that I looked a bit into WebGrease as well. I figured since System.Web.Optimization depends on WebGrease I could just use that lib and make something myself, but I think that would be a bad case of re-inventing the wheel - if the pros at Redmond can't make something useable with WebGrease, what would some scrub midwest dev be able to do?


wwb posted:

I'd admit defeat and look at the grunt option -- it really is the way forward and I suspect it will become more and more prevalent in ASP.NET as they move away from VS dependence.

I will admit that node seems like a funky dependency and there is a whole lot of stupid poo poo on the platform but there is some pretty cool or handy poo poo as well. Or at least grunt is pretty awesome -- having a pretty good build / integration tool for static stuff is pretty worthwhile. Karma -- a javascript unit testing framework -- is pretty sweet as well.

Thanks for your opinion on this. I'm fighting it in my head but I think you're right that with how vNext is looking that interoping with other technologies is the way to go.

Ithaqua posted:

I've had good luck with RequestReduce.

Hey, that that looks promising too, I'll check it out. Thanks!

Careful Drums fucked around with this message at 02:56 on Aug 20, 2014

Gul Banana
Nov 28, 2003

Essential posted:

Can MEF be used to load & unload a library from a running application? I want to be able to silently update files while a system tray app runs.

I've done the same thing with a windows service and AppDomain, however I'm wondering if MEF is a better option.

I thought I read before that MEF cannot unload a library once it's loaded (without closing the app down of course), but now I can't find anything on that.

The only way to unload an assembly is to kill its app domain - MEF doesn't provide any special facilities for this.

Gul Banana
Nov 28, 2003

Ithaqua posted:

C#6 will have this in the form of primary constructors. I'm sure someone will correct me if I'm wrong, but you'll be able to do:

code:
public class Employee(int salary) 
{

}
and it will generate a private field for the value, no explicit constructor necessary.

I was really sad to see in Roslyn dev notes that VB.NET is not getting any equivalent to this feature :(

Careful Drums
Oct 30, 2007

by FactsAreUseless

Ithaqua posted:

I've had good luck with RequestReduce.

Holeeee poo poo it 'just worked' installing via NuGet. I thought it was too good to be true. Now all I have to do is convince the team!

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Is it possible to have a WPF application, depending on certain command line options being present, not bother with the Windows part and just run in the current console (or a new one if run from a shortcut)? I have a project that a customer wants to add some scheduled processing to.

Mr. Crow
May 22, 2008

Snap City mayor for life

Ciaphas posted:

Is it possible to have a WPF application, depending on certain command line options being present, not bother with the Windows part and just run in the current console (or a new one if run from a shortcut)? I have a project that a customer wants to add some scheduled processing to.

I don't see why not, just don't set the StartupUI property and launch/hook your console in a Startup event handler.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
Never done EF before, found some old code left by a good contractor who split since govt doesn't pay what this guy was worth. Great code though.

Anyway this is all EF and I don't even know where to begin trying to find where the connection string either in the .edmx file by hand or using the designer. It's basically WebAPI that emits JSON for some jQuery/KO sitting in a web forms page. I can open the designer and look at object models but I've tried googling and poking for the frigging connection strings and apparently called in stupid this morning.

:downs:

EDIT: I didn't scroll far enough right, it's in web.config. :downsrim:

Fuck them fucked around with this message at 17:03 on Aug 20, 2014

Careful Drums
Oct 30, 2007

by FactsAreUseless

gently caress them posted:

Never done EF before, found some old code left by a good contractor who split since govt doesn't pay what this guy was worth. Great code though.

Anyway this is all EF and I don't even know where to begin trying to find where the connection string either in the .edmx file by hand or using the designer. It's basically WebAPI that emits JSON for some jQuery/KO sitting in a web forms page. I can open the designer and look at object models but I've tried googling and poking for the frigging connection strings and apparently called in stupid this morning.

:downs:

EDIT: I didn't scroll far enough right, it's in web.config. :downsrim:

I was gonna say, isn't that usually where they go? glad to hear that good code exists somewhere, though.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
code:
<connectionStrings>
    <add name="$PROJECTEntities" connectionString="metadata=res://*/Mode$PROJECT.csdl|res://*/Model$PROJECT.ssdl|res://*/Model$PROJECT.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=$SOURCE;initial catalog=$PROJECT;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
I just don't know why all this poo poo is packed up into the connection string.

TheReverend
Jun 21, 2005

Hey folks,
I have a C++ library that I'm supposed to use.
Problem is, we do everything in C#.

Is there a good way to use this library that isn't "wrapper class" because it has way to many functions,classes,stucts,enums,etc that making a wrapper class would be awful.

Any tools or tricks? Please :ohdear: ?

wwb
Aug 17, 2004

gently caress them posted:

code:
ef4 connection string
I just don't know why all this poo poo is packed up into the connection string.

Looks like you were using an earlier version of the EF when they needed a special connection string because they were stuck on using the designer and I guess a good old fasioned connection string isn't good enough. Anyhow, that isn't too complex -- just a typical connection string xml encoded. But it was a PITA and it is now gone.

PS: see http://odetocode.com/blogs/scott/archive/2014/08/14/c-6-0-features-part-ii-primary-constructors.aspx for stuff on C# 6 constructor parameters. I'm not sure how much they do for me given resharper has got it down to a few wacks of alt-enter.

Essential
Aug 14, 2003

Gul Banana posted:

The only way to unload an assembly is to kill its app domain - MEF doesn't provide any special facilities for this.

Thanks, that's what I was thinking.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

wwb posted:

PS: see http://odetocode.com/blogs/scott/archive/2014/08/14/c-6-0-features-part-ii-primary-constructors.aspx for stuff on C# 6 constructor parameters. I'm not sure how much they do for me given resharper has got it down to a few wacks of alt-enter.

It reduces the boilerplate for DI a fair bit, and makes it slightly less error-prone.
code:
public class Foo(IButts butts, IDongs dongs) 
{
    private readonly IButts _butts = butts;
    private readonly IDongs _dongs = dongs;
    public Foo() : this(new RegularButts(), new RegularDongs()) {}
}

Sedro
Dec 31, 2008
You should already have the fields generated, so the code would reduce to this
C# code:
public class Foo(IButts butts, IDongs dongs) 
{
    public Foo() : this(new RegularButts(), new RegularDongs()) {}
}

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Sedro posted:

You should already have the fields generated, so the code would reduce to this
C# code:
public class Foo(IButts butts, IDongs dongs) 
{
    public Foo() : this(new RegularButts(), new RegularDongs()) {}
}

I thought so at first, but I did some reading that indicated that the primary constructor parameters are only available during class initialization, so you have to assign them into a field or something.

ljw1004
Jan 18, 2005

rum

TheReverend posted:

Hey folks,
I have a C++ library that I'm supposed to use.
Problem is, we do everything in C#.

Is there a good way to use this library that isn't "wrapper class" because it has way to many functions,classes,stucts,enums,etc that making a wrapper class would be awful.

Any tools or tricks? Please :ohdear: ?

Start with the PInvoke Interop Assistant
http://clrinterop.codeplex.com/releases/view/14120

The idea is that you paste C++ code into the assistant, and it spits out C# interop code. It will spit out C# interop code for structs, enums, functions, COM interfaces. Then you can invoke them directly.

As for classes? I think you're stuck here. It's fine for C# to call a C-style function directly, but there's no way for C# to call a C++ class member directly. You'll have to write a wrapper.

Sedro
Dec 31, 2008

Ithaqua posted:

I thought so at first, but I did some reading that indicated that the primary constructor parameters are only available during class initialization, so you have to assign them into a field or something.
So primary constructors will save exactly 1 line of code (excluding braces)? I hope that's not the case.

Edit: I guess it also removes the need for field assignments e.g. this.foo = foo. But still not in the same league as scala's case classes.

Sedro fucked around with this message at 19:29 on Aug 20, 2014

raminasi
Jan 25, 2005

a last drink with no ice

Sedro posted:

So primary constructors will save exactly 1 line of code (excluding braces)? I hope that's not the case.

Edit: I guess it also removes the need for field assignments e.g. this.foo = foo. But still not in the same league as scala's case classes.

There's syntax to automatically plug them into auto properties, which is really nice.

wwb
Aug 17, 2004

None of this is beating resharper + alt-enter for me. All of it is a lot harder to read / follow.

Then again I'm a luddite at times.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Something I was thinking about earlier:

Let's say you have an event. When you fire the event, you want to provide some event args, but the contents of the event args don't really match up with any strongly-typed models you have, and it's a bit too specific to warrant any sort of reuse, and also you're a lazy jerk.

Is it wrong to do public event EventHandler<dynamic> FooEvent;?

The invocation (in my mind) would be to handle a case like this:

code:
FooEvent(this, new { Stuff=whatever, OtherStuff=butts });
It feels wrong, but I can't express what's so wrong about it.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer

Ithaqua posted:

Something I was thinking about earlier:

Let's say you have an event. When you fire the event, you want to provide some event args, but the contents of the event args don't really match up with any strongly-typed models you have, and it's a bit too specific to warrant any sort of reuse, and also you're a lazy jerk.

Is it wrong to do public event EventHandler<dynamic> FooEvent;?

The invocation (in my mind) would be to handle a case like this:

code:
FooEvent(this, new { Stuff=whatever, OtherStuff=butts });
It feels wrong, but I can't express what's so wrong about it.
It feels wrong because you won't catch a typo there and it's a public interface. It's pretty borderline IMO, a class definition for that event args would be what, four lines? On the other hand it's a call in one place and not gonna be reused so who cares?

I'd consider who's on my team and who's gonna be supporting it because I wouldn't mind either way but there are people that would care *really hard* about it, and you could be setting a precedent.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Ithaqua posted:

It feels wrong, but I can't express what's so wrong about it.

I hate the ever-living poo poo out of it, but I also have an imbalanced dislike of dynamic in general. As Destroyenator said, you have a public interface with a lack of compile time type/typo checking. You could use Tuple to gain those benefits, but the code is still ugly with .Item1, .Item2. I feel like there's a happy medium that should exist in the language that's best described as "public anonymous types" or maybe "structural types" in the loosest sense of the term. Though this is all rehashing old discussions.

In your case, I would probably just define a public class nested in the class that is spawning the event. If it's only used in that specific case, then there's no need to clutter your namespace with the event definition. This goes directly against being a lazy jerk, though.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
In my case, there are no team members and no public API, but your points are well taken. I will opt against committing this minor atrocity.

Cryolite
Oct 2, 2006
sodium aluminum fluoride
Aren't you proposing essentially what MVC does with route values? e.g. Url.Action("ActionName", new { id = "ohmy", somethingElse = "hello" }). Not that this makes it right - I remember reading an interview where Anders expressed strong disapproval of this pattern.

ljw1004
Jan 18, 2005

rum

Gul Banana posted:

I was really sad to see in Roslyn dev notes that VB.NET is not getting any equivalent to this feature :(

Sorry, that was partly my doing. The reason for not doing them in VB is:

* We foresee something nicer coming along, e.g. https://roslyn.codeplex.com/discussions/560339
In C# the primary constructor syntax will already be taken, so C# would have to express "plain old data" objects with some kind of other syntax e.g. "record class Point(int x, int y);" and there'll be several similar kinds of things. In VB, if we don't do primary constructors now, then we'll leave the syntax free for the something nicer in the future.

* VB already lets one member initializer refer to another, e.g.
code:
Class C
   Public X% = 15
   Public Y% = X + 5
End Class
If we had primary constructors, and the lowercase name "x" was used for it, then the above initialization of Y would now refer to that primary constructor parameter x rather than to the member.

* VB isn't case sensitive and so can't rely on different casing conventions like C# has for constructor parameters vs members

* There are a bunch of things that don't quite work right, e.g. you can't do XML doc-comments right on primary constructors. And by the time you start putting in complicated type names e.g. "Class C(x As List(Of Tuple(Of IDiagnosticProvider, ISymbol)))" then it's pretty wordy.

A Tartan Tory
Mar 26, 2010

You call that a shotgun?!
Does anyone know of a good tutorial/example/primer set of C# GUI design? Preferably in a MVC format? I've done it before kinda...in Java, but it would be nice to see it done properly (coding wise) before attempting it.

A Tartan Tory fucked around with this message at 13:07 on Aug 21, 2014

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

A Tartan Tory posted:

Does anyone know of a good tutorial/example/primer set of C# GUI design? Preferably in a MVC format? I've done it before kinda...in Java, but it would be nice to see it done properly (coding wise) before attempting it.

App store (Metro), WinForms, WPF? Or are you talking web?

A Tartan Tory
Mar 26, 2010

You call that a shotgun?!

Ithaqua posted:

App store (Metro), WinForms, WPF? Or are you talking web?

WPF or Windows forms, whatever is easier, on Visual Express 2013. Sorry, should have specified.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Are there no chart/graph/etc. controls built in to .NET/WPF by default? I've seen downloadable controls but I can't use those on my work machine.

silentpenguins
May 9, 2013

Abysswalking
I'm trying to set up an asychronously updating list (a list of emails successfully sent) on the last step of a wizardstep in .Net 3.5. Modifying the response (response.write/flush/end) seems to be breaking the Wizardstep, is there a better way to do it? Most of the alternatives appear to be for 4.0 or 4.5.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
I think this the right place. I'm having some trouble with XAML since I'm completely new to it. Specifically I'm having trouble with the data binding.

XML code:
<Page
    x:Class="CompanyWidgetMobileApp.MarginCalculatorPage"
    DataContext="{Binding DefaultViewModel.Item, RelativeSource={RelativeSource Self}}"
    d:DataContext="{Binding Groups[0].Items[0], Source={d:DesignData 
Source=../CompanyWidgetMobileApp.Shared/DataModel/MenuData.json, 
Type=data:MenuDataSource}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CompanyWidgetMobileApp"
    xmlns:data="using:CompanyWidgetMobileApp.Data"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

...

<!--TODO: Content should be placed within the following grid-->
            <Grid Grid.Row="1" 
                  x:Name="ContentRoot" 
                  Margin="19,9.5,19,0">
                <Grid.Resources>
                    // Problem here? Compiler error but it should work?
                    <data:MarginModel x:Key="myMarginModel" Item="ax1234"/> 
                </Grid.Resources>
Here is my class I'm trying to bind.

C# code:
namespace CompanyWidgetMobileApp.Data
{
    public partial class MarginModel
    {
        #region fields

        private ItemModel item;
        private double salesCost;
        private double salesPrice;

        #endregion

        #region accessors

        public ItemModel Item
        {
            get { return item; }
            set { item = value; }
        }

        public double SalesCost
        {
            get { return salesCost; }
            set { salesCost = value; }
        }

        public double SalesPrice
        {
            get { return salesPrice; }
            set { salesPrice = value; }
        }

        #endregion
    }
}

I cannot for the life of me figure out how to get the fields to bind to my class. Any ideas?

Windows Phone 8.1 is the target environment. It's close enough to wpf that solutions may have a good chance at working if you're familiar with that.

Thanks in advance.

Faldoncow
Jun 29, 2007
Munchin' on some steak
What's the compiler error?

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

A Tartan Tory posted:

WPF or Windows forms, whatever is easier, on Visual Express 2013. Sorry, should have specified.

Pretty sure windows form is being discouraged, and WPF is recommended now. Something something separation of logic.

Knyteguy fucked around with this message at 00:16 on Aug 22, 2014

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Faldoncow posted:

What's the compiler error?

The name "MarginModel" does not exist in the namespace "using:CompanyWidgetMobileApp.Data".

Which drives me crazy because Intellisense is showing me the class.

Faldoncow
Jun 29, 2007
Munchin' on some steak
I haven't seen the "using:..." in WPF. Usually I use "clr-namespace" instead of using, like so:

code:
xmlns:local="clr-namespace:CompanyWidgetMobileApp.Data"
If I change some of my code from clr-namespace to using the compiler shits out a ton of errors that it can't find things anymore.

I've only been using WPF for a month though, so that may not be the issue.

Adbot
ADBOT LOVES YOU

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Faldoncow posted:

I haven't seen the "using:..." in WPF. Usually I use "clr-namespace" instead of using, like so:

code:
xmlns:local="clr-namespace:CompanyWidgetMobileApp.Data"
If I change some of my code from clr-namespace to using the compiler shits out a ton of errors that it can't find things anymore.

I've only been using WPF for a month though, so that may not be the issue.

No luck unfortunately. Thanks though.

I feel like Windows 8.1 Phone development is still in beta stages or something. Not a whole lot of helpful debugging information.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply