TryAdd() static private method

static private TryAdd ( IntPtr ptr ) : Attachment
ptr System.IntPtr
return Attachment
Ejemplo n.º 1
0
        /// <summary>
        /// Gets the attachment at the specified slot and index.
        /// </summary>
        /// <param name="index">Attachment index</param>
        /// <param name="characterSlot">Index of the character slot we wish to get an attachment from</param>
        /// <returns>null if failed, otherwise the attachment.</returns>
        public Attachment GetAttachment(int index, int characterSlot = 0)
        {
            var ptr = NativeEntityMethods.GetAttachmentByIndex(this.GetIEntity(), index, characterSlot);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            return(Attachment.TryAdd(ptr, this));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the attachment by name at the specified slot.
        /// </summary>
        /// <param name="name">Attachment name</param>
        /// <param name="characterSlot">Index of the character slot we wish to get an attachment from</param>
        /// <returns>null if failed, otherwise the attachment.</returns>
        public Attachment GetAttachment(string name, int characterSlot = 0)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
#endif

            var ptr = NativeEntityMethods.GetAttachmentByName(this.GetIEntity(), name, characterSlot);

            return(Attachment.TryAdd(ptr, this));
        }