Beispiel #1
0
        /// <summary>
        /// Constructs and instance of ConstructorArguments from a parsable object. This is the inverse of Construct().
        /// Note: will always set SubtypeName to the Type of object.
        /// </summary>
        /// <param name="obj">The object from which to construct the ConstructorArguments</param>
        /// <param name="suppressDefaults">Specifies whether values that are equal to the defaults should be included in the resulting ArgumentCollection</param>
        /// <returns>The result</returns>
        public static ConstructorArguments FromParsable(object obj, Type parseTypeOrNull = null, bool suppressDefaults = false)
        {
            ConstructorArguments constructor = new ConstructorArguments();

            constructor.SubtypeName = parseTypeOrNull == null || !parseTypeOrNull.Equals(obj.GetType()) ? obj.GetType().ToTypeString() : null;
            constructor.PopulateFromParsableObject(obj, suppressDefaults);
            return(constructor);
        }