/// <summary>
        /// Loads the specified sprite animation.
        /// </summary>
        private static SpriteAnimation LoadInternal(this ContentManager contentManager, SpriteAnimationID id, ScreenDensityBucket density, Boolean cache)
        {
            var sprite = contentManager.Load <Sprite>(SpriteAnimationID.GetSpriteAssetIDRef(ref id), density, cache);

            var name = SpriteAnimationID.GetAnimationNameRef(ref id);

            if (!String.IsNullOrEmpty(name))
            {
                var value = sprite[name];
                if (value == null)
                {
                    throw new ArgumentException(UltravioletStrings.InvalidSpriteAnimationReference.Format(id));
                }

                return(value);
            }

            var index = SpriteAnimationID.GetAnimationIndexRef(ref id);

            if (index < 0 || index >= sprite.AnimationCount)
            {
                throw new ArgumentException(UltravioletStrings.InvalidSpriteAnimationReference.Format(id));
            }

            return(sprite[index]);
        }
 /// <summary>
 /// Writes a sprite animation identifier to the stream.
 /// </summary>
 /// <param name="writer">The <see cref="BinaryWriter"/> with which to write the sprite animation identifier.</param>
 /// <param name="id">The <see cref="SpriteAnimationID"/> to write to the stream.</param>
 public static void Write(this BinaryWriter writer, SpriteAnimationID id)
 {
     writer.Write(id.IsValid);
     if (id.IsValid)
     {
         writer.Write(SpriteAnimationID.GetSpriteAssetIDRef(ref id));
         writer.Write(SpriteAnimationID.GetAnimationNameRef(ref id));
         writer.Write(SpriteAnimationID.GetAnimationIndexRef(ref id));
     }
 }