Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

The InsertClass Merge Strategy is useful when you want to insert your template output into a previously existing class in the output file. At first this may sound very similar to the Insert Region Merge Strategy, and indeed it did start out that way; however, this Merge Strategy has many additional settings and features that separate it from it's other fellow Merge Strategies, and that make it a very robust and powerful tool.

...

I think the best way to describe this Merge Strategy is through example; but before we can do that, we must first go over it's configuration options.

LanguageString, RequiredOnly Support C# and VB.

ClassName

String, RequiredName of the class to insert into.
PreserveClassAttributesBoolean, defaults to FalseWhether or not the merge should preserve the existing classes attributes. By default, the merge tries to replace the entire existing class, which includes the attributes on the top of the class; this option leaves the attributes from the top of the original class.
OnlyInsertMatchingClassBoolean, defaults to FalseInsert the whole template output or just the matching class.
MergeImportsBoolean, defaults to FalseMerge the import/using statements of the existing file and generated output.
NotFoundActionEnum, defaults to None

What to do if the class is not found in the existing file. There are three options:

None: Don't merge anything, just leave the existing file as is.

InsertAtBottom: Append the output of the template to the bottom of existing file.

InsertInParent. Insert the output of the template at the bottom of a speficied parent section (specified by the NotFoundParent property).

NotFoundParentString, no default

If you specified InsertInParent for the NotFoundAction configuration, you must specify a name for the parent region. This can be the name of a Region or a Class.

Example Configuration...

Language: C#
ClassName: "Pet"
PreserveClassAttributes: True
OnlyInsertMatchingClass: True
MergeImports: True

...