示例#1
0
 private static void EndRead()
 {
     schemeStyle = null;
     readerStyle = null;
     tempComments.Clear();
     tempOptionalValues.Clear();
     tempSectionName = null;
     tempExceptions.Clear();
 }
示例#2
0
 private static void BeginRead()
 {
     if (schemeStyle == null)
     {
         schemeStyle = new IniSchemeStyle();
     }
     if (readerStyle == null)
     {
         readerStyle = new IniReaderStyle();
     }
     tempComments.Clear();
     tempOptionalValues.Clear();
     tempSectionName = null;
     tempExceptions.Clear();
 }
示例#3
0
        public static IniData ReadFromString(string iniString, IniSchemeStyle schemeStyle = null, IniReaderStyle readerStyle = null)
        {
            IniReader.schemeStyle = schemeStyle;
            IniReader.readerStyle = readerStyle;

            BeginRead();

            IniData iniData = new IniData();

            IniTextBuffer stringBuffer = new IniTextBuffer(iniString);

            while (stringBuffer.ReadLine())
            {
                try
                {
                    ProcessLine(stringBuffer, iniData);
                }
                catch (Exception e)
                {
                    tempExceptions.Add(e);

                    if (readerStyle.ThrowExceptionsOnError)
                    {
                        EndRead();

                        throw;
                    }
                }
            }

            if (tempExceptions.Count > 0)
            {
                iniData = null;
            }

            EndRead();

            return(iniData);
        }