Object Driven Interface Part 4 of 4
Part 4 of Creating an Object Driven Interface using Custom Attributes, reflection Custom Web Controls and much more. in this part we finally get to use our interface generator The Attached Zip file contains the complete code for all four parts of this article, which i had to split up due to size limits
AI
KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Quellcode
<style> p.numberedbullets, li.numberedbullets, div.numberedbullets {style-name:"numbered bullets"; style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:9.0pt; margin-left:48.2pt; text-indent:-19.85pt; pagination:none; list:l65 level1 lfo125; tab-stops:0cm 1.0cm list 48.2pt; font-size:9.0pt; bidi-font-size:10.0pt; font-family:"Baskerville BE Regular"; fareast-font-family:"Times New Roman"; bidi-font-family:"Times New Roman"; letter-spacing:.4pt; ansi-language:EN-US;}
p.HeaderOdd, li.HeaderOdd, div.HeaderOdd {style-name:HeaderOdd; style-update:auto; style-parent:Header; margin:0cm; margin-bottom:.0001pt; text-align:right; pagination:none; tab-stops:center 207.65pt right 415.3pt; border:none; border-bottom-alt:solid windowtext .5pt; padding:0cm; padding-alt:0cm 0cm 1.0pt 0cm; font-size:12.0pt; bidi-font-size:10.0pt; font-family:"ITC Franklin Gothic Book"; fareast-font-family:"Times New Roman"; bidi-font-family:"Times New Roman"; letter-spacing:.2pt; ansi-language:EN-US; font-weight:bold; bidi-font-weight:normal;}
p.background, li.background, div.background {style-name:"background"; style-next:Normal; margin-top:4.0pt; margin-right:33.85pt; margin-bottom:4.0pt; margin-left:33.85pt; pagination:none; hyphenate:none; font-size:9.0pt; bidi-font-size:10.0pt; font-family:"Baskerville BE Regular"; fareast-font-family:"Times New Roman"; bidi-font-family:"Times New Roman"; letter-spacing:.2pt; ansi-language:EN-US; font-style:italic; bidi-font-style:normal;}
p.chaptertitle, li.chaptertitle, div.chaptertitle {style-name:"chapter title"; style-parent:""; style-next:Normal; margin-top:48.0pt; margin-right:0cm; margin-bottom:42.0pt; margin-left:0cm; text-align:right; pagination:none; font-size:26.0pt; bidi-font-size:10.0pt; font-family:FrGothHeavy; fareast-font-family:"Times New Roman"; bidi-font-family:"Times New Roman"; color:black; font-kerning:14.0pt; ansi-language:EN-US;}
p.codebackground, li.codebackground, div.codebackground {style-name:"code background"; style-parent:"code foreground"; style-next:Normal; margin-top:0cm; margin-right:5.65pt; margin-bottom:0cm; margin-left:31.2pt; margin-bottom:.0001pt; line-height:10.0pt; pagination:none; hyphenate:none; tab-stops:2.0cm 3.0cm 4.0cm 5.0cm 6.0cm; border:none; border-alt:solid white 1.5pt; padding:0cm; padding-alt:1.0pt 2.0pt 1.0pt 15.0pt; font-size:8.0pt; bidi-font-size:10.0pt; font-family:Courier; fareast-font-family:"Times New Roman"; bidi-font-family:"Times New Roman"; ansi-language:EN-US;}
p.codeforeground, li.codeforeground, div.codeforeground {style-name:"code foreground"; style-parent:""; style-next:Normal; margin-top:0cm; margin-right:5.65pt; margin-bottom:0cm; margin-left:31.2pt; margin-bottom:.0001pt; line-height:10.0pt; pagination:none; hyphenate:none; tab-stops:2.0cm 3.0cm 4.0cm 5.0cm 6.0cm; background:#F2F2F2; shading:windowtext; pattern:gray-5 auto; border:none; border-alt:solid white 1.5pt; padding:0cm; padding-alt:1.0pt 2.0pt 1.0pt 15.0pt; font-size:8.0pt; bidi-font-size:10.0pt; font-family:Courier; fareast-font-family:"Times New Roman"; bidi-font-family:"Times New Roman"; ansi-language:EN-US;}
span.codeintext {style-name:"code in text"; style-parent:""; ascii-font-family:Courier; hansi-font-family:Courier; letter-spacing:0pt;}
span.screentext {style-name:"screen text"; style-parent:""; ansi-font-size:9.0pt; ascii-font-family:Helvetica; hansi-font-family:Helvetica; letter-spacing:.2pt;}
</style>
<DIV>
<p class="chaptertitle"><span>Part 4 Using
our interface Generator</span></p>
<p class="background"><span>For this we
will create a simple Web project to use our interface generator.</span></p>
<p><span>
<p>
</span>
<p>
<p><span>Because we
cant use resources for our images that we will be using on the web page we need
to add these to the Web project the images are in a file called “images.zip” in
the attached file, the complete Web Project with the images is in a file called
“WizardTest.zip” in the attached file.</span></p>
<p><span>
<p>
</span>
<p>
<p><span>Using our
interface generator is really simple; we create a Web project and add a
Placeholder called PropertyHolder to the page. We the create an instance of our
business object, once we have our business object we create an instance of our
interface generator passing it our business object in the .ctor., the Interface
Generator is declared withevents so that we can handle the </span><span style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';LETTER-SPACING:0pt">ValuesUpdated</span><span style="FONT-SIZE:10pt; FONT-FAMILY:'Courier New'; LETTER-SPACING:0pt"> event.</span></p>
<p><span>
<p>
</span>
<p>
<div style="BORDER-RIGHT:white 1.5pt solid; PADDING-RIGHT:2pt; BORDER-TOP:white 1.5pt solid; PADDING-LEFT:15pt; BACKGROUND:#f2f2f2; PADDING-BOTTOM:1pt; BORDER-LEFT:white 1.5pt solid; PADDING-TOP:1pt; BORDER-BOTTOM:white 1.5pt solid; shading:windowtext; pattern:gray-5 auto">
<p class="codeforeground"><span>…</span></p>
<p class="codeforeground"><span style="COLOR:blue; bidi-font-family:'Courier New'">Dim</span><span style="bidi-font-family:'Courier New'"> <span style="COLOR:blue">WithEvents</span> Generator <span style="COLOR:blue">As</span> Wizard.Control.Prototype.InterfaceGenerator
<p></span>
<p>
<p class="codeforeground"><span>…</span></p>
<p class="codeforeground"><span style="COLOR:blue">Private</span><span> <span style="COLOR:blue">Sub</span> Page_Load(<span style="COLOR:blue">ByVal</span> sender <span style="COLOR:blue">As</span> System.Object, <span style="COLOR:blue">ByVal</span> e <span style="COLOR:blue">As</span> System.EventArgs) <span style="COLOR:blue">Handles</span> <span style="COLOR:blue">MyBase</span>.Load</span></p>
<p class="codeforeground"><span><span style="spacerun:yes"> </span>
<span style="COLOR:green">'Put user code to initialize the page
here
<p></span>
</span>
<p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>TestObject = <span style="COLOR:blue">New</span>
Customer</span></p>
<p class="codeforeground"><span><span style="spacerun:yes"> </span>Generator
= <span style="COLOR:blue">New</span>
Wizard.Control.Prototype.InterfaceGenerator(TestObject)</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>PropertyHolder.Controls.Add(Generator)</span></p>
<p class="codeforeground"><span><span style="spacerun:yes"> </span><span style="COLOR:blue">If</span> IsPostBack <span style="COLOR:blue">Then
<p></span></span>
<p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>PropertyHolder.Visible = <span style="COLOR:blue">False
<p></span></span>
<p>
<p class="codeforeground"><span><span style="spacerun:yes"> </span>
<span style="COLOR:blue">End</span>
<span style="COLOR:blue">If
<p></span>
</span>
<p>
<p class="codeforeground"><span style="COLOR:blue">
<p>
</span>
<p>
<p class="codeforeground"><span style="COLOR:blue">End</span><span>
<span style="COLOR:blue">Sub
<p></span>
</span>
<p>
<p class="codeforeground"><span class="codeintext"><span>…
<p></span>
</span>
<p></p>
</div>
<p><span>
<p>
</span>
<p>
<p><span>For the test
when the event is triggered we display the values to the user.</span></p>
<p><span>
<p>
</span>
<p>
<div style="BORDER-RIGHT:white 1.5pt solid; PADDING-RIGHT:2pt; BORDER-TOP:white 1.5pt solid; PADDING-LEFT:15pt; BACKGROUND:#f2f2f2; PADDING-BOTTOM:1pt; BORDER-LEFT:white 1.5pt solid; PADDING-TOP:1pt; BORDER-BOTTOM:white 1.5pt solid; shading:windowtext; pattern:gray-5 auto">
<p class="codeforeground"><span style="COLOR:blue">Private</span><span> <span style="COLOR:blue">Sub</span>
Generator_ValuesUpdated(<span style="COLOR:blue">ByVal</span> sender <span style="COLOR:blue">As</span> <span style="COLOR:blue">Object</span>, <span style="COLOR:blue">ByVal</span> e <span style="COLOR:blue">As</span> System.EventArgs) <span style="COLOR:blue">Handles</span> Generator.ValuesUpdated</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>TestObject = Generator.WizardObject</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write("<P>The Following Properties Values now exist in the
Object:</P>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.Active & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.Address1 & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.Address2 & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.City & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.Contact & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.CreditLimit & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.Number & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.Phone & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes">
</span>Response.Write(TestObject.Postal & "<BR>")</span></p>
<p class="codeforeground"><span><span style="spacerun:yes"> </span>
<span style="COLOR:blue">End</span>
<span style="COLOR:blue">Sub</span>
</span></p>
</div>
<p><span>
<p>
</span>
<p>
<p><span>
<p>
</span>
<p>
<p><span>Now that was
cool wasn’t it!</span></p>
</DIV>
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine