Example #1
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);
        }
        /// <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;
        }