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
Kekekela
Oct 28, 2004

Gul Banana posted:

it's an Atom-like html app

It seems like you think Atom is bad, which is also kind of the vibe I get from other people whose technical opinions that I value. Can you elaborate on why if its not too off-topic? (or is it just the large files thing?)

I've been trying to transition to doing more of my non-VS development on my macbook and I've been using Atom. I'd switched to it a couple months ago because Sublime made me feel guilty about being cheap. Mainly its smaller github projects and files for now and Atom's been great. If I'm going to run into a wall with it though, I'd like to know now rather than later so I can shift to a plan B. (which I guess would be Webstorm or back to Sublime)

Adbot
ADBOT LOVES YOU

amotea
Mar 23, 2008
Grimey Drawer

Factor Mystic posted:

I also wish WPF would become less bad, so we agree on that point. However, you can take your xaml & data binding & mvvm principles and use them to build universal apps which are now much more integrated with the desktop.

And man you are behind the times wrt Silverlight. Browser plugins are dead, completely. Much better js runtimes & mobile killed it. It was a neat idea in its time but c'mon.

The problem is businesses have invested in .NET + WPF for years, meaning they have huge codebases. Just speaking for myself we have close to a million lines, and there is no way in hell we're going to port that over to this new universal app stuff or Javascript.

I agree browser plugins are dead for the masses, and I'd never use Silverlight when developing a new public website. But for enterprise stuff with existing .NET/WPF codebases there is no alternative (there are some open source efforts going on to convert XAML to JS, but I don't see those going anywhere anytime soon).

Microsoft has to realize most developers probably don't see the benefit in this whole universal app thing. Windows phone isn't big enough to be concerned about, tablets are mostly for small single-purpose apps, Surface is a niche, Xbox is a gaming console. This leaves the desktop, and why bother switching tech when the end result is the same?

And good luck with getting companies to install Windows 10 just to run your application, we've only JUST managed to convince some customers to drop Windows XP.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
I've used a similar pattern of query/command on a few projects, it's worked really well and how big you make the infrastructure is up to your needs.

I got fairly far with a really simple implementation in one case, along the lines of:
C# code:
public interface ICommand
{
    Task Execute(IDbConnection connection, IDbTransaction transaction);
}

public class CreateThingCommand : ICommand
{
    public Guid Id { get; private set; }
    public string Something { get; private set; }

    public CreateThingCommand(Guid id, string something)
    {
        // throw validation errors here
        Id = id;
        Something = something;
    }

    public async Task Execute(IDbConnection connection, IDbTransaction transaction)
    {
       // dapper goes here
    }
}
With this on the BaseController:
C# code:
public async Task ExecuteCommandAsync(ICommand command)
{
    using (var conn = GetConnection()) // some ioc magic here
    using (var trans = conn.BeginTransaction())
    {
        await command.Execute(conn, trans);
        trans.Commit();
    }
}
There's a separation of concerns thing there about the command being it's own handler and once you start scaling up you'll want to inject something with the "Execute" method for testing purposes but those are simple to solve when you start hitting pain points.
The controllers end up being fairly declarative and readable too:
C# code:
[HttpPost]
public async Task<ActionResult> CreateMeAThing(string something)
{
    var id = Guid.New(); 
    var command = new CreateThingCommand(id, something);
            
    await ExecuteCommandAsync(command);
            
    return RedirectToAction("View", new { id });
}

Gul Banana
Nov 28, 2003

Kekekela posted:

It seems like you think Atom is bad, which is also kind of the vibe I get from other people whose technical opinions that I value. Can you elaborate on why if its not too off-topic? (or is it just the large files thing?)

I've been trying to transition to doing more of my non-VS development on my macbook and I've been using Atom. I'd switched to it a couple months ago because Sublime made me feel guilty about being cheap. Mainly its smaller github projects and files for now and Atom's been great. If I'm going to run into a wall with it though, I'd like to know now rather than later so I can shift to a plan B. (which I guess would be Webstorm or back to Sublime)

If Atom works for you that's fine. I just prefer the native controls & performance that you get from a lower-level editor. Using HTML5 by preference for UI development is just.. a weird trend that I don't fully understand; it's like people learned javascript and don't want to ever go beyond that, despite its disadvantages for complex applications. A text editor *seems* simple, but a good programming editor has a lot of features these days.

Performance is a specific concern - I have some 4 MB .cs files here, 90k lines or so of generated code. My machine is also bogged down with virtual machines, conference calls and debug utilities.. I don't want to have to worry about a mess of DOM spans for just my editor windows.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
Bit of a stupid question here, but for anyone who has run the new VSCode editor, where does it install on the system? I installed and ran it yesterday, but it hasn't shown up in my path (supposed to be 'code', I think). It also doesn't show up from searching 'code' in the start menu, and doesn't seem to be in either Program Files/ or Program Files (x86)/.

Running the installer again pops the splash install screen, which then disappears and doesn't seem to change anything :/.

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Newf posted:

Bit of a stupid question here, but for anyone who has run the new VSCode editor, where does it install on the system? I installed and ran it yesterday, but it hasn't shown up in my path (supposed to be 'code', I think). It also doesn't show up from searching 'code' in the start menu, and doesn't seem to be in either Program Files/ or Program Files (x86)/.

Running the installer again pops the splash install screen, which then disappears and doesn't seem to change anything :/.

Mine is in %appdata%\..\local\Code. Somewhere in %appdata% seems to be where the cool kids are going instead of Program Files. Is %appdata% more locked down than Program Files?

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

gariig posted:

Mine is in %appdata%\..\local\Code. Somewhere in %appdata% seems to be where the cool kids are going instead of Program Files. Is %appdata% more locked down than Program Files?

Ah, I should have known, given that it's made with the same UI framework as Atom.

I guess this means that we can expect for the location of the executable to change when the program updates - something that gave me a pretty good surprise last week when my powershell alias for atom suddenly stopped working.

AstuteCat
May 4, 2007

gariig posted:

Mine is in %appdata%\..\local\Code. Somewhere in %appdata% seems to be where the cool kids are going instead of Program Files. Is %appdata% more locked down than Program Files?

Actually, the opposite* - local app data isn't locked down as much as program files because it's per-user and not a machine-wide application data location. This means that elevation isn't required to install or update the application, either.

* - for the logged in user, iirc by default that location is locked for other users.

AstuteCat fucked around with this message at 15:24 on Apr 30, 2015

xgalaxy
Jan 27, 2004
i write code

Gul Banana posted:

If Atom works for you that's fine. I just prefer the native controls & performance that you get from a lower-level editor. Using HTML5 by preference for UI development is just.. a weird trend that I don't fully understand; it's like people learned javascript and don't want to ever go beyond that, despite its disadvantages for complex applications. A text editor *seems* simple, but a good programming editor has a lot of features these days.

Performance is a specific concern - I have some 4 MB .cs files here, 90k lines or so of generated code. My machine is also bogged down with virtual machines, conference calls and debug utilities.. I don't want to have to worry about a mess of DOM spans for just my editor windows.

You should probably download and try VS Code. Because this thing is outperforming Atom for me by large margins.
Not sure what they did under the hood but it doesn't feel sluggish at all.

Space Whale
Nov 6, 2014
I've got an issue with JSON serialization.

An endpoint I hit does not like lists of length 1, saying "the string isn't formatted properly" unless it's sent as just an object. The thing is, the given property is basically a list as I see it, with one or two entries.

Is there a way to tell Newtonsoft (or any other json serializer) to serialize a list of 1 as just an object?

Edit: it's fine. Whitespace poo poo with my pretty-printed json I was passing to it made it screw up. WTF? ??

Space Whale fucked around with this message at 21:28 on Apr 30, 2015

Calidus
Oct 31, 2011

Stand back I'm going to try science!
So am I missing anything?

  • Win10 runs iOS and Android with App-V
  • .Net Core5 allows ASP.NET 5 to run on Linux and OSX.
  • Windows Universal Apps allows a single application to run on Windows desktops, tablets, phones, xbox and halolens
  • Visual Studio can debug Android and iOS apps
  • ASP.NET 5 will not support Web Forms
  • ASP.NET 5 will not support VB
  • VS2015 has templates for AngularJS

ljw1004
Jan 18, 2005

rum

Calidus posted:

So am I missing anything?
  • Win10 runs iOS and Android with App-V
  • .Net Core5 allows ASP.NET 5 to run on Linux and OSX.
  • Windows Universal Apps allows a single application to run on Windows desktops, tablets, phones, xbox and halolens
  • Visual Studio can debug Android and iOS apps
  • ASP.NET 5 will not support Web Forms
  • ASP.NET 5 will not support VB
  • VS2015 has templates for AngularJS

Actually ASP.NET 5 will support VB.
http://blogs.msdn.com/b/webdev/archive/2015/04/23/making-it-better-asp-net-with-visual-basic-14.aspx

quote:

ASP.NET 5 – C# Support And Also Visual Basic

We’ve talked about ASP.NET 5 as a major update of the ASP.NET framework with Roslyn and cross-platform support in mind since our initial public discussions. It is not a short path, and we focused initially on completing support for C#. In the months since our initial announcements, we have heard from many of you, telling us how much you like Visual Basic and that they want to see support for it in ASP.NET 5.

We are excited today to announce that ASP.NET 5 will have full support with Visual Basic (both tooling and runtime – including cross platform runtime support). As always, we will continue this development of ASP.NET 5 in the open, and you can track our progress or even contribute on GitHub at http://github.com/aspnet/home.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Is there a "correct" way to bind a text control's content to non-string data in one's model? My solution was something like this (working from memory, again...):

C# code:
public class RawRecord
{
  // ...
  public byte[] Payload {get; set;}
  public string PayloadHex { get {
    StringBuilder s = new StringBuilder();
    foreach (var b in Payload) s.AppendFormat("{0:X2} ", b); // something like that I think
    return s.ToString();
  }}
}
XML code:
<!-- I might be loving up some property names, going from memory -->
<!-- Also, DataContext is my viewmodel, RawRecords is ObservableCollection<RawRecord> -->
<DataGrid ItemsContent="{Binding RawRecords}">
  <DataGridTextColumn Text="{Binding PayloadHex}" />
  <!-- ... -->
</DataGrid>
It feels vaguely wrong that Just Make Another Property is my answer to all my binding problems when there are properties like ContentsStringFormat on Label for example, but I couldn't work out how to use that with a byte[].

Ciaphas fucked around with this message at 22:43 on Apr 30, 2015

Dreadrush
Dec 29, 2008

RICHUNCLEPENNYBAGS posted:

OK, that's what we were all talking about a few posts ago when we mentioned "projection," but that doesn't help if you want to mutate data. For read-only queries projection is the way to go (even if you aren't going after navigation properties you will select the entire row without it).

As for your point about controllers: no, I entirely disagree. The purpose of the controller is not to do data access. I have no idea what it means for "each controller to represent a different HTTP resource."

Instead of creating controllers to correspond with concepts in your application like a "UsersController" which contains many different methods related to a User, but containing different routes (e.g. [Route("/users")], [Route("/users/current")]), I suggest creating separate controllers to represent each of these resources - UsersController, CurrentUserController - placed inside a folder structure mimicking the route e.g. UsersController might be kept in /controllers/users, CurrentUserController in /controllers/users/current. This leaves less ambiguity as to where methods go (someone might put some method for [Route("/tickets/user"] inside the UsersController, and someone else in the TicketsController with the first approach), and also will help to keep those classes small. I also suggest to keep any objects returned from these controllers or passed into these controllers inside these same folders, rather than externally inside "/models" folder. These objects represent the relevant web resource.

Ok so now my controller classes are much smaller, and they are more closely following how the web actually works. Those CQS examples are probably not needed in the vast majority of cases (there are no silver bullets - what I am saying here applies to most projects, not every project) - my get requests are like requests, and post/put/del/patch are like commands, with modelbinding already passing through the request/command objects.

From here, why should I create an extra layer to enforce that all data access is performed inside? This is a lot of extra work for me, and makes the code more complex. I choose to simplify my code as much as possible, and write EF queries directly in the controllers. In lots of cases, the queries/commands used will be unique to a particular controller. In other cases I might want to be able to compose parts of queries, so in those cases I will share that code by placing the queries inside helper methods.

This gives me the most simple code for the majority of cases, and in more complex cases I can abstract code away into additional classes. When changes/problems come up, I am able to quickly and easily see what is happening inside a request, rather than having to step down additional layers.

As for the use of Include - there was an example given with problems of using Include which was retrieving data, where I don't think this should be done at all. When it comes to updates/inserts, then it is a case-by-case basis. Sometimes the code is best written so that it only updates a single column, without any selects. Sometimes it is best written so that a row is retrieved, then values are updated.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Ciaphas posted:

Is there a "correct" way to bind a text control's content to non-string data in one's model? My solution was something like this (working from memory, again...):

This is the classic use case for a Value Converter.

Opulent Ceremony
Feb 22, 2012

I don't even know where to start with any of this craziness. You know what makes sharing queries easy? Putting them somewhere outside of a controller in the first place. When you write unit tests for your multitude of microcontroller classes that are also doing EF, you are testing the same class and probably the same method when you test whether the user is being routed to the proper place as well as when you test whether some state change occurred in your data based on user-provided inputs. You can't make a separate project for model-related stuff to allow re-use and quick extension for other projects that might want to use the same data because you mixed your model stuff directly into ASP.NET.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Bognar posted:

This is the classic use case for a Value Converter.

Thanks, I'll give it a proper look later. Seems like a lot more faff than just doing what I did, at least at first glance, though.

RICHUNCLEPENNYBAGS
Dec 21, 2010

Dreadrush posted:

Instead of creating controllers to correspond with concepts in your application like a "UsersController" which contains many different methods related to a User, but containing different routes (e.g. [Route("/users")], [Route("/users/current")]), I suggest creating separate controllers to represent each of these resources - UsersController, CurrentUserController - placed inside a folder structure mimicking the route e.g. UsersController might be kept in /controllers/users, CurrentUserController in /controllers/users/current. This leaves less ambiguity as to where methods go (someone might put some method for [Route("/tickets/user"] inside the UsersController, and someone else in the TicketsController with the first approach), and also will help to keep those classes small. I also suggest to keep any objects returned from these controllers or passed into these controllers inside these same folders, rather than externally inside "/models" folder. These objects represent the relevant web resource.

Ok so now my controller classes are much smaller, and they are more closely following how the web actually works. Those CQS examples are probably not needed in the vast majority of cases (there are no silver bullets - what I am saying here applies to most projects, not every project) - my get requests are like requests, and post/put/del/patch are like commands, with modelbinding already passing through the request/command objects.

From here, why should I create an extra layer to enforce that all data access is performed inside? This is a lot of extra work for me, and makes the code more complex. I choose to simplify my code as much as possible, and write EF queries directly in the controllers. In lots of cases, the queries/commands used will be unique to a particular controller. In other cases I might want to be able to compose parts of queries, so in those cases I will share that code by placing the queries inside helper methods.

This gives me the most simple code for the majority of cases, and in more complex cases I can abstract code away into additional classes. When changes/problems come up, I am able to quickly and easily see what is happening inside a request, rather than having to step down additional layers.

As for the use of Include - there was an example given with problems of using Include which was retrieving data, where I don't think this should be done at all. When it comes to updates/inserts, then it is a case-by-case basis. Sometimes the code is best written so that it only updates a single column, without any selects. Sometimes it is best written so that a row is retrieved, then values are updated.

OK, man. Do what you want. I think it's nuts to use attributes to hand-configure all your routes instead of just using a convention to do it once too.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

xgalaxy posted:

You should probably download and try VS Code. Because this thing is outperforming Atom for me by large margins.
Not sure what they did under the hood but it doesn't feel sluggish at all.

They don't actually use Atom-proper. They just use "atom-shell" (which GitHub hastily branded as Electron for this release) which is a cross-platform wrapper for Chrome/io.js. It's effectively from-scratch other than that base.

Dreadrush
Dec 29, 2008

Opulent Ceremony posted:

I don't even know where to start with any of this craziness. You know what makes sharing queries easy? Putting them somewhere outside of a controller in the first place. When you write unit tests for your multitude of microcontroller classes that are also doing EF, you are testing the same class and probably the same method when you test whether the user is being routed to the proper place as well as when you test whether some state change occurred in your data based on user-provided inputs. You can't make a separate project for model-related stuff to allow re-use and quick extension for other projects that might want to use the same data because you mixed your model stuff directly into ASP.NET.

Are you talking about mvc controllers? I am talking about api controllers here.

RICHUNCLEPENNYBAGS
Dec 21, 2010

Dreadrush posted:

Are you talking about mvc controllers? I am talking about api controllers here.

It doesn't matter. Whichever you're talking about, you're talking nonsense.

roflsaurus
Jun 5, 2004

GAOooooooh!! RAOR!!!
Can anyone point me to some solid resources on authentication + authorization for web api?

My client has an existing web app using SqlMembershipProvider for authentication. I have to build a mobile app (xamarin) that re-uses this authentication store. However most of the tutorials on web api 2 are all using the full OWIN + oAuth stack.

They'd also like to do sliding scale session expiration.

My current thoughts are to use the guide here for Basic HTTP authentication : http://www.asp.net/web-api/overview/security/authentication-filters

But instead of passing username + password in every request I would roll my own (basic) session management.

i.e.

  1. User hits login (string username, string password, string deviceUID)
  2. Login function uses old provider database to check username + password
  3. Login function creates a Session ID and saves to DB, returns Session ID.
  4. Session ID is linked to Requesting IP Address
  5. Every subsequent request passes in Username, IP address and Session ID via the HttpHeaders. (passing in session ID instead of password)
  6. Each request checks the DB to ensure the request is linked to an active session
  7. Every request resets the "last access time"
  8. if Session is inactive for X minutes, it invalidates the session.

Are there any obvious gaps in this approach? I would prefer to go one of the standard methods, but i'm restricted because we can't implement the new owin model and any of the generic oAuth bearer token stuff can't do sliding expiration. The token refresh looks to be way overkill as well.

If I use basic HTTP auth (wrapped in SSL), then this means I can always change the auth method down the track without having to change any controller method signatures.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
I'm assuming the existing web app uses a session cookie to maintain authorization state? If so, you can just use cookies with HttpClient. It lets you set a CookieContainer, which will handle cookies like a browser would.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
So I updated my Windows 10 build to the newest one available, and got VS 2015 RC and the newest SDK drop. Now when I compile pages, I'm getting this error:

quote:

Error CS0535 'UserProfilePage' does not implement interface member 'IComponentConnector2.Connect(int, object, object)' AwfulForumsReader C:\Users\Butts\Documents\Other-Apps\Awful-Forums-Reader\AwfulForumsReader-UAP\AwfulForumsReader\obj\x64\Debug\Pages\UserProfilePage.g.cs 16

This is in generated code. I can implement the interface, but it's just going to get overwritten at some point. Any ideas of what's going on?

EDIT: Actually I think it's an SDK issue. :psyduck:

Drastic Actions fucked around with this message at 17:37 on May 1, 2015

brap
Aug 23, 2004

Grimey Drawer
So I've got a WCF two way TCP service running in a WPF app, and clients to that service running in a Winforms tray icon app. Right now I have the client app set up to create a new service client and try to reconnect when the fault event occurs. This is supposed to make it so it automatically reconnects if there's a temporary issue communicating with the server. In practice though it causes my server app to freeze if I launch the client before launching the server. What should I be doing differently?

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug
I've come across a weird issue with using XDocument to read, update and save a simple XML file. The source file contains a tag with an attribute that has a value like "Randy's Hamburgers" but when loaded/saved using XDocument.Load/Save it's being rewritten as "Randy's Hamburgers" which is causing another system downstream to poo poo itself. What can I do to preserve the files exisiting encoding?

Edit: I think I may have found my answer.

So this would involve me doing some rewrites, which I'm not against but would like to avoid if possible. Thoughts?

Dr. Poz fucked around with this message at 20:17 on May 1, 2015

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Dr. Poz posted:

I've come across a weird issue with using XDocument to read, update and save a simple XML file. The source file contains a tag with an attribute that has a value like "Randy's Hamburgers" but when loaded/saved using XDocument.Load/Save it's being rewritten as "Randy's Hamburgers" which is causing another system downstream to poo poo itself. What can I do to preserve the files exisiting encoding?

Edit: I think I may have found my answer.

So this would involve me doing some rewrites, which I'm not against but would like to avoid if possible. Thoughts?
You can specify the encoding you want in the TextWriter.

Example of forcing UTF32:
C# code:
using (FileStream fileStream = File.OpenWrite("myfile.xml"))
using (StreamWriter writer = new StreamWriter(fileStream, Encoding.UTF32))
    xdoc.Save(writer);

Mellow_
Sep 13, 2010

:frog:

Drastic Actions posted:

So I updated my Windows 10 build to the newest one available, and got VS 2015 RC and the newest SDK drop. Now when I compile pages, I'm getting this error:


This is in generated code. I can implement the interface, but it's just going to get overwritten at some point. Any ideas of what's going on?

EDIT: Actually I think it's an SDK issue. :psyduck:

You have a class that is derived from an interface that is not implementing a method from the interface.

Why that's happening in generated code is quite honestly.. Baffling. Are there any Windows 10 specific SDK changes?

Mellow_ fucked around with this message at 21:16 on May 1, 2015

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

AuxPriest posted:

You have a class that I derived from an interface that is not implementing a method from the interface.

Why that's happening in generated code is quite honestly.. Baffling. Are there and Windows 10 specific SDK changes?

I figured it out, it was just a SDK screw up. I uninstalled the old version and reinstalled the new one. It works again.

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug

Inverness posted:

You can specify the encoding you want in the TextWriter.

Example of forcing UTF32:
C# code:
using (FileStream fileStream = File.OpenWrite("myfile.xml"))
using (StreamWriter writer = new StreamWriter(fileStream, Encoding.UTF32))
    xdoc.Save(writer);

Interesting, but this doesn't seem to be getting me to the result I'm after as it still leaves the apostrophe in a tags value. For clarity, here is the XML as it exists when I read it in using XDocument.Load:

code:
<?xml version="1.0" encoding="utf-8"?>
<foo stuff="Randy&apos;s stupid burgers">
</foo>
And here is what it looks like when saved out with the XDocument objects Save:

code:
<?xml version="1.0" encoding="utf-8"?>
<foo stuff="Randy's stupid burgers">
</foo>
After running the example code you provided, the document is encoded differently but the apostrophe remains in the "stuff" attribute.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Dr. Poz posted:

Interesting, but this doesn't seem to be getting me to the result I'm after as it still leaves the apostrophe in a tags value. For clarity, here is the XML as it exists when I read it in using XDocument.Load:

code:
<?xml version="1.0" encoding="utf-8"?>
<foo stuff="Randy&apos;s stupid burgers">
</foo>
And here is what it looks like when saved out with the XDocument objects Save:

code:
<?xml version="1.0" encoding="utf-8"?>
<foo stuff="Randy's stupid burgers">
</foo>
After running the example code you provided, the document is encoded differently but the apostrophe remains in the "stuff" attribute.
Oh that is different. Your first post didn't actually have any difference in the two strings you posted, so I didn't know what you were talking about.

This is a different sort of encoding. Maybe the HtmlWriter or XHtmlWriter would do it automatically? I don't know. This is out of my knowledge area.

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug
Aw shoot, you're right. Derp! I went over the problem with a co-worker a bit earlier and they just got back to me with this solution which seems perfect for the situation.

code:
void Main()
{
	XDocument.Parse(@"<node value=""Randy&apos;s Fine Dinner's"">Randys Fine Diner &gt; other diner &quot; &amp;&amp; &lt; better diner</node>")
		.Save(new SuperXmlTextWriter(Console.Out));
}

class SuperXmlTextWriter : XmlTextWriter
{
	public SuperXmlTextWriter(TextWriter tw) : base (tw) {}
	public override void WriteString(string value)
	{
		base.WriteRaw(SecurityElement.Escape(value));
	}
}

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Ciaphas posted:

Thanks, I'll give it a proper look later. Seems like a lot more faff than just doing what I did, at least at first glance, though.

Quoting myself because now that I've done this, I see the point. Ran into a problem, though. Here's something like my code:
XML code:
<Window x:Class="DataViewer.MainWindow"
...
xmlns:conv="clr-namespace:DataViewer.Converters">
<!-- DataContext set in code behind -->
<DataGrid ItemsSource="{Binding RawRecords}" AutoGenerateColumns="False">
  <DataGridTextColumn Binding="{Binding Bytes, Converter={conv:ByteArrayToHexStringConverter}}" />
</DataGrid>
C# code:
namespace DataViewer.Converters
{
  abstract class ConverterBase : MarkupExtension, IValueConverter
  {
    public override object ProvideValue(IServiceProvicer serviceProvider) { return this; }
    public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);
    public abstract object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);
  }

  class ByteArrayToHexStringConverter : ConverterBase
  {
    public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // StringBuilder poo poo }
    public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); }
  }
}
VS2012 complains about my xaml with the error "The name "ByteArrayToHexStringConverter" does not exist in the namespace "clr-namespace:DataViewer.Converters"." But if I go to build and run, it all works. Is there any way to make that error message go away?


Separate question. My ViewModel has an ObservableCollection<RawRecord> RawRecords. One of RawRecord's properties is Category; in my UI I want to display a distinct list of Categories that are present in the collection. I can easily work out that result into a List<int>--something like RawRecords.Select(x=>x.Category).Distinct().ToList(), I think--but I have no real idea how to bind to that. Is it possible, or am I going to have to create a separate ObservableCollection containing the list of categories I've found?

Mellow_
Sep 13, 2010

:frog:
So a product I'm working with uses WebMatrix to create and store Users/Accounts in the database. We're managing deletion of accounts with an IsDeleted flag... standard stuff.

Anyone know of a way to create duplicate user accounts with WebMatrix? Say I have the user AuxPriest that is deleted and a user wants to create a fresh AuxPriest account, it will throw an exception (username already in use).

Any way to allow duplicate users by checking that only one may have IsDeleted=false, ignoring those that have been 'deleted'?

I figure probably not, just wondering if anyone has any advice.


E: I know this is rather bad design, but what my lead dev requires, if it is possible.

Mellow_ fucked around with this message at 21:59 on May 1, 2015

Inverness
Feb 4, 2009

Fully configurable personal assistant.

AuxPriest posted:

So a product I'm working with uses WebMatrix to create and store Users/Accounts in the database. We're managing deletion of accounts with an IsDeleted flag... standard stuff.

Anyone know of a way to create duplicate user accounts with WebMatrix? Say I have the user AuxPriest that is deleted and a user wants to create a fresh AuxPriest account, it will throw an exception (username already in use).

Any way to allow duplicate users by checking that only one may have IsDeleted=false, ignoring those that have been 'deleted'?

I figure probably not, just wondering if anyone has any advice.


E: I know this is rather bad design, but what my lead dev requires, if it is possible.
So this WebMatrix thing identifies user accounts only by name and not with some kind of ID?

Well, maybe you could rename accounts you delete with some sort of suffix?

Mellow_
Sep 13, 2010

:frog:

Inverness posted:

So this WebMatrix thing identifies user accounts only by name and not with some kind of ID?

Well, maybe you could rename accounts you delete with some sort of suffix?

That's a clever solution I'm angry I never thought of.

I'll talk to my lead dev about it on Monday.

We have the ability to un-delete accounts so I'm not sure why our users are having this issue...

crashdome
Jun 28, 2011

AuxPriest posted:

We have the ability to un-delete accounts so I'm not sure why our users are having this issue...

Wait. So user "BigGoon" can delete their account and then another user can come along and use "BigGoon" and then the first user can undelete and now you have duplicate usernames?

Mellow_
Sep 13, 2010

:frog:

crashdome posted:

Wait. So user "BigGoon" can delete their account and then another user can come along and use "BigGoon" and then the first user can undelete and now you have duplicate usernames?

Yeah that would basically be how it works unless I stop undelete if an existing user with that name exists in an undelete state.

It's basically going to be a mess. But hey I don't design it, just write it.

The same thing is going to be done with user groups and permissions lmao.

E: to clarify, only admin users can manage accounts, they create the account and then hand them out to users.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Hay GrumpyDoctor, Bognar, NihilCredo, thanks for answering my large file write question back on April 13. I no longer work for that organization, which is why I haven't been back here to give you fist bumps on your advice. But daps all around, I really appreciate you guys answering questions.

Adbot
ADBOT LOVES YOU

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Calidus posted:

So am I missing anything?

  • Win10 runs iOS and Android with App-V

This isn't right, I think. App-V is for Win32/.NET app packaging for store listings. For ObjC & Android, it's native lang support in VS + implementing portions of those platform APIs using Universal Windows apis and then you recompile that project for Windows.

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