Tinidazole 300mg Pills $251.00

4Jun/103

Prednisone 40mg Pills $262.00

Prednisone 40mg pills $262.00 This week I ran into wanting to use C# 4.0 optional parameters, prednisone 40mg pills $262.00 but wanted StructureMap (my IoC tool of choice) to respect the default value specified for those optional parameters.

The Problem

Prednisone 40mg pills $262.00 In this example, prednisone 40mg pills $262.00 we’ll be pulling a command out of the container.  The important part is the optional constructor parameter (level), prednisone 40mg pills $262.00 and it’s default value (Level.Info).

public class LogCommand

{

    IDestination _destination;

    Level _level;

 

    public LogCommand(

        IDestination destination, prednisone 40mg pills $262.00 Level level = Level.Info)

    {

        _destination = destination;

        _level = level;

    }

 

    /* logging code here */

}

 

Prednisone 40mg pills $262.00 Here is your basic usage, prednisone 40mg pills $262.00 but doesn’t work since StructureMap doesn’t know how to take advantage of the optional parameters with default values.

var container = new Container(config =>

{

    config.Scan(scanner =>

    {

        scanner.TheCallingAssembly();

        scanner.AddAllTypesOf<IDestination>();

        scanner.WithDefaultConventions();

    });

});

 

var logCommand = container.GetInstance<LogCommand>();

 

Prednisone 40mg pills $262.00 The last line results in an exception because StructureMap doesn’t know how to fill in the level parameter.

The Solution

Prednisone 40mg pills $262.00 We can solve this by adding a new convention.  One that adds information about default constructor arguments.  Here is the implementation of the convention:

public class DefaultCtorParameterConvention : IRegistrationConvention

{

    public void Process(Type type, prednisone 40mg pills $262.00 Registry registry)

    {

        if(type.IsAbstract || type.IsEnum)

            return;

 

        var ctor = type.GetGreediestCtor();

 

        if(!ctor.HasOptionalParameters())

            return;

 

        var inst = registry.For(type).Use(type);

 

        foreach(var param in ctor.GetOptionalParameters())

            inst.Child(param.Name).Is(param.DefaultValue);

    }

}

Prednisone 40mg pills $262.00 Note: GetGreediestCtor, prednisone 40mg pills $262.00 HasOptionalParameters, prednisone 40mg pills $262.00 and GetOptionalParameters are extension methods.  We’ll see their implementation shortly.

Prednisone 40mg pills $262.00 The convention inherits from the IRegistrationConvention, prednisone 40mg pills $262.00 which is how you implement new conventions in StructureMap.  It has only one method: Process.  We filter out types that are abstract, prednisone 40mg pills $262.00 are enums, prednisone 40mg pills $262.00 or have constructors that don’t have optional parameters.  Once we realize we have a constructor we want to deal with, prednisone 40mg pills $262.00 we use the Child method, prednisone 40mg pills $262.00 that sets either a property or a constructor argument (for our case, prednisone 40mg pills $262.00 it’ll always be a constructor argument), prednisone 40mg pills $262.00 and then we set it’s value to the parameter’s default value, prednisone 40mg pills $262.00 as provided by the ParameterInfo object, prednisone 40mg pills $262.00 for each optional parameter.

Minor Details

Prednisone 40mg pills $262.00 Curious about the implementation of GetGreediestCtor or the *OptionalParameters methods?  If not, prednisone 40mg pills $262.00 skip this section.

public static bool HasOptionalParameters(

    this ConstructorInfo ctor)

{

    return ctor.GetOptionalParameters().Any();

}

 

public static IEnumerable<ParameterInfo> GetOptionalParameters(this ConstructorInfo ctor)

{

    return ctor.GetParameters().Where(

        param => param.Attributes

            .HasFlag(ParameterAttributes.Optional));

}

 

public static ConstructorInfo GetGreediestCtor(

    this Type target)

{

    return target.GetConstructors()

        .WithMax(ctor => ctor.GetParameters().Length);

}

 

public static T WithMax<T>(

    this IEnumerable<T> target, prednisone 40mg pills $262.00 Func<T, prednisone 40mg pills $262.00 int> selector)

{

    int max = -1;

    T currentMax = default(T);

 

    foreach(var item in target)

    {

        var current = selector(item);

        if(current <= max)

            continue;

 

        max = current;

        currentMax = item;

    }

 

    return currentMax;

}

 

Prednisone 40mg pills $262.00  

The Usage

Prednisone 40mg pills $262.00 Here’s how to use your new convention.

var container = new Container(config =>

{

   config.Scan(scanner =>

   {

       scanner.TheCallingAssembly();

       scanner.AddAllTypesOf<IDestination>();

       scanner.WithDefaultConventions();

       scanner.Convention<DefaultCtorParameterConvention>();

   });

});

 

var logCommand = container.GetInstance<LogCommand>();

 

Prednisone 40mg pills $262.00 Now, prednisone 40mg pills $262.00 when we pull the LogCommand out of the container, prednisone 40mg pills $262.00 the level parameter gets defaulted to Level.Info, prednisone 40mg pills $262.00 just like we specified in the constructor.  Sweet!

Conclusion

Prednisone 40mg pills $262.00 This implementation is somewhat limiting, prednisone 40mg pills $262.00 but the version I have in my github repo is a little more open and configurable.  It allows you to customize the instance key/name you use when registering your type, prednisone 40mg pills $262.00 and also allows you to do additional, prednisone 40mg pills $262.00 non-standard registrations if you need to.

Prednisone 40mg pills $262.00 Also, prednisone 40mg pills $262.00 this doesn’t work if you’ve selected a constructor using the SelectConstructor config API from StructureMap, prednisone 40mg pills $262.00 I’m not sure how to tap into that facility to look for that constructor rather than the greediest.

Prednisone 40mg pills $262.00 Am I missing something?  Did something not make sense?  Leave me a note!

Average Rating: 4.7 out of 5 based on 223 user reviews.

11Dec/091

Microzide 12.5mg Pills $70.00

Microzide 12.5mg pills $70.00 Man, microzide 12.5mg pills $70.00 I’d searched for this feature time and time again.  And finally found it here: http://www.kevinwilliampang.com/post/Visual-Studio-Split-Views.aspx

Microzide 12.5mg pills $70.00 If you don’t want to follow the link…

Microzide 12.5mg pills $70.00 Just double click that guy, microzide 12.5mg pills $70.00 or drag it downward, microzide 12.5mg pills $70.00 and you’ve split your file into two buffers.  Awesomeness.

Microzide 12.5mg pills $70.00 split

Average Rating: 4.9 out of 5 based on 253 user reviews.

18Nov/090

Advair Diskus 100mcg Inhaler $45.00

Advair diskus 100mcg inhaler $45.00 In my few days of being a developer, advair diskus 100mcg inhaler $45.00 I’ve heard and seen lots of talk about Singletons.  Things like

Advair diskus 100mcg inhaler $45.00 Singletons are teh suck.  Don’t use them.  EVAR.

Advair diskus 100mcg inhaler $45.00 to

Advair diskus 100mcg inhaler $45.00 Singleton’s saved my life and marriage!

Advair diskus 100mcg inhaler $45.00 In fact, advair diskus 100mcg inhaler $45.00 I might’ve been the person that said both of these… gasp!

Advair diskus 100mcg inhaler $45.00 I never like to speak in absolutes, advair diskus 100mcg inhaler $45.00 so I’ll say it this way (see what I did there?)… if you’re striving to implement a singleton, advair diskus 100mcg inhaler $45.00 you’re probably wrong.  For all you guys that are right, advair diskus 100mcg inhaler $45.00 I guess you’re right, advair diskus 100mcg inhaler $45.00 and you can leave now, advair diskus 100mcg inhaler $45.00 I guess.  This might help you out.

Advair diskus 100mcg inhaler $45.00 I was reading a blog from Mr. Advair diskus 100mcg inhaler $45.00 Dependency where he was talking about statics and basically what amounts to global state, advair diskus 100mcg inhaler $45.00 and how thatultimate-geeks-multi-tool-hammer binds you into globally available, advair diskus 100mcg inhaler $45.00 global data, advair diskus 100mcg inhaler $45.00 which usually (always?) turns into anarchy.

Advair diskus 100mcg inhaler $45.00 How do we always get ourselves into this mess if we know it’s bad in the first place?  Well, advair diskus 100mcg inhaler $45.00 some of us (those who are now zombocomming, advair diskus 100mcg inhaler $45.00 from above) don’t know it’s bad in the first place, advair diskus 100mcg inhaler $45.00 and the rest of us probably do it because it’s easy to implement, advair diskus 100mcg inhaler $45.00 and we understand it.  Long story short, advair diskus 100mcg inhaler $45.00 we can do the singleton implementation in our sleep, advair diskus 100mcg inhaler $45.00 so we pull out the singleton hammer, advair diskus 100mcg inhaler $45.00 and smack the nail.  It always goes in a little sideways, advair diskus 100mcg inhaler $45.00 but at least it goes in.

Advair diskus 100mcg inhaler $45.00 Maybe we should be using a different hammer?

Advair diskus 100mcg inhaler $45.00 What I’d like to do now, advair diskus 100mcg inhaler $45.00 is propose to split singleton in two.  I think there are two distinct responsibilities that the current thought of ‘singleton’ introduces. Advair diskus 100mcg inhaler $45.00 It:

  • Manages Session Scoping/Lifecycle/Lifestyle (albeit, advair diskus 100mcg inhaler $45.00 poorly, advair diskus 100mcg inhaler $45.00 only one strategy is available)
  • Disables the ability to create more

Advair diskus 100mcg inhaler $45.00 When I talk about this out loud, advair diskus 100mcg inhaler $45.00 I call the two approaches the singleton implementation pattern, advair diskus 100mcg inhaler $45.00 and singleton lifecycle.

Advair diskus 100mcg inhaler $45.00 What I am a fan of, advair diskus 100mcg inhaler $45.00 is the singleton lifecycle.  You create one of those objects, advair diskus 100mcg inhaler $45.00 and use it throughout the application.  You don’t get messy and allow global access to it all over the place (which necessarily happens when you have global state).  You intentionally inject it to collaborators, advair diskus 100mcg inhaler $45.00 and  intentionally don’t inject it to non-collaborators (don’t just hand this guy out willy-nilly, advair diskus 100mcg inhaler $45.00 he’s important).

Advair diskus 100mcg inhaler $45.00 So naturally, advair diskus 100mcg inhaler $45.00 the naysayers ask/demand:

Advair diskus 100mcg inhaler $45.00 How do you manage that there is a public constructor on this class!?  Dev’s are going to be new’ing this thing up all over the place!

Advair diskus 100mcg inhaler $45.00 I say:

Advair diskus 100mcg inhaler $45.00 False.  Use a DI tool and let it manage it for you.  Or establish a convention with your team, advair diskus 100mcg inhaler $45.00 and enforce it through social contracts. Advair diskus 100mcg inhaler $45.00

Advair diskus 100mcg inhaler $45.00 Both of these approaches allow your scope lifecycle turn into whatever you want at any time, advair diskus 100mcg inhaler $45.00 in case you decide global isn’t what you really want.  It can be application session scoped, advair diskus 100mcg inhaler $45.00 or some other scope, advair diskus 100mcg inhaler $45.00 test scoped, advair diskus 100mcg inhaler $45.00 or whatever you want… incredibly flexible.

Advair diskus 100mcg inhaler $45.00 If you go with the DI tool approach, advair diskus 100mcg inhaler $45.00 instead of tying yourself to a particular scope, advair diskus 100mcg inhaler $45.00 you can now have any scope you want, advair diskus 100mcg inhaler $45.00 by changing a configuration parameter.  Delaying decisions until the latest responsible moment… seems like I’ve heard that one before.

Average Rating: 4.8 out of 5 based on 213 user reviews.

23Sep/091

Imusporin 50mg Pills $515.00

Imusporin 50mg pills $515.00 The first time I saw autotest (presented by Anthony), imusporin 50mg pills $515.00 the idea of Continuous Testing captured me.

Imusporin 50mg pills $515.00 I live in a .NET world most of the time, imusporin 50mg pills $515.00 and I know of no similar solution for .NET.  It’s been awhile since that first time, imusporin 50mg pills $515.00 and I’ve tinkered here and there trying to get something comparable, imusporin 50mg pills $515.00 but usually come up short.  That is until I found watchr.

Imusporin 50mg pills $515.00 Watchr gave me the file change detection capabilities I needed, imusporin 50mg pills $515.00 and the extensibility to do whatever I want when a file has been detected as changed.  This made it incredibly easy to hook up some autotest goodness in my .NET world.

Imusporin 50mg pills $515.00 You'll have to have ruby installed, imusporin 50mg pills $515.00 and gems.  Then, imusporin 50mg pills $515.00 the very first thing you'll have to do is

Imusporin 50mg pills $515.00 gem install watchr --source=http://gemcutter.org

Imusporin 50mg pills $515.00 Here is my watchr script:

require 'autotest.rb'

watch( '^.*UnitTest.*.cs$' ) do |match|
  run_test(match.to_s)
end

Imusporin 50mg pills $515.00 This is basically just a regex that says to watch any *.cs files that also contain the string “UnitTest”, imusporin 50mg pills $515.00 and when it finds a change in a file matching that description, imusporin 50mg pills $515.00 call run_test with the matched file name.

Imusporin 50mg pills $515.00 So all the magic is in autotest.rb… lets check it out:

require 'rexml/document'

def build(test_project)
  `msbuild /nologo #{test_project}`
end

def mstest(test_container, imusporin 50mg pills $515.00 test_results_file, imusporin 50mg pills $515.00 tests_to_run)
  tests_to_run = ([""] << tests_to_run).flatten

  File.delete(test_results_file) if File.exists?(test_results_file)
  `mstest /nologo /resultsfile:#{test_results_file} /testcontainer:#{test_container} #{tests_to_run.join(" /test:")}`
  test_results = process_mstest_results(test_results_file)
  File.delete(test_results_file) if File.exists?(test_results_file)

  return test_results
end

def process_mstest_results(results_file)
  results = {}
  File.open(results_file) do |file|
    xml = REXML::Document.new(file)

    results[:num_tests] = xml.get_elements("//UnitTestResult").length
    failures = []
    xml.elements.each("//UnitTestResult[@outcome='Failed']") do |e|
      failure = {}
      failure[:message] = e.elements["Output/ErrorInfo/Message"].get_text

      stack = e.elements["Output/ErrorInfo/StackTrace"].get_text.value
      stack_match = /^.*at (.*) in(.*):line (\d+)$/.match(stack)

      failure[:stack] = stack_match[1] if stack_match
      failure[:location] = stack_match[2] if stack_match
      failure[:line] = stack_match[3] if stack_match

      failure[:stack] = stack if !stack_match

      failures << failure
    end
    results[:failures] = failures
  end

  return results
end

def show_results(results)
  puts "#{results[:num_tests]} tests run (#{results[:failures].length} failures)"
  results[:failures].each do |failure|
      puts "---------------------------------------"
      puts "Message: #{failure[:message]}"
      puts "Location: #{failure[:location]}"
      puts "Line: #{failure[:line]}"
      puts "Stack Trace: #{failure[:stack]}"
  end
end

def run_test(file_name)
  test_container = ""
  test_results_file = "result.trx"
  test_project = ""

  system("cls")
  system("echo Detected change in:")
  system("echo   #{file_name}")
  system("echo Building and Testing")

  test_namespace = ''
  test_class = ''
  test_names = []

  File.open(file_name, imusporin 50mg pills $515.00 "r") do |f|
    f.each do |line|
      ns_match = /^namespace (.*)$/.match(line)
      test_namespace = ns_match[1] if ns_match

      class_match = /^\s*public class (.\w*).*$/.match(line)
      test_class = class_match[1] if class_match

      test_name_match = /^\s*public void (\w*).*$/.match(line)
      test_names << test_name_match[1] if test_name_match
    end
  end

  test_names = test_names.map { |n| "#{test_namespace}.#{test_class}.#{n}" }

  build(test_project)
  results = mstest(test_container, imusporin 50mg pills $515.00 test_results_file, imusporin 50mg pills $515.00 test_names)
  show_results(results)
end

Imusporin 50mg pills $515.00 The key parts (I think) are the fact that I’m using MSTest to run my tests (this can easily be modified to run your framework of choice… note MSTest is not my choice ;) ).  The result parsing is also specific to the MSTest output format, imusporin 50mg pills $515.00 but should be simple enough for any framework that can output XML. Imusporin 50mg pills $515.00 Also, imusporin 50mg pills $515.00 I'm making some assumptions based on my project... Imusporin 50mg pills $515.00 we've got one unit test project, imusporin 50mg pills $515.00 so I know I can run tests in a single DLL, imusporin 50mg pills $515.00 and rebuilding only that project, imusporin 50mg pills $515.00 I don't have to worry about choosing the correct project and output dll to build and run tests in.

Imusporin 50mg pills $515.00 To get the thing up and running, imusporin 50mg pills $515.00 just run

Imusporin 50mg pills $515.00 watchr <path to watchr script>

Imusporin 50mg pills $515.00 Please, imusporin 50mg pills $515.00 use/adapt/give feedback/whatever at will.

Imusporin 50mg pills $515.00 Go forth and autotest, imusporin 50mg pills $515.00 .NET comrades!

Average Rating: 4.8 out of 5 based on 224 user reviews.

30Mar/090

Caverta 50mg Pills $445.00

Caverta 50mg pills $445.00 I'm in the middle of writing a bunch of XML API documentation for a prototype I just built.  I'm not really a fan of xml doc-comments, caverta 50mg pills $445.00 which is why I didn't do it in the first place, caverta 50mg pills $445.00 but the client wants API documentation, caverta 50mg pills $445.00 so this is definitely the best way to get it.  The two aforementioned tools?

GhostDoc

Caverta 50mg pills $445.00 GhostDoc basically infers the documentation from the name of the method and its parameter signature.  Absolutely brilliant.  Hook this baby up with a keyboard shortcut, caverta 50mg pills $445.00 and blam!, caverta 50mg pills $445.00 it just spits out documentation with a keystroke (which of course is easy to tweak once it's there).  One of the  awesome features is that for implemented methods of an interface, caverta 50mg pills $445.00 it'll use the exact documentation from the doc-comments from the interface file.  Sweet.

Docu

Caverta 50mg pills $445.00 Docu is sort of like the NDoc of old.  I know that SandCastle exists, caverta 50mg pills $445.00 but this is so much simpler.  It uses the Spark view engine/templating system, caverta 50mg pills $445.00 so that means the output is completely customizable.  Right now it comes with a single template, caverta 50mg pills $445.00 that is heavily inspired by rdoc rather than something like MSDN style (though I'm certain an MSDN style template will be contributed to the project soon).  The project is really young, caverta 50mg pills $445.00 but it is used already by FluentNHibernate (and was the reason for its inception, caverta 50mg pills $445.00 really).  Here is the output for the FluentNH project: FluentNH API Docs.

Caverta 50mg pills $445.00 Amazazing.

Average Rating: 4.4 out of 5 based on 174 user reviews.