string.RemoveComments()

Here are the examples of the csharp api string.RemoveComments() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 Source : StringExtension.cs
with Apache License 2.0
from sjn4048

static public InjectData[] ToInjectData(this string str)
        {
            string[] lines = str.Trim().RemoveComments().RemoveBlanks().Split(new[] { Resources.AddressSplitter, Resources.CodeSplitter });
            var ret = new List<InjectData>();

            for (int i = 0; i < lines.Length; i += 2)
            {
                if (lines[i].Any(x => !x.IsHexDigit()))
                    throw new InvalidHexException(lines[i].First(x => !x.IsHexDigit()));
                if (lines[i + 1].Any(x => !x.IsHexDigit()))
                    throw new InvalidHexException(lines[i].First(x => !x.IsHexDigit()));
                int address = Int32.Parse(lines[i], System.Globalization.NumberStyles.HexNumber);
                byte[] value = Enumerable.Range(0, lines[i + 1].Length)
                 .Where(x => x % 2 == 0)
                 .Select(x => Convert.ToByte(lines[i + 1].Substring(x, 2), 16))
                 .ToArray();
                ret.Add(new InjectData(value, address));
            }

            return ret.ToArray();
        }