This is just a spot to keep miscellaneous links. It also shows you what a geek I am.
Tuesday, September 06, 2011
Wednesday, July 13, 2011
WCF Notes
To discover WCF services, make sure that https is turned off. This is done in two places, apparently:
- In the binding, on the Security tab, Mode property, make sure the property is not set to “Transport”.
- In the service behaviors, serviceMetadata, make sure httpsGetEnabled is set to false and that httpsGetEnabled is set to true.
When you’re done, turn those things back on again.
Common Design Patterns Resources : Steve Smith's Blog
Steve Smith gave a great talk last night at Bennett Adelson's .NET SIG, with many good links. Here's the link to his blog post on it: Common Design Patterns Resources : Steve Smith's Blog
Monday, July 11, 2011
Irony - .NET Language Implementation Kit.
Wow. Very interesting stuff here. There are links here on how to implement a DSL. Irony - .NET Language Implementation Kit.
Here is one of the links: Writing your first Domain-Specific Language
Thursday, June 23, 2011
Cleaning up POSTs in ASP.NET MVC | Jimmy Bogard's Blog
Cleaning up POSTs in ASP.NET MVC | Jimmy Bogard's Blog:
"What we see over and over and over again is a similar pattern of:
Where all the things in red are things that change from POST action to POST action."
"What we see over and over and over again is a similar pattern of:
[HttpPost] public ActionResult Edit(SomeEditModel form) { if (IsNotValid) { return ShowAView(form); } DoActualWork(); return RedirectToSuccessPage(); }
Where all the things in red are things that change from POST action to POST action."
Friday, June 10, 2011
How to replace all automatic properties of string type with a string type which is never null
I have to do this in a piece of code, so I'm recording this here for my future reference.
In Visual Studio's Find and Replace dialog, type the following in the "Find what:" field:
public string \{:i\} \{ get; set; \}
Type this into the "Replace with" field:
private string _\1;\npublic string \1 \{\nget \{ return _\1 ?? ""; \}\nset \{ _\1 = value; \}\n\}
This pattern of performing a test in the getter versus the setter guarantees that it will never be null, and is the pattern used in the TextBox web control's Text property.
Afterwards you'll want to reformat the code, and possibly rename the backing fields, e.g. _FirstName, to be more camel-cased instead of being Pascal-cased(-like), e.g. _firstName instead of _FirstName.
In Visual Studio's Find and Replace dialog, type the following in the "Find what:" field:
public string \{:i\} \{ get; set; \}
Type this into the "Replace with" field:
private string _\1;\npublic string \1 \{\nget \{ return _\1 ?? ""; \}\nset \{ _\1 = value; \}\n\}
This pattern of performing a test in the getter versus the setter guarantees that it will never be null, and is the pattern used in the TextBox web control's Text property.
Afterwards you'll want to reformat the code, and possibly rename the backing fields, e.g. _FirstName, to be more camel-cased instead of being Pascal-cased(-like), e.g. _firstName instead of _FirstName.
Thursday, June 09, 2011
Date & Time Formats on the Web
Everything you've always wanted to know about date/time formats but were afraid to ask.
Date & Time Formats on the Web: "There are several different formats used in different places in the technologies of the World Wide Web to represent dates, times and date/time combinations (hereafter collectively referred to as “datetimes” unless a distinction has to be made). This document presents a survey of the most significant, details which formats are mandated by the key technologies of the web, and offers advice for deciding what formats you should use in your own web applications."
Date & Time Formats on the Web: "There are several different formats used in different places in the technologies of the World Wide Web to represent dates, times and date/time combinations (hereafter collectively referred to as “datetimes” unless a distinction has to be made). This document presents a survey of the most significant, details which formats are mandated by the key technologies of the web, and offers advice for deciding what formats you should use in your own web applications."
Wednesday, May 11, 2011
Josh Reed Schramm - Software Development Thoughts And Opinions - Blog - Unit Testing Role Based Security w/ ASP.Net MVC
When attributes are an integral part of the work flow, testing is a bitch. Luckily I found this code.
Josh Reed Schramm - Software Development Thoughts And Opinions - Blog - Unit Testing Role Based Security w/ ASP.Net MVC: "I took Paul's code and turned it into a series of three controller extension methods which verify if the entire controller requires authorization, a particular method requires authorization or if a particular method requires a given role (i have not yet written the obvious 4th case - an entire controller requires a given role but it should be trivial.)"
Josh Reed Schramm - Software Development Thoughts And Opinions - Blog - Unit Testing Role Based Security w/ ASP.Net MVC: "I took Paul's code and turned it into a series of three controller extension methods which verify if the entire controller requires authorization, a particular method requires authorization or if a particular method requires a given role (i have not yet written the obvious 4th case - an entire controller requires a given role but it should be trivial.)"
Tuesday, May 10, 2011
Compiling MVC Views In A Build Environment
Compiling MVC Views In A Build Environment: "It turns out we had a bug in our project templates in earlier versions of ASP.NET MVC that we fixed in ASP.NET MVC 3 Tools Update.
But if you created your project using an older version of ASP.NET MVC including ASP.NET MVC 3 RTM (the one before the Tools Update), your csproj/vbproj file will still have this bug."
But if you created your project using an older version of ASP.NET MVC including ASP.NET MVC 3 RTM (the one before the Tools Update), your csproj/vbproj file will still have this bug."
Thursday, April 21, 2011
Knock Me Out
Knock Me Out: "Ideas, thoughts, and discussion about Knockout (KnockoutJS.com) and related technologies (jQuery and jQuery Templates)"
Monday, April 18, 2011
Friday, April 08, 2011
Why I Still L.O.V.E. ASP.NET WebForms - John Katsiotis
This guy uses the Model-View-Presenter (MVP) pattern with ASP.NET WebForms. A Microsoft MSDN link is here; a Martin Fowler article here.
Thursday, April 07, 2011
Don't mock HttpContext
Don't mock HttpContext: "It's so easy to take a direct dependency on HttpContext and not even realize it. If you're in the code behind in Web Forms or in a controller action in MVC, it's just right there, tempting you to use it to access session variables, application security, etc.
But don't."
But don't."
Monday, April 04, 2011
dapper-dot-net - Simple SQL object mapper for SQL Server - Google Project Hosting
Wow. Impressive! Great for quick and dirty stuff, no? It uses dynamic types extensively.
dapper-dot-net - Simple SQL object mapper for SQL Server - Google Project Hosting: "Dapper - a simple object mapper for .Net
Dapper is a single file you can drop in to your project that will extend your IDbConnection interface."
dapper-dot-net - Simple SQL object mapper for SQL Server - Google Project Hosting: "Dapper - a simple object mapper for .Net
Dapper is a single file you can drop in to your project that will extend your IDbConnection interface."
Friday, April 01, 2011
Setting the Text of a ListControl in ASP.NET
If you try the following, it should set the visible text of the dropdown control in question, right?
You may be asking yourself why I am trying to set the visible text and not the value of the control. The reason is that the application I'm working on receives the displayed text from a web service and not the value that is passed in the form variables. Why not create a dictionary, look up the the text string in the dictionary, and pass that to the control?
The answer? I already have a dictionary. It's called the SELECT control itself. The generated HTML for my control is, say, the following:
This control is essentially a dictionary of key-value pairs: the key is the value attribute of the option tag, and the value is the visible text that is displayed for the given item in the dropdown list. So in the spirit of Don't Repeat Yourself (DRY), I wrote a extension function to allow me to set not just the value but also the text. I give you ListControlExtensions.cs:
Here's a typical usage. In this particular scenario, my data should be scrubbed, but if not I log a warning:
listControl.Text = "4 Year College";Well, unfortunately, no! The "Text" property is named that way for consistency across all ASP.NET controls and refers to the form value that is passed to the server when the page is submitted. So unfortunately for me, the "Text" property silently rejected my attempt to set it and the page did not work.You may be asking yourself why I am trying to set the visible text and not the value of the control. The reason is that the application I'm working on receives the displayed text from a web service and not the value that is passed in the form variables. Why not create a dictionary, look up the the text string in the dictionary, and pass that to the control?
The answer? I already have a dictionary. It's called the SELECT control itself. The generated HTML for my control is, say, the following:
This control is essentially a dictionary of key-value pairs: the key is the value attribute of the option tag, and the value is the visible text that is displayed for the given item in the dropdown list. So in the spirit of Don't Repeat Yourself (DRY), I wrote a extension function to allow me to set not just the value but also the text. I give you ListControlExtensions.cs:
Here's a typical usage. In this particular scenario, my data should be scrubbed, but if not I log a warning:
Monday, March 28, 2011
Five advanced Git merge techniques : Inside P4
Includes the handy-dandy command: git config --global merge.conflictstyle diff3
by Edward Z. Yang
Have you ever performed a merge in Git and not have it quite turn out the way you wanted it to? For example, you accidentally converted all of your UNIX line endings to DOS line endings, and now the entire file reports a conflict? Maybe you see a conflict that you don't really care about resolving, and want to resolve as theirs? Or perhaps the conflicted file is empty and you can't figure out just what happened there?"
Friday, March 25, 2011
Caffeine-Powered Life - Nested Collection Models in ASP.NET MVC 3
Wow! Caffeine-Powered Life - Nested Collection Models in ASP.NET MVC 3: "We want to create form where I can save information about a person. That person has zero or more phone numbers and zero or more email addresses. The customer would like to edit everything about a person all at once, on a single form. This is a dynamic nested model problem."