本文整理汇总了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]);
}
}
示例2: ToBase64
static string ToBase64 (int len, Base64FormattingOptions options)
{
return Convert.ToBase64String (new byte [len], options);
}
示例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));
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例14: ToBase64CharArray
public static int ToBase64CharArray(byte[] inArray, int offsetIn, int length, char[] outArray, int offsetOut, Base64FormattingOptions options) {}
示例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
}