Group: StrataFrame Users
Posts: 112,
Visits: 1.2K
|
Hi all -
Thought I'd post the modified version of GenerateBusinessObject() which I am using for C# projects, so that anyone who may be able to benefit from this great Add-in can do so.
Hope this helps, and thanks again, Paul!
________________
_____/ Regards,
____/ al
Private Function GenerateBusinessObject(ByVal FileName As String) As Boolean
'-- Variables
Dim loStartEditPoint As EditPoint
Dim loEndEditPoint As EditPoint
Dim loTextDocument As TextDocument
Dim lodocument As Document
Dim loProjectItem As ProjectItem
'-- Make Sure We ar on the Correct Project
GotoProject(_Project.Name)
' Check to see if file exists
'---
If System.IO.File.Exists(_Project.FullName.Substring(0, _Project.FullName.LastIndexOf("\"c)) & "\" & FileName) Then
If ChkOverwrite.Checked Then
System.IO.File.Delete(_Project.FullName.Substring(0, _Project.FullName.LastIndexOf("\"c)) & "\" & FileName)
Else
Return False
End If
End If
'-
Try
loProjectItem = _Project.DTE.ItemOperations.AddNewItem("Visual C# Items\SF Business Object", FileName)
'// 12-11-2008 AEL: loProjectItem = _Project.DTE.ItemOperations.AddNewItem("Common Items\SF Business Object", FileName)
'Get Ref to New bus obj
lodocument = _Project.DTE.ActiveDocument
loTextDocument = DirectCast(lodocument.Object, TextDocument)
' Create edit point
loStartEditPoint = loTextdocument.CreateEditPoint()
'// [START] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= AEL Mod. 12-12-2008 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [START]
'//
'loStartEditPoint.MoveToLineAndOffset(7, 5)
'' Create edit point at the end of Document
'loEndEditPoint = loStartEditPoint.CreateEditPoint
'loEndEditPoint.EndOfLine()
'Delete Original Line and replace with the Inherits Statement on Text Box
'// 12-12-2008 AEL: loStartEditPoint.Delete(loEndEditPoint)
'// 12-12-2008 AEL: loStartEditPoint.Insert("Inherits " & Me.txtinherits.Text)
loStartEditPoint.MoveToLineAndOffset(13, 1) ' Start of partial class declaration for the new BO
If loStartEditPoint.FindPattern(":") = False Then
MsgBox("Error: Did not find ':' in partial class declaration! Could not change inheritance to custom BO class!!")
Return False
Else
'' Create edit point at the end of Document
loEndEditPoint = loStartEditPoint.CreateEditPoint
loEndEditPoint.EndOfLine()
'Delete Original Line and replace with the Inherits Statement on Text Box
loStartEditPoint.Delete(loEndEditPoint)
loStartEditPoint.Insert(": " & Me.txtinherits.Text)
End If
'//
'// [END] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= AEL Mod. 12-12-2008 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [END]
'Close The Document
lodocument.Close(vsSaveChanges.vsSaveChangesYes)
Return True
Catch ex As Exception
MessageBox.Show("Exception Thrown: " & ex.Message)
Return False
End Try
End Function
________________ _____/ Regards, ____/ al
|