Exemplo n.º 1
0
        /// <summary>
        /// Converts an ODCM type into a PowerShell acceptable type.
        /// </summary>
        /// <param name="odcmType">The ODCM type</param>
        /// <param name="isCollection">Whether or not the type is the type of object in a collection (e.g. an array)</param>
        /// <returns>The PowerShell type.</returns>
        public static Type ToPowerShellType(this OdcmType odcmType, bool isCollection = false)
        {
            if (odcmType == null)
            {
                throw new ArgumentNullException(nameof(odcmType));
            }

            // Convert the type (default to System.Object if we can't convert the type)
            Type result = odcmType.ToDotNetType();

            // Make it an array type if necessary
            if (isCollection)
            {
                result = result.MakeArrayType();
            }

            return(result);
        }