本文整理汇总了C#中FileReader.Length方法的典型用法代码示例。如果您正苦于以下问题:C# FileReader.Length方法的具体用法?C# FileReader.Length怎么用?C# FileReader.Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader.Length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tags
/// <summary>
/// Tagses the specified presious.
/// </summary>
/// <param name="files">The files.</param>
/// <returns></returns>
public List<string> Tags(List<string> files )
{
foreach (var file in files)
{
_fileReader = new FileReader(file);
_length = _fileReader.Length();
long currentPosition = 0;
var trigger = string.Empty;
var skip = false;
var inTrigger = false;
while (_length > currentPosition)
{
var s = _fileReader.ReadString(1);
currentPosition++;
if (s == "<")
{
trigger = string.Empty;
skip = false;
inTrigger = true;
}
trigger = trigger + s;
if (s == " ")
{
if (inTrigger)
{
if (!_tags.Contains(trigger))
{
_tags.Add(trigger);
}
trigger = string.Empty;
skip = true;
inTrigger = false;
}
}
if (s == ">")
{
if (!skip)
{
if (inTrigger)
{
if (!_tags.Contains(trigger))
{
_tags.Add(trigger);
}
trigger = string.Empty;
inTrigger = false;
}
}
}
}
}
return _tags;
}
示例2: Bounce
/// <summary>
/// Bounces the specified tags.
/// </summary>
/// <param name="tags">The tags.</param>
/// <param name="files">The files.</param>
public void Bounce(List<string> tags, List<string> files)
{
foreach (var file in files)
{
using ( var fileReader = new FileReader(file))
{
_length = fileReader.Length();
var output = string.Empty;
var trigger = string.Empty;
var bounce = false;
var close = false;
_currentPosition = 0;
while (_length > _currentPosition)
{
var s = fileReader.ReadString(1);
_currentPosition++;
if (s == ">")
close = true;
if (s == "<")
{
trigger = string.Empty;
bounce = false;
close = false;
}
if (!close)
{
trigger = trigger + s;
}
if (close)
{
if (s == ">")
{
trigger = trigger + s;
foreach (var tag in tags)
{
if (trigger.Contains(tag))
bounce = true;
}
if (!bounce)
{
output = output + trigger;
}
}
else
{
output = output + s;
}
}
}
fileReader.Close();
using (var fileWriter = new FileWriter())
{
fileWriter.WriteFile(output, file);
}
}
}
}