/// <summary>
        /// Initializes the current instance of the DataPartRelationship class.
        /// </summary>
        /// <param name="containter">The owner <see cref="OpenXmlPartContainer"/> that holds the <see cref="ReferenceRelationship"/>.</param>
        /// <param name="dataPart">The target DataPart of the reference relationship.</param>
        /// <param name="relationshipType">The relationship type of the reference relationship.</param>
        /// <param name="id">The relationship ID.</param>
        internal void Initialize(OpenXmlPartContainer containter, DataPart dataPart, string relationshipType, string id)
        {
            Debug.Assert(containter != null);
            Debug.Assert(dataPart != null);

            this.Initialize(dataPart.Uri, false, relationshipType, id);
            this.Container = containter;
            this.DataPart = dataPart;
        }
예제 #2
0
        /// <summary>
        /// Initializes the current instance of the DataPartRelationship class.
        /// </summary>
        /// <param name="containter">The owner <see cref="OpenXmlPartContainer"/> that holds the <see cref="ReferenceRelationship"/>.</param>
        /// <param name="dataPart">The target DataPart of the reference relationship.</param>
        /// <param name="relationshipType">The relationship type of the reference relationship.</param>
        /// <param name="id">The relationship ID.</param>
        internal void Initialize(OpenXmlPartContainer containter, DataPart dataPart, string relationshipType, string id)
        {
            Debug.Assert(containter != null);
            Debug.Assert(dataPart != null);

            this.Initialize(dataPart.Uri, false, relationshipType, id);
            this.Container = containter;
            this.DataPart  = dataPart;
        }
 public void WriteMedia(DataPart part)
 {
     using (Stream s = part.GetStream(FileMode.Create, FileAccess.ReadWrite))
         s.Write(Media, 0, Media.GetUpperBound(0) + 1);
 }
 public MediaData(DataPart part)
 {
     ContentType = part.ContentType;
     using (Stream s = part.GetStream(FileMode.Open, FileAccess.Read))
     {
         Media = new byte[s.Length];
         s.Read(Media, 0, (int)s.Length);
     }
 }
예제 #5
0
        /// <summary>
        /// Creates a new instance of the DataPartRelationship class based on the relationship type.
        /// </summary>
        /// <param name="containter">The owner <see cref="OpenXmlPartContainer"/> that holds the <see cref="ReferenceRelationship"/>.</param>
        /// <param name="dataPart">The target DataPart of the reference relationship.</param>
        /// <param name="relationshipType">The relationship type of the reference relationship.</param>
        /// <param name="id">The relationship ID.</param>
        internal static DataPartReferenceRelationship CreateDataPartReferenceRelationship(OpenXmlPartContainer containter, DataPart dataPart, string relationshipType, string id)
        {
            Debug.Assert(containter != null);
            Debug.Assert(dataPart != null);

            DataPartReferenceRelationship dataPartReferenceRelationship;

            switch (relationshipType)
            {
            case MediaReferenceRelationship.RelationshipTypeConst:
                dataPartReferenceRelationship = new MediaReferenceRelationship((MediaDataPart)dataPart, id);
                break;

            case AudioReferenceRelationship.RelationshipTypeConst:
                dataPartReferenceRelationship = new AudioReferenceRelationship((MediaDataPart)dataPart, id);
                break;

            case VideoReferenceRelationship.RelationshipTypeConst:
                dataPartReferenceRelationship = new VideoReferenceRelationship((MediaDataPart)dataPart, id);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(relationshipType));
            }
            dataPartReferenceRelationship.Container = containter;
            return(dataPartReferenceRelationship);
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the DataPartReferenceRelationship class using the supplied
 /// DataPart, relationship type, and relationship ID.
 /// </summary>
 /// <param name="dataPart">The target DataPart of the reference relationship.</param>
 /// <param name="relationshipType">The relationship type of the reference relationship.</param>
 /// <param name="id">The relationship ID.</param>
 internal protected DataPartReferenceRelationship(DataPart dataPart, string relationshipType, string id)
     : base(dataPart.Uri, false, relationshipType, id)
 {
     this.DataPart = dataPart;
 }
        /// <summary>
        /// Creates a new instance of the DataPartRelationship class based on the relationship type.
        /// </summary>
        /// <param name="containter">The owner <see cref="OpenXmlPartContainer"/> that holds the <see cref="ReferenceRelationship"/>.</param>
        /// <param name="dataPart">The target DataPart of the reference relationship.</param>
        /// <param name="relationshipType">The relationship type of the reference relationship.</param>
        /// <param name="id">The relationship ID.</param>
        internal static DataPartReferenceRelationship CreateDataPartReferenceRelationship(OpenXmlPartContainer containter, DataPart dataPart, string relationshipType, string id)
        {
            Debug.Assert(containter != null);
            Debug.Assert(dataPart != null);

            DataPartReferenceRelationship dataPartReferenceRelationship;

            switch (relationshipType)
            {
                case MediaReferenceRelationship.RelationshipTypeConst:
                    dataPartReferenceRelationship = new MediaReferenceRelationship((MediaDataPart)dataPart, id);
                    break;

                case AudioReferenceRelationship.RelationshipTypeConst:
                    dataPartReferenceRelationship = new AudioReferenceRelationship((MediaDataPart)dataPart, id);
                    break;

                case VideoReferenceRelationship.RelationshipTypeConst:
                    dataPartReferenceRelationship = new VideoReferenceRelationship((MediaDataPart)dataPart, id);
                    break;

                default:
                    throw new ArgumentOutOfRangeException("relationshipType");
            }
            dataPartReferenceRelationship.Container = containter;
            return dataPartReferenceRelationship;
        }
 /// <summary>
 /// Initializes a new instance of the DataPartReferenceRelationship class using the supplied
 /// DataPart, relationship type, and relationship ID.
 /// </summary>
 /// <param name="dataPart">The target DataPart of the reference relationship.</param>
 /// <param name="relationshipType">The relationship type of the reference relationship.</param>
 /// <param name="id">The relationship ID.</param>
 internal protected DataPartReferenceRelationship(DataPart dataPart, string relationshipType, string id)
     : base(dataPart.Uri, false, relationshipType, id)
 {
     this.DataPart = dataPart;
 }
 internal protected DataPartReferenceRelationship(DataPart dataPart, string relationshipType, string id)
     : base(dataPart?.Uri, false, relationshipType, id)
 {
     DataPart = dataPart ?? throw new ArgumentNullException(nameof(dataPart));
 }
예제 #10
0
 /// <summary>
 /// Initializes the current instance of the DataPartRelationship class.
 /// </summary>
 /// <param name="containter">The owner <see cref="OpenXmlPartContainer"/> that holds the <see cref="ReferenceRelationship"/>.</param>
 /// <param name="dataPart">The target DataPart of the reference relationship.</param>
 /// <param name="relationshipType">The relationship type of the reference relationship.</param>
 /// <param name="id">The relationship ID.</param>
 internal DataPartReferenceRelationship(OpenXmlPartContainer containter, DataPart dataPart, string relationshipType, string id)
     : base(dataPart.Uri, false, relationshipType, id)
 {
     Container = containter;
     DataPart  = dataPart;
 }