Ejemplo n.º 1
0
 /// <summary>
 /// Searches for TLD.
 /// </summary>
 /// <param name="domainName"></param>
 /// <param name="type">QType</param>
 /// <param name="sendBy"></param>
 public Lookup(string domainName, QTypes type, SendBy sendBy)
 {
     this.domainName = domainName;
     this.type       = type;
     this.sendBy     = sendBy;
     send();
 }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------//
        private static object GuidArray2Q(Array a)
        {
            var dim1 = a.GetLength(0);

            if (a.Rank == 1) //one dimensional array (from VBA)
            {
                var res = new Guid[dim1];
                for (var i = 0; i < dim1; i++)
                {
                    var val         = a.GetValue(i);
                    var convertFrom = TypeDescriptor.GetConverter(typeof(Guid)).ConvertFrom(val);
                    if (convertFrom != null)
                    {
                        res[i] = val == null
                            ? (Guid)QTypes.GetQNull(QType.Guid)
                            : (Guid)convertFrom;
                    }
                }
                return(res);
            }
            //two dimensional array (sheet)
            var dim2 = a.GetLength(1);
            var r    = new object[dim2];

            for (var i = 0; i < dim2; i++)
            {
                var elem = new Guid[dim1];
                for (var j = 0; j < dim1; j++)
                {
                    var val         = a.GetValue(j, i);
                    var convertFrom = TypeDescriptor.GetConverter(typeof(Guid)).ConvertFrom(val);
                    if (convertFrom != null)
                    {
                        elem[j] = val == null
                            ? (Guid)QTypes.GetQNull(QType.Guid)
                            : (Guid)convertFrom;
                    }
                }
                r[i] = elem;
            }
            return(r);
        }
Ejemplo n.º 3
0
 internal static extern uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQInfo);
Ejemplo n.º 4
0
 internal static extern uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo);
Ejemplo n.º 5
0
 internal static uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQInfo)
 {
     return(s_is64bitProcess ?
            SNINativeManagedWrapperX64.SNISetInfo(pConn, QType, ref pbQInfo) :
            SNINativeManagedWrapperX86.SNISetInfo(pConn, QType, ref pbQInfo));
 }
Ejemplo n.º 6
0
 internal static uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo)
 {
     return(s_is64bitProcess ?
            SNINativeManagedWrapperX64.SNIQueryInfo(QType, ref pbQInfo) :
            SNINativeManagedWrapperX86.SNIQueryInfo(QType, ref pbQInfo));
 }
Ejemplo n.º 7
0
        //-------------------------------------------------------------------//
        /// <summary>
        ///     Simply retrieves value of the COM object (workseet ranges are often passed
        ///     as COM objects).
        /// </summary>
        /// <returns>value associated with given COM object</returns>
        /// <summary>
        ///     Performs conversion of given value to given q type
        /// </summary>
        /// <param name="value">value to be converted</param>
        /// <param name="type">type to convert to</param>
        /// <returns>converted value</returns>
        public static object Convert2Q(object value, string type)
        {
            if (value == null || value is string && value.ToString() == "" || ExcelEmpty.Value == value)
            {
                return(QTypes.GetQNull(ToQtype[type]));
            }

            if (type == null)
            {
                return(value.ToString());
            }

            switch (type.ToLowerInvariant())
            {
            case "b":
                return(Boolean2Q(value));

            case "g":
                return(Guid2Q(value));

            case "x":
                return(Byte2Q(value));

            case "h":
                return(Short2Q(value));

            case "i":
                return(Int2Q(value));

            case "j":
                return(Long2Q(value));

            case "e":
                return(Real2Q(value));

            case "f":
                return(Float2Q(value));

            case "c":
                return(Char2Q(value));

            case "t":
                return(ExcelDate2QTime(value));

            case "d":
                return(ExcelDate2QDate(value));

            case "z":
                return(ExcelDate2QDateTime(value));

            case "p":
                return(ExcelDate2QTimestamp(value));

            case "n":
                return(ExcelDate2QTimespan(value));

            case "m":
                return(ExcelDate2QMonth(value));

            case "v":
                return(ExcelDate2QSecond(value));

            case "u":
                return(ExcelDate2QMinute(value));

            case "*":
            case "s":
                return(Sym2Q(value));

            default:
                return(value.ToString());
            }
        }
Ejemplo n.º 8
0
        //-------------------------------------------------------------------//
        /// <summary>
        ///     Converts data received from q process to data types that are displayable on
        ///     the worksheet.
        /// </summary>
        /// <param name="result">value to be converted</param>
        /// <returns>value displayable on the worksheet</returns>
        internal static object Convert2Excel(object result)
        {
            if (result == null)
            {
                return("");
            }
            var type = result.GetType().Name.ToLower();

            switch (type)
            {
            case "int16":
                return((((short)result) == (short)QTypes.GetQNull(QType.Short)) ? "" : result);

            case "int32":
                return((((int)result) == (int)QTypes.GetQNull(QType.Int)) ? "" : result);

            case "int64":
            case "long":
                if ((((long)result) == (long)QTypes.GetQNull(QType.Long)))
                {
                    return("");
                }
                return(Environment.Is64BitProcess ? result : Convert.ToDouble(result));

            case "double":
                return(Double.IsNaN((double)result) ? "" : result);

            case "single":
                return(Single.IsNaN(((float)result)) ? "" : result);

            case "boolean":
            case "byte":
                return(result);

            case "guid":
                return((((Guid)result) == (Guid)QTypes.GetQNull(QType.Guid)) ? "" : result.ToString());

            case "char":
                return((((char)result) == (char)QTypes.GetQNull(QType.Char)) ? "" : result.ToString());

            case "string":
                return(result.ToString() == QTypes.GetQNull(QType.Symbol).ToString()
                        ? ""
                        : result);

            case "char[]":
                return(((char[])result).Length > 0 ? new string((char[])result) : "");

            case "qlambda":
                return(((QLambda)result).Expression);

            case "qtimestamp":
            {
                if (!((QTimestamp)result).Equals(((QTimestamp)QTypes.GetQNull(QType.Timestamp))))
                {
                    return(((QTimestamp)result).ToDateTime());
                }
                return("");
            }

            case "qdatetime":
            {
                if (!((QDateTime)result).Equals(QTypes.GetQNull(QType.Datetime)))
                {
                    return(((QDateTime)result).ToDateTime());
                }
                return("");
            }

            case "qtime":
            {
                if (!((QTime)result).Equals(QTypes.GetQNull(QType.Time)))
                {
                    return(GetTime((QTime)result));
                }
                return("");
            }

            case "qdate":
            {
                if (!((QDate)result).Equals(QTypes.GetQNull(QType.Date)))
                {
                    return(((QDate)result).ToDateTime());
                }
                return("");
            }

            case "qtimespan":
            {
                if (!((QTimespan)result).Equals(QTypes.GetQNull(QType.Timespan)))
                {
                    return(((QTimespan)result).ToDateTime());
                }
                return("");
            }

            case "qsecond":
            {
                if (!((QSecond)result).Equals(QTypes.GetQNull(QType.Second)))
                {
                    return(GetTime((QSecond)result));
                }

                return("");
            }

            case "qmonth":
            {
                if (!((QMonth)result).Equals(QTypes.GetQNull(QType.Month)))
                {
                    return(((QMonth)result).ToDateTime());
                }
                return("");
            }

            case "qminute":
            {
                if (!((QMinute)result).Equals(QTypes.GetQNull(QType.Minute)))
                {
                    return(GetTime((QMinute)result));
                }

                return("");
            }

            case "qdictionary":
                return(QDict2Excel((QDictionary)result));

            case "qtable":
                return(QTable2Excel((QTable)result));

            case "qkeyedtable":
                return(QKeyedTable2Excel((QKeyedTable)result));

            default:
                if (type.Contains("[]"))
                {
                    return(Convert2DimArray(result as Array));
                }
                return(result.ToString());
            }
        }
 internal static extern uint SNISetInfo(SNIHandle pConn, QTypes QType, [In] ref uint pbQInfo);
Ejemplo n.º 10
0
 private static extern uint SNIGetInfoWrapper([In] SniNativeHandle pConn, QTypes QType, out Guid pbQInfo);
 internal static extern uint SNIQueryInfo(QTypes QType, ref IntPtr pbQInfo);
Ejemplo n.º 12
0
 public static uint SNIQueryInfo(QTypes q, ref IntPtr value)
 {
     throw new NotSupportedException(msg);
 }
Ejemplo n.º 13
0
 public static uint SNISetInfo(SafeHandle handle, QTypes q, ref uint result)
 {
     throw new NotSupportedException(msg);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Searches for TLD.
 /// </summary>
 /// <param name="domainName"></param>
 /// <param name="type">QType</param>
 /// <param name="sendBy"></param>
 public Lookup(string domainName, QTypes type, SendBy sendBy)
 {
     this.domainName = domainName;
     this.type = type;
     this.sendBy = sendBy;
     send();
 }
Ejemplo n.º 15
0
		public static uint SNIQueryInfo (QTypes q, ref IntPtr value)
		{
			throw new NotSupportedException (msg);
		}
Ejemplo n.º 16
0
		public static uint SNISetInfo (SafeHandle handle, QTypes q, ref uint result)
		{
			throw new NotSupportedException (msg);
		}