當前位置: 首頁>>代碼示例>>C#>>正文


C# Base64FormattingOptions類代碼示例

本文整理匯總了C#中Base64FormattingOptions的典型用法代碼示例。如果您正苦於以下問題:C# Base64FormattingOptions類的具體用法?C# Base64FormattingOptions怎麽用?C# Base64FormattingOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Base64FormattingOptions類屬於命名空間,在下文中一共展示了Base64FormattingOptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetStandardValues

        public virtual void GetStandardValues()
        {
            LexographicEnumConverter TestSubject = new LexographicEnumConverter(typeof(Base64FormattingOptions));

            Base64FormattingOptions[] expected = new Base64FormattingOptions[]
            {
                Base64FormattingOptions.InsertLineBreaks,
                Base64FormattingOptions.None
            };

            Base64FormattingOptions[] actual = new Base64FormattingOptions[2];

            TestSubject.GetStandardValues().CopyTo(actual,0);

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
開發者ID:plusql,項目名稱:hsqldb-snapshot-20160112,代碼行數:19,代碼來源:TestLexographicEnumConverter.cs

示例2: ToBase64

		static string ToBase64 (int len, Base64FormattingOptions options)
		{
			return Convert.ToBase64String (new byte [len], options);
		}
開發者ID:carrie901,項目名稱:mono,代碼行數:4,代碼來源:ConvertTest.cs

示例3: ToBase64String

		public static string ToBase64String (byte[] inArray, int offset, int length, Base64FormattingOptions options)
		{
			if (inArray == null)
				throw new ArgumentNullException ("inArray");
			if (offset < 0 || length < 0)
				throw new ArgumentOutOfRangeException ("offset < 0 || length < 0");
			// avoid integer overflow
			if (offset > inArray.Length - length)
				throw new ArgumentOutOfRangeException ("offset + length > array.Length");

			if (length == 0)
				return String.Empty;

			if (options == Base64FormattingOptions.InsertLineBreaks)
				return ToBase64StringBuilderWithLine (inArray, offset, length).ToString ();
			else
				return Encoding.ASCII.GetString (Base64Helper.TransformFinalBlock (inArray, offset, length));
		}
開發者ID:GirlD,項目名稱:mono,代碼行數:18,代碼來源:Convert.cs

示例4: ToBase64String

        public static unsafe String ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options) {
            //Do data verfication
            if (inArray==null) 
                throw new ArgumentNullException("inArray");
            if (length<0)
                throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_Index"));
            if (offset<0)
                throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
            if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
                throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options));
            Contract.Ensures(Contract.Result<string>() != null);
            Contract.EndContractBlock();

            int inArrayLength;
            int stringLength;

            inArrayLength = inArray.Length;
            if (offset > (inArrayLength - length))
                throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"));
           
            if (inArrayLength == 0)
                return String.Empty;

            bool insertLineBreaks = (options == Base64FormattingOptions.InsertLineBreaks);
            //Create the new string.  This is the maximally required length.
            stringLength = ToBase64_CalculateAndValidateOutputLength(length, insertLineBreaks);

            string returnString = string.FastAllocateString(stringLength);
            fixed (char* outChars = returnString){
                fixed (byte* inData = inArray) {
                    int j = ConvertToBase64Array(outChars,inData,offset,length, insertLineBreaks);
                    BCLDebug.Assert(returnString.Length == j, "returnString.Length == j");
                    return returnString;
                }
            }
        }
開發者ID:destinyclown,項目名稱:coreclr,代碼行數:36,代碼來源:Convert.cs

示例5: ToBase64String

		public unsafe static string ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options)
		{
			if (inArray == null)
			{
				throw new ArgumentNullException("inArray");
			}
			if (length < 0)
			{
				throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_Index"));
			}
			if (offset < 0)
			{
				throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
			}
			if (options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks)
			{
				throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", new object[]
				{
					(int)options
				}));
			}
			int num = inArray.Length;
			if (offset > num - length)
			{
				throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"));
			}
			if (num == 0)
			{
				return string.Empty;
			}
			bool insertLineBreaks = options == Base64FormattingOptions.InsertLineBreaks;
			int length2 = Convert.CalculateOutputLength(length, insertLineBreaks);
			string text = string.FastAllocateString(length2);
			fixed (char* outChars = text)
			{
				fixed (byte* ptr = inArray)
				{
					Convert.ConvertToBase64Array(outChars, ptr, offset, length, insertLineBreaks);
					return text;
				}
			}
		}
開發者ID:ChristianWulf,項目名稱:CSharpKDMDiscoverer,代碼行數:42,代碼來源:Convert.cs

示例6: ToBase64CharArray

    public static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut, Base64FormattingOptions options)
    {
      Contract.Ensures(0 <= Contract.Result<int>());

      return default(int);
    }
開發者ID:asvishnyakov,項目名稱:CodeContracts,代碼行數:6,代碼來源:System.Convert.cs

示例7: ToBase64String

 /// <summary>
 /// Create a Base64String from the Surface by saving it to a memory stream and converting it.
 /// Should be avoided if possible, as this uses a lot of memory.
 /// </summary>
 /// <returns>string</returns>
 public string ToBase64String(Base64FormattingOptions formattingOptions)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         ImageOutput.SaveToStream(_surface, stream, _outputSettings);
         return Convert.ToBase64String(stream.GetBuffer(), 0, (int)stream.Length, formattingOptions);
     }
 }
開發者ID:ElectronicWar,項目名稱:ShareX,代碼行數:13,代碼來源:NetworkHelper.cs

示例8: ToString

 /// <summary>
 /// Converts a byte array into a base 64 string
 /// </summary>
 /// <param name="Input">Input array</param>
 /// <param name="Count">
 /// Number of bytes starting at the index to convert (use -1 for the entire array starting
 /// at the index)
 /// </param>
 /// <param name="Index">Index to start at</param>
 /// <param name="Options">Base 64 formatting options</param>
 /// <returns>The equivalent byte array in a base 64 string</returns>
 public static string ToString(this byte[] Input, Base64FormattingOptions Options, int Index = 0, int Count = -1)
 {
     Contract.Requires<ArgumentException>(Index >= 0, "Index");
     if (Count == -1)
         Count = Input.Length - Index;
     return Input == null ? "" : Convert.ToBase64String(Input, Index, Count, Options);
 }
開發者ID:modulexcite,項目名稱:Craig-s-Utility-Library,代碼行數:18,代碼來源:ValueTypeExtensions.cs

示例9: ToBase64String

        public static unsafe String ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options) {
            int     inArrayLength;
            int     stringLength;

            //Do data verfication
            if (inArray==null) 
                throw new ArgumentNullException("inArray");
            if (length<0)
                throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_Index"));
            if (offset<0)
                throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
            inArrayLength = inArray.Length;
            if (offset > (inArrayLength - length))
                throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"));

            if( options < Base64FormattingOptions.None || options > Base64FormattingOptions.InsertLineBreaks) {
                throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options));
            }
            
            if (inArrayLength == 0)
                return String.Empty;

            bool insertLineBreaks = (options == Base64FormattingOptions.InsertLineBreaks);
            //Create the new string.  This is the maximally required length.
            stringLength = CalculateOutputLength(length, insertLineBreaks);

            string returnString = String.GetStringForStringBuilder(String.Empty, stringLength);
            fixed (char* outChars = returnString){
                fixed (byte* inData = inArray) {
                    int j = ConvertToBase64Array(outChars,inData,offset,length, insertLineBreaks);
                    returnString.SetLength(j);
                    return returnString;
                }
            }
        }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:35,代碼來源:convert.cs

示例10: ToBase64String

 /// <summary>
 ///     Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is
 ///     encoded with base-64 digits. Parameters specify the subset as an offset in the input array, the number of
 ///     elements in the array to convert, and whether to insert line breaks in the return value.
 /// </summary>
 /// <param name="inArray">An array of 8-bit unsigned integers.</param>
 /// <param name="offset">An offset in .</param>
 /// <param name="length">The number of elements of  to convert.</param>
 /// <param name="options">to insert a line break every 76 characters, or  to not insert line breaks.</param>
 /// <returns>The string representation in base 64 of  elements of , starting at position .</returns>
 public static String ToBase64String(this Byte[] inArray, Int32 offset, Int32 length, Base64FormattingOptions options)
 {
     return Convert.ToBase64String(inArray, offset, length, options);
 }
開發者ID:ChuangYang,項目名稱:Z.ExtensionMethods,代碼行數:14,代碼來源:ByteArray.ToBase64String.cs

示例11: ToBase64String

 /// <summary>
 /// Converts the route to IOF XML 3.0 binary format and returns it as a base64-encoded string.
 /// </summary>
 /// <param name="formattingOptions">The formatting options for the base64-encoded string.</param>
 public string ToBase64String(Base64FormattingOptions formattingOptions = Base64FormattingOptions.None)
 {
     return Convert.ToBase64String(ToByteArray(), formattingOptions);
 }
開發者ID:hennings,項目名稱:iof-data-standard-v3,代碼行數:8,代碼來源:IofXml30Route.cs

示例12: WriteByteList

 private void WriteByteList(List<byte> bytes, Base64FormattingOptions options)
 {
     byte[] array = bytes.ToArray();
     bytes = null;
     string base64 = Convert.ToBase64String(array, options);
     array = null;
     WriteObject(base64);
 }
開發者ID:nickchal,項目名稱:pash,代碼行數:8,代碼來源:ConvertToBase64Command.cs

示例13: ToDataString

 /// <summary>Converts the specified array to a Base64 string.</summary>
 /// <param name="value">The array to convert.</param>
 /// <param name="options">The <see cref="T:Base64FormattingOptions"/> to use.</param>
 /// <returns>The converted string.</returns>
 public static string ToDataString(this byte[] value, Base64FormattingOptions options)
 {
     return value.HasItems()
         ? Convert.ToBase64String(value, options)
         : String.Empty;
 }
開發者ID:tommy-carlier,項目名稱:tc-libs,代碼行數:10,代碼來源:ConvertBytes.cs

示例14: ToBase64CharArray

	public static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut, Base64FormattingOptions options) {}
開發者ID:Pengfei-Gao,項目名稱:source-Insight-3-for-centos7,代碼行數:1,代碼來源:Convert.cs

示例15: ToBase64String

        public static string ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options)
        {
            if (inArray == null)
                throw new ArgumentNullException("inArray");
            if (offset < 0 || length < 0)
                throw new ArgumentOutOfRangeException("offset < 0 || length < 0");
            // avoid integer overflow
            if (offset > inArray.Length - length)
                throw new ArgumentOutOfRangeException("offset + length > array.Length");

            if (length == 0)
                return String.Empty;

#if ANDROID_8P
            return Base64.EncodeToString(inArray, offset, length, Base64.DEFAULT);
#else
			throw new NotImplementedException("System.Convert.ToBase64String");
#endif
        }
開發者ID:nguyenkien,項目名稱:api,代碼行數:19,代碼來源:Convert.cs


注:本文中的Base64FormattingOptions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。