Exemple #1
0
        public override BuildKeyedList <BuildComponentConfiguration> Clone()
        {
            BuildComponentConfigurationList clonedList =
                new BuildComponentConfigurationList(this);

            int itemCount = this.Count;

            for (int i = 0; i < itemCount; i++)
            {
                clonedList.Add(this[i].Clone());
            }

            return(clonedList);
        }
        private void ReadXmlComponentConfiguration(XmlReader reader)
        {
            string startElement = reader.Name;

            Debug.Assert(String.Equals(startElement, "componentConfigurations"));

            if (reader.IsEmptyElement)
            {
                return;
            }

            // Determine whether we are dealing with plugin or system configuration
            bool isPlugin = String.Equals(reader.GetAttribute("type"),
                                          "Plugin", StringComparison.OrdinalIgnoreCase);

            if (_componentConfigurations == null)
            {
                _componentConfigurations = new BuildComponentConfigurationList();
            }
            if (_pluginComponentConfigurations == null)
            {
                _pluginComponentConfigurations = new BuildComponentConfigurationList();
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, BuildComponentConfiguration.TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        BuildComponentConfiguration componentConfiguration = null;

                        string tempText = reader.GetAttribute("name");
                        if (!String.IsNullOrEmpty(tempText))
                        {
                            if (isPlugin)
                            {
                                componentConfiguration = _pluginComponentConfigurations[tempText];
                            }
                            else
                            {
                                componentConfiguration = _componentConfigurations[tempText];
                            }

                            // If the configuration is not found, lets create it...
                            if (componentConfiguration == null)
                            {
                                componentConfiguration = this.OnCreateComponentConfiguration(
                                    tempText, isPlugin);
                                if (componentConfiguration != null)
                                {
                                    if (isPlugin)
                                    {
                                        _pluginComponentConfigurations.Add(componentConfiguration);
                                    }
                                    else
                                    {
                                        _componentConfigurations.Add(componentConfiguration);
                                    }
                                }
                            }
                        }

                        if (componentConfiguration == null)
                        {
                            if (isPlugin)
                            {
                                throw new BuildException(String.Format(
                                                             "The plugin component configuration '{0}' cannot be found.", tempText));
                            }
                            else
                            {
                                throw new BuildException(String.Format(
                                                             "The system component configuration '{0}' cannot be found.", tempText));
                            }
                        }
                        componentConfiguration.ReadXml(reader);
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }