Exemplo n.º 1
0
        /// <summary>
        /// Fills the object.
        /// </summary>
        /// <param name="objectToPopulate">The object to populate.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="entityPrefix">The entity prefix.</param>
        public static void FillObject(DiscoveryBusinessObject objectToPopulate, TextFieldCollection fields, string entityPrefix)
        {
            // Qualified property name
            string qualifiedProperty = "";

            // Iterate over the properties of the type
            List <PropertyInfo> objectProperties = TextFieldParser.GetPropertyInfo(objectToPopulate.GetType());

            foreach (PropertyInfo objectProperty in objectProperties)
            {
                // Build the qualified name
                qualifiedProperty = ((string.IsNullOrEmpty(entityPrefix))?"":entityPrefix + ".") + objectProperty.Name;

                // See if we can write to the property
                if (objectProperty.CanWrite)
                {
                    // See if it's a complex type
                    if (objectProperty.PropertyType.IsSubclassOf(typeof(DiscoveryBusinessObject)))
                    {
                        // It's a complext type
                        FillObject(
                            (DiscoveryBusinessObject)objectProperty.GetValue(objectToPopulate, null),
                            fields,
                            qualifiedProperty);
                    }
                    else if (null != fields[qualifiedProperty])
                    {
                        // See if the property is in the text fields collection
                        objectProperty.SetValue(
                            objectToPopulate,
                            Convert.ChangeType(fields[qualifiedProperty].Value, objectProperty.PropertyType), null);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the contents of another 'TextFieldCollection' at the end of this instance.
        /// </summary>
        /// <param name="texValue">A 'TextFieldCollection' containing the objects to add to the collection.</param>
        public void AddRange(TextFieldCollection texValue)
        {
            int intCounter = 0;

            while ((intCounter < texValue.Count))
            {
                Add(texValue[intCounter]);
                intCounter = (intCounter + 1);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:TextFieldCollection"/> class based on an already existing instance.
 /// </summary>
 /// <param name="texValue">The 'TextFieldCollection' from which the contents is copied.</param>
 public TextFieldCollection(TextFieldCollection texValue) : base()
 {
     AddRange(texValue);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Fills the object.
 /// </summary>
 /// <param name="objectToPopulate">The object to populate.</param>
 /// <param name="fields">The fields.</param>
 public static void FillObject(DiscoveryBusinessObject objectToPopulate, TextFieldCollection fields)
 {
     // Call default implementation to fill base object
     FillObject(objectToPopulate, fields, "");
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:TextFieldParser"/> class.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="fileType">Type of the file.</param>
 public TextFieldParser(string fileName, FileFormat fileType)
 {
     this.fileName = fileName;
     this.fileType = fileType;
     textFields    = new TextFieldCollection();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Enumerator constructor
 /// Initializes a new instance of the <see cref="T:TextFieldEnumerator"/> class.
 /// </summary>
 /// <param name="texMappings">The tex mappings.</param>
 public TextFieldEnumerator(TextFieldCollection texMappings) : base()
 {
     iEnLocal = texMappings;
     iEnBase  = iEnLocal.GetEnumerator();
 }