Пример #1
0
        internal override object ConvertGatewayToRuntimeField(DBField dbField, object gatewayValue)
        {
            var gatewayBlob = (GatewayBlob)gatewayValue;

            byte[] blobData = (gatewayBlob.BlobSize > 0)? ((byte[])gatewayBlob.Blob) : null;
            return(BlobType.createFromBytes(blobData, (char)dbField.BlobContent));
        }
Пример #2
0
        protected override void Add(GatewayAdapterCursor gatewayAdapterCursor)
        {
            GatewayRecord record = new GatewayRecord();

            for (int fldIdx = 0; fldIdx < gatewayAdapterCursor.Definition.FieldsDefinition.Count; fldIdx++)
            {
                DBField field = gatewayAdapterCursor.Definition.FieldsDefinition[fldIdx];
                if (field.IsBlob())
                {
                    if (field.IsBinaryBlob())
                    {
                        string blobData = string.Empty;
                        if (!gatewayAdapterCursor.CurrentRecord[fldIdx].IsNull)
                        {
                            string blobDataWithPrefix = BlobType.createFromBytes((byte[])(((GatewayBlob)gatewayAdapterCursor.CurrentRecord[fldIdx].Value).Blob), BlobType.CONTENT_TYPE_BINARY);
                            blobData = BlobType.getString(blobDataWithPrefix);
                        }

                        record.FieldValues.Add(new FieldData(field.DbName,
                                                             blobData,
                                                             gatewayAdapterCursor.CurrentRecord[fldIdx].IsNull));
                    }
                    else
                    {
                        record.FieldValues.Add(new FieldData(field.DbName,
                                                             (((GatewayBlob)gatewayAdapterCursor.CurrentRecord[fldIdx].Value).Blob).ToString(),
                                                             gatewayAdapterCursor.CurrentRecord[fldIdx].IsNull));
                    }
                }
                else
                {
                    record.FieldValues.Add(new FieldData(gatewayAdapterCursor.Definition.FieldsDefinition[fldIdx].DbName,
                                                         gatewayAdapterCursor.CurrentRecord[fldIdx].Value == null ? null : gatewayAdapterCursor.CurrentRecord[fldIdx].Value.ToString(),
                                                         gatewayAdapterCursor.CurrentRecord[fldIdx].IsNull));
                }
            }
            records.Add(record);
        }
Пример #3
0
        /// <summary>
        /// Converts 'dotNetObj' to 'Blob' Magic type
        /// </summary>
        /// <param name="dotNetObj"></param>
        /// <returns></returns>
        private static string convertDotNetToBlob(object dotNetObj)
        {
            String blob       = BlobType.createFromString("", BlobType.CONTENT_TYPE_UNKNOWN);
            Type   dotNetType = dotNetObj.GetType();

            if (dotNetType == typeof(Byte))
            {
                Byte[] bytes = new Byte[] { (Byte)dotNetObj };
                blob = BlobType.createFromBytes(bytes, BlobType.CONTENT_TYPE_BINARY);
            }
            else if (dotNetType == typeof(Byte[]))
            {
                Byte[] bytes = (Byte[])dotNetObj;
                blob = BlobType.createFromBytes(bytes, BlobType.CONTENT_TYPE_BINARY);
            }
            else if (dotNetType == typeof(Char))
            {
                String blobStr = new String((Char)dotNetObj, 1);
                blob = BlobType.createFromString(blobStr, BlobType.CONTENT_TYPE_UNICODE);
            }
            else if (dotNetType == typeof(Char[]))
            {
                String blobStr = new String((Char[])dotNetObj);
                blob = BlobType.createFromString(blobStr, BlobType.CONTENT_TYPE_UNICODE);
            }
            else if (dotNetType == typeof(String))
            {
                blob = BlobType.createFromString((String)dotNetObj, BlobType.CONTENT_TYPE_UNICODE);
            }
            else if (dotNetType == typeof(StringBuilder))
            {
                String blobStr = ((StringBuilder)dotNetObj).ToString();
                blob = BlobType.createFromString(blobStr, BlobType.CONTENT_TYPE_UNICODE);
            }

            return(blob);
        }