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


C# StringType类代码示例

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


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

示例1: GenerateRandomString

        /// <summary>
        /// Generate a random string of characters
        /// </summary>
        /// <param name="length">length of string</param>
        /// <param name="type">type of string to be generated</param>
        /// <returns></returns>
        public static string GenerateRandomString(int length, StringType type)
        {
            switch (type)
            {
                case StringType.AlphaNumeric:
                    string allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
                    char[] chars = new char[length];
                    Random rd = new Random();

                    for (int i = 0; i < length; i++)
                    {
                        chars[i] = allowedChars[rd.Next(0, allowedChars.Length)];
                    }

                    return new string(chars);
                    break;

                case StringType.AlphaNumericSymbol:
                    //Generate a cryptographic random number.
                    var rng = new RNGCryptoServiceProvider();
                    var buff = new byte[length];
                    rng.GetBytes(buff);

                    rng.Dispose();

                    // Return a Base64 string representation of the random number.
                    return Convert.ToBase64String(buff);
                    break;
                default:
                    throw new ArgumentException("Type not supported");
            }
        }
开发者ID:shawnmclean,项目名称:ShawnMclean-.Net-Utility-Library,代码行数:38,代码来源:StringHelpers.cs

示例2: ShouldDecodeLongString

 public virtual void ShouldDecodeLongString()
 {
     var stringType = new StringType();
     var longString = "MonkeyVeryLongStringmljalkdjflksjf lkdfjlsfjalkfjlsflskfjlsflsfjasdfjlsjflksfjlskjf fjlskfjlsjfs fkj lakdflsjfsa fafd sa";
     var result = stringType.Encode(longString);
     Assert.Equal(longString, stringType.Decode<string>(result));
 }
开发者ID:Nethereum,项目名称:Nethereum,代码行数:7,代码来源:StringEncodingTests.cs

示例3: Validate

        /// <summary>
        ///   Validates given string for the given type.
        /// </summary>
        /// <param name="stringToValidate"> string to be validated. </param>
        /// <param name="type"> Type of the string. </param>
        /// <returns> True if string validates the required parameter </returns>
        public static bool Validate(string stringToValidate, StringType type)
        {
            if (null == stringToValidate)
            {
                ExceptionManager.Throw(new ArgumentNullException("stringToValidate"));
            }

            bool result = false;
            switch (type)
            {
                case StringType.Name:
                    result = ValidateName(stringToValidate);
                    break;
                case StringType.EmailAddress:
                    result = ValidateEmailAddress(stringToValidate);
                    break;
                case StringType.Address:
                    break;
                case StringType.Password:
                    result = ValidatePassword(stringToValidate);
                    break;
                default:
                    ExceptionManager.Throw(new ArgumentOutOfRangeException("type"));
                    break;
            }
            return result;
        }
开发者ID:gitter-badger,项目名称:UROCare,代码行数:33,代码来源:StringValidation.cs

示例4: CertStrToName

 internal extern static bool CertStrToName(CertEncodingType dwCertEncodingType,
                                             [MarshalAs(UnmanagedType.LPWStr)]string pszX500,
                                             StringType dwStrType,
                                             IntPtr pvReserved,
                                             byte[] pbEncoded,
                                             [In, Out]ref int pcbEncoded,
                                             [MarshalAs(UnmanagedType.LPWStr)]ref StringBuilder ppszError);
开发者ID:marteaga,项目名称:healthvault-azurestorage,代码行数:7,代码来源:NativeMethods.cs

示例5: UnsynchronisedLyricsFrame

 public UnsynchronisedLyricsFrame(string description, string language, StringType encoding) : base(FrameType.USLT, 4)
 {
     this.encoding = TagLib.Id3v2.Tag.DefaultEncoding;
     this.encoding = encoding;
     this.language = language;
     this.description = description;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:7,代码来源:UnsynchronisedLyricsFrame.cs

示例6: StringData

		public StringData(string name, uint offset, uint address, StringType type, string value, int size, uint pluginLine)
			: base(name, offset, address, pluginLine)
		{
			_value = value;
			_size = size;
			_type = type;
		}
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:7,代码来源:StringData.cs

示例7: CommentsFrame

 public CommentsFrame(string description, string language, StringType encoding) : base(FrameType.COMM, 4)
 {
     this.encoding = TagLib.Id3v2.Tag.DefaultEncoding;
     this.encoding = encoding;
     this.language = language;
     this.description = description;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:7,代码来源:CommentsFrame.cs

示例8: SynchronisedLyricsFrame

 public SynchronisedLyricsFrame (string description, string language, SynchedTextType type, StringType encoding) : base (FrameType.SYLT, 4)
 {
    this.text_encoding = encoding;
    this.language      = language;
    this.description   = description;
    this.lyrics_type   = type;
 }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:7,代码来源:SynchronizedLyricsFrame.cs

示例9: ParseCommentsFields

		private void ParseCommentsFields(ByteVector data)
		{
			if (data.Count < 5)
			{
				TagLibDebugger.Debug("A comment frame must contain at least 5 bytes.");
				return;
			}

			textEncoding = (StringType)data[0];
			language = data.Mid(1, 3);

			int byte_align = textEncoding == StringType.Latin1 || textEncoding == StringType.UTF8 ? 1 : 2;

			ByteVectorCollection l = ByteVectorCollection.Split(data.Mid(4), TextDelimiter(textEncoding), byte_align, 2);

			if (l.Count == 2)
			{
				if (l[0].Data != null && l[0].Data.Count > 0)
					description = l[0].ToString(textEncoding);
				else description = string.Empty;
				
				if (l[1].Data != null && l[1].Data.Count > 0)
					text = l[1].ToString(textEncoding);
				else text = string.Empty;
			}
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:26,代码来源:Id3v2CommentsFrame.cs

示例10: Id3v2CommentsFrame

		public Id3v2CommentsFrame(StringType encoding) : base("COMM")
		{
			textEncoding = encoding;
			//language = null;
			//fields = null;
			//type = null;
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:7,代码来源:Id3v2CommentsFrame.cs

示例11: FindStrings

 public IEnumerable<ProgramAddress> FindStrings(StringType stringType, int minLength)
 {
     foreach (var segment in program.ImageMap.Segments.Values)
     {
         Address segEnd = segment.Address + segment.Size;
         var rdr = program.Architecture.CreateImageReader(program.Image, segment.Address);
         Address addrStartRun = null;
         int cValid = 0;
         while (rdr.Address < segEnd)
         {
             byte ch = rdr.ReadByte();
             if (!IsValid((char)ch))
             {
                 if (ch == 0 && cValid >= minLength)
                 {
                     yield return new ProgramAddress(program, addrStartRun);
                 }
                 addrStartRun = null;
                 cValid = 0;
             }
             else
             {
                 if (addrStartRun == null)
                     addrStartRun = rdr.Address - 1;
                 ++cValid;
             }
         }
     }
 }
开发者ID:nemerle,项目名称:reko,代码行数:29,代码来源:StringFinder.cs

示例12: CorrectEncoding

 protected static StringType CorrectEncoding(StringType type, byte version)
 {
     if (TagLib.Id3v2.Tag.ForceDefaultEncoding)
     {
         type = TagLib.Id3v2.Tag.DefaultEncoding;
     }
     return (((version >= 4) || (type != StringType.UTF8)) ? type : StringType.UTF16);
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:8,代码来源:Frame.cs

示例13: StringContentTokenizer

        public StringContentTokenizer(StringType properties, char terminator, char openingParenthesis) {
            Debug.Assert(!Tokenizer.IsLetterOrDigit(terminator));

            _properties = properties;
            _terminator = terminator;
            _openingParenthesis = openingParenthesis;
            _nestingLevel = 0;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:8,代码来源:StringTokenizer.cs

示例14: StringFeatureAttribute

        public StringFeatureAttribute(StringType splitType, string separator = " ", string exclusions = null)
        {
            SplitType = splitType;
            Separator = separator;
            ExclusionFile = exclusions;

            CalculateExclusions();
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:8,代码来源:StringFeatureAttribute.cs

示例15: WriteTomlStrings

        public void WriteTomlStrings(StringType s, string expected)
        {
            // Act
            var written = Toml.WriteString(s);

            // Assert
            Assert.Equal(expected, written.Trim());
        }
开发者ID:paiden,项目名称:Nett,代码行数:8,代码来源:WriteTomlTypesTests.cs


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