本文整理汇总了C#中FileManager.GetFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileManager.GetFile方法的具体用法?C# FileManager.GetFile怎么用?C# FileManager.GetFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager.GetFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadOptions
private void ReadOptions(string fileName,FileManager manager) {
string res;
using (var stream = manager.GetFile(Registry, fileName)) {
Tools.LoadFileToString(stream, out res);
}
var lines = res.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var item in lines) {
var r = item.Trim();
if (r == "AllowRussianJo") {
_allowRussianJo = true;
}
}
}
示例2: Load
public bool Load(string grammarFileName,FileManager manager) {
Clear();
using (var file = manager.GetFile(Lemmatizer.Registry, grammarFileName)) {
string line = null;
var reader = new BinaryReader(file, Tools.InternalEncoding);
line = Tools.ReadLine(reader);
if (line == null) {
return false;
}
int nodeCount;
int.TryParse(line, out nodeCount);
if (nodeCount <= 0) {
return false;
}
if (_nodes != null) {
throw new MorphException("_nodes != null");
}
var len = nodeCount * sizeof(int);
var buffer = reader.ReadBytes(len);
if (buffer.Length != len) {
return false;
}
var bufferInt = new int[nodeCount];
Buffer.BlockCopy(buffer, 0, bufferInt, 0, buffer.Length);
_nodes = new MorphAutomNode[nodeCount];
for (var i = 0; i < nodeCount; i++) {
_nodes[i] = new MorphAutomNode { Data = bufferInt[i] }; ;
}
line = Tools.ReadLine(reader);
if (line == null) {
return false;
}
int.TryParse(line, out nodeCount);
len = nodeCount * sizeof(int);
buffer = reader.ReadBytes(len);
if (buffer.Length != len) {
return false;
}
bufferInt = new int[nodeCount];
Buffer.BlockCopy(buffer, 0, bufferInt, 0, buffer.Length);
_relations = new MorphAutomRelation[nodeCount];
for (int i = 0; i < nodeCount; i++) {
_relations[i] = new MorphAutomRelation { Data = bufferInt[i] };
}
len = Constants.AlphabetSize * sizeof(int);
buffer = reader.ReadBytes(len);
if (buffer.Length != len) {
return false;
}
var buf = new int[Constants.AlphabetSize];
Buffer.BlockCopy(buffer, 0, buf, 0, buffer.Length);
if (!Tools.ListEquals(buf, _alphabet2Code)) {
throw new MorphException(Tools.GetStringByLanguage(Language) + "alphabet has changed; cannot load morph automat");
}
}
BuildChildrenCache();
return true;
}