Пример #1
0
        public int IndexBoolFlag(string param)
        {
            //
            // Returnerer lengden på flagget som er funnet
            //
            var best_match  = new BoolOptions();
            int best_length = 0;

            // Sjekk mot longname først
            foreach (var item in bo)
            {
                if (param.StartsWith(item.longname) && item.longname != "")
                {
                    if (item.longname.Length > best_length)
                    {
                        best_length = item.longname.Length;
                        best_match  = item;
                    }

                    return(item.longname.Length);
                }
            }

            if (best_length != 0)
            {
                return(best_match.longname.Length);
            }

            // Ikke funnet som longname, sjekk mot shortname
            foreach (var item in bo)
            {
                if (param.StartsWith(item.shortname) && item.shortname != "")
                {
                    if (item.shortname.Length > best_length)
                    {
                        best_length = item.shortname.Length;
                        best_match  = item;
                    }
                }
            }
            if (best_length != 0)
            {
                return(best_match.shortname.Length);
            }

            return(0); //default
        }
Пример #2
0
        public void AddBoolOpt(string flags)
        {
            // Oppretter ny BoolOpions med lange og korte flaggnavn

            BoolOptions strb = new BoolOptions();

            string[] f = flags.Split(" ");
            if (f.Length == 1)
            {
                strb.shortname = f[0];
                strb.longname  = "";
            }

            if (f.Length == 2)
            {
                strb.shortname = f[0];
                strb.longname  = f[1];
            }

            strb.isActive = false;

            bo.Add(strb);
        }
Пример #3
0
 public ulong GetUlongOptionValue()
 {
     int[] array = new int[1];
     BoolOptions.CopyTo(array, 0);
     return((ulong)array[0]);
 }
Пример #4
0
 public bool GetOption(CUFBoolOptions opt)
 {
     return(BoolOptions.Get((int)opt));
 }
Пример #5
0
 public void SetOption(CUFBoolOptions opt, byte arg)
 {
     BoolOptions.Set((int)opt, arg != 0);
 }