public string GenerateCode(ITreeComponent tree, string newLine) { if (tree is LeafComponent) return GenerateCode(tree as LeafComponent); if (tree is NodeComponent) return GenerateCode(tree as NodeComponent, newLine); if (tree is TreeRefComponent) return GenerateCode(tree as TreeRefComponent); throw new NotSupportedException("type is not supported " + tree.GetType()); }