本文整理汇总了C#中IFile.getContents方法的典型用法代码示例。如果您正苦于以下问题:C# IFile.getContents方法的具体用法?C# IFile.getContents怎么用?C# IFile.getContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFile
的用法示例。
在下文中一共展示了IFile.getContents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: load
public bool load(IFile file) {
if (file.exists()) {
try {
var libraries = new ArrayList<ProjectLibrary>();
var preprocessorSymbols = new HashSet<String>();
var outputPath = "bin";
var document = XmlHelper.load(new InputStreamReader(file.getContents()));
var nodeList = document.getElementsByTagName("library");
int length = nodeList.getLength();
for (int i = 0; i < length; i++) {
var e = (Element)nodeList.item(i);
var lib = new ProjectLibrary(e.getAttribute("name"));
var enabled = e.getAttribute("enabled");
lib.setEnabled(enabled.length() == 0 || !enabled.equals("false"));
libraries.add(lib);
}
nodeList = document.getElementsByTagName("preprocessorSymbols");
if (nodeList.getLength() == 1) {
foreach (var s in nodeList.item(0).getTextContent().split(";")) {
preprocessorSymbols.add(s.trim());
}
}
nodeList = document.getElementsByTagName("outputPath");
if (nodeList.getLength() == 1) {
outputPath = nodeList.item(0).getTextContent();
}
this.Libraries = libraries;
this.PreprocessorSymbols = preprocessorSymbols;
this.OutputPath = outputPath;
return true;
} catch (Exception e) {
Environment.logException(e);
}
}
this.Libraries = Query.empty<ProjectLibrary>();
this.PreprocessorSymbols = Query.empty<String>();
return false;
}
示例2: getText
private char[] getText(IFile file) {
char[] text;
if (parameters.AllFiles.getProjectRelativeName(file).equals(parameters.EditedFileName)) {
text = parameters.EditedFileText;
} else {
using (var reader = new InputStreamReader(file.getContents(), file.getCharset())) {
var sb = new StringBuilder();
int read;
while ((read = reader.read(buffer)) != -1) {
sb.append(buffer, 0, read);
}
text = new char[sb.length()];
sb.getChars(0, sizeof(text), text, 0);
}
}
if (sizeof(text) > 0) {
if (text[sizeof(text) - 1] == '\u001a') {
text[sizeof(text) - 1] = ' ';
}
}
return text;
}