Updates from July, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • Richard 1:31 pm on July 27, 2011 Permalink |  

    I seem to get a lot less eye… 

    I seem to get a lot less eye strain when I use a dark theme in Visual Studio. Here are the settings I use.

    http://dl.dropbox.com/u/624582/CodeRead/DarkTheme.vssettings

    Advertisement
     
  • Richard 12:40 pm on July 27, 2011 Permalink |
    Tags:   

    I quite like the Windows Azure cost calculator on the Microsoft site:

    http://www.microsoft.com/windowsazure/pricing-calculator/

     
  • Richard 1:49 pm on July 25, 2011 Permalink |  

    This pluralsight tool is a useful way of quickly creating an X509 certificate. Very handy.

    http://www.pluralsight-training.net/community/blogs/keith/archive/2009/01/22/create-self-signed-x-509-certificates-in-a-flash-with-self-cert.aspx

     
  • Richard 11:59 am on July 8, 2011 Permalink |  

    Adding Castle ActiveRecord to an MVC3 application 

    Install Castle ActiveRecord

    In the NuGet package manager, install the Castle.ActiveRecord package.

    PM> Install-Package Castle.Activerecord

    Configure your application

    Next, update your Web.config file to include the following settings:

    <configuration>
      <configSections>
        <section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
      </configSections>
    
      <activerecord isWeb="true" isDebug="false" pluralizeTableNames="false">
        <config>
          <add key="dialect" value="NHibernate.Dialect.MsSql2008Dialect" />
          <add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
          <add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
          <add key="connection.connection_string_name" value="ApplicationServices" />
          <add key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />
          <add key="show_sql" value="false" />
        </config>
      </activerecord>
    
      <connectionStrings>
        <add name="ApplicationServices"
             connectionString="Data Source=.\SQLServer;Initial Catalog=[dbname];Integrated Security=True;" providerName="System.Data.SqlClient" />
      </connectionStrings>
      ...

    Hook in the Initialization

    Next, you’ll need to initialise ActiveRecord on application start. Update the Application_Start method in your Global.asax.cs file to include the first two lines in this sample:

    protected void Application_Start()
    {
        Castle.ActiveRecord.ActiveRecordStarter.Initialize();
        Castle.ActiveRecord.ActiveRecordStarter.UpdateSchema();
    
        AreaRegistration.RegisterAllAreas();
    
        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    }

    The ‘UpdateSchema’ line is added as a development convenience, and should be taken out of a production system. It will update your database schema following changes to your models every time your application starts.

    Automatically manage the session scope

    Another convenience is to automatically manage your SessionScope. Create a base class for your controller that looks like this:

    public class BaseController : Controller
    {
        public Castle.ActiveRecord.SessionScope Scope { get; private set; }
    
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!this.HttpContext.Items.Contains("ar.session"))
            {
                this.Scope = new Castle.ActiveRecord.SessionScope();
                this.HttpContext.Items.Add("ar.session", this.Scope);
                base.OnActionExecuting(filterContext);
            }
        }
    }

    The reason for putting it here, rather than in Application_BeginRequest, is that Application_BeginRequest gets called for every request to the web server, including static content. Creating the SessionScope object is a costly operation, and shouldn’t be performed unnecessarily. By putting it in the OnActionExecuting method of the controller, we only create the session when we need it. If you have controllers that don’t require database access, don’t inherit this base class.

    We also need to dispose of the SessionScope, so add this method to your Global.asax.cs file:

    protected void Application_EndRequest()
    {
        if (HttpContext.Current.Items.Contains("ar.session"))
        {
            var session = HttpContext.Current.Items["ar.session"] as SessionScope;
            session.Dispose();
        }
    }

    This is placed here, rather than in the controller base class, because if lazy loading is enabled on your ActiveRecord models, the view will require the SessionScope, so disposing of it need to happen at the end of the Request, rather than the end of the action execution.

    Start using it!

    You’re now ready to create some models like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Castle.ActiveRecord;
    using Castle.ActiveRecord.Framework;
    
    namespace Example
    {
        [ActiveRecord]
        public class Foo : ActiveRecordLinqBase<Foo>
        {
            [PrimaryKey]
            public int ID { get; protected set; }
    
            [Property]
            public string Name { get; set; }
        }
    }

    In your controllers you can now query the model like this:

    var foos = (from f in Foo.Queryable where name == "example" select f).ToArray();

    Farewell SQL!

    
    	
     
    • necu 5:10 pm on May 24, 2013 Permalink | Log in to Reply

      The moment that is certainly motivated you additionally need to have to find out if they may be any additional prices i. Your credit ratings desires significant maintenance? So does your automobile? If that is so, you are just one of lots of stressed consumers attempting to escape detrimental group of moving money into and outdated car or truck and will certainly conserve for a down payment for a new auto. Everything, particularly rates of interest, is based on around the terms and conditions on the individual bank not like the government mortgage loan once it is actually manipulated from the federal. These car and truck loans online are available to the borrower into two sorts. Poor credit takes place, especially in the abrasive and slip economical periods by which find our own selves. Also, for folks who have to have or want to save cash or are involved regarding it saving money for costs, then a more substantial transaction term may help, because monthly installments towards mortgage will be reduced. Fast cash cover anything from 1000 to 25000. Also, a real verifying or savings is needed. In person by way of almost all of the years fraxel arrange revenue was used the economy, our prime-run income plus the income present supply been rising to ensure awareness will never be seen as an problem. Should the person is in dreadful demand for cash create will get an entire lump sum simultaneously. The complete point of loan refinancing your home is to save cash so be sure to evaluate the give very carefully in advance of making a dedication for any property finance loan deal. Quite often, you might receive the alert e mail inside 60 minutes payday loan payday on-line cash loans can be had in quantities which range from buck100 to bucks1500.

      They merely count on their job opportunities and consider that they may settle all they must pay back, even though they maintain getting far more. In addition to these standard key elements, lenders also evaluate the credit standing of your customer. House loans loans have certainly been open to those looking for those style of personal loans for a time. The truth is, they offer enable you to better a bad credit score history. Joblessness Loans, Much like Other Lending products, Appear In 2 Types: Anchored and Unleveraged.

      When that happens our credit rating uses a nose dive, producing thinking about finding a Dollar5,000 unsecured loan little more illusion, however it’s not truly impossible in any way. Video clips a Alter Home loan. There is even now hope as well as your beloved ones future. Additionally, there are approaches to make that quick money final for a-term web salary. How many details you should make prior to talk about pushes you to get automobile insurance relies on you’re. So then the chances of you receiving a re-mortgage accredited yet again will likely be much superior as well as method that quicker. With mortgage rates mountaineering length of thousands in terms if interest rate. This is an excellent factor after your melancholy and sensations of worthlessness that will join any personal bankruptcy going forward. This way, one can get the wanted consequence. Home interest rates and loans offered will be different greatly. This is an issue that will function a range of backyard garden expenditures. Purchase an additional occupation for some several hours a single day and nite a week then reserved that money to use in your lowest repayment for your student loans. Nevertheless, you merely call for having a Personal computer with world wide web online connectivity. So, you’ll be able for debtors to produce program each time. A new market has put their hands up to plan for this as they understand that a huge majority of these people are going to pay the loan returning.

      The only issue you would possibly knowledge when getting online payday loans might be having the proper company that can supply you with lots of added benefits. Will not use swiftly next to such thinggs as your own home in support of use exactly what you need. Certainly, nobody can be entitled to a home loan. The sole distinction the operating of on the web personal loan granting firm to that of list loan company is right here you ought to do the deals on line. Advantages – Online Debt Consolidation Reduction Financial loan. The various advantages and disadvantages of hiring or investing in a home are mentioned down below. You may produce a person check each and every month. Payday loans might help in preparing short term with out fax any paperwork at the actual time once you expected pressing finance. The best part connected with bank loans is the fact that everybody is absolve to choose and rehearse from the huge types available. Even so the huge competitiveness in financial market can make your loan accompany realistic interest rate. If you find that you’ll favor working with a standard bank as well as other loan provider you understand, maybe a person with who you have already a merchant account obtain their internet site. Not so sure the amount of fix should be applied. It is strongly advised to have a plan T should the profit reduces.

  • Richard 12:23 pm on July 7, 2011 Permalink |  

    Tail Recursion Optimisation in .NET 4 

    In C#, the tail recursion optimisation only seems to apply when you do a release build for x64.

    If you create a console application, which does something like this:

    static void Main(string[] args)
    {
        Recur();
    }
     
    static void Recur()
    {
        Recur();
    }

    …and run in debug, it’s doesn’t take very long until this happens:

    Process is terminated due to StackOverflowException.

    Change the platform target to x64, do a release build, and run it without debugging. It will run forever!

    Why does this optimisation only get used under these conditions?

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel