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


C# String.Name方法代码示例

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


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

示例1: IsDirectoryEmpty

 public static Boolean IsDirectoryEmpty(String path)
 {
     path.Name("path").NotNullEmptyOrOnlyWhitespace();
       return IsDirectoryEmpty(new DirectoryInfo(path));
 }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:5,代码来源:FileIO.cs

示例2: SafelyCreateEmptyFile

 public static void SafelyCreateEmptyFile(String filename)
 {
     filename.Name("filename").NotNullEmptyOrOnlyWhitespace();
       CreateEmptyFile(filename, Overwrite.No);
 }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:5,代码来源:FileIO.cs

示例3: DeleteEmptyDirectories

 public static void DeleteEmptyDirectories(String path)
 {
     path.Name("path").NotNullEmptyOrOnlyWhitespace();
       DeleteEmptyDirectories(new DirectoryInfo(path));
 }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:5,代码来源:FileIO.cs

示例4: GetMD5Checksum

 public static String GetMD5Checksum(String filename)
 {
     filename.Name("filename").NotNullEmptyOrOnlyWhitespace();
       using (var fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
     return GetMD5Checksum(fs);
 }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:6,代码来源:FileIO.cs

示例5: GetBracketedSqlIdentifier

        "Unicode",
        "Until",
        "Where"
          };

        private static Configuration _configuration;
        private static Boolean _isInitialized = false;
        private static List<String> _targetLanguageKeywords;

        #endregion Fields

        #region Methods

        /// <summary>
        /// Given a T-SQL identifier, return the same identifier with all of its
        /// constituent parts wrapped in square brackets.
        /// </summary>
        public static String GetBracketedSqlIdentifier(String identifier)
        {
            identifier.Name("identifier").NotNullEmptyOrOnlyWhitespace();

              Func<String, String> wrap = s => s.Any() ? String.Concat("[", s.Trim(_brackets), "]") : "";

              return
            identifier
            /* Keep empty array elements, because parts of a multi-part T-SQL identifier
               can be empty (e.g. "server.database..object", where the schema name is omitted). */
            .Split(".".ToCharArray(), StringSplitOptions.None)
            .Select(element => wrap(element))
            .Join(".");
        }

        public static String GetStrippedSqlIdentifier(String identifier)
        {
            return identifier.Replace("[", "").Replace("]", "");
        }

        /// <summary>
        /// Convert an SQL identifier, like a database name or column name, into a valid
        /// identifier for the target language (C#, F#, etc.) that was set in
        /// the configuration.
        /// <para>NOTE: IdentifierHelper.Init() must be called before this method is called for the first time, otherwise an exception will be thrown.</para>
        /// <para>System.dll has code providers for both C# (Microsoft.CSharp.CSharpCodeProvider) and
        /// Visual Basic (Microsoft.VisualBasic.VBCodeProvider).  Why not use code from those classes
        /// to determine if a given string is a valid identifier?</para>
        /// <para>There are several reasons.  One is that .Net does not provide a corresponding F# code provider.
        /// The second reason is that the code providers' CreateValidIdentifier() method
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:47,代码来源:IdentifierHelper.cs

示例6: CreateEmptyFile

        public static void CreateEmptyFile(String filename, Overwrite overwrite)
        {
            filename.Name("filename").NotNullEmptyOrOnlyWhitespace();

              if ((overwrite == Overwrite.Yes) || !File.Exists(filename))
              {
            using (var fs = File.Create(filename))
            {
              /* Create an empty file. */
            }
              }
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:12,代码来源:FileIO.cs

示例7: GetImageFormatFromFileExtension

        public static ImageFormat GetImageFormatFromFileExtension(String filename)
        {
            filename.Name("filename").NotNullEmptyOrOnlyWhitespace();

              var fileExtension = GetFileExtension(filename);

              switch (fileExtension)
              {
            case "bmp":
              return ImageFormat.Bmp;

            case "emf":
              return ImageFormat.Emf;

            case "exif":
              return ImageFormat.Exif;

            case "gif":
              return ImageFormat.Gif;

            case "icon":
              return ImageFormat.Icon;

            case "jpg":
            case "jpeg":
              return ImageFormat.Jpeg;

            case "png":
              return ImageFormat.Png;

            case "tif":
            case "tiff":
              return ImageFormat.Tiff;

            case "wmf":
              return ImageFormat.Wmf;

            default:
              throw new Exception(String.Format(Properties.Resources.Graphics_BadFileExtension, fileExtension));
              }
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:41,代码来源:Graphics.cs

示例8: WriteMemoryStreamToFile

        public static void WriteMemoryStreamToFile(String filename, MemoryStream ms)
        {
            filename.Name("filename").NotNullEmptyOrOnlyWhitespace();
              ms.Name("ms").NotNull();

              using (var fs = File.Create(filename))
            ms.WriteTo(fs);
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:8,代码来源:FileIO.cs

示例9: Item

        public Item(String pathname)
            : this()
        {
            pathname.Name("pathname").NotNullEmptyOrOnlyWhitespace().FileExists();

              var fileContents = File.ReadAllText(pathname);

              this.Filename = Path.GetFileName(pathname);
              this.Pathname = pathname;
              this.SchemaName = "";
              this.ObjectName = "";
              this.FileContentsMD5Hash = fileContents.MD5Checksum();
              this.Type = _userDefinedTableTypeRegex.IsMatch(fileContents) ? "TT" : "  ";
              this.NeedsToBeCompiled = true;
              this.IsPresentOnServer = false;
              this.DropOrder = 0;
              this.NeedsToBeDropped = false;
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:18,代码来源:Make.cs

示例10: GetContentTypeFromFileExtension

        public static String GetContentTypeFromFileExtension(String filename)
        {
            filename.Name("filename").NotNullEmptyOrOnlyWhitespace();

              var fileExtension = GetFileExtension(filename);

              if (String.IsNullOrWhiteSpace(fileExtension))
            throw new Exception(String.Format(Properties.Resources.Graphics_EmptyFileExtension, filename));
              else
            return "image/" + fileExtension;
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:11,代码来源:Graphics.cs

示例11: AddFolder

        public void AddFolder(String folder, String filemask = "*.*", SearchOption searchOption = SearchOption.TopDirectoryOnly)
        {
            folder.Name("folder").NotNullEmptyOrOnlyWhitespace().DirectoryExists();
              filemask.Name("filemask").NotNullEmptyOrOnlyWhitespace();

              filemask = filemask.Trim();

              var pathnames = Directory.EnumerateFiles(folder, "*", searchOption);

              if ((filemask == "*") || (filemask == "*.*"))
              {
            this.AddFiles(pathnames);
              }
              else
              {
            /* Directory.EnumerateFiles()'s searchPattern parameter has an odd behavior
               when matching pathname extensions.
               (Read the "Remarks" section at https://msdn.microsoft.com/en-us/library/dd413233%28v=vs.110%29.aspx).
               That odd (IMO buggy) behavior is avoided by converting the filemask to an equivalent
               regular expression. */

            var filemaskRegexPattern =
              filemask
              /* Escape all regex-related characters except '*' and '?'. */
              .RegexEscape('*', '?')
              /* Convert '*' and '?' to their regex equivalents. */
              .Replace('?', '.')
              .Replace("*", ".*?");
            var _saneFilemaskRegex = new Regex(filemaskRegexPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);

            this.AddFiles(pathnames.Where(f => _saneFilemaskRegex.IsMatch(Path.GetFileName(f))));
              }
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:33,代码来源:Make.cs

示例12: AddFile

        public void AddFile(String pathname)
        {
            pathname.Name("pathname").NotNullEmptyOrOnlyWhitespace().FileExists();

              this._pathnames.Add(Path.GetFullPath(pathname));
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:6,代码来源:Make.cs

示例13: GetUrlAsRoot

        public static String GetUrlAsRoot(String url)
        {
            url.Name("url").NotNull();

              if (url.StartsWith("~/"))
            return url;
              else if (url.StartsWith("/"))
            return "~" + url;
              else
            return "~/" + url;
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:11,代码来源:HttpUtils.cs

示例14: Touch

        public static void Touch(String filename)
        {
            filename.Name("filename").NotNullEmptyOrOnlyWhitespace();

              Touch(filename, DateTime.Now);
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:6,代码来源:FileIO.cs

示例15: ShellExecute

        /// <summary>
        /// Passes the given command to the shell and executes it.
        /// </summary>
        /// <param name="command">
        /// String containing a valid shell command.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// Thrown if the command parameter is null or empty.
        /// </exception>
        public static void ShellExecute(String command)
        {
            command.Name("command").NotNullEmptyOrOnlyWhitespace();

              var browser = new Process();
              browser.StartInfo.FileName = command;
              browser.Start();
        }
开发者ID:ctimmons,项目名称:cs_utilities,代码行数:17,代码来源:Win32API.cs


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