/// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="name"></param>
        /// <param name="itemObjectDbType"></param>
        /// <param name="itemDbTypeDef"></param>
        /// <param name="itemObjectType"></param>
        internal OracleObjectType(string owner, string name, OracleObjectDbType itemObjectDbType, OracleDbTypeDef itemDbTypeDef, OracleObjectType itemObjectType)
        {
            if (string.IsNullOrWhiteSpace(owner))
            {
                throw new ArgumentException(nameof(owner));
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name));
            }
            if (itemObjectDbType == OracleObjectDbType.DbType && itemDbTypeDef == null)
            {
                throw new ArgumentNullException(nameof(itemDbTypeDef), "Table of DbType requires a ItemDbTypeDef.");
            }
            if (itemObjectDbType == OracleObjectDbType.Object && itemObjectType?.objectDbType != OracleObjectDbType.Object)
            {
                throw new ArgumentNullException(nameof(itemDbTypeDef), "Table of Object requires a ItemObjectDbType of type Object.");
            }

            this.owner            = owner;
            this.name             = name;
            this.objectDbType     = OracleObjectDbType.Table;
            this.itemObjectDbType = itemObjectDbType;
            this.itemDbTypeDef    = itemDbTypeDef;
            this.itemObjectType   = itemObjectType;
        }
        /// <summary>
        /// Gets the Oracle object type associated with the queue for batched operations.
        /// </summary>
        /// <returns></returns>
        public async Task <OracleObjectType> GetPayloadArrayTypeAsync()
        {
            if (PayloadArrayTypeName == null)
            {
                throw new InvalidOperationException($"{nameof(PayloadArrayTypeName)} is null during attempt to dequeue multiple UDT messages.");
            }

            // retrieve type
            if (payloadArrayType == null)
            {
                payloadArrayType = await OracleObjectTypeProvider.GetObjectMetadataAsync(Connection, PayloadArrayTypeName, log);
            }

            return(payloadArrayType);
        }
        /// <summary>
        /// Deserializes the given UDT result value in XML into a type described by the <see cref="OracleObjectType"/>.
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="name"></param>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static OracleObjectValue Deserialize(OracleObjectType metadata, XDocument xml)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            if (xml == null)
            {
                return(new OracleObjectValue(metadata, true));
            }

            // map XML to UDT
            return(new OracleObjectValue(
                       metadata,
                       metadata.Attributes
                       .Select(i => (i.Name, DeserializeAttribute(i, xml.Root.Element(i.Name))))));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reads the given results into the message.
        /// </summary>
        /// <param name="payloadType"></param>
        /// <param name="messageId"></param>
        /// <param name="properties"></param>
        /// <param name="payload"></param>
        /// <returns></returns>
        static OracleAQMessage ReadUdtMessage(OracleObjectType payloadType, byte[] messageId, string properties, string payload)
        {
            if (payloadType == null)
            {
                throw new ArgumentNullException(nameof(payloadType));
            }
            if (messageId == null)
            {
                throw new ArgumentNullException(nameof(messageId));
            }
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            return(new OracleAQMessage(
                       messageId,
                       OracleObjectXmlTransferSerializer.Deserialize(payloadType, payload != null ? XDocument.Parse(payload) : null),
                       DeserializeMessageProperties(XDocument.Parse(properties))));
        }
        /// <summary>
        /// Gets the UDT type associated with the queue.
        /// </summary>
        /// <returns></returns>
        public async Task <OracleObjectType> GetPayloadTypeAsync()
        {
            if (PayloadTypeName == null)
            {
                throw new InvalidOperationException($"{nameof(PayloadTypeName)} is null during attempt to dequeue a UDT message.");
            }

            // retrieve type
            if (payloadType == null)
            {
                payloadType = await OracleObjectTypeProvider.GetObjectMetadataAsync(Connection, PayloadTypeName, log);
            }

            // failure to get metadata
            if (payloadType == null)
            {
                throw new OracleAQException($"Unable to retrieve metadata for UDT {PayloadTypeName}.");
            }

            return(payloadType);
        }
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="name"></param>
        /// <param name="itemObjectDbType"></param>
        /// <param name="itemDbTypeDef"></param>
        /// <param name="itemObjectType"></param>
        /// <param name="capacity"></param>
        internal OracleObjectType(string owner, string name, OracleObjectDbType itemObjectDbType, OracleDbTypeDef itemDbTypeDef, OracleObjectType itemObjectType, int capacity)
        {
            if (string.IsNullOrWhiteSpace(owner))
            {
                throw new ArgumentException(nameof(owner));
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name));
            }
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(capacity));
            }

            this.owner            = owner;
            this.name             = name;
            this.objectDbType     = OracleObjectDbType.Array;
            this.itemObjectDbType = itemObjectDbType;
            this.itemDbTypeDef    = itemDbTypeDef;
            this.itemObjectType   = itemObjectType;
            this.capacity         = capacity;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="typeOwner"></param>
        /// <param name="typeName"></param>
        /// <param name="objectType"></param>
        internal OracleObjectTypeAttribute(
            string name,
            string typeOwner,
            string typeName,
            OracleObjectType objectType)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name));
            }
            if (string.IsNullOrWhiteSpace(typeName))
            {
                throw new ArgumentException(nameof(typeName));
            }
            if (objectType == null)
            {
                throw new ArgumentNullException(nameof(objectType));
            }

            Name       = name;
            TypeOwner  = typeOwner;
            TypeName   = typeName;
            ObjectType = ObjectType;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Reads the set of messages from the output arrays.
        /// </summary>
        /// <param name="payloadType"></param>
        /// <param name="count"></param>
        /// <param name="ids"></param>
        /// <param name="properties"></param>
        /// <param name="payloads"></param>
        /// <returns></returns>
        static IEnumerable <OracleAQMessage> ReadUdtMessages(OracleObjectType payloadType, int count, byte[][] ids, string[] properties, string[] payloads)
        {
            if (payloadType == null)
            {
                throw new ArgumentNullException(nameof(payloadType));
            }
            if (ids == null)
            {
                throw new ArgumentNullException(nameof(ids));
            }
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }
            if (payloads == null)
            {
                throw new ArgumentNullException(nameof(payloads));
            }

            for (var i = 0; i < count; i++)
            {
                yield return(ReadUdtMessage(payloadType, ids[i], properties[i], payloads[i]));
            }
        }
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="metadata"></param>
 /// <param name="attributes"></param>
 internal OracleObjectValue(OracleObjectType metadata, IEnumerable <(string, object)> attributes) :
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="metadata"></param>
 /// <param name="isNull"></param>
 internal OracleObjectValue(OracleObjectType metadata, bool isNull = false)
 {
     this.metadata   = metadata ?? throw new ArgumentNullException(nameof(metadata));
     this.attributes = new Dictionary <string, object>();
     this.isNull     = isNull;
 }