Ejemplo n.º 1
0
        /// <summary>
        /// Process all files in the directory passed in, recurse on any directories that are found,
        /// and process the files they contain.
        /// </summary>
        /// <param name="targetDirectory"> The target directory. </param>
        private static void ProcessDirectory(string targetDirectory)
        {
            // Process the list of files found in the directory.
            string[] fileEntries = Directory.GetFiles(targetDirectory);
            foreach (string fileName in fileEntries)
            {
                FileInfo file = new FileInfo(fileName);
                if (file.Name.Contains("object-meta"))
                {
                    Console.WriteLine("Processed object from File:  '{0}'.", fileName);
                    // If all information has been gather for the Salesforce object then add it to
                    // the list
                    if (completedObject == true)
                    {
                        sFObjectsList.Add(sFObject);
                        completedObject = false;
                        Console.WriteLine(sFObject.ToString());
                    }
                    //Read the first XML file to gather the objects base level information
                    sFObject = CreateSfObject(file);
                    break;
                }
                else if (file.Name.Contains("recordType-meta"))
                {
                    //If the Salesforce object has a record type then add it to the current object
                    sFObject = getSfObjectRecordTypes(file, sFObject);
                }
                else if (file.Name.Contains("field-meta"))
                {
                    //If the Salesforce object has fields then add it to the current object
                    sFObject = getSfObjectFieldProperties(file, sFObject);
                    //When the field level is reached then there are no more level to the object, so marked as completed
                    completedObject = true;
                }
            }

            // Recurse into subdirectories of this directory.
            string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
            foreach (string subdirectory in subdirectoryEntries)
            {
                ProcessDirectory(subdirectory);
            }
        }