예제 #1
0
        public static IT4Directive AddDirective([NotNull] this IT4File t4File, [NotNull] IT4Directive directive, [NotNull] DirectiveInfoManager directiveInfoManager)
        {
            Pair <IT4Directive, BeforeOrAfter> anchor = directive.FindAnchor(t4File.GetDirectives().ToArray(), directiveInfoManager);

            if (anchor.First == null)
            {
                return(t4File.AddDirective(directive));
            }

            return(anchor.Second == BeforeOrAfter.Before
                                ? t4File.AddDirectiveBefore(directive, anchor.First)
                                : t4File.AddDirectiveAfter(directive, anchor.First));
        }
예제 #2
0
        private void AddDirective([NotNull] IT4File t4File, [NotNull] IT4Directive directive)
        {
            Pair <IT4Directive, BeforeOrAfter> anchor = directive.FindAnchor(t4File.GetDirectives().ToArray(), _directiveInfoManager);

            if (anchor.First != null)
            {
                if (anchor.Second == BeforeOrAfter.Before)
                {
                    t4File.AddDirectiveBefore(directive, anchor.First);
                }
                else
                {
                    t4File.AddDirectiveAfter(directive, anchor.First);
                }
            }
            else
            {
                t4File.AddDirective(directive);
            }
        }