Ejemplo n.º 1
0
        /// <summary>
        /// Returns file normalized text if applicable, original text otherwise
        /// </summary>
        /// <returns></returns>
        internal string Normalize()
        {
            var t = this is EditorFile ? (this as EditorFile).Text : (this as ProjectFile).Text;

            if (Type == Types.SceneryMain || Type == Types.SceneryPart)
            {
                t = new ScnSyntax.HWhiteSpace().Replace(t, " ");
                t = new ScnSyntax.VWhiteSpace().Replace(t, "\r\n");
                t = new ScnSyntax.LineEnd().Replace(t, "");
                t = new ScnSyntax.XVWhiteSpace().Replace(t, "\r\n\r\n");
                t = new ScnSyntax.ExplicitTexExt().Replace(t, "");
                var      lines = new ScnSyntax.VWhiteSpace().Split(t);
                var      count = lines.Length / 2;
                string[] even  = new string[count], odd = new string[count];
                for (int i = 0; i < count; i++)
                {
                    even[i] = lines[2 * i]; odd[i] = lines[2 * i + 1];
                }
                var interleaved = false;
                interleaved |= even.All(i => String.IsNullOrWhiteSpace(i));
                interleaved |= odd.All(i => String.IsNullOrWhiteSpace(i));
                if (interleaved)
                {
                    t = new ScnSyntax.LineInterleave().Replace(t, "\r\n");
                }
                return(t.Trim());
            }
            else
            {
                return(t);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns file normalized text if applicable, original text otherwise
 /// </summary>
 /// <returns></returns>
 internal string Normalize()
 {
     var t = this is EditorFile ? (this as EditorFile).Text : (this as ProjectFile).Text;
     if (Type == Types.SceneryMain || Type == Types.SceneryPart) {
         t = new ScnSyntax.HWhiteSpace().Replace(t, " ");
         t = new ScnSyntax.VWhiteSpace().Replace(t, "\r\n");
         t = new ScnSyntax.LineEnd().Replace(t, "");
         t = new ScnSyntax.XVWhiteSpace().Replace(t, "\r\n\r\n");
         t = new ScnSyntax.ExplicitTexExt().Replace(t, "");
         var lines = new ScnSyntax.VWhiteSpace().Split(t);
         var count = lines.Length / 2;
         string[] even = new string[count], odd = new string[count];
         for (int i = 0; i < count; i++) { even[i] = lines[2 * i]; odd[i] = lines[2 * i + 1]; }
         var interleaved = false;
         interleaved |= even.All(i => String.IsNullOrWhiteSpace(i));
         interleaved |= odd.All(i => String.IsNullOrWhiteSpace(i));
         if (interleaved) t = new ScnSyntax.LineInterleave().Replace(t, "\r\n");
         return t.Trim();
     } else return t;
 }