コード例 #1
0
        public Fooder Create(FooderType fooderType, FooderDesignation fooderDesignation)
        {
            var(part, relationship) = fooderType switch
            {
                FooderType.Header => package.AddHeaderPart(),
                FooderType.Footer => package.AddFooterPart(),
                _ => throw new ArgumentOutOfRangeException(nameof(fooderType))
            };

            var document = PackagePartHelper.ReadPackagePart(part);

            Fooder fooder = fooderType switch
            {
                FooderType.Header => new Header(part, document, relationship, fooderDesignation, wordDocument),
                FooderType.Footer => new Footer(part, document, relationship, fooderDesignation, wordDocument),
                _ => throw new ArgumentOutOfRangeException(nameof(fooderType))
            };

            var packagePartUri = PackagePartHelper.EnsureCorrectUri(relationship.TargetUri);

            fooders[packagePartUri] = fooder;

            EnsureDefaultStyles(fooderType);

            return(fooder);
        }
コード例 #2
0
 public void Delete(Fooder fooder)
 {
     fooders.Remove(fooder.Relationship.TargetUri);
     package.DeletePart(fooder.Relationship);
 }