Click here to Skip to main content
15,886,799 members
Articles / Web Development / ASP.NET

Secrets for Setting Up Continuous Integration

Rate me:
Please Sign up or sign in to vote.
2.88/5 (7 votes)
23 Feb 2009CPOL5 min read 65.4K   54   41  
A few simple tips that should help when you are considering setting up CI
using System;

namespace Agile.Common.Reflections
{
    /// <summary>
    /// When we invoke methods using reflection, we need to know the parameter
    /// types to get the method and we need the actual parameter values when
    /// we call Invoke. 
    /// This class encapsulates those parameter details.
    /// </summary>
    public class MethodParameterDetails
    {
        /// <summary>
        /// Stores the parameter details
        /// </summary>
        private readonly object[] _parameters;

        /// <summary>
        /// Construct with the parameters
        /// </summary>
        private MethodParameterDetails(params object[] parameters)
        {
            _parameters = parameters;
        }

        /// <summary>
        /// Gets the number of parameters that have been provided for the Instantiation method.
        /// </summary>
        private int NumberOfParameters
        {
            get { return _parameters.Length; }
        }

        /// <summary>
        /// Returns true if there are no parameters defined.
        /// </summary>
        public bool HasNoParameters
        {
            get { return _parameters == null; }
        }

        /// <summary>
        /// Gets the signature (not return type tho) details.
        /// Essentially the Types of the parameters that were provided on
        /// instantiation.
        /// </summary>
        public Type[] Signature
        {
            get
            {
                if (HasNoParameters)
                    return new Type[0];

                var instantiateMethodParameters = new Type[NumberOfParameters];
                for (int i = 0; i < NumberOfParameters; i++)
                {
                    instantiateMethodParameters[i] = _parameters[i].GetType();
                }
                return instantiateMethodParameters;
            }
        }

        /// <summary>
        /// Gets the parameter values.
        /// </summary>
        public object[] Parameters
        {
            get { return _parameters; }
        }

        /// <summary>
        /// Instantiate the required parameters. 
        /// </summary>
        /// <param name="parameters">All of the parameters required for the method.
        /// NOTE: Must be in the correct order!</param>
        /// <returns></returns>
        public static MethodParameterDetails Build(params object[] parameters)
        {
            return new MethodParameterDetails(parameters);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Peer Placements Pty Ltd
Australia Australia
I live in Sydney and have been a developer for almost a decade now. I have a passion for technology and a strong interest in discovering 'better, cleaner, faster' ways to get systems out the door because I believe software development takes too long. If I have an idea I want to realise it as quickly as possible...plus writing systems for someone else I want to deliver quickly so I can move onto the next interesting project!

Comments and Discussions