Esempio n. 1
0
File: PCH.cs Progetto: 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);
        }
Esempio n. 2
0
File: PCH.cs Progetto: 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;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
File: PCH.cs Progetto: 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);
        }
Esempio n. 4
0
File: PCH.cs Progetto: 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);
        }
Esempio n. 5
0
File: PCH.cs Progetto: 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;
            }
        }