Exemplo n.º 1
0
Arquivo: PCH.cs Projeto: djey47/tdumt
        /// <summary>
        /// Returns group according to provided name. If group does not exist, it is created and returned
        /// </summary>
        /// <param name="groupName"></param>
        /// <returns></returns>
        public InstallGroup GetGroupFromName(string groupName)
        {
            InstallGroup returnedGroup = new InstallGroup {
                exists = true
            };

            if (!string.IsNullOrEmpty(groupName))
            {
                bool isFound = false;

                foreach (InstallGroup anotherGroup in _Groups)
                {
                    if (groupName.Equals(anotherGroup.name))
                    {
                        returnedGroup = anotherGroup;
                        isFound       = true;
                        break;
                    }
                }

                if (!isFound)
                {
                    returnedGroup = new InstallGroup {
                        name = groupName, exists = true
                    };
                    _Groups.Add(returnedGroup);
                }
            }

            return(returnedGroup);
        }
Exemplo n.º 2
0
Arquivo: PCH.cs Projeto: djey47/tdumt
        /// <summary>
        /// Removes group with specified name
        /// </summary>
        /// <param name="groupToDelete"></param>
        public void RemoveGroup(string groupToDelete)
        {
            // Required group can't be removed
            if (!REQUIRED_GROUP_NAME.Equals(groupToDelete))
            {
                InstallGroup currentGroup = _GetGroup(groupToDelete, _Groups);

                if (currentGroup.exists)
                {
                    _Groups.Remove(currentGroup);

                    // Set instructions to required group
                    InstallGroup requiredGroup = _GetGroup(REQUIRED_GROUP_NAME, _Groups);

                    for (int i = 0; i < _PatchInstructions.Count; i++)
                    {
                        PatchInstruction currentInstruction = _PatchInstructions[i];

                        if (currentInstruction.Group.Equals(currentGroup))
                        {
                            currentInstruction.Group = requiredGroup;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
Arquivo: PCH.cs Projeto: djey47/tdumt
        /// <summary>
        /// Returns group in specified list
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="groups"></param>
        /// <returns></returns>
        private static InstallGroup _GetGroup(string groupName, IEnumerable <InstallGroup> groups)
        {
            InstallGroup returnedGroup = new InstallGroup();

            if (groups != null)
            {
                foreach (InstallGroup anotherGroup in groups)
                {
                    if (anotherGroup.name.Equals(groupName))
                    {
                        returnedGroup = anotherGroup;
                    }
                }
            }

            return(returnedGroup);
        }
Exemplo n.º 4
0
Arquivo: PCH.cs Projeto: djey47/tdumt
        /// <summary>
        /// Computes et return dependancy level of specified group in list
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="groups"></param>
        /// <returns>-1 if specified group does not exist</returns>
        public static int GetDependancyLevel(string groupName, List <InstallGroup> groups)
        {
            // Retrieving group in list
            int          returnedLevel = -1;
            InstallGroup startGroup    = _GetGroup(groupName, groups);

            if (startGroup.name != null)
            {
                returnedLevel++;

                while (startGroup.parentName != null)
                {
                    returnedLevel++;

                    startGroup = _GetGroup(startGroup.parentName, groups);
                }
            }

            return(returnedLevel);
        }
Exemplo n.º 5
0
Arquivo: PCH.cs Projeto: djey47/tdumt
        /// <summary>
        /// Updates specified group
        /// </summary>
        /// <param name="newGroup"></param>
        public void UpdateGroup(InstallGroup newGroup)
        {
            // Searches group with the same name...
            int  index   = 0;
            bool isFound = false;

            foreach (InstallGroup anotherGroup in _Groups)
            {
                if (newGroup.name != null &&
                    newGroup.name.Equals(anotherGroup.name))
                {
                    isFound = true;
                    break;
                }

                index++;
            }

            if (isFound)
            {
                _Groups[index] = newGroup;
            }
        }