Tag: .Net
-
Passing in “this” in StructureMap
I’ve been working with StructureMap lately, and struggled when I need to pass this in. The following code is an example of resolving that issue… namespace StateMachine { public class StateRegistry : StructureMap.Configuration.DSL.Registry { public StateRegistry () { For<IState>.Use<StateA>.Named(“FirstState”); For<IState>.Use<StateB>.Named(“SecondState”); } } public interface IStateMachine { void ChangeState(IState state); } public interface IState { void […]
-
Function Name Instead of Lambda in Linq Functions
I did not realize that functions can fill in for predicates directly without lambda notation. To illustrate, consider the following: void Main() { var words = new List<string>() { “therapists”, “s words”, “slang”, “mustache”, “sean connery” }; var s_words = words.Where(w => w.StartsWith(“s” ,StringComparison.CurrentCultureIgnoreCase)); foreach(var word in s_words) { Console.WriteLine(word); } } It works, but […]
-
MSpec “Hello World” Sample
I’ve been working with MSpec lately. It’s a BDD framework for .Net. Here’s a hello world type example that uses Trace Writing to show a little bit about what it does. using System; using Machine.Specifications; using System.Diagnostics; namespace UnitedIndustrial.DataImportConcerns { [Subject(“Sample”)] public class SampleConcerns { static string _myString; Establish _context = () => { _myString […]
-
IEnumerable and Linq
I was helping someone on StackOverFlow.com and ran into an interesting issue. The post is here. I explained the issue in my response, but I’ll try to sum up. Newer collection types implement IEnumerable(Of T) as opposed to the original IEnumerable interface. For example, System.Generic.List(Of T) implements IEnumerable(Of T), so the following is valid without […]
-
SilverLight and Z-Index
When implementing a new SilverLight custom control, it was blocking menu popups (html / javascript) on the page. I set the z-index of the div and object tags that contained SilverLight to no avail. After a lot of googling, I found the following solution. Set the Windowless property to true. In the case of manually […]