当前位置: 首页>>代码示例>>C#>>正文


C# MutableString.ConvertToString方法代码示例

本文整理汇总了C#中MutableString.ConvertToString方法的典型用法代码示例。如果您正苦于以下问题:C# MutableString.ConvertToString方法的具体用法?C# MutableString.ConvertToString怎么用?C# MutableString.ConvertToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MutableString的用法示例。


在下文中一共展示了MutableString.ConvertToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFile

        public static RubyFile/*!*/ CreateFile(RubyClass/*!*/ self, MutableString/*!*/ path, MutableString mode) {
            if (path.IsEmpty) {
                throw new Errno.InvalidError();
            }

            return new RubyFile(self.Context, path.ConvertToString(), (mode != null) ? mode.ConvertToString() : "r");
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:7,代码来源:FileOps.cs

示例2: Scalar

 internal Node Scalar(MutableString taguri, MutableString value, SymbolId style) {
     return Scalar(
         taguri != null ? taguri.ConvertToString() : "",
         value != null ? value.ConvertToString() : "",
         //It's not clear what style argument really means, it seems to be always :plain
         //for now we are ignoring it, defaulting to \0 (see Representer class)
         '\0'
     );
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:9,代码来源:RubyRepresenter.cs

示例3: ParserEngineState

        public ParserEngineState(Parser parser, RubyScope scope, MutableString source)
        {
            Parser = parser;
            Scope = scope;
            OriginalSource = source;
            Source = source.ConvertToString();

            CreateID = Helpers.GetCreateId(scope);
            AllowNaN = DEFAULT_ALLOW_NAN;
            MaxNesting = DEFAULT_MAX_NESTING;
            CurrentNesting = 0;
            Memo = 0;
        }
开发者ID:nrk,项目名称:ironruby-json,代码行数:13,代码来源:ParserEngineState.cs

示例4: ChangeDirectory

        public static object ChangeDirectory(BlockParam block, object/*!*/ self, MutableString dir) {
            string strDir = dir.ConvertToString();

            if (block == null) {
                SetCurrentDirectory(strDir);
                return 0;
            } else {
                string current = Directory.GetCurrentDirectory();
                try {
                    SetCurrentDirectory(strDir);
                    object result;
                    block.Yield(dir, out result);
                    return result;
                } finally {
                    SetCurrentDirectory(current);
                }
            }
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:18,代码来源:Dir.cs

示例5: Format

 public static MutableString/*!*/ Format(RubyContext/*!*/ context, MutableString/*!*/ self, object arg) {
     IList args = arg as IList;
     if (args == null) {
         args = new object[] { arg };
     }
     StringFormatter formatter = new StringFormatter(context, self.ConvertToString(), args);
     return formatter.Format().TaintBy(self);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:8,代码来源:MutableStringOps.cs

示例6: ToClrString

 public static string/*!*/ ToClrString(MutableString/*!*/ str) {
     return str.ConvertToString();
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:MutableStringOps.cs

示例7: StripWhitespace

 private static string/*!*/ StripWhitespace(MutableString/*!*/ str) {
     int i = 0;
     while (i < str.Length) {
         char c = str.GetChar(i);
         if (c == ' ' || c == '_' || c == '\t' || c == '\n' || c == '\r') {
             i += 1;
         } else {
             return str.GetSlice(i).ConvertToString().Replace("_", "");
         }
     }
     return str.ConvertToString().Replace("_", "");
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:12,代码来源:MutableStringOps.cs

示例8: LoadFile

        /// <summary>
        /// Returns <b>true</b> if a Ruby file is successfully loaded, <b>false</b> if it is already loaded.
        /// </summary>
        public bool LoadFile(Scope/*!*/ globalScope, object self, MutableString/*!*/ path, LoadFlags flags) {
            Assert.NotNull(globalScope, path);

            string assemblyName, typeName;

            string strPath = path.ConvertToString();
            if (TryParseAssemblyName(strPath, out typeName, out assemblyName)) {

                if (AlreadyLoaded(path, flags)) {
                    return false;
                }

                if (LoadAssembly(assemblyName, typeName, false)) {
                    FileLoaded(path, flags);
                    return true;
                }
            }

            return LoadFromPath(globalScope, self, strPath, flags);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:23,代码来源:Loader.cs

示例9: ToYamlNode

        public static Node ToYamlNode(MutableString/*!*/ self, [NotNull]RubyRepresenter/*!*/ rep) {
            if (RubyOps.IsTrue(_IsBinaryData.Target(_IsBinaryData, rep.Context, self))) {
                return rep.BaseCreateNode(self.ConvertToBytes());
            }

            string str = self.ConvertToString();
            RubyArray props = RubyRepresenter.ToYamlProperties(rep.Context, self);
            if (props.Count == 0) {
                MutableString taguri = RubyRepresenter.TagUri(rep.Context, self);

                char style = (char)0;
                if (str.StartsWith(":")) {
                    style = '"';
                } else {
                    MutableString styleStr = RubyRepresenter.ToYamlStyle(rep.Context, self) as MutableString;
                    if (styleStr != null && styleStr.Length > 0) {
                        style = styleStr.GetChar(0);
                    }
                }

                return rep.Scalar(taguri != null ? taguri.ConvertToString() : "", str, style);
            }

            Hash map = new Hash(rep.Context);
            map.Add(MutableString.Create("str"), str);
            RubyRepresenter.AddYamlProperties(rep.Context, self, map, props);
            return rep.Map(self, map);
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:28,代码来源:BuiltinsOps.cs

示例10: Format

 public static MutableString/*!*/ Format(StringFormatterSiteStorage/*!*/ storage, MutableString/*!*/ self, object arg) {
     IList args = arg as IList ?? new object[] { arg };
     StringFormatter formatter = new StringFormatter(storage, self.ConvertToString(), self.Encoding, args);
     return formatter.Format().TaintBy(self);
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:5,代码来源:MutableStringOps.cs

示例11: GetShell

        // Looks for RUBYSHELL and then COMSPEC under Windows
        internal static ProcessStartInfo/*!*/ GetShell(RubyContext/*!*/ context, MutableString/*!*/ command) {
            PlatformAdaptationLayer pal = context.DomainManager.Platform;
            string shell = pal.GetEnvironmentVariable("RUBYSHELL");
            if (shell == null) {
                shell = pal.GetEnvironmentVariable("COMSPEC");
            }

            if (shell == null) {
                string [] commandParts = command.ConvertToString().Split(new char[] { ' ' }, 2);
                return new ProcessStartInfo(commandParts[0], commandParts.Length == 2 ? commandParts[1] : null);
            } else {
                return new ProcessStartInfo(shell, String.Format("/C \"{0}\"", command.ConvertToString()));
            }
        }
开发者ID:aceptra,项目名称:ironruby,代码行数:15,代码来源:KernelOps.cs

示例12: DirName

        private static MutableString/*!*/ DirName(MutableString/*!*/ path) {
            string strPath = path.ConvertToString();
            string directoryName = strPath;

            if (IsValidPath(strPath)) {
                strPath = StripPathCharacters(strPath);

                // handle top-level UNC paths
                directoryName = Path.GetDirectoryName(strPath);
                if (directoryName == null) {
                    return MutableString.CreateMutable(strPath, path.Encoding);
                }

                string fileName = Path.GetFileName(strPath);
                if (!String.IsNullOrEmpty(fileName)) {
                    directoryName = StripPathCharacters(strPath.Substring(0, strPath.LastIndexOf(fileName, StringComparison.Ordinal)));
                }
            } else {
                if (directoryName.Length > 1) {
                    directoryName = "//";
                }
            }

            directoryName = String.IsNullOrEmpty(directoryName) ? "." : directoryName;
            return MutableString.CreateMutable(directoryName, path.Encoding);
        }
开发者ID:rpattabi,项目名称:ironruby,代码行数:26,代码来源:FileOps.cs

示例13: BaseName

        private static MutableString/*!*/ BaseName(MutableString/*!*/ path, MutableString suffix) {
            if (path.IsEmpty) {
                return path;
            }

            string strPath = path.ConvertToString();
            string[] parts = strPath.Split(new[] { DirectorySeparatorChar, AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length == 0) {
                return MutableString.CreateMutable(path.Encoding).Append((char)path.GetLastChar()).TaintBy(path);
            }

            if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX) {
                string first = parts[0];
                if (strPath.Length >= 2 && IsDirectorySeparator(strPath[0]) && IsDirectorySeparator(strPath[1])) {
                    // UNC: skip 2 parts 
                    if (parts.Length <= 2) {
                        return MutableString.CreateMutable(path.Encoding).Append(DirectorySeparatorChar).TaintBy(path);
                    }
                } else if (first.Length == 2 && Tokenizer.IsLetter(first[0]) && first[1] == ':') {
                    // skip drive letter "X:"
                    if (parts.Length <= 1) {
                        var result = MutableString.CreateMutable(path.Encoding).TaintBy(path);
                        if (strPath.Length > 2) {
                            result.Append(strPath[2]);
                        }
                        return result;
                    }
                }
            }

            string last = parts[parts.Length - 1];
            if (MutableString.IsNullOrEmpty(suffix)) {
                return MutableString.CreateMutable(last, path.Encoding);
            }

            StringComparison comparison = Environment.OSVersion.Platform == PlatformID.Unix ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
            int matchLength = last.Length;

            if (suffix != null) {
                string strSuffix = suffix.ToString();
                if (strSuffix.LastCharacter() == '*' && strSuffix.Length > 1) {
                    int suffixIdx = last.LastIndexOf(
                        strSuffix.Substring(0, strSuffix.Length - 1),
                        comparison
                    );
                    if (suffixIdx >= 0 && suffixIdx + strSuffix.Length <= last.Length) {
                        matchLength = suffixIdx;
                    }
                } else if (last.EndsWith(strSuffix, comparison)) {
                    matchLength = last.Length - strSuffix.Length;
                }
            }

            return MutableString.CreateMutable(path.Encoding).Append(last, 0, matchLength).TaintBy(path);
        }
开发者ID:rpattabi,项目名称:ironruby,代码行数:56,代码来源:FileOps.cs

示例14: RunIfFileExists

 private static bool RunIfFileExists(RubyContext/*!*/ context, MutableString/*!*/ path, Func<FileSystemInfo, bool> del) {
     return RunIfFileExists(context, path.ConvertToString(), del);
 }
开发者ID:BenHall,项目名称:ironruby,代码行数:3,代码来源:FileTest.cs

示例15: OpenFileForRead

        //write_nonblock
        
        #endregion

        #region read, read_nonblock

        private static RubyIO/*!*/ OpenFileForRead(RubyContext/*!*/ context, MutableString/*!*/ path) {
            string strPath = path.ConvertToString();
            if (!File.Exists(strPath)) {
                throw RubyErrno.CreateENOENT(String.Format("No such file or directory - {0}", strPath));
            }
            return new RubyIO(context, File.OpenRead(strPath), "r");
        }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:13,代码来源:IoOps.cs


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