コード例 #1
0
        public override string[] GetEntryNames(string section)
        {
            if (!this.HasSection(section))
            {
                return((string[])null);
            }
            this.VerifyAndAdjustSection(ref section);
            int size = 500;

            byte[] numArray;
            int    num;

            while (true)
            {
                numArray = new byte[size];
                num      = 2 * Ini.GetPrivateProfileString(section, 0, "", numArray, size, this.Name);
                if (num >= size - 3)
                {
                    size *= 2;
                }
                else
                {
                    break;
                }
            }
            string str = Encoding.Unicode.GetString(numArray, 0, num - (num > 0 ? 2 : 0));

            return(str == "" ? new string[0] : str.Split(new char[1]));
        }
コード例 #2
0
        public override string[] GetSectionNames()
        {
            if (!File.Exists(this.Name))
            {
                return((string[])null);
            }
            int size = 500;

            byte[] numArray;
            int    num;

            while (true)
            {
                numArray = new byte[size];
                num      = 2 * Ini.GetPrivateProfileString(0, "", "", numArray, size, this.Name);
                if (num >= size - 3)
                {
                    size *= 2;
                }
                else
                {
                    break;
                }
            }
            string str = Encoding.Unicode.GetString(numArray, 0, num - (num > 0 ? 2 : 0));

            return(str == "" ? new string[0] : str.Split(new char[1]));
        }
コード例 #3
0
        public override object GetValue(string section, string entry)
        {
            if (section == null || entry == null)
            {
                return((object)null);
            }
            this.VerifyName();
            this.VerifyAndAdjustSection(ref section);
            this.VerifyAndAdjustEntry(ref entry);
            int           num1 = 250;
            StringBuilder result;
            int           num2;

            while (true)
            {
                result = new StringBuilder(num1);
                num2   = 2 * Ini.GetPrivateProfileString(section, entry, "", result, num1, this.Name);
                if (num2 >= num1 - 2)
                {
                    num1 *= 2;
                }
                else
                {
                    break;
                }
            }
            return(num2 == 0 && !this.HasEntry(section, entry) ? (object)null : (object)result.ToString());
        }