• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Builtins.RubyFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IronRuby.Builtins.RubyFile的典型用法代码示例。如果您正苦于以下问题:C# RubyFile类的具体用法?C# RubyFile怎么用?C# RubyFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RubyFile类属于IronRuby.Builtins命名空间,在下文中一共展示了RubyFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);

            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;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:33,代码来源:RubyOps.cs


示例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);

            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;
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:30,代码来源:RubyOps.cs


示例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);
        }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:13,代码来源:RubyOps.cs


示例4: Reinitialize

        public static RubyFile/*!*/ Reinitialize(
            ConversionStorage<int?>/*!*/ toInt,
            ConversionStorage<IDictionary<object, object>>/*!*/ toHash,
            ConversionStorage<MutableString>/*!*/ toPath,
            ConversionStorage<MutableString>/*!*/ toStr,
            RubyFile/*!*/ self,
            object descriptorOrPath, 
            [Optional]object optionsOrMode, 
            [Optional]object optionsOrPermissions,
            [DefaultParameterValue(null), DefaultProtocol]IDictionary<object, object> options) {

            var context = self.Context;
            
            Protocols.TryConvertToOptions(toHash, ref options, ref optionsOrMode, ref optionsOrPermissions);
            var toIntSite = toInt.GetSite(TryConvertToFixnumAction.Make(toInt.Context));

            IOInfo info = new IOInfo();
            if (optionsOrMode != Missing.Value) {
                int? m = toIntSite.Target(toIntSite, optionsOrMode);
                info = m.HasValue ? new IOInfo((IOMode)m) : IOInfo.Parse(context, Protocols.CastToString(toStr, optionsOrMode));
            }

            int permissions = 0;
            if (optionsOrPermissions != Missing.Value) {
                int? p = toIntSite.Target(toIntSite, optionsOrPermissions);
                if (!p.HasValue) {
                    throw RubyExceptions.CreateTypeConversionError(context.GetClassName(optionsOrPermissions), "Integer");
                }
                permissions = p.Value;
            }

            if (options != null) {
                info = info.AddOptions(toStr, options);
            }

            // TODO: permissions
            
            // descriptor or path:
            int? descriptor = toIntSite.Target(toIntSite, descriptorOrPath);
            if (descriptor.HasValue) {
                RubyIOOps.Reinitialize(self, descriptor.Value, info);
            } else {
                Reinitialize(self, Protocols.CastToPath(toPath, descriptorOrPath), info, permissions);
            }

            return self;
        }
开发者ID:rpattabi,项目名称:ironruby,代码行数:47,代码来源:FileOps.cs


示例5: Reinitialize

        public static RubyFile/*!*/ Reinitialize(RubyFile/*!*/ self,
            [DefaultProtocol, NotNull]Union<int, MutableString> descriptorOrPath, int mode, [Optional]int permission) {

            // TODO: remove duplicity (constructors vs initializers)

            if (descriptorOrPath.IsFixnum()) {
                RubyIOOps.Reinitialize(self, descriptorOrPath.Fixnum(), mode);
            } else {
                var path = self.Context.DecodePath(descriptorOrPath.Second);
                var stream = RubyFile.OpenFileStream(self.Context, path, (IOMode)mode);

                self.Path = path;
                self.Mode = (IOMode)mode;
                self.SetStream(stream);
                self.SetFileDescriptor(self.Context.AllocateFileDescriptor(stream));
            }
            // TODO: permission
            return self;
        }
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:19,代码来源:FileOps.cs


示例6: SysOpen

 public static int SysOpen(RubyClass/*!*/ self, [NotNull]MutableString path, [Optional]MutableString mode, [Optional]int perm) {
     if (FileTest.DirectoryExists(self.Context, path)) {
         // TODO: What file descriptor should be returned for a directory?
         return -1;
     }
     RubyIO io = new RubyFile(self.Context, path.ToString(), IOModeEnum.Parse(mode));
     int fileDesc = io.GetFileDescriptor();
     io.Close();
     return fileDesc;
 }
开发者ID:ghouston,项目名称:ironlanguages,代码行数:10,代码来源:IoOps.cs


示例7: 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);
            }
        }
开发者ID:rafacv,项目名称:iron_languages,代码行数:21,代码来源:IoOps.cs


示例8: Open

 public static object Open(BlockParam block, RubyClass/*!*/ self,
     [DefaultProtocol, NotNull]MutableString/*!*/ path,
     [DefaultParameterValue(0)]int level,
     [DefaultParameterValue(DEFAULT_STRATEGY)]int strategy)
 {
     var strPath = self.Context.DecodePath(path);
     var file = new RubyFile(self.Context, strPath, IOMode.WriteOnly | IOMode.Truncate | IOMode.CreateIfNotExists);
     var gzipWriter = Create(self, file, level, strategy);
     return gzipWriter.Do(block);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:10,代码来源:zlib.cs


示例9: Create

 // TODO: should work for IO and files w/o paths:
 internal static FileSystemInfo/*!*/ Create(RubyFile/*!*/ file) {
     file.RequireInitialized();
     if (file.Path == null) {
         throw new NotSupportedException("TODO: cannot get file info for files without path");
     }
     return Create(file.Context, file.Path);
 }
开发者ID:rpattabi,项目名称:ironruby,代码行数:8,代码来源:FileOps.cs


示例10: Inspect

 public static MutableString/*!*/ Inspect(RubyFile/*!*/ self) {
     return MutableString.CreateMutable(self.Context.GetPathEncoding()).
         Append("#<").
         Append(self.Context.GetClassOf(self).GetName(self.Context)).
         Append(':').
         Append(self.Path).
         Append(self.Closed ? " (closed)" : "").
         Append('>');
 }
开发者ID:rpattabi,项目名称:ironruby,代码行数:9,代码来源:FileOps.cs


示例11: ModifiedTime

 public static RubyTime ModifiedTime(RubyContext/*!*/ context, RubyFile/*!*/ self) {
     return RubyStatOps.ModifiedTime(RubyStatOps.Create(self));
 }
开发者ID:rpattabi,项目名称:ironruby,代码行数:3,代码来源:FileOps.cs


示例12: LoadFile

 public static object LoadFile(RubyScope/*!*/ scope, RubyModule/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ path) {
     using (RubyFile file = new RubyFile(self.Context, path.ConvertToString(), IOMode.Default)) {
         foreach (object obj in MakeConstructor(scope.GlobalScope, file.GetReadableStream())) {
             return obj;
         }
     }
     return null;
 }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:8,代码来源:RubyYaml.cs


示例13: GetPath

 public static MutableString GetPath(RubyFile/*!*/ self) {
     return self.Path != null ? self.Context.EncodePath(self.Path) : null;
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:3,代码来源:FileOps.cs


示例14: Inspect

 public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, RubyFile/*!*/ self) {
     return MutableString.CreateMutable(context.GetPathEncoding()).
         Append("#<File:").
         Append(self.Path).
         Append(self.Closed ? " (closed)" : "").
         Append('>');
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:7,代码来源:FileOps.cs


示例15: Stat

 public static FileSystemInfo Stat(RubyContext/*!*/ context, RubyFile/*!*/ self) {
     return RubyStatOps.Create(context, self.Path);
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:3,代码来源:FileOps.cs


示例16: CreateTime

 public static RubyTime CreateTime(RubyContext/*!*/ context, RubyFile/*!*/ self) {
     return RubyStatOps.CreateTime(RubyStatOps.Create(context, self.Path));
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:3,代码来源:FileOps.cs


示例17: AccessTime

 public static RubyTime AccessTime(RubyContext/*!*/ context, RubyFile/*!*/ self) {
     return RubyStatOps.AccessTime(RubyStatOps.Create(self));
 }
开发者ID:rpattabi,项目名称:ironruby,代码行数:3,代码来源:FileOps.cs


示例18: ParseFile

 public static object ParseFile(RubyModule/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ path) {
     using (Stream stream = new RubyFile(self.Context, path.ConvertToString(), IOMode.Default).GetReadableStream()) {
         foreach (Node obj in MakeComposer(self.Context, stream)) {
             return obj;
         }
     }
     return ScriptingRuntimeHelpers.False;
 }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:8,代码来源:RubyYaml.cs


示例19: Stat

 public static FileSystemInfo Stat(RubyFile/*!*/ self) {
     return RubyStatOps.Create(self);
 }
开发者ID:rpattabi,项目名称:ironruby,代码行数:3,代码来源:FileOps.cs


示例20: GetPath

 public static MutableString GetPath(RubyFile/*!*/ self) {
     self.RequireInitialized();
     return self.Path != null ? self.Context.EncodePath(self.Path) : null;
 }
开发者ID:rpattabi,项目名称:ironruby,代码行数:4,代码来源:FileOps.cs



注:本文中的IronRuby.Builtins.RubyFile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Builtins.RubyIO类代码示例发布时间:2022-05-26
下一篇:
C# Builtins.RubyEncoding类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap