本文整理汇总了C#中AList.AsIterable方法的典型用法代码示例。如果您正苦于以下问题:C# AList.AsIterable方法的具体用法?C# AList.AsIterable怎么用?C# AList.AsIterable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AList
的用法示例。
在下文中一共展示了AList.AsIterable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestJoinIterable
public virtual void TestJoinIterable()
{
IList<string> strings = new AList<string>();
strings.Add("A");
strings.Add("B");
strings.Add("C");
Sharpen.Tests.AreEqual("A;B;C", StringUtil.Join(strings.AsIterable(), ";"));
Sharpen.Tests.AreEqual(string.Empty, StringUtil.Join(new AList<string>(), ";"));
}
示例2: SetUp
public virtual void SetUp()
{
Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
IList<sbyte[]> jpegSegments = new AList<sbyte[]>();
jpegSegments.Add(FileUtil.ReadBytes("Tests/Data/withXmpAndIptc.jpg.app1.1"));
new XmpReader().ReadJpegSegments(jpegSegments.AsIterable(), metadata, JpegSegmentType.App1);
ICollection<XmpDirectory> xmpDirectories = metadata.GetDirectoriesOfType<XmpDirectory>();
NUnit.Framework.Assert.IsNotNull(xmpDirectories);
Sharpen.Tests.AreEqual(1, xmpDirectories.Count);
_directory = xmpDirectories.Iterator().Next();
Sharpen.Tests.IsFalse(_directory.HasErrors());
}
示例3: Extract
/// <exception cref="Com.Drew.Imaging.Png.PngProcessingException"/>
/// <exception cref="System.IO.IOException"/>
public virtual Iterable<PngChunk> Extract(SequentialReader reader, ICollection<PngChunkType> desiredChunkTypes)
{
//
// PNG DATA STREAM
//
// Starts with a PNG SIGNATURE, followed by a sequence of CHUNKS.
//
// PNG SIGNATURE
//
// Always composed of these bytes: 89 50 4E 47 0D 0A 1A 0A
//
// CHUNK
//
// 4 - length of the data field (unsigned, but always within 31 bytes), may be zero
// 4 - chunk type, restricted to [65,90] and [97,122] (A-Za-z)
// * - data field
// 4 - CRC calculated from chunk type and chunk data, but not length
//
// CHUNK TYPES
//
// Critical Chunk Types:
//
// IHDR - image header, always the first chunk in the data stream
// PLTE - palette table, associated with indexed PNG images
// IDAT - image data chunk, of which there may be many
// IEND - image trailer, always the last chunk in the data stream
//
// Ancillary Chunk Types:
//
// Transparency information: tRNS
// Colour space information: cHRM, gAMA, iCCP, sBIT, sRGB
// Textual information: iTXt, tEXt, zTXt
// Miscellaneous information: bKGD, hIST, pHYs, sPLT
// Time information: tIME
//
reader.SetMotorolaByteOrder(true);
// network byte order
if (!Arrays.Equals(PngSignatureBytes, reader.GetBytes(PngSignatureBytes.Length)))
{
throw new PngProcessingException("PNG signature mismatch");
}
bool seenImageHeader = false;
bool seenImageTrailer = false;
IList<PngChunk> chunks = new AList<PngChunk>();
ICollection<PngChunkType> seenChunkTypes = new HashSet<PngChunkType>();
while (!seenImageTrailer)
{
// Process the next chunk.
int chunkDataLength = reader.GetInt32();
PngChunkType chunkType = new PngChunkType(reader.GetBytes(4));
sbyte[] chunkData = reader.GetBytes(chunkDataLength);
// Skip the CRC bytes at the end of the chunk
// TODO consider verifying the CRC value to determine if we're processing bad data
reader.Skip(4);
if (seenChunkTypes.Contains(chunkType) && !chunkType.AreMultipleAllowed())
{
throw new PngProcessingException(Sharpen.Extensions.StringFormat("Observed multiple instances of PNG chunk '%s', for which multiples are not allowed", chunkType));
}
if (chunkType.Equals(PngChunkType.Ihdr))
{
seenImageHeader = true;
}
else
{
if (!seenImageHeader)
{
throw new PngProcessingException(Sharpen.Extensions.StringFormat("First chunk should be '%s', but '%s' was observed", PngChunkType.Ihdr, chunkType));
}
}
if (chunkType.Equals(PngChunkType.Iend))
{
seenImageTrailer = true;
}
if (desiredChunkTypes == null || desiredChunkTypes.Contains(chunkType))
{
chunks.Add(new PngChunk(chunkType, chunkData));
}
seenChunkTypes.Add(chunkType);
}
return chunks.AsIterable();
}