Example #1
0
 public void Set(MyIniKey key, float value)
 {
     this.Set(key, value.ToString("R", CultureInfo.InvariantCulture));
 }
Example #2
0
 public void Set(MyIniKey key, bool value)
 {
     this.Set(key, value ? "true" : "false");
 }
Example #3
0
 public void Set(MyIniKey key, sbyte value)
 {
     this.Set(key, value.ToString(CultureInfo.InvariantCulture));
 }
Example #4
0
        private string GenerateContent()
        {
            Func <StringSegment, int> keySelector = null;
            string          str6;
            StringBuilder   tmpContentBuilder = this.TmpContentBuilder;
            List <MyIniKey> tmpKeyList        = this.TmpKeyList;
            List <string>   tmpStringList     = this.TmpStringList;

            try
            {
                StringSegment endCommentSegment;
                bool          flag = false;
                if (keySelector == null)
                {
                    keySelector = s => this.m_sections[s];
                }
                foreach (StringSegment segment2 in this.m_sections.Keys.OrderBy <StringSegment, int>(keySelector))
                {
                    if (flag)
                    {
                        tmpContentBuilder.Append('\n');
                    }
                    flag = true;
                    endCommentSegment = this.GetSectionCommentSegment(segment2);
                    if (!endCommentSegment.IsEmpty)
                    {
                        endCommentSegment.GetLines(tmpStringList);
                        foreach (string str in tmpStringList)
                        {
                            tmpContentBuilder.Append(";");
                            tmpContentBuilder.Append(str);
                            tmpContentBuilder.Append('\n');
                        }
                    }
                    tmpContentBuilder.Append("[");
                    tmpContentBuilder.Append(segment2);
                    tmpContentBuilder.Append("]\n");
                    this.GetKeys(segment2, tmpKeyList);
                    for (int i = 0; i < tmpKeyList.Count; i++)
                    {
                        MyIniKey      key         = tmpKeyList[i];
                        StringSegment nameSegment = key.NameSegment;
                        endCommentSegment = this.GetCommentSegment(key);
                        if (!endCommentSegment.IsEmpty)
                        {
                            endCommentSegment.GetLines(tmpStringList);
                            foreach (string str2 in tmpStringList)
                            {
                                tmpContentBuilder.Append(";");
                                tmpContentBuilder.Append(str2);
                                tmpContentBuilder.Append('\n');
                            }
                        }
                        tmpContentBuilder.Append(nameSegment.Text, nameSegment.Start, nameSegment.Length);
                        tmpContentBuilder.Append('=');
                        StringSegment segment4 = this.m_items[key];
                        if (NeedsMultilineFormat(ref segment4))
                        {
                            this.Realize(ref key, ref segment4);
                            segment4.GetLines(tmpStringList);
                            tmpContentBuilder.Append('\n');
                            foreach (string str3 in tmpStringList)
                            {
                                tmpContentBuilder.Append("|");
                                tmpContentBuilder.Append(str3);
                                tmpContentBuilder.Append('\n');
                            }
                        }
                        else
                        {
                            tmpContentBuilder.Append(segment4.Text, segment4.Start, segment4.Length);
                            tmpContentBuilder.Append('\n');
                        }
                    }
                }
                endCommentSegment = this.GetEndCommentSegment();
                if (!endCommentSegment.IsEmpty)
                {
                    tmpContentBuilder.Append('\n');
                    endCommentSegment.GetLines(tmpStringList);
                    foreach (string str4 in tmpStringList)
                    {
                        tmpContentBuilder.Append(";");
                        tmpContentBuilder.Append(str4);
                        tmpContentBuilder.Append('\n');
                    }
                }
                if (this.m_endContent.Length > 0)
                {
                    tmpContentBuilder.Append('\n');
                    tmpContentBuilder.Append("---\n");
                    tmpContentBuilder.Append(this.m_endContent);
                }
                string str5 = tmpContentBuilder.ToString();
                tmpContentBuilder.Clear();
                tmpKeyList.Clear();
                str6 = str5;
            }
            finally
            {
                tmpContentBuilder.Clear();
                tmpKeyList.Clear();
            }
            return(str6);
        }