public IncludeContentList(IncludeContentList source)
     : base(source)
 {
     _default    = source._default;
     _conceptual = source._conceptual;
     _references = source._references;
 }
        public void Remove(string contentName, int index)
        {
            IncludeContent content = this.GetContent(contentName);

            if (content != null)
            {
                content.Remove(index);
            }
        }
        public void Clear(string contentName)
        {
            IncludeContent content = this.GetContent(contentName);

            if (content != null && content.Count != 0)
            {
                content.Clear();
            }
        }
        public void Remove(string contentName, IncludeItem item)
        {
            IncludeContent content = this.GetContent(contentName);

            if (content != null)
            {
                content.Remove(item);
            }
        }
        public void Add(string contentName, IList <IncludeItem> items)
        {
            IncludeContent content = this.GetContent(contentName);

            if (content != null)
            {
                content.Add(items);
            }
        }
        public bool Contains(string contentName, IncludeItem item)
        {
            IncludeContent content = this.GetContent(contentName);

            if (content != null)
            {
                return(content.Contains(item));
            }

            return(false);
        }
        private void ReadXmlContents(XmlReader reader)
        {
            string startElement = reader.Name;

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

            if (reader.IsEmptyElement)
            {
                return;
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (!reader.IsEmptyElement && String.Equals(reader.Name, "content",
                                                                StringComparison.OrdinalIgnoreCase))
                    {
                        switch (reader.GetAttribute("type").ToLower())
                        {
                        case "shared":
                            if (_sharedContent == null)
                            {
                                _sharedContent = new SharedContent();
                            }
                            if (reader.ReadToDescendant(SharedContent.TagName))
                            {
                                _sharedContent.ReadXml(reader);
                            }
                            break;

                        case "include":
                            if (_includeContent == null)
                            {
                                _includeContent = new IncludeContent();
                            }
                            if (reader.ReadToDescendant(IncludeContent.TagName))
                            {
                                _includeContent.ReadXml(reader);
                            }
                            break;
                        }
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
        public IncludeItem this[string contentName, string itemName]
        {
            get
            {
                IncludeContent content = this.GetContent(contentName);
                if (content != null)
                {
                    return(content[itemName]);
                }

                return(null);
            }
        }
Exemple #9
0
        public virtual void Initialize(BuildContext context)
        {
            if (_isInitialized)
            {
                return;
            }

            BuildExceptions.NotNull(context, "context");

            _context  = context;
            _settings = context.Settings;
            _logger   = context.Logger;

            if (_logger.IsInitialized == false)
            {
                _logger.Initialize(_context.BaseDirectory, _settings.HelpTitle);
            }

            //string workingDir = _settings.WorkingDirectory;
            //if (String.IsNullOrEmpty(workingDir))
            //{
            //    workingDir = Environment.CurrentDirectory;
            //}
            //else
            //{
            //    workingDir = Environment.ExpandEnvironmentVariables(workingDir);
            //    workingDir = Path.GetFullPath(workingDir);
            //}
            //if (String.IsNullOrEmpty(workingDir))
            //{
            //    return _isInitialized;
            //}
            //if (!Directory.Exists(workingDir))
            //{
            //    Directory.CreateDirectory(workingDir);
            //}
            //_settings.WorkingDirectory = workingDir;

            BuildEngineSettings engineSettings =
                _settings.EngineSettings[this.EngineType];

            Debug.Assert(engineSettings != null);
            if (engineSettings == null)
            {
                return;
            }
            _includeContent = engineSettings.IncludeContent;

            _isInitialized = true;
        }
        // look up shared content
        protected override string GetContent(string key, string[] parameters)
        {
            if (String.IsNullOrEmpty(key) || _settings == null ||
                _engineSettings == null)
            {
                return(base.GetContent(key, parameters));
            }

            IncludeContent includeContent = _settings.IncludeContent;
            bool           isFound        = false;
            string         value          = String.Empty;
            IncludeItem    item           = includeContent[key];

            if (item != null)
            {
                isFound = true;
                value   = item.Value;
            }
            else
            {
                includeContent = _engineSettings.IncludeContent;
                item           = includeContent[key];
                if (item != null)
                {
                    isFound = true;
                    value   = item.Value;
                }
            }
            if (isFound)
            {
                if (parameters != null && parameters.Length != 0)
                {
                    try
                    {
                        value = String.Format(value, parameters);
                    }
                    catch
                    {
                        LogMessage(BuildLoggerLevel.Error, String.Format(
                                       "The shared content item '{0}' could not be formatted with {1} parameters.",
                                       key, parameters.Length));
                    }
                }

                return(value);
            }

            return(base.GetContent(key, parameters));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BuildEngineSettings"/> class
        /// with parameters copied from the specified instance of the
        /// <see cref="BuildEngineSettings"/> class, a copy constructor.
        /// </summary>
        /// <param name="source">
        /// An instance of the <see cref="BuildEngineSettings"/> class from which the
        /// initialization parameters or values will be copied.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the parameter <paramref name="source"/> is <see langword="null"/>.
        /// </exception>
        protected BuildEngineSettings(BuildEngineSettings source)
            : base(source)
        {
            _engineName = source._engineName;
            _engineType = source._engineType;
            _properties = source._properties;

            _sharedContent  = source._sharedContent;
            _includeContent = source._includeContent;

            _configurations                = source._configurations;
            _pluginConfigurations          = source._pluginConfigurations;
            _componentConfigurations       = source._componentConfigurations;
            _pluginComponentConfigurations = source._pluginComponentConfigurations;
        }
        /// <overloads>
        /// Initializes a new instance of the <see cref="BuildEngineSettings"/> class.
        /// </overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="BuildEngineSettings"/> class
        /// with the default parameters.
        /// </summary>
        /// <param name="name">
        /// The name uniquely identifying this engine settings.
        /// </param>
        /// <param name="engineType">
        /// The engine type implementing this settings.
        /// </param>
        protected BuildEngineSettings(string name, BuildEngineType engineType)
        {
            BuildExceptions.NotNullNotEmpty(name, "name");

            _engineName     = name;
            _engineType     = engineType;
            _properties     = new BuildProperties();
            _sharedContent  = new SharedContent(_engineType.ToString());
            _includeContent = new IncludeContent(_engineType.ToString());

            _configurations                = new BuildConfigurationList(_engineType);
            _pluginConfigurations          = new BuildConfigurationList(_engineType);
            _componentConfigurations       = new BuildComponentConfigurationList(_engineType);
            _pluginComponentConfigurations = new BuildComponentConfigurationList(_engineType);
        }
 public IncludeContentList()
 {
     _default    = new IncludeContent(IncludeDefault);
     _conceptual = new IncludeContent(IncludeConceptual);
     _references = new IncludeContent(IncludeReferences);
 }