当前位置: 首页>>代码示例>>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;未经允许,请勿转载。