예제 #1
0
        public override int GetHashCode()
        {
            int hashCode = 1042699274;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Type);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Id);

            hashCode = hashCode * -1521134295 + EqualityComparer <InlineKeyboardMarkup> .Default.GetHashCode(ReplyMarkup);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ParseMode);

            hashCode = hashCode * -1521134295 + EqualityComparer <IEnumerable <MessageEntity> > .Default.GetHashCode(CaptionEntities);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Type);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(AudioUrl);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Caption);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Performer);

            hashCode = hashCode * -1521134295 + AudioDuration.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <InputMessageContent> .Default.GetHashCode(InputMessageContent);

            return(hashCode);
        }
        /// <summary>
        /// Splits the audio media data at a given split point in time,
        /// <c>this</c> retaining the audio before the split point,
        /// creating a new <see cref="AudioMediaData"/> containing the audio after the split point
        /// </summary>
        /// <param name="splitPoint">The given split point</param>
        /// <returns>A audio media data containing the audio after the split point</returns>
        /// <exception cref="exception.MethodParameterIsNullException">
        /// Thrown when the given split point is <c>null</c>
        /// </exception>
        /// <exception cref="exception.MethodParameterIsOutOfBoundsException">
        /// Thrown when the given split point is negative or is beyond the duration of <c>this</c>
        /// </exception>
        public virtual AudioMediaData Split(Time splitPoint)
        {
            if (OriginalRelativePath != null && DataProvider != null)
            {
                throw new NotImplementedException();
            }

            //throw new NotImplementedException("AudioMediaData.Split() should never be called ! (WavAudioMediaData instead)");

            if (splitPoint == null)
            {
                throw new exception.MethodParameterIsNullException(
                          "The split point can not be null");
            }
            if (splitPoint.IsNegative)
            {
                throw new exception.MethodParameterIsOutOfBoundsException(
                          "The split point can not be negative");
            }
            if (splitPoint.IsGreaterThan(AudioDuration))
            {
                throw new exception.MethodParameterIsOutOfBoundsException(
                          "The split point can not be beyond the end of the AudioMediaData");
            }
            MediaData md = Presentation.MediaDataFactory.Create(GetType());

            if (!(md is AudioMediaData))
            {
                throw new exception.FactoryCannotCreateTypeException(String.Format(
                                                                         "The MediaDataFactory can not create a AudioMediaData matching Xuk QName {1}:{0}",
                                                                         GetXukName(), GetXukNamespace()));
            }
            AudioMediaData secondPartAMD         = (AudioMediaData)md;
            Time           spDur                 = AudioDuration.GetDifference(splitPoint);
            Stream         secondPartAudioStream = OpenPcmInputStream(splitPoint);

            try
            {
                secondPartAMD.AppendPcmData(secondPartAudioStream, spDur);
            }
            finally
            {
                secondPartAudioStream.Close();
            }
            RemovePcmData(splitPoint);
            return(secondPartAMD);
        }