private int GetSkillId(CusIdType idType, CusSkillType skillType, string shortName)
        {
            CUS_File cusFile = (CUS_File)install.GetParsedFile <CUS_File>(CUS_PATH);

            List <Skill> skills = null;

            switch (skillType)
            {
            case CusSkillType.Super:
                skills = cusFile.SuperSkills;
                break;

            case CusSkillType.Ultimate:
                skills = cusFile.UltimateSkills;
                break;

            case CusSkillType.Evasive:
                skills = cusFile.EvasiveSkills;
                break;

            case CusSkillType.Blast:
                skills = cusFile.BlastSkills;
                break;

            case CusSkillType.Awoken:
                skills = cusFile.AwokenSkills;
                break;
            }

            foreach (var skill in skills)
            {
                if (skill.Str_00.ToLower() == shortName)
                {
                    switch (idType)
                    {
                    case CusIdType.ID1:
                        return(int.Parse(skill.Index));

                    case CusIdType.ID2:
                        return(int.Parse(skill.I_10));
                    }
                }
            }

            return(NullTokenInt); //Skill wasn't found
        }
        private string ParseBinding <T>(string binding, string comment, string filePath, IEnumerable <T> entries1, IEnumerable <T> entries2, bool allowAutoId = true, ushort maxId = ushort.MaxValue, List <string> usedIds = null) where T : IInstallable
        {
            if (IsBinding(binding))
            {
                string originalBinding = binding;
                string Path            = String.Empty;
                int    ID           = -1;
                int    defaultValue = 0;

                List <BindingValue> bindings = ProcessBinding(binding, comment, originalBinding);
                bindings = ValidateBindings(bindings, comment, originalBinding);

                ErrorHandling errorHandler = ErrorHandling.Stop;
                string        formating    = "0";
                int           increment    = 0;

                foreach (var b in bindings)
                {
                    switch (b.Function)
                    {
                    case Function.Format:
                        formating = b.GetArgument1();
                        break;

                    case Function.SetAlias:
                        Aliases.Add(new AliasValue()
                        {
                            ID = ID + increment, Alias = b.GetArgument1()
                        });
                        break;

                    case Function.AliasLink:
                        ID = GetAliasId(b.GetArgument1(), comment);
                        break;

                    case Function.SkillID1:
                    {
                        CusSkillType skillType = GetSkillType(b.GetArgument2());
                        ID = GetSkillId(CusIdType.ID1, skillType, b.GetArgument1());
                        break;
                    }

                    case Function.SkillID2:
                    {
                        CusSkillType skillType = GetSkillType(b.GetArgument2());
                        ID = GetSkillId(CusIdType.ID2, skillType, b.GetArgument1());
                        break;
                    }

                    case Function.CharaID:
                        ID = GetCharaId(b.GetArgument1());
                        break;

                    case Function.AutoID:
                        if (!allowAutoId)
                        {
                            throw new Exception(String.Format("The AutoID binding function is not available for this value. ({0})", comment));
                        }

                        int minIndex = (!String.IsNullOrWhiteSpace(b.GetArgument1())) ? int.Parse(b.GetArgument1()) : 0;
                        int maxIndex = (!String.IsNullOrWhiteSpace(b.GetArgument2())) ? int.Parse(b.GetArgument2()) : maxId;
                        if (maxIndex > maxId)
                        {
                            maxIndex = maxId;                       //If maxIndex (declared in binding) is greater than maxId (declared on Property), then set maxIndex to maxId (which is the highest possible value)
                        }
                        int nextID = GetUnusedIndex(entries1, entries2, minIndex, maxIndex, usedIds);

                        if (nextID == NullTokenInt && errorHandler == ErrorHandling.Stop)
                        {
                            GeneralInfo.SpecialFailState = GeneralInfo.SpecialFailStates.AutoIdBindingFailed;
                            throw new Exception(String.Format("An ID could not be allocated in {2}. Install failed. \n\nBinding: {1}\nProperty: {0}", comment, binding, filePath));
                        }

                        ID = nextID;
                        break;

                    case Function.Error:
                        errorHandler = b.GetErrorHandlingType();
                        break;

                    case Function.DefaultValue:
                        defaultValue = int.Parse(b.GetArgument1());
                        break;

                    case Function.X2MSkillID1:
                    {
                        CusSkillType skillType = GetSkillType(b.GetArgument2());
                        int          id1       = _X2MHelper.GetX2MSkillID1(b.GetArgument1(), skillType);

                        if (id1 == NullTokenInt && errorHandler == ErrorHandling.Stop)
                        {
                            GeneralInfo.SpecialFailState = GeneralInfo.SpecialFailStates.X2MNotFound;
                            throw new Exception(String.Format("Required X2M skill not found. Install failed. \nBinding: {1}\n({0})", comment, binding, filePath));
                        }

                        ID = id1;
                        break;
                    }

                    case Function.X2MSkillID2:
                    {
                        CusSkillType skillType = GetSkillType(b.GetArgument2());
                        int          id2       = _X2MHelper.GetX2MSkillID2(b.GetArgument1(), skillType);

                        if (id2 == NullTokenInt && errorHandler == ErrorHandling.Stop)
                        {
                            GeneralInfo.SpecialFailState = GeneralInfo.SpecialFailStates.X2MNotFound;
                            throw new Exception(String.Format("Required X2M skill not found. Install failed. \nBinding: {1}\n({0})", comment, binding, filePath));
                        }

                        ID = id2;
                        break;
                    }

                    case Function.AutoPartSet:
                    {
                        if (!allowAutoId)
                        {
                            throw new Exception(String.Format("The AutoPartSet binding function is not available for this value. ({0})", comment));
                        }
                        int min    = (b.HasArgument(1)) ? int.Parse(b.GetArgument1()) : 0;
                        int max    = (b.HasArgument(2)) ? int.Parse(b.GetArgument2()) : 999;
                        int nextId = GetFreePartSet(min, max);

                        if (nextId == NullTokenInt && errorHandler == ErrorHandling.Stop)
                        {
                            GeneralInfo.SpecialFailState = GeneralInfo.SpecialFailStates.AutoIdBindingFailed;
                            throw new Exception(String.Format("A PartSet ID could not be allocated in {2}. Install failed. \n\nBinding: {1}\nProperty: {0}", comment, binding, filePath));
                        }

                        ID = nextId;
                    }
                    break;

                    case Function.Increment:
                        if (!b.HasArgument())
                        {
                            throw new Exception($"No argument found on Increment binding!");
                        }

                        if (!int.TryParse(b.GetArgument1(), out increment))
                        {
                            throw new Exception($"Error while parsing the argument on Increment binding. (Binding: {binding})");
                        }

                        break;

                    case Function.X2MSkillPath:

                    {
                        CusSkillType skillType    = GetSkillType(b.GetArgument2());
                        string       x2mSkillPath = _X2MHelper.GetX2MSkillPath(b.GetArgument1(), skillType);

                        if (x2mSkillPath == NullTokenStr && errorHandler == ErrorHandling.Stop)
                        {
                            GeneralInfo.SpecialFailState = GeneralInfo.SpecialFailStates.X2MNotFound;
                            throw new Exception(String.Format("Required X2M skill not found. Install failed. \nBinding: {1}\n({0})", comment, binding, filePath));
                        }

                        Path = x2mSkillPath;
                        break;
                    }
                    }
                }

                //Generic error handling code
                if (ID == NullTokenInt && errorHandler == ErrorHandling.Stop)
                {
                    GeneralInfo.SpecialFailState = GeneralInfo.SpecialFailStates.IdBindingFailed;
                    throw new Exception(String.Format("An ID could not be assigned according to the binding. Install failed. \nBinding: {1}\n({0})", comment, binding));
                }
                else if (ID == NullTokenInt && errorHandler == ErrorHandling.UseDefaultValue)
                {
                    ID = defaultValue;
                }
                // Path wasn't used
                if (Path == String.Empty)
                {
                    return(ApplyFormatting(ID + increment, formating));
                }
                else  //a special case for returning a Path to use in installPath
                {
                    return(Path);
                }
            }
            else
            {
                //Not a binding.
                return(binding);
            }
        }