Пример #1
0
        private static StructBaseParam ReadParameter(string strLine, int LineNumber)
        {
            StructBaseParam BaseParam = new StructBaseParam();

            BaseParam.Line = LineNumber;

            int EqualPos = strLine.IndexOf('=');

            if (EqualPos != -1)
            {
                BaseParam.Name  = strLine.Substring(0, EqualPos);
                BaseParam.Value = strLine.Substring(EqualPos + 1);
            }

            return(BaseParam);
        }
Пример #2
0
        public static bool Read_v8i()
        {
            bool Result = false;

            v8i_info = new Dictionary <string, iBasesEdit.StructBaseInfo>();

            v8i_file = GetFileV8I();

            if (!String.IsNullOrEmpty(v8i_file))
            {
                try
                {
                    FileStream   fsFile = new FileStream(v8i_file, FileMode.Open);
                    StreamReader rdFile = new StreamReader(fsFile);

                    string         strLine;
                    string         ConnectionString = null;
                    StructBaseInfo BaseInfo         = new StructBaseInfo();

                    int LineNumber = 1;

                    strLine = rdFile.ReadLine();
                    while (strLine != null)
                    {
                        strLine = strLine.Trim();

                        if (!strLine.StartsWith("//"))
                        {
                            if (strLine.StartsWith("[") && strLine.EndsWith("]"))
                            {
                                if (!String.IsNullOrEmpty(ConnectionString))
                                {
                                    BaseInfo.EndLine = LineNumber - 1;

                                    if (!v8i_info.ContainsKey(ConnectionString))
                                    {
                                        v8i_info.Add(ConnectionString, BaseInfo);
                                    }

                                    ConnectionString = "";
                                }

                                BaseInfo            = new StructBaseInfo();
                                BaseInfo.StartLine  = LineNumber;
                                BaseInfo.Name       = strLine.Substring(1, strLine.Length - 2);
                                BaseInfo.Parameters = new Dictionary <string, StructBaseParam>();
                            }
                            else
                            {
                                if (strLine.ToLower().StartsWith("connect="))
                                {
                                    ConnectionString = GetUniConnectionString(strLine);
                                }

                                StructBaseParam BaseParam = ReadParameter(strLine, LineNumber);
                                string          ParamName = BaseParam.Name.ToLower();

                                if (!BaseInfo.Parameters.ContainsKey(ParamName))
                                {
                                    BaseInfo.Parameters.Add(ParamName, BaseParam);
                                }
                            }
                        }

                        strLine = rdFile.ReadLine();
                        LineNumber++;
                    }


                    if (LineNumber > 1)
                    {
                        BaseInfo.EndLine = LineNumber - 1;
                        if (!v8i_info.ContainsKey(ConnectionString))
                        {
                            v8i_info.Add(ConnectionString, BaseInfo);
                        }
                    }

                    rdFile.Close();
                    rdFile.Dispose();

                    fsFile.Close();
                    fsFile.Dispose();

                    Result = true;
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Error: {0}", e.ToString());
                }
            }

            return(Result);
        }