本文整理汇总了C#中IronRuby.Builtins.RubyFile.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# RubyFile.Seek方法的具体用法?C# RubyFile.Seek怎么用?C# RubyFile.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Builtins.RubyFile
的用法示例。
在下文中一共展示了RubyFile.Seek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMainTopLevelScope
public static RubyTopLevelScope/*!*/ CreateMainTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
out object self, out RuntimeFlowControl/*!*/ rfc, string dataPath, int dataOffset) {
Assert.NotNull(locals, globalScope, language);
RubyContext context = (RubyContext)language;
RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false);
RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals);
scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
scope.SetDebugName("top-main");
var objectClass = context.ObjectClass;
objectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope));
if (dataOffset >= 0) {
RubyFile dataFile;
if (context.DomainManager.Platform.FileExists(dataPath)) {
dataFile = new RubyFile(context, dataPath, RubyFileMode.RDONLY);
dataFile.Seek(dataOffset, SeekOrigin.Begin);
} else {
dataFile = null;
}
objectClass.SetConstant("DATA", dataFile);
}
self = scope.SelfObject;
rfc = scope.RuntimeFlowControl;
return scope;
}
示例2: CreateMainTopLevelScope
public static RubyTopLevelScope/*!*/ CreateMainTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
out object self, out RuntimeFlowControl/*!*/ rfc, string dataPath, int dataOffset) {
Assert.NotNull(locals, globalScope, language);
GlobalScopeExtension rubyGlobalScope = (GlobalScopeExtension)language.EnsureScopeExtension(globalScope);
RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals);
scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
scope.SetDebugName(rubyGlobalScope.IsHosted ? "top-primary-hosted" : "top-primary");
// define TOPLEVEL_BINDING constant:
if (!rubyGlobalScope.IsHosted) {
var objectClass = rubyGlobalScope.Context.ObjectClass;
objectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope));
if (dataOffset >= 0) {
RubyFile dataFile;
if (File.Exists(dataPath)) {
dataFile = new RubyFile(rubyGlobalScope.Context, dataPath, RubyFileMode.RDONLY);
dataFile.Seek(dataOffset, SeekOrigin.Begin);
} else {
dataFile = null;
}
objectClass.SetConstant("DATA", dataFile);
}
}
self = scope.SelfObject;
rfc = scope.RuntimeFlowControl;
return scope;
}
示例3: SetDataConstant
public static void SetDataConstant(RubyScope/*!*/ scope, string/*!*/ dataPath, int dataOffset) {
Debug.Assert(dataOffset >= 0);
RubyFile dataFile;
RubyContext context = scope.RubyContext;
if (context.DomainManager.Platform.FileExists(dataPath)) {
dataFile = new RubyFile(context, dataPath, RubyFileMode.RDONLY);
dataFile.Seek(dataOffset, SeekOrigin.Begin);
} else {
dataFile = null;
}
context.ObjectClass.SetConstant("DATA", dataFile);
}
示例4: Read
public static MutableString/*!*/ Read(
ConversionStorage<IDictionary<object, object>>/*!*/ toHash,
ConversionStorage<int>/*!*/ fixnumCast,
ConversionStorage<MutableString>/*!*/ toPath,
RubyClass/*!*/ self,
object path,
[Optional]object optionsOrLength,
[Optional]object optionsOrOffset,
[DefaultParameterValue(null), DefaultProtocol]IDictionary<object, object> options) {
Protocols.TryConvertToOptions(toHash, ref options, ref optionsOrLength, ref optionsOrOffset);
var site = fixnumCast.GetSite(ConvertToFixnumAction.Make(fixnumCast.Context));
int length = (optionsOrLength != Missing.Value && optionsOrLength != null) ? site.Target(site, optionsOrLength) : 0;
int offset = (optionsOrOffset != Missing.Value && optionsOrOffset != null) ? site.Target(site, optionsOrOffset) : 0;
if (offset < 0) {
throw RubyExceptions.CreateEINVAL();
}
if (length < 0) {
throw RubyExceptions.CreateArgumentError("negative length {0} given", length);
}
// TODO: options
using (RubyIO io = new RubyFile(self.Context, self.Context.DecodePath(Protocols.CastToPath(toPath, path)), IOMode.ReadOnly)) {
if (offset > 0) {
io.Seek(offset, SeekOrigin.Begin);
}
if (optionsOrLength != Missing.Value && optionsOrLength != null) {
return Read(io, length, null);
} else {
return Read(io);
}
}
}
示例5: Read
public static MutableString/*!*/ Read(ConversionStorage<int>/*!*/ fixnumCast, RubyClass/*!*/ self,
[DefaultProtocol, NotNull]MutableString/*!*/ path, [DefaultParameterValue(null)]object lengthObj,
[DefaultParameterValue(0)]object offsetObj) {
var site = fixnumCast.GetSite(ConvertToFixnumAction.Make(fixnumCast.Context));
int length = (lengthObj != null) ? site.Target(site, lengthObj) : 0;
int offset = (offsetObj != null) ? site.Target(site, offsetObj) : 0;
if (offset < 0) {
throw RubyExceptions.CreateEINVAL();
}
if (length < 0) {
throw RubyExceptions.CreateArgumentError("negative length {0} given", length);
}
using (RubyIO io = new RubyFile(self.Context, path.ConvertToString(), IOMode.ReadOnly)) {
if (offset > 0) {
io.Seek(offset, SeekOrigin.Begin);
}
if (lengthObj == null) {
return Read(io);
} else {
return Read(io, length, null);
}
}
}
示例6: Binread
public static MutableString/*!*/ Binread(RubyClass/*!*/ self,
[DefaultProtocol, NotNull]MutableString/*!*/ path,
[DefaultProtocol, Optional]int? length,
[DefaultProtocol, Optional]int? offset)
{
if (offset.HasValue && offset.Value < 0) {
throw RubyExceptions.CreateEINVAL();
}
if (length.HasValue && length.Value < 0) {
throw RubyExceptions.CreateArgumentError("negative length {0} given", length);
}
using (RubyIO io = new RubyFile(self.Context, path.ToString(), IOMode.ReadOnly)) {
if (offset.HasValue && offset.Value > 0) {
io.Seek(offset.Value, SeekOrigin.Begin);
}
return (length.HasValue) ? Read(io, length.Value, null) : Read(io);
}
}