about us      downloads      documentation      contact      home 
 products
 antHR
 workflow studio
 technical toolkits
 content entry
 workflow
 security
 hierarchy
 concepts
 how tos
 reference
 FAQs
previous: Markup class for content entry  next: Marking the class for storage

How to: Content entry attributes - Test editing the class

  Step 1 : Summary
  Step 2 : Build the class
  Step 3 : Markup class for content entry
  Step 4 : Test editing the class
  Step 5 : Marking the class for storage
  Step 6 : Being flexible in storage

Take the class and generate a form from it - (page 4 of 6)

Level: developer

Add the following class to you project.
using System;
using System.Xml;
using System.Windows.Forms;
using Ant.ContentEntry;
using Ant.ContentEntry.Windows;
using Ant.Licensing;
namespace HowTos
{
    /// <summary>
    /// Class which is run to start the application, edit the class and trace the results
    /// </summary>
    public class MainClass
    {
        static public int Main(string[] args)
        {
            // Gets the content definition for our class, using default (null) user
            ContentDefinition def = new ContentDefinitionFactory(null, "ENGLISH", 0).ForClass(typeof(TelevisionProgramme));
            // Construct a version of our class to edit
            TelevisionProgramme programme = new TelevisionProgramme();
            // Construct a form off this object
            ContentEntryWindowsForm form = new ContentEntryWindowsForm("Test", def, XmlHelper.GetInstanceFromObject(def, programme));
            // Show the form and check the OK button was checked
            if (form.ShowDialog() == DialogResult.OK)
            {
                // Map the values back in to the object
                programme = XmlHelper.GetObjectFromInstance(def, form.InstanceData) as TelevisionProgramme;
                //Trace out the results
                System.Diagnostics.Trace.WriteLine("Programme name:"+programme.ProgrammeName);    
                System.Diagnostics.Trace.WriteLine("Channel:"+programme.Channel.ToString());    
                System.Diagnostics.Trace.WriteLine("Date:"+programme.Start.ToString("dd-MM-yyyy HH:mm"));    
                System.Diagnostics.Trace.WriteLine("Duration:"+programme.Duration.ToString());    
            }
            return 0;
        }
    }
}
Running this code allows you to edit the class in an automatically generated form. The information you enter in to the form is then mapped back to the object and traced.


 

Did you find this article helpful? Comments on this page are welcome and can only help us improve the quality of our documentation.
© Ant Organisation Ltd, 2003