Grifulvin V 250mg Pills $117.00

4Jun/103

Biaxin 500mg Pills $262.00

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

The Problem

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

public class LogCommand

{

    IDestination _destination;

    Level _level;

 

    public LogCommand(

        IDestination destination, biaxin 500mg pills $262.00 Level level = Level.Info)

    {

        _destination = destination;

        _level = level;

    }

 

    /* logging code here */

}

 

Biaxin 500mg pills $262.00 Here is your basic usage, biaxin 500mg 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>();

 

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

The Solution

Biaxin 500mg 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, biaxin 500mg 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);

    }

}

Biaxin 500mg pills $262.00 Note: GetGreediestCtor, biaxin 500mg pills $262.00 HasOptionalParameters, biaxin 500mg pills $262.00 and GetOptionalParameters are extension methods.  We’ll see their implementation shortly.

Biaxin 500mg pills $262.00 The convention inherits from the IRegistrationConvention, biaxin 500mg 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, biaxin 500mg pills $262.00 are enums, biaxin 500mg pills $262.00 or have constructors that don’t have optional parameters.  Once we realize we have a constructor we want to deal with, biaxin 500mg pills $262.00 we use the Child method, biaxin 500mg pills $262.00 that sets either a property or a constructor argument (for our case, biaxin 500mg pills $262.00 it’ll always be a constructor argument), biaxin 500mg pills $262.00 and then we set it’s value to the parameter’s default value, biaxin 500mg pills $262.00 as provided by the ParameterInfo object, biaxin 500mg pills $262.00 for each optional parameter.

Minor Details

Biaxin 500mg pills $262.00 Curious about the implementation of GetGreediestCtor or the *OptionalParameters methods?  If not, biaxin 500mg 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, biaxin 500mg pills $262.00 Func<T, biaxin 500mg 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;

}

 

Biaxin 500mg pills $262.00  

The Usage

Biaxin 500mg 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>();

 

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

Conclusion

Biaxin 500mg pills $262.00 This implementation is somewhat limiting, biaxin 500mg 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, biaxin 500mg pills $262.00 and also allows you to do additional, biaxin 500mg pills $262.00 non-standard registrations if you need to.

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

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

Average Rating: 4.5 out of 5 based on 169 user reviews.

11Dec/091

Hydrochlorothiazide 25mg Pills $83.00

Hydrochlorothiazide 25mg pills $83.00 Man, hydrochlorothiazide 25mg pills $83.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

Hydrochlorothiazide 25mg pills $83.00 If you don’t want to follow the link…

Hydrochlorothiazide 25mg pills $83.00 Just double click that guy, hydrochlorothiazide 25mg pills $83.00 or drag it downward, hydrochlorothiazide 25mg pills $83.00 and you’ve split your file into two buffers.  Awesomeness.

Hydrochlorothiazide 25mg pills $83.00 split

Average Rating: 5 out of 5 based on 158 user reviews.

18Nov/090

Fluconazole 150mg Pills $103.00

Fluconazole 150mg pills $103.00 In my few days of being a developer, fluconazole 150mg pills $103.00 I’ve heard and seen lots of talk about Singletons.  Things like

Fluconazole 150mg pills $103.00 Singletons are teh suck.  Don’t use them.  EVAR.

Fluconazole 150mg pills $103.00 to

Fluconazole 150mg pills $103.00 Singleton’s saved my life and marriage!

Fluconazole 150mg pills $103.00 In fact, fluconazole 150mg pills $103.00 I might’ve been the person that said both of these… gasp!

Fluconazole 150mg pills $103.00 I never like to speak in absolutes, fluconazole 150mg pills $103.00 so I’ll say it this way (see what I did there?)… if you’re striving to implement a singleton, fluconazole 150mg pills $103.00 you’re probably wrong.  For all you guys that are right, fluconazole 150mg pills $103.00 I guess you’re right, fluconazole 150mg pills $103.00 and you can leave now, fluconazole 150mg pills $103.00 I guess.  This might help you out.

Fluconazole 150mg pills $103.00 I was reading a blog from Mr. Fluconazole 150mg pills $103.00 Dependency where he was talking about statics and basically what amounts to global state, fluconazole 150mg pills $103.00 and how thatultimate-geeks-multi-tool-hammer binds you into globally available, fluconazole 150mg pills $103.00 global data, fluconazole 150mg pills $103.00 which usually (always?) turns into anarchy.

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

Fluconazole 150mg pills $103.00 Maybe we should be using a different hammer?

Fluconazole 150mg pills $103.00 What I’d like to do now, fluconazole 150mg pills $103.00 is propose to split singleton in two.  I think there are two distinct responsibilities that the current thought of ‘singleton’ introduces. Fluconazole 150mg pills $103.00 It:

  • Manages Session Scoping/Lifecycle/Lifestyle (albeit, fluconazole 150mg pills $103.00 poorly, fluconazole 150mg pills $103.00 only one strategy is available)
  • Disables the ability to create more

Fluconazole 150mg pills $103.00 When I talk about this out loud, fluconazole 150mg pills $103.00 I call the two approaches the singleton implementation pattern, fluconazole 150mg pills $103.00 and singleton lifecycle.

Fluconazole 150mg pills $103.00 What I am a fan of, fluconazole 150mg pills $103.00 is the singleton lifecycle.  You create one of those objects, fluconazole 150mg pills $103.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, fluconazole 150mg pills $103.00 and  intentionally don’t inject it to non-collaborators (don’t just hand this guy out willy-nilly, fluconazole 150mg pills $103.00 he’s important).

Fluconazole 150mg pills $103.00 So naturally, fluconazole 150mg pills $103.00 the naysayers ask/demand:

Fluconazole 150mg pills $103.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!

Fluconazole 150mg pills $103.00 I say:

Fluconazole 150mg pills $103.00 False.  Use a DI tool and let it manage it for you.  Or establish a convention with your team, fluconazole 150mg pills $103.00 and enforce it through social contracts. Fluconazole 150mg pills $103.00

Fluconazole 150mg pills $103.00 Both of these approaches allow your scope lifecycle turn into whatever you want at any time, fluconazole 150mg pills $103.00 in case you decide global isn’t what you really want.  It can be application session scoped, fluconazole 150mg pills $103.00 or some other scope, fluconazole 150mg pills $103.00 test scoped, fluconazole 150mg pills $103.00 or whatever you want… incredibly flexible.

Fluconazole 150mg pills $103.00 If you go with the DI tool approach, fluconazole 150mg pills $103.00 instead of tying yourself to a particular scope, fluconazole 150mg pills $103.00 you can now have any scope you want, fluconazole 150mg pills $103.00 by changing a configuration parameter.  Delaying decisions until the latest responsible moment… seems like I’ve heard that one before.

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

23Sep/091

Desyrel 100mg Pills $128.00

Desyrel 100mg pills $128.00 The first time I saw autotest (presented by Anthony), desyrel 100mg pills $128.00 the idea of Continuous Testing captured me.

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

Desyrel 100mg pills $128.00 Watchr gave me the file change detection capabilities I needed, desyrel 100mg pills $128.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.

Desyrel 100mg pills $128.00 You'll have to have ruby installed, desyrel 100mg pills $128.00 and gems.  Then, desyrel 100mg pills $128.00 the very first thing you'll have to do is

Desyrel 100mg pills $128.00 gem install watchr --source=http://gemcutter.org

Desyrel 100mg pills $128.00 Here is my watchr script:

require 'autotest.rb'

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

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

Desyrel 100mg pills $128.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, desyrel 100mg pills $128.00 test_results_file, desyrel 100mg pills $128.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, desyrel 100mg pills $128.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, desyrel 100mg pills $128.00 test_results_file, desyrel 100mg pills $128.00 test_names)
  show_results(results)
end

Desyrel 100mg pills $128.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, desyrel 100mg pills $128.00 but should be simple enough for any framework that can output XML. Desyrel 100mg pills $128.00 Also, desyrel 100mg pills $128.00 I'm making some assumptions based on my project... Desyrel 100mg pills $128.00 we've got one unit test project, desyrel 100mg pills $128.00 so I know I can run tests in a single DLL, desyrel 100mg pills $128.00 and rebuilding only that project, desyrel 100mg pills $128.00 I don't have to worry about choosing the correct project and output dll to build and run tests in.

Desyrel 100mg pills $128.00 To get the thing up and running, desyrel 100mg pills $128.00 just run

Desyrel 100mg pills $128.00 watchr <path to watchr script>

Desyrel 100mg pills $128.00 Please, desyrel 100mg pills $128.00 use/adapt/give feedback/whatever at will.

Desyrel 100mg pills $128.00 Go forth and autotest, desyrel 100mg pills $128.00 .NET comrades!

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

30Mar/090

Diabecon 60 Tablet Bottle $107.00

Diabecon 60 tablet bottle $107.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, diabecon 60 tablet bottle $107.00 which is why I didn't do it in the first place, diabecon 60 tablet bottle $107.00 but the client wants API documentation, diabecon 60 tablet bottle $107.00 so this is definitely the best way to get it.  The two aforementioned tools?

GhostDoc

Diabecon 60 tablet bottle $107.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, diabecon 60 tablet bottle $107.00 and blam!, diabecon 60 tablet bottle $107.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, diabecon 60 tablet bottle $107.00 it'll use the exact documentation from the doc-comments from the interface file.  Sweet.

Docu

Diabecon 60 tablet bottle $107.00 Docu is sort of like the NDoc of old.  I know that SandCastle exists, diabecon 60 tablet bottle $107.00 but this is so much simpler.  It uses the Spark view engine/templating system, diabecon 60 tablet bottle $107.00 so that means the output is completely customizable.  Right now it comes with a single template, diabecon 60 tablet bottle $107.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, diabecon 60 tablet bottle $107.00 but it is used already by FluentNHibernate (and was the reason for its inception, diabecon 60 tablet bottle $107.00 really).  Here is the output for the FluentNH project: FluentNH API Docs.

Diabecon 60 tablet bottle $107.00 Amazazing.

Average Rating: 5 out of 5 based on 249 user reviews.