Example #1
0
        /// <summary>
        /// Get the parameters for the specified builder type, possibly creating it, if there
        /// is not yet one in the build data collection.
        /// </summary>
        /// <param name="builderType">Type of the builder to request a set of sample data for.</param>
        /// <param name="paraType">Type of the parameter class.</param>
        /// <param name="properties">The global properties storage.</param>
        /// <returns>
        /// A new instance of a matching parameter data set for the specified builder.
        /// </returns>
        /// <exception cref="KeyNotFoundException">The given <paramref name="builderType"/> was not present in the lookup.</exception>
        public IMemberBuildParameters GetParameters(Type builderType, Type paraType, IBuildDataDictionary properties)
        {
            Guard.NotNull(() => properties, properties);
            IBuilderData result;
            var          found = properties.TryGetValue(string.Empty + builderType.FullName, out result);

            if (found)
            {
                return(result as IMemberBuildParameters);
            }

            var paraInstance = Activator.CreateInstance(paraType);
            var setupPara    = (IMemberBuildParameters)paraInstance;

            properties.AddDataItem(string.Empty + builderType.FullName, setupPara);
            return(setupPara);
        }
Example #2
0
        /// <summary>
        /// Get the parameters for the specified builder type, possibly creating it, if there
        /// is not yet one in the build data collection.
        /// </summary>
        /// <param name="builderType">Type of the builder to request a set of sample data for.</param>
        /// <param name="paraType">Type of the parameter class.</param>
        /// <param name="properties">The global properties storage.</param>
        /// <returns>
        /// A new instance of a matching parameter data set for the specified builder.
        /// </returns>
        /// <exception cref="KeyNotFoundException">The given <paramref name="builderType"/> was not present in the lookup.</exception>
        public IMemberBuildParameters GetParameters(Type builderType, Type paraType, IBuildDataDictionary properties)
        {
            Guard.NotNull(() => properties, properties);
            IBuilderData result;
            var found = properties.TryGetValue(string.Empty + builderType.FullName, out result);
            if (found)
            {
                return result as IMemberBuildParameters;
            }

            var paraInstance = Activator.CreateInstance(paraType);
            var setupPara = (IMemberBuildParameters)paraInstance;

            properties.AddDataItem(string.Empty + builderType.FullName, setupPara);
            return setupPara;
        }