private static void read_directives( XmlNodeReader NodeReader, Item_Aggregation HierarchyObject, string Directory )
        {
            string directiveCode = String.Empty;
            string directiveFile = String.Empty;
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                        case "HI:CODE":
                            NodeReader.Read();
                            directiveCode = NodeReader.Value.Replace("<%","").Replace("%>","");
                            break;

                        case "HI:SOURCE":
                            NodeReader.Read();
                            directiveFile = NodeReader.Value;
                            break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == "HI:DIRECTIVE" )
                    {
                        if ((directiveCode.Length > 0) && (directiveFile.Length > 0))
                        {
                            string contents;
                            try
                            {
                                // Look for the matching file
                                if (File.Exists(Directory + "\\" + directiveFile))
                                {
                                    StreamReader reader = new StreamReader(Directory + "\\" + directiveFile);
                                    contents = reader.ReadToEnd();
                                    reader.Close();

                                }
                                else
                                {
                                    contents = "MISSING DIRECTIVE SOURCE FILE ('" + directiveFile + "')";
                                }
                            }
                            catch
                            {
                                contents = "EXCEPTION WHILE READING DIRECTIVE SOURCE FILE ('" + directiveFile + "')";
                            }

                            // Create the custom derivative object
                            Item_Aggregation_Custom_Directive newDirective = new Item_Aggregation_Custom_Directive(directiveCode, directiveFile, contents);
                            HierarchyObject.Custom_Directives["<%" + directiveCode.ToUpper() + "%>"] = newDirective;

                        }
                        directiveCode = String.Empty;
                        directiveFile = String.Empty;
                    }

                    if (NodeReader.Name.Trim().ToUpper() == "HI:DIRECTIVES")
                    {
                        // Done with all the directives so return
                        return;
                    }
                }
            }
        }
Beispiel #2
0
        private static void read_directives(XmlNodeReader NodeReader, Item_Aggregation HierarchyObject, string Directory)
        {
            string directiveCode = String.Empty;
            string directiveFile = String.Empty;

            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:CODE":
                        NodeReader.Read();
                        directiveCode = NodeReader.Value.Replace("<%", "").Replace("%>", "");
                        break;

                    case "HI:SOURCE":
                        NodeReader.Read();
                        directiveFile = NodeReader.Value;
                        break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == "HI:DIRECTIVE")
                    {
                        if ((directiveCode.Length > 0) && (directiveFile.Length > 0))
                        {
                            string contents;
                            try
                            {
                                // Look for the matching file
                                if (File.Exists(Directory + "\\" + directiveFile))
                                {
                                    StreamReader reader = new StreamReader(Directory + "\\" + directiveFile);
                                    contents = reader.ReadToEnd();
                                    reader.Close();
                                }
                                else
                                {
                                    contents = "MISSING DIRECTIVE SOURCE FILE ('" + directiveFile + "')";
                                }
                            }
                            catch
                            {
                                contents = "EXCEPTION WHILE READING DIRECTIVE SOURCE FILE ('" + directiveFile + "')";
                            }

                            // Create the custom derivative object
                            Item_Aggregation_Custom_Directive newDirective = new Item_Aggregation_Custom_Directive(directiveCode, directiveFile, contents);
                            HierarchyObject.Custom_Directives["<%" + directiveCode.ToUpper() + "%>"] = newDirective;
                        }
                        directiveCode = String.Empty;
                        directiveFile = String.Empty;
                    }

                    if (NodeReader.Name.Trim().ToUpper() == "HI:DIRECTIVES")
                    {
                        // Done with all the directives so return
                        return;
                    }
                }
            }
        }