HAUPPAUGE WinTV-PVR und Media Center Edition 2005: Fernbedienung
Mrz 3

Von: Patrick Dahmen
03.03.2004 

Ein hübsches Makro für den WebProgrammierer. Weiter unten beim normalen 'automatischen Property...' ist beschrieben, wie man eine Tastaturkombination dafür hinkriegt:)

 

    Sub InsertViewStateProperty()

        Dim ts As TextSelection = DTE.ActiveWindow.Selection

        Dim Type As String = InputBox("Enter the Typename: ")

 

        If Type.Trim.Length = 0 Then

            MsgBox("You must specify a type!")

            Exit Sub

        End If

 

        Dim ExternalName As String = InputBox("Enter the external (public) property name: ")

        If Type.Trim.Length = 0 Then

            MsgBox("You must specify an external name.")

            Exit Sub

        End If

 

        Dim DefaultValue As String = InputBox("Enter the default value for the property: ")

        If Type.Trim.Length = 0 Then

            MsgBox("You must specify a default value.")

            Exit Sub

        End If

 

 

        Dim vp As Integer = ts.AnchorPoint.AbsoluteCharOffset

 

 

        ts.NewLine()

        ts.Insert("// " & ExternalName)

        ts.NewLine()

        ts.Insert("public " & Type & " " & ExternalName)

        ts.NewLine()

        ts.Insert("{")

        ts.NewLine()

        ts.Insert("get {")

        ts.NewLine()

        ts.Insert("if (ViewState[""" & ExternalName & """] == null)")

        ts.NewLine()

        ts.Insert("return " & DefaultValue & ";")

        ts.NewLine()

        ts.NewLine()

        ts.Insert("return (" & Type & ") ViewState[""" & ExternalName & """];")

        ts.NewLine()

        ts.Insert("}")

        ts.NewLine()

        ts.Insert("set {")

        ts.NewLine()

        ts.Insert("ViewState[""" & ExternalName & """] = value;")

        ts.NewLine()

        ts.Insert("}")

        ts.NewLine()

        ts.Insert("}")

 

 

        'ts.MoveToPoint(vp, True)

        ts.MoveToAbsoluteOffset(vp, True)

        ts.SmartFormat()

    End Sub

 

?>

?>

Tags:
Nutzungsbedingungen
(c) 2010 e-llusions