Esempio n. 1
0
        /// <summary>Registers a creator function for the type that can create
        /// an instance of type based on a thread.
        /// </summary>
        /// <param name="type">
        /// The type to register.
        /// </param>
        /// <param name="creator">
        /// The creator function.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the type or the creator is null.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// If the type is generic, or has no converter, or a convertor that can not
        /// convert from string.
        /// </exception>
        /// <remarks>
        /// These creators are used to generate a value, if no one is
        /// assigned or configured.
        /// </remarks>
        public static void Register(Type type, Func <Thread, object> creator)
        {
            Qowaiv.Guard.NotNull(type, "type");
            Qowaiv.Guard.NotNull(creator, "creator");
            Guard(type, Creators.ContainsKey(type));

            Creators.TryAdd(type, creator);
        }