本文整理汇总了C#中LineInfo类的典型用法代码示例。如果您正苦于以下问题:C# LineInfo类的具体用法?C# LineInfo怎么用?C# LineInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineInfo类属于命名空间,在下文中一共展示了LineInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected internal virtual void Initialize(Symbol symbol, LineInfo position) {
if (symbol == null) {
throw new ArgumentNullException("symbol");
}
this.symbol = symbol;
this.position = position;
}
示例2: Parse
/// <summary>
/// Parse node contents add return a fresh node.
/// </summary>
/// <param name="parent">Node that this is a subnode to. Can be null</param>
/// <param name="prototypes">A list with node types</param>
/// <param name="line">Line to parse</param>
/// <param name="offset">Where to start the parsing. Will be set to where the next node should start parsing</param>
/// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
/// <exception cref="CodeGeneratorException"></exception>
public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
{
if (offset > line.Data.Length - 1)
throw new CodeGeneratorException(line.LineNumber, line.Data, "Tried to parse after end of line");
if (line.Data[offset] != '_')
throw new CodeGeneratorException(line.LineNumber, line.Data, "Not a PartialNode");
// From the first " sign (offset + 2) find the next " sign
int pos = -1;
for (int i = offset + 2; i < line.Data.Length; ++i)
{
if (line.Data[i] == '\"')
{
pos = i;
break;
}
}
if (pos == -1)
throw new CodeGeneratorException(line.LineNumber, line.Data, "PartialNode does not contain an end paranthesis.");
// Cut out the data between the two above found " signs and then start processing the address
// The address is converted from the format /example/example/ to \\example\\example.haml
PartialNode node = (PartialNode)prototypes.CreateNode("_", parent);
node._target = line.Data.Substring(offset + 2, pos - offset - 2);
if (node._target[node._target.Length - 1] == '/')
node._target = node._target.Substring(0, node._target.Length - 1);
if (node._target[0] == '/')
node._target = node._target.Substring(1);
node._target = node._target.Replace("/", "\\\\");
node._target += ".haml";
offset = pos + 1;
return node;
}
示例3: Read
public string Read(int count, out LineInfo position) {
position = new LineInfo(bufferPosition+bufferOffset, line, column);
if (count == 0) {
return string.Empty;
}
if (!EnsureBuffer(count-1)) {
throw new ArgumentOutOfRangeException("count");
}
rollbackBufferOffset = bufferOffset;
rollbackBufferPosition = bufferPosition;
rollbackColumn = column;
rollbackLine = line;
rollbackPrevious = previous;
var result = new string(buffer, bufferOffset, count);
for (int i = 0; i < count; i++) {
char current = buffer[bufferOffset++];
switch (current) {
case '\r':
HandleNewline(current, '\n');
break;
case '\n':
HandleNewline(current, '\r');
break;
default:
column++;
previous = current;
break;
}
}
return result;
}
示例4: Parse
/// <summary>
/// Parse node contents add return a fresh node.
/// </summary>
/// <param name="prototypes">List containing all node types</param>
/// <param name="parent">Node that this is a subnode to. Can be null</param>
/// <param name="line">Line to parse</param>
/// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
/// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
/// <exception cref="Exceptions.CodeGeneratorException"></exception>
public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
{
offset = line.Data.Length;
return new DocTypeTag(
@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">".Replace("\"", "\"\""),
parent);
}
示例5: TextToken
private readonly string text; // Token text.
internal TextToken(Symbol symbol, LineInfo position, string text) {
if (symbol == null) {
throw new ArgumentNullException("symbol");
}
if (text == null) {
throw new ArgumentNullException("text");
}
this.symbol = symbol;
this.position = position;
this.text = this.symbol.Name.Equals(text, StringComparison.Ordinal) ? this.symbol.Name : text; // "intern" short strings which are equal to the terminal name
}
示例6: NewLine
private LineInfo NewLine ( int i ) {
if ( lIndex >= 999 ) {
lIndex = 0;
}
LineInfo newLine = new LineInfo ( i, lineHeight );
lines[lIndex] = ( newLine );
height += lineHeight;
lIndex++;
return newLine;
}
示例7: Parse
/// <summary>
/// Parse node contents add return a fresh node.
/// </summary>
/// <param name="prototypes">List containing all node types</param>
/// <param name="parent">Node that this is a subnode to. Can be null</param>
/// <param name="line">Line to parse</param>
/// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
/// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
/// <exception cref="Exceptions.CodeGeneratorException"></exception>
public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
{
// text on tag rows are identified by a single space.
if (parent != null && line.Data[offset] == ' ')
++offset;
TextNode node = new TextNode(parent, line.Data.Substring(offset));
if (parent == null)
node.LineInfo = line;
offset = line.Data.Length;
return node;
}
示例8: FunctionImportEntityTypeMapping
internal FunctionImportEntityTypeMapping(IEnumerable<EntityType> isOfTypeEntityTypes,
IEnumerable<EntityType> entityTypes, IEnumerable<FunctionImportEntityTypeMappingCondition> conditions,
Collection<FunctionImportReturnTypePropertyMapping> columnsRenameList,
LineInfo lineInfo)
: base(columnsRenameList, lineInfo)
{
this.IsOfTypeEntityTypes = new ReadOnlyCollection<EntityType>(
EntityUtil.CheckArgumentNull(isOfTypeEntityTypes, "isOfTypeEntityTypes").ToList());
this.EntityTypes = new ReadOnlyCollection<EntityType>(
EntityUtil.CheckArgumentNull(entityTypes, "entityTypes").ToList());
this.Conditions = new ReadOnlyCollection<FunctionImportEntityTypeMappingCondition>(
EntityUtil.CheckArgumentNull(conditions, "conditions").ToList());
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:13,代码来源:FunctionImportMapping.ReturnTypeRenameMapping.cs
示例9: GivenModeIsAlwaysQuotedWhenLineInfoIsNotQuotedThenAnExceptionIsThrown
public void GivenModeIsAlwaysQuotedWhenLineInfoIsNotQuotedThenAnExceptionIsThrown() {
var fi = new Mock<FieldInfo>();
fi.Setup(f => f.FieldType).Returns(typeof (string));
var fieldUnderTest = new DelimitedField(fi.Object, ";") {
QuoteChar = '%',
QuoteMode = QuoteMode.AlwaysQuoted
};
var invalidLineInfo = new LineInfo("Hello, World") {
mReader = new ForwardReader(new Mock<IRecordReader>().Object, 0),
};
Assert.Throws<BadUsageException>(() => fieldUnderTest.ExtractFieldString(invalidLineInfo));
}
示例10: AddMe
/// <summary>
/// Creates a DIV node and add's the specified node to it.
/// </summary>
/// <param name="prototypes">Contains all prototypes for each control char. used to instanciate new nodes.</param>
/// <param name="parent">parent node</param>
/// <param name="line">current line information</param>
/// <param name="me">node to add to the DIV node</param>
/// <returns>current node</returns>
public Node AddMe(NodeList prototypes, Node parent, LineInfo line, Node me)
{
if (parent == null)
{
TagNode tag = (TagNode)prototypes.CreateNode("%", null);
tag.Name = "div";
tag.LineInfo = line;
tag.AddModifier(me);
return tag;
}
return me;
}
示例11: IsMultiLine
/// <summary>
/// Determines if this node spans over multiple lines.
/// </summary>
/// <param name="line">contains line information (and text)</param>
/// <param name="isContinued">true if the previous line was continued.</param>
/// <returns>true if this line continues onto the next.</returns>
public override bool IsMultiLine(LineInfo line, bool isContinued)
{
string trimmed = line.Data.TrimEnd();
if (trimmed.Length == 0)
return false;
if (trimmed.EndsWith("|"))
{
line.TrimRight(1);
return true;
}
return false;
}
示例12: IsMultiLine
/// <summary>
/// Determines if this node spans over multiple lines.
/// </summary>
/// <param name="line">contains line information (and text)</param>
/// <param name="isContinued">true if the previous line was continued.</param>
/// <returns>true if this line continues onto the next.</returns>
public override bool IsMultiLine(LineInfo line, bool isContinued)
{
// hack to dont include code
// a more proper way would have bene to scan after each tag
if (!isContinued)
{
char ch = line.Data[0];
if (ch != '#' && ch != '%' && ch != '.')
return false;
}
bool inQuote = false;
bool inAttribute = false;
if (isContinued && line.Data.IndexOf('{') == -1)
inAttribute = true;
foreach (char ch in line.Data)
{
if (ch == '"')
inQuote = !inQuote;
else if (ch == '{' && !inQuote)
{
if (inAttribute)
throw new CodeGeneratorException(line.LineNumber, line.Data,
"Found another start of attributes, but no close tag. Have you forgot one '}'?");
inAttribute = true;
}
else if (ch == '}' && !inQuote)
inAttribute = false;
}
if (inQuote)
throw new CodeGeneratorException(line.LineNumber, line.Data, "Attribute quotes can not span over multiple lines.");
if (inAttribute)
{
//todo: Attach a log writer.
//Console.WriteLine("Attribute is not closed, setting unfinished rule");
line.UnfinishedRule = this;
line.Data.TrimEnd();
if (line.Data.EndsWith("|"))
line.TrimRight(1);
return true;
}
return inAttribute;
}
示例13: Parse
/// <summary>
/// Parse node contents add return a fresh node.
/// </summary>
/// <param name="prototypes">List containing all node types</param>
/// <param name="parent">Node that this is a subnode to. Can be null</param>
/// <param name="line">Line to parse</param>
/// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
/// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
/// <exception cref="CodeGeneratorException"></exception>
public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
{
if (offset > line.Data.Length)
throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data");
int pos = line.Data.Length;
++offset;
string code = line.Data.Substring(offset, pos - offset);
offset = pos;
SilentCodeNode node = (SilentCodeNode)prototypes.CreateNode("-", parent);
node._code = code;
if (parent != null)
node.LineInfo = line;
return node;
}
示例14: parse
/// <summary>
/// The general idea is to create a regex based of the "Format: "-line in .ass file. Which
/// then can be used to easily filter the required information (namely timestamps, text and
/// actor).
/// </summary>
/// <param name="settings">Settings.</param>
/// <param name="rawLines">Raw lines.</param>
public List<LineInfo> parse(Settings settings, LinkedList<String> rawLines) {
List<LineInfo> lines = new List<LineInfo> ();
string formatRegex = GetFormatRegex (rawLines);
if (formatRegex == null)
return null;
// parse every line with format regex and save lines in LineInfo
foreach(string rawLine in rawLines) {
Match lineMatch = Regex.Match(rawLine, formatRegex, RegexOptions.IgnoreCase | RegexOptions.Compiled);
if (!lineMatch.Success)
continue;
string startTimeString = lineMatch.Groups ["StartTime"].ToString ().Trim ();
string endTimeString = lineMatch.Groups ["EndTime"].ToString ().Trim ();
string nameString = lineMatch.Groups ["Name"].ToString ().Trim ();
string textString = lineMatch.Groups ["Text"].ToString ().Trim ();
if (settings.IgnoreStyledSubLines &&
textString.StartsWith ("{") // NOTE: this is a really big hint for styled subtitles but might create false-negatives -- research common patterns in subtitle files
&& !textString.StartsWith ("{\\b1}") // bold
&& !textString.StartsWith ("{\\u1}") // underline
&& !textString.StartsWith ("{\\i1}") // italics
&& !textString.StartsWith ("{\\an8}") // text align: up
) {
continue;
}
// remove styling in subtitles
textString = Regex.Replace(textString, "{.*?}", "");
if (textString == "")
continue; // ignore lines without text
// generate line info
LineInfo li = new LineInfo(parseTime(startTimeString), parseTime(endTimeString), textString, new List<String>(new String[]{ nameString }));
lines.Add(li);
}
return lines;
}
示例15: Parse
/// <summary>
/// Parse node contents add return a fresh node.
/// </summary>
/// <param name="prototypes">List containing all node types</param>
/// <param name="parent">Node that this is a subnode to. Can be null</param>
/// <param name="line">Line to parse</param>
/// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
/// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
/// <exception cref="CodeGeneratorException"></exception>
public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
{
if (offset > line.Data.Length - 1)
throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data");
int pos = GetEndPos(offset, line.Data);
if (pos == -1)
pos = line.Data.Length;
++offset;
string name = line.Data.Substring(offset, pos - offset);
offset = pos;
ClassNode node = (ClassNode)prototypes.CreateNode(".", parent);
node._name = name;
return AddMe(prototypes, parent, line, node);
}