示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="String"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public String(Variable variable)
            : base(variable)
        {
            // Check if code type is string type
            ClrCodeType codeType = variable.GetCodeType() as ClrCodeType;

            if (codeType == null || !codeType.ClrType.IsString)
            {
                throw new WrongCodeTypeException(variable.GetCodeType(), nameof(variable), "System.String");
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Exception"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public Exception(Variable variable)
            : base(variable)
        {
            // Check if code type is exception type
            ClrCodeType codeType = variable.GetCodeType() as ClrCodeType;
            bool        found    = false;

            while (!found && codeType != null)
            {
                if (codeType.Name == "System.Exception")
                {
                    found = true;
                }
                else
                {
                    codeType = (ClrCodeType)codeType.InheritedClass;
                }
            }

            if (!found)
            {
                throw new WrongCodeTypeException(variable.GetCodeType(), nameof(variable), "System.Exception");
            }
        }