/// <summary> /// Initializes a new instance of the <see cref="T:MailKit.Search.FilterSearchQuery"/> class. /// </summary> /// <remarks> /// A search query that references a predefined filter. /// </remarks> /// <param name="filter">The metadata tag representing the filter.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="filter"/> does not reference a valid filter. /// </exception> public FilterSearchQuery (MetadataTag filter) : base (SearchTerm.Filter) { if (filter.Id.StartsWith ("/private/filters/values/", StringComparison.Ordinal)) Name = filter.Id.Substring ("/private/filters/values/".Length); else if (filter.Id.StartsWith ("/shared/filters/values/", StringComparison.Ordinal)) Name = filter.Id.Substring ("/shared/filters/values/".Length); else throw new ArgumentException ("Metadata tag does not reference a valid filter.", nameof (filter)); }
public SwfDisplayList Visit(MetadataTag tag, SwfDisplayList dl) { return(dl); }
/// <summary> /// Initializes a new instance of the <see cref="MailKit.Metadata"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="Metadata"/>. /// </remarks> /// <param name="tag">The metadata tag.</param> /// <param name="value">The meatdata value.</param> public Metadata (MetadataTag tag, string value) { Value = value; Tag = tag; }
/// <summary> /// Lists all objects with the given tag. This method returns both the objects' IDs as well /// as their metadata. /// </summary> /// <param name="tag">Tag the tag to search for</param> /// <returns>The list of objects with the given tag. If no objects are found the array will be empty.</returns> /// <exception cref="T:EsuApiLib.EsuException">if no objects are found (code 1003)</exception> public List<ObjectResult> ListObjectsWithMetadata(MetadataTag tag) { return ListObjectsWithMetadata(tag.Name); }
/// <summary> /// Lists all objects with the given tag. /// </summary> /// <param name="tag">Tag the tag to search for</param> /// <returns>The list of objects with the given tag. If no objects are found the array will be empty.</returns> /// <exception cref="T:EsuApiLib.EsuException">if no objects are found (code 1003)</exception> public List<ObjectId> ListObjects( MetadataTag tag ) { return ListObjects(tag.Name); }
public void MetadataTag() { FITAG tag; MetadataTag metaTag; Random rand = new Random(); dib = iManager.GetBitmap(ImageType.Metadata, ImageColorType.Type_01_Dither); Assert.IsFalse(dib.IsNull); Assert.That(FreeImage.GetMetadataCount(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib) > 0); FIMETADATA mData = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, dib, out tag); Assert.IsFalse(tag.IsNull); Assert.IsFalse(mData.IsNull); // // Constructors // metaTag = new MetadataTag(tag, dib); Assert.That(metaTag.Model == FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN); metaTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN); Assert.That(metaTag.Model == FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN); // // Properties // metaTag.ID = ushort.MinValue; Assert.That(metaTag.ID == ushort.MinValue); metaTag.ID = ushort.MaxValue; Assert.That(metaTag.ID == ushort.MaxValue); metaTag.ID = ushort.MaxValue / 2; Assert.That(metaTag.ID == ushort.MaxValue / 2); metaTag.Description = ""; Assert.That(metaTag.Description == ""); metaTag.Description = "A"; Assert.That(metaTag.Description == "A"); metaTag.Description = "ABCDEFG"; Assert.That(metaTag.Description == "ABCDEFG"); metaTag.Key = ""; Assert.That(metaTag.Key == ""); metaTag.Key = "A"; Assert.That(metaTag.Key == "A"); metaTag.Key = "ABCDEFG"; Assert.That(metaTag.Key == "ABCDEFG"); // // SetValue // try { metaTag.SetValue(null, FREE_IMAGE_MDTYPE.FIDT_ASCII); Assert.Fail(); } catch { } // // FREE_IMAGE_MDTYPE.FIDT_ASCII // string testString = ""; Assert.IsTrue(metaTag.SetValue(testString, FREE_IMAGE_MDTYPE.FIDT_ASCII)); Assert.IsNotNull(metaTag.Value); Assert.That(((string)metaTag.Value).Length == 0); testString = "X"; Assert.IsTrue(metaTag.SetValue(testString, FREE_IMAGE_MDTYPE.FIDT_ASCII)); Assert.IsNotNull(metaTag.Value); Assert.That(((string)metaTag.Value).Length == testString.Length); Assert.That(((string)metaTag.Value) == testString); testString = "TEST-STRING"; Assert.IsTrue(metaTag.SetValue(testString, FREE_IMAGE_MDTYPE.FIDT_ASCII)); Assert.IsNotNull(metaTag.Value); Assert.That(((string)metaTag.Value).Length == testString.Length); Assert.That(((string)metaTag.Value) == testString); // // FREE_IMAGE_MDTYPE.FIDT_BYTE // byte testByte; byte[] testByteArray; Assert.IsTrue(metaTag.SetValue(byte.MinValue, FREE_IMAGE_MDTYPE.FIDT_BYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == 1); Assert.That(((byte[])metaTag.Value)[0] == byte.MinValue); Assert.IsTrue(metaTag.SetValue(byte.MaxValue, FREE_IMAGE_MDTYPE.FIDT_BYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == 1); Assert.That(((byte[])metaTag.Value)[0] == byte.MaxValue); for (int i = 0; i < 10; i++) { testByte = (byte)rand.Next(byte.MinValue, byte.MaxValue); testByteArray = new byte[rand.Next(0, 31)]; for (int j = 0; j < testByteArray.Length; j++) testByteArray[j] = (byte)rand.Next(); Assert.IsTrue(metaTag.SetValue(testByte, FREE_IMAGE_MDTYPE.FIDT_BYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 1); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_BYTE); Assert.That(((byte[])metaTag.Value)[0] == testByte); Assert.IsTrue(metaTag.SetValue(testByteArray, FREE_IMAGE_MDTYPE.FIDT_BYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == testByteArray.Length); Assert.That(metaTag.Count == testByteArray.Length); Assert.That(metaTag.Length == testByteArray.Length * 1); byte[] value = (byte[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testByteArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_DOUBLE // double testDouble; double[] testDoubleArray; Assert.IsTrue(metaTag.SetValue(double.MinValue, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); Assert.IsNotNull(metaTag.Value); Assert.That(((double[])metaTag.Value).Length == 1); Assert.That(((double[])metaTag.Value)[0] == double.MinValue); Assert.IsTrue(metaTag.SetValue(double.MaxValue, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); Assert.IsNotNull(metaTag.Value); Assert.That(((double[])metaTag.Value).Length == 1); Assert.That(((double[])metaTag.Value)[0] == double.MaxValue); for (int i = 0; i < 10; i++) { testDouble = (double)rand.NextDouble(); testDoubleArray = new double[rand.Next(0, 31)]; for (int j = 0; j < testDoubleArray.Length; j++) testDoubleArray[j] = rand.NextDouble(); Assert.IsTrue(metaTag.SetValue(testDouble, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); Assert.IsNotNull(metaTag.Value); Assert.That(((double[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 8); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_DOUBLE); Assert.That(((double[])metaTag.Value)[0] == testDouble); Assert.IsTrue(metaTag.SetValue(testDoubleArray, FREE_IMAGE_MDTYPE.FIDT_DOUBLE)); Assert.IsNotNull(metaTag.Value); Assert.That(((double[])metaTag.Value).Length == testDoubleArray.Length); Assert.That(metaTag.Count == testDoubleArray.Length); Assert.That(metaTag.Length == testDoubleArray.Length * 8); double[] value = (double[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testDoubleArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_FLOAT // float testfloat; float[] testFloatArray; Assert.IsTrue(metaTag.SetValue(float.MinValue, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); Assert.IsNotNull(metaTag.Value); Assert.That(((float[])metaTag.Value).Length == 1); Assert.That(((float[])metaTag.Value)[0] == float.MinValue); Assert.IsTrue(metaTag.SetValue(float.MaxValue, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); Assert.IsNotNull(metaTag.Value); Assert.That(((float[])metaTag.Value).Length == 1); Assert.That(((float[])metaTag.Value)[0] == float.MaxValue); for (int i = 0; i < 10; i++) { testfloat = (float)rand.NextDouble(); testFloatArray = new float[rand.Next(0, 31)]; for (int j = 0; j < testFloatArray.Length; j++) testFloatArray[j] = (float)rand.NextDouble(); Assert.IsTrue(metaTag.SetValue(testfloat, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); Assert.IsNotNull(metaTag.Value); Assert.That(((float[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 4); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_FLOAT); Assert.That(((float[])metaTag.Value)[0] == testfloat); Assert.IsTrue(metaTag.SetValue(testFloatArray, FREE_IMAGE_MDTYPE.FIDT_FLOAT)); Assert.IsNotNull(metaTag.Value); Assert.That(((float[])metaTag.Value).Length == testFloatArray.Length); Assert.That(metaTag.Count == testFloatArray.Length); Assert.That(metaTag.Length == testFloatArray.Length * 4); float[] value = (float[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testFloatArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_IFD // uint testUint; uint[] testUintArray; Assert.IsTrue(metaTag.SetValue(uint.MinValue, FREE_IMAGE_MDTYPE.FIDT_IFD)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == 1); Assert.That(((uint[])metaTag.Value)[0] == uint.MinValue); Assert.IsTrue(metaTag.SetValue(uint.MaxValue, FREE_IMAGE_MDTYPE.FIDT_IFD)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == 1); Assert.That(((uint[])metaTag.Value)[0] == uint.MaxValue); for (int i = 0; i < 10; i++) { testUint = (uint)rand.NextDouble(); testUintArray = new uint[rand.Next(0, 31)]; for (int j = 0; j < testUintArray.Length; j++) testUintArray[j] = (uint)rand.Next(); Assert.IsTrue(metaTag.SetValue(testUint, FREE_IMAGE_MDTYPE.FIDT_IFD)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 4); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_IFD); Assert.That(((uint[])metaTag.Value)[0] == testUint); Assert.IsTrue(metaTag.SetValue(testUintArray, FREE_IMAGE_MDTYPE.FIDT_IFD)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == testUintArray.Length); Assert.That(metaTag.Count == testUintArray.Length); Assert.That(metaTag.Length == testUintArray.Length * 4); uint[] value = (uint[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testUintArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_LONG // Assert.IsTrue(metaTag.SetValue(uint.MinValue, FREE_IMAGE_MDTYPE.FIDT_LONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == 1); Assert.That(((uint[])metaTag.Value)[0] == uint.MinValue); Assert.IsTrue(metaTag.SetValue(uint.MaxValue, FREE_IMAGE_MDTYPE.FIDT_LONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == 1); Assert.That(((uint[])metaTag.Value)[0] == uint.MaxValue); for (int i = 0; i < 10; i++) { testUint = (uint)rand.NextDouble(); testUintArray = new uint[rand.Next(0, 31)]; for (int j = 0; j < testUintArray.Length; j++) testUintArray[j] = (uint)rand.Next(); Assert.IsTrue(metaTag.SetValue(testUint, FREE_IMAGE_MDTYPE.FIDT_LONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 4); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_LONG); Assert.That(((uint[])metaTag.Value)[0] == testUint); Assert.IsTrue(metaTag.SetValue(testUintArray, FREE_IMAGE_MDTYPE.FIDT_LONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((uint[])metaTag.Value).Length == testUintArray.Length); Assert.That(metaTag.Count == testUintArray.Length); Assert.That(metaTag.Length == testUintArray.Length * 4); uint[] value = (uint[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testUintArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_NOTYPE // try { metaTag.SetValue(new object(), FREE_IMAGE_MDTYPE.FIDT_NOTYPE); Assert.Fail(); } catch (NotSupportedException) { } // // FREE_IMAGE_MDTYPE.FIDT_PALETTE // RGBQUAD testRGBQUAD; RGBQUAD[] testRGBQUADArray; for (int i = 0; i < 10; i++) { testRGBQUAD = new RGBQUAD(Color.FromArgb(rand.Next())); testRGBQUADArray = new RGBQUAD[rand.Next(0, 31)]; for (int j = 0; j < testRGBQUADArray.Length; j++) testRGBQUADArray[j] = new RGBQUAD(Color.FromArgb(rand.Next())); Assert.IsTrue(metaTag.SetValue(testRGBQUAD, FREE_IMAGE_MDTYPE.FIDT_PALETTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((RGBQUAD[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 4); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_PALETTE); Assert.That(((RGBQUAD[])metaTag.Value)[0] == testRGBQUAD); Assert.IsTrue(metaTag.SetValue(testRGBQUADArray, FREE_IMAGE_MDTYPE.FIDT_PALETTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((RGBQUAD[])metaTag.Value).Length == testRGBQUADArray.Length); Assert.That(metaTag.Count == testRGBQUADArray.Length); Assert.That(metaTag.Length == testRGBQUADArray.Length * 4); RGBQUAD[] value = (RGBQUAD[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testRGBQUADArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_RATIONAL // FIURational testFIURational; FIURational[] testFIURationalArray; for (int i = 0; i < 10; i++) { testFIURational = new FIURational((uint)rand.Next(), (uint)rand.Next()); testFIURationalArray = new FIURational[rand.Next(0, 31)]; for (int j = 0; j < testFIURationalArray.Length; j++) testFIURationalArray[j] = new FIURational((uint)rand.Next(), (uint)rand.Next()); Assert.IsTrue(metaTag.SetValue(testFIURational, FREE_IMAGE_MDTYPE.FIDT_RATIONAL)); Assert.IsNotNull(metaTag.Value); Assert.That(((FIURational[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 8); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_RATIONAL); Assert.That(((FIURational[])metaTag.Value)[0] == testFIURational); Assert.IsTrue(metaTag.SetValue(testFIURationalArray, FREE_IMAGE_MDTYPE.FIDT_RATIONAL)); Assert.IsNotNull(metaTag.Value); Assert.That(((FIURational[])metaTag.Value).Length == testFIURationalArray.Length); Assert.That(metaTag.Count == testFIURationalArray.Length); Assert.That(metaTag.Length == testFIURationalArray.Length * 8); FIURational[] value = (FIURational[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testFIURationalArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_SBYTE // sbyte testSByte; sbyte[] testSByteArray; Assert.IsTrue(metaTag.SetValue(sbyte.MinValue, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((sbyte[])metaTag.Value).Length == 1); Assert.That(((sbyte[])metaTag.Value)[0] == sbyte.MinValue); Assert.IsTrue(metaTag.SetValue(sbyte.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((sbyte[])metaTag.Value).Length == 1); Assert.That(((sbyte[])metaTag.Value)[0] == sbyte.MaxValue); for (int i = 0; i < 10; i++) { testSByte = (sbyte)rand.Next(sbyte.MinValue, sbyte.MaxValue); testSByteArray = new sbyte[rand.Next(0, 31)]; for (int j = 0; j < testSByteArray.Length; j++) testSByteArray[j] = (sbyte)rand.Next(); Assert.IsTrue(metaTag.SetValue(testSByte, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((sbyte[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 1); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SBYTE); Assert.That(((sbyte[])metaTag.Value)[0] == testSByte); Assert.IsTrue(metaTag.SetValue(testSByteArray, FREE_IMAGE_MDTYPE.FIDT_SBYTE)); Assert.IsNotNull(metaTag.Value); Assert.That(((sbyte[])metaTag.Value).Length == testSByteArray.Length); Assert.That(metaTag.Count == testSByteArray.Length); Assert.That(metaTag.Length == testSByteArray.Length * 1); sbyte[] value = (sbyte[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testSByteArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_SHORT // ushort testUShort; ushort[] testUShortArray; Assert.IsTrue(metaTag.SetValue(ushort.MinValue, FREE_IMAGE_MDTYPE.FIDT_SHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((ushort[])metaTag.Value).Length == 1); Assert.That(((ushort[])metaTag.Value)[0] == ushort.MinValue); Assert.IsTrue(metaTag.SetValue(ushort.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((ushort[])metaTag.Value).Length == 1); Assert.That(((ushort[])metaTag.Value)[0] == ushort.MaxValue); for (int i = 0; i < 10; i++) { testUShort = (ushort)rand.Next(ushort.MinValue, sbyte.MaxValue); testUShortArray = new ushort[rand.Next(0, 31)]; for (int j = 0; j < testUShortArray.Length; j++) testUShortArray[j] = (ushort)rand.Next(); Assert.IsTrue(metaTag.SetValue(testUShort, FREE_IMAGE_MDTYPE.FIDT_SHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((ushort[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 2); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SHORT); Assert.That(((ushort[])metaTag.Value)[0] == testUShort); Assert.IsTrue(metaTag.SetValue(testUShortArray, FREE_IMAGE_MDTYPE.FIDT_SHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((ushort[])metaTag.Value).Length == testUShortArray.Length); Assert.That(metaTag.Count == testUShortArray.Length); Assert.That(metaTag.Length == testUShortArray.Length * 2); ushort[] value = (ushort[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testUShortArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_SLONG // int testInt; int[] testIntArray; Assert.IsTrue(metaTag.SetValue(int.MinValue, FREE_IMAGE_MDTYPE.FIDT_SLONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((int[])metaTag.Value).Length == 1); Assert.That(((int[])metaTag.Value)[0] == int.MinValue); Assert.IsTrue(metaTag.SetValue(int.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SLONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((int[])metaTag.Value).Length == 1); Assert.That(((int[])metaTag.Value)[0] == int.MaxValue); for (int i = 0; i < 10; i++) { testInt = (int)rand.NextDouble(); testIntArray = new int[rand.Next(0, 31)]; for (int j = 0; j < testIntArray.Length; j++) testIntArray[j] = rand.Next(); Assert.IsTrue(metaTag.SetValue(testInt, FREE_IMAGE_MDTYPE.FIDT_SLONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((int[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 4); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SLONG); Assert.That(((int[])metaTag.Value)[0] == testInt); Assert.IsTrue(metaTag.SetValue(testIntArray, FREE_IMAGE_MDTYPE.FIDT_SLONG)); Assert.IsNotNull(metaTag.Value); Assert.That(((int[])metaTag.Value).Length == testIntArray.Length); Assert.That(metaTag.Count == testIntArray.Length); Assert.That(metaTag.Length == testIntArray.Length * 4); int[] value = (int[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testIntArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_SRATIONAL // FIRational testFIRational; FIRational[] testFIRationalArray; for (int i = 0; i < 10; i++) { testFIRational = new FIRational(rand.Next(), rand.Next()); testFIRationalArray = new FIRational[rand.Next(0, 31)]; for (int j = 0; j < testFIRationalArray.Length; j++) testFIRationalArray[j] = new FIRational(rand.Next(), rand.Next()); Assert.IsTrue(metaTag.SetValue(testFIRational, FREE_IMAGE_MDTYPE.FIDT_SRATIONAL)); Assert.IsNotNull(metaTag.Value); Assert.That(((FIRational[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 8); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SRATIONAL); Assert.That(((FIRational[])metaTag.Value)[0] == testFIRational); Assert.IsTrue(metaTag.SetValue(testFIRationalArray, FREE_IMAGE_MDTYPE.FIDT_SRATIONAL)); Assert.IsNotNull(metaTag.Value); Assert.That(((FIRational[])metaTag.Value).Length == testFIRationalArray.Length); Assert.That(metaTag.Count == testFIRationalArray.Length); Assert.That(metaTag.Length == testFIRationalArray.Length * 8); FIRational[] value = (FIRational[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testFIRationalArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_SSHORT // short testShort; short[] testShortArray; Assert.IsTrue(metaTag.SetValue(short.MinValue, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((short[])metaTag.Value).Length == 1); Assert.That(((short[])metaTag.Value)[0] == short.MinValue); Assert.IsTrue(metaTag.SetValue(short.MaxValue, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((short[])metaTag.Value).Length == 1); Assert.That(((short[])metaTag.Value)[0] == short.MaxValue); for (int i = 0; i < 10; i++) { testShort = (short)rand.Next(short.MinValue, short.MaxValue); testShortArray = new short[rand.Next(0, 31)]; for (int j = 0; j < testShortArray.Length; j++) testShortArray[j] = (short)rand.Next(); Assert.IsTrue(metaTag.SetValue(testShort, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((short[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 2); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_SSHORT); Assert.That(((short[])metaTag.Value)[0] == testShort); Assert.IsTrue(metaTag.SetValue(testShortArray, FREE_IMAGE_MDTYPE.FIDT_SSHORT)); Assert.IsNotNull(metaTag.Value); Assert.That(((short[])metaTag.Value).Length == testShortArray.Length); Assert.That(metaTag.Count == testShortArray.Length); Assert.That(metaTag.Length == testShortArray.Length * 2); short[] value = (short[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testShortArray[j] == value[j]); } // // FREE_IMAGE_MDTYPE.FIDT_UNDEFINED // Assert.IsTrue(metaTag.SetValue(byte.MinValue, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == 1); Assert.That(((byte[])metaTag.Value)[0] == byte.MinValue); Assert.IsTrue(metaTag.SetValue(byte.MaxValue, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == 1); Assert.That(((byte[])metaTag.Value)[0] == byte.MaxValue); for (int i = 0; i < 10; i++) { testByte = (byte)rand.Next(byte.MinValue, byte.MaxValue); testByteArray = new byte[rand.Next(0, 31)]; for (int j = 0; j < testByteArray.Length; j++) testByteArray[j] = (byte)rand.Next(); Assert.IsTrue(metaTag.SetValue(testByte, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == 1); Assert.That(metaTag.Count == 1); Assert.That(metaTag.Length == 1); Assert.That(metaTag.Type == FREE_IMAGE_MDTYPE.FIDT_UNDEFINED); Assert.That(((byte[])metaTag.Value)[0] == testByte); Assert.IsTrue(metaTag.SetValue(testByteArray, FREE_IMAGE_MDTYPE.FIDT_UNDEFINED)); Assert.IsNotNull(metaTag.Value); Assert.That(((byte[])metaTag.Value).Length == testByteArray.Length); Assert.That(metaTag.Count == testByteArray.Length); Assert.That(metaTag.Length == testByteArray.Length * 1); byte[] value = (byte[])metaTag.Value; for (int j = 0; j < value.Length; j++) Assert.That(testByteArray[j] == value[j]); } FreeImage.UnloadEx(ref dib); }
public void ImageMetadata() { ImageMetadata metadata; List<MetadataModel> modelList; MetadataTag tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS); tag.Key = "KEY"; tag.ID = 11; tag.Value = new double[] { 0d, 41d, -523d, -0.41d }; dib = FreeImage.Allocate(1, 1, 1, 1, 0, 0); Assert.IsFalse(dib.IsNull); metadata = new ImageMetadata(dib, true); Assert.AreEqual(0, metadata.Count); Assert.IsTrue(metadata.HideEmptyModels); Assert.IsEmpty(metadata.List); metadata = new ImageMetadata(dib, false); Assert.AreEqual(FreeImage.FREE_IMAGE_MDMODELS.Length, metadata.Count); Assert.IsFalse(metadata.HideEmptyModels); Assert.IsNotEmpty(metadata.List); metadata.HideEmptyModels = true; metadata.AddTag(tag); Assert.AreEqual(1, metadata.Count); Assert.IsNotEmpty(metadata.List); modelList = metadata.List; Assert.AreEqual(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, modelList[0].Model); System.Collections.IEnumerator enumerator = metadata.GetEnumerator(); Assert.IsTrue(enumerator.MoveNext()); Assert.IsNotNull((MetadataModel)enumerator.Current); Assert.IsFalse(enumerator.MoveNext()); FreeImage.UnloadEx(ref dib); }
public void FreeImage_FindNextMetadata() { MetadataTag tag; FIMETADATA mdHandle; dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); Assert.IsFalse(dib.IsNull); FREE_IMAGE_MDMODEL[] models = (FREE_IMAGE_MDMODEL[])Enum.GetValues(typeof(FREE_IMAGE_MDMODEL)); foreach (FREE_IMAGE_MDMODEL model in models) { mdHandle = FreeImage.FindFirstMetadata(model, dib, out tag); Assert.IsTrue(mdHandle.IsNull); } tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS); tag.Key = "KEY1"; tag.Value = 12345; tag.AddToImage(dib); tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS); tag.Key = "KEY2"; tag.Value = 54321; tag.AddToImage(dib); mdHandle = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, out tag); Assert.IsFalse(mdHandle.IsNull); Assert.IsTrue(FreeImage.FindNextMetadata(mdHandle, out tag)); Assert.IsFalse(FreeImage.FindNextMetadata(mdHandle, out tag)); FreeImage.FindCloseMetadata(mdHandle); FreeImage.UnloadEx(ref dib); }
/// <summary> /// Find the next tag, if any, that matches the metadata model argument in a previous call /// to FindFirstMetadata, and then alters the tag object contents accordingly. /// </summary> /// <param name="mdhandle">Unique search handle provided by FindFirstMetadata.</param> /// <param name="tag">Tag that matches the metadata model.</param> /// <returns>Returns true on success, false on failure.</returns> public static bool FindNextMetadata(FIMETADATA mdhandle, out MetadataTag tag) { FITAG _tag; bool result; if (FindNextMetadata(mdhandle, out _tag)) { tag = new MetadataTag(_tag, metaDataSearchHandler[mdhandle]); result = true; } else { tag = null; result = false; } return result; }
/// <summary> /// Provides information about the first instance of a tag that matches the metadata model. /// </summary> /// <param name="model">The model to match.</param> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <param name="tag">Tag that matches the metadata model.</param> /// <returns>Unique search handle that can be used to call FindNextMetadata or FindCloseMetadata. /// Null if the metadata model does not exist.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static FIMETADATA FindFirstMetadata( FREE_IMAGE_MDMODEL model, FIBITMAP dib, out MetadataTag tag) { if (dib.IsNull) { throw new ArgumentNullException("dib"); } FITAG _tag; FIMETADATA result = FindFirstMetadata(model, dib, out _tag); if (result.IsNull) { tag = null; return result; } tag = new MetadataTag(_tag, model); if (metaDataSearchHandler.ContainsKey(result)) { metaDataSearchHandler[result] = model; } else { metaDataSearchHandler.Add(result, model); } return result; }
/// <summary> /// Attach a new metadata tag to a FreeImage bitmap. /// </summary> /// <param name="model">The metadata model used to store the tag.</param> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <param name="key">The tag field name.</param> /// <param name="tag">The <see cref="MetadataTag"/> to be attached.</param> /// <returns>Returns true on success, false on failure.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static bool SetMetadata( FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, MetadataTag tag) { if (dib.IsNull) { throw new ArgumentNullException("dib"); } return SetMetadata(model, dib, key, tag.tag); }
/// <summary> /// Sets the comment of a JPEG, PNG or GIF image. /// </summary> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <param name="comment">New comment of the FreeImage bitmap. /// Use null to remove the comment.</param> /// <returns>Returns true on success, false on failure.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static bool SetImageComment(FIBITMAP dib, string comment) { if (dib.IsNull) { throw new ArgumentNullException("dib"); } bool result; if (comment != null) { FITAG tag = CreateTag(); MetadataTag metadataTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_COMMENTS); metadataTag.Value = comment; result = SetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", tag); DeleteTag(tag); } else { result = SetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", 0); } return result; }
/// <summary> /// Retrieve a metadata attached to a FreeImage bitmap. /// </summary> /// <param name="model">The metadata model to look for.</param> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <param name="key">The metadata field name.</param> /// <param name="tag">A <see cref="MetadataTag"/> structure returned by the function.</param> /// <returns>Returns true on success, false on failure.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static bool GetMetadata( FREE_IMAGE_MDMODEL model, FIBITMAP dib, string key, out MetadataTag tag) { if (dib.IsNull) { throw new ArgumentNullException("dib"); } FITAG _tag; bool result; if (GetMetadata(model, dib, key, out _tag)) { tag = new MetadataTag(_tag, model); result = true; } else { tag = null; result = false; } return result; }
/// <summary> /// Returns the comment of a JPEG, PNG or GIF image. /// </summary> /// <param name="dib">Handle to a FreeImage bitmap.</param> /// <returns>Comment of the FreeImage bitmp, or null in case no comment exists.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="dib"/> is null.</exception> public static string GetImageComment(FIBITMAP dib) { string result = null; if (dib.IsNull) { throw new ArgumentNullException("dib"); } FITAG tag; if (GetMetadata(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, dib, "Comment", out tag)) { MetadataTag metadataTag = new MetadataTag(tag, FREE_IMAGE_MDMODEL.FIMD_COMMENTS); result = metadataTag.Value as string; } return result; }
public static void AreEqual(MetadataTag expected, MetadataTag actual) { Assert.AreEqual(expected.Metadata, actual.Metadata); Assert.AreEqual(expected.RestData, actual.RestData); }
static SwfTagBase Create(SwfTagData tag_data) { var reader = new SwfStreamReader(tag_data.TagData); switch (tag_data.TagId) { // Display list case (int)SwfTagType.PlaceObject: return(PlaceObjectTag.Create(reader)); case (int)SwfTagType.PlaceObject2: return(PlaceObject2Tag.Create(reader)); case (int)SwfTagType.PlaceObject3: return(PlaceObject3Tag.Create(reader)); case (int)SwfTagType.RemoveObject: return(RemoveObjectTag.Create(reader)); case (int)SwfTagType.RemoveObject2: return(RemoveObject2Tag.Create(reader)); case (int)SwfTagType.ShowFrame: return(ShowFrameTag.Create(reader)); // Control case (int)SwfTagType.SetBackgroundColor: return(SetBackgroundColorTag.Create(reader)); case (int)SwfTagType.FrameLabel: return(FrameLabelTag.Create(reader)); case (int)SwfTagType.Protect: return(ProtectTag.Create(reader)); case (int)SwfTagType.End: return(EndTag.Create(reader)); case (int)SwfTagType.ExportAssets: return(ExportAssetsTag.Create(reader)); case (int)SwfTagType.ImportAssets: return(UnsupportedTag.Create(SwfTagType.ImportAssets)); case (int)SwfTagType.EnableDebugger: return(EnableDebuggerTag.Create(reader)); case (int)SwfTagType.EnableDebugger2: return(EnableDebugger2Tag.Create(reader)); case (int)SwfTagType.ScriptLimits: return(ScriptLimitsTag.Create(reader)); case (int)SwfTagType.SetTabIndex: return(UnsupportedTag.Create(SwfTagType.SetTabIndex)); case (int)SwfTagType.ImportAssets2: return(UnsupportedTag.Create(SwfTagType.ImportAssets2)); case (int)SwfTagType.SymbolClass: return(SymbolClassTag.Create(reader)); case (int)SwfTagType.Metadata: return(MetadataTag.Create(reader)); case (int)SwfTagType.DefineScalingGrid: return(UnsupportedTag.Create(SwfTagType.DefineScalingGrid)); case (int)SwfTagType.DefineSceneAndFrameLabelData: return(DefineSceneAndFrameLabelDataTag.Create(reader)); // Actions case (int)SwfTagType.DoAction: return(UnsupportedTag.Create(SwfTagType.DoAction)); case (int)SwfTagType.DoInitAction: return(UnsupportedTag.Create(SwfTagType.DoInitAction)); case (int)SwfTagType.DoABC: return(DoABCTag.Create(reader)); // Shape case (int)SwfTagType.DefineShape: return(DefineShapeTag.Create(reader)); case (int)SwfTagType.DefineShape2: return(DefineShape2Tag.Create(reader)); case (int)SwfTagType.DefineShape3: return(DefineShape3Tag.Create(reader)); case (int)SwfTagType.DefineShape4: return(DefineShape4Tag.Create(reader)); // Bitmaps case (int)SwfTagType.DefineBits: return(UnsupportedTag.Create(SwfTagType.DefineBits)); case (int)SwfTagType.JPEGTables: return(UnsupportedTag.Create(SwfTagType.JPEGTables)); case (int)SwfTagType.DefineBitsJPEG2: return(UnsupportedTag.Create(SwfTagType.DefineBitsJPEG2)); case (int)SwfTagType.DefineBitsJPEG3: return(UnsupportedTag.Create(SwfTagType.DefineBitsJPEG3)); case (int)SwfTagType.DefineBitsLossless: return(DefineBitsLosslessTag.Create(reader)); case (int)SwfTagType.DefineBitsLossless2: return(DefineBitsLossless2Tag.Create(reader)); case (int)SwfTagType.DefineBitsJPEG4: return(UnsupportedTag.Create(SwfTagType.DefineBitsJPEG4)); // Shape Morphing case (int)SwfTagType.DefineMorphShape: return(UnsupportedTag.Create(SwfTagType.DefineMorphShape)); case (int)SwfTagType.DefineMorphShape2: return(UnsupportedTag.Create(SwfTagType.DefineMorphShape2)); // Fonts and Text case (int)SwfTagType.DefineFont: return(UnsupportedTag.Create(SwfTagType.DefineFont)); case (int)SwfTagType.DefineFontInfo: return(UnsupportedTag.Create(SwfTagType.DefineFontInfo)); case (int)SwfTagType.DefineFontInfo2: return(UnsupportedTag.Create(SwfTagType.DefineFontInfo2)); case (int)SwfTagType.DefineFont2: return(UnsupportedTag.Create(SwfTagType.DefineFont2)); case (int)SwfTagType.DefineFont3: return(UnsupportedTag.Create(SwfTagType.DefineFont3)); case (int)SwfTagType.DefineFontAlignZones: return(UnsupportedTag.Create(SwfTagType.DefineFontAlignZones)); case (int)SwfTagType.DefineFontName: return(UnsupportedTag.Create(SwfTagType.DefineFontName)); case (int)SwfTagType.DefineText: return(UnsupportedTag.Create(SwfTagType.DefineText)); case (int)SwfTagType.DefineText2: return(UnsupportedTag.Create(SwfTagType.DefineText2)); case (int)SwfTagType.DefineEditText: return(UnsupportedTag.Create(SwfTagType.DefineEditText)); case (int)SwfTagType.CSMTextSettings: return(UnsupportedTag.Create(SwfTagType.CSMTextSettings)); case (int)SwfTagType.DefineFont4: return(UnsupportedTag.Create(SwfTagType.DefineFont4)); // Sounds case (int)SwfTagType.DefineSound: return(UnsupportedTag.Create(SwfTagType.DefineSound)); case (int)SwfTagType.StartSound: return(UnsupportedTag.Create(SwfTagType.StartSound)); case (int)SwfTagType.StartSound2: return(UnsupportedTag.Create(SwfTagType.StartSound2)); case (int)SwfTagType.SoundStreamHead: return(UnsupportedTag.Create(SwfTagType.SoundStreamHead)); case (int)SwfTagType.SoundStreamHead2: return(UnsupportedTag.Create(SwfTagType.SoundStreamHead2)); case (int)SwfTagType.SoundStreamBlock: return(UnsupportedTag.Create(SwfTagType.SoundStreamBlock)); // Buttons case (int)SwfTagType.DefineButton: return(UnsupportedTag.Create(SwfTagType.DefineButton)); case (int)SwfTagType.DefineButton2: return(UnsupportedTag.Create(SwfTagType.DefineButton2)); case (int)SwfTagType.DefineButtonCxform: return(UnsupportedTag.Create(SwfTagType.DefineButtonCxform)); case (int)SwfTagType.DefineButtonSound: return(UnsupportedTag.Create(SwfTagType.DefineButtonSound)); // Sprites and Movie Clips case (int)SwfTagType.DefineSprite: return(DefineSpriteTag.Create(reader)); // Video case (int)SwfTagType.DefineVideoStream: return(UnsupportedTag.Create(SwfTagType.DefineVideoStream)); case (int)SwfTagType.VideoFrame: return(UnsupportedTag.Create(SwfTagType.VideoFrame)); // Metadata case (int)SwfTagType.FileAttributes: return(FileAttributesTag.Create(reader)); case (int)SwfTagType.EnableTelemetry: return(EnableTelemetryTag.Create(reader)); case (int)SwfTagType.DefineBinaryData: return(DefineBinaryDataTag.Create(reader)); default: return(UnknownTag.Create(tag_data.TagId)); } }
/// <summary> /// Initializes a new instance of the <see cref="MailKit.Metadata"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="Metadata"/>. /// </remarks> /// <param name="tag">The metadata tag.</param> /// <param name="value">The metadata value.</param> public Metadata(MetadataTag tag, string value) { Value = value; Tag = tag; }
public void FreeImage_SetMetadata() { MetadataTag tag; Random rand = new Random(); dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); Assert.IsFalse(dib.IsNull); ushort value = (ushort)rand.Next(); tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_CUSTOM); tag.ID = value; Assert.IsTrue(FreeImage.SetMetadata(FREE_IMAGE_MDMODEL.FIMD_CUSTOM, dib, "~~~~~", tag)); Assert.IsTrue(FreeImage.GetMetadata(FREE_IMAGE_MDMODEL.FIMD_CUSTOM, dib, "~~~~~", out tag)); Assert.AreEqual(value, tag.ID); FreeImage.UnloadEx(ref dib); }
/// <summary> /// Asynchronously gets the specified metadata. /// </summary> /// <remarks> /// Gets the specified metadata. /// </remarks> /// <returns>The requested metadata value.</returns> /// <param name="tag">The metadata tag.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="ImapClient"/> has been disposed. /// </exception> /// <exception cref="ServiceNotConnectedException"> /// The <see cref="ImapClient"/> is not connected. /// </exception> /// <exception cref="ServiceNotAuthenticatedException"> /// The <see cref="ImapClient"/> is not authenticated. /// </exception> /// <exception cref="System.NotSupportedException"> /// The IMAP server does not support the METADATA or METADATA-SERVER extension. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The operation was canceled via the cancellation token. /// </exception> /// <exception cref="System.IO.IOException"> /// An I/O error occurred. /// </exception> /// <exception cref="ImapProtocolException"> /// The server's response contained unexpected tokens. /// </exception> /// <exception cref="ImapCommandException"> /// The server replied with a NO or BAD response. /// </exception> public override Task <string> GetMetadataAsync(MetadataTag tag, CancellationToken cancellationToken = default(CancellationToken)) { return(GetMetadataAsync(tag, true, cancellationToken)); }
public void MetadataModel() { MetadataTag tag; dib = FreeImage.Allocate(1, 1, 1, 0, 0, 0); Assert.IsFalse(dib.IsNull); MetadataModel model = new MDM_GEOTIFF(dib); Assert.AreEqual(0, model.Count); Assert.IsFalse(model.Exists); Assert.IsEmpty(model.List); Assert.AreEqual(model.Model, FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); Assert.IsTrue(model.DestoryModel()); foreach (MetadataTag m in model) Assert.Fail(); tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); tag.Key = "KEY"; tag.Value = 54321f; Assert.IsTrue(model.AddTag(tag)); Assert.AreEqual(1, model.Count); Assert.IsTrue(model.Exists); Assert.IsNotEmpty(model.List); Assert.AreEqual(model.Model, FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); Assert.IsTrue(model.DestoryModel()); Assert.AreEqual(0, model.Count); Assert.IsFalse(model.Exists); Assert.IsEmpty(model.List); Assert.AreEqual(model.Model, FREE_IMAGE_MDMODEL.FIMD_GEOTIFF); FreeImage.UnloadEx(ref dib); }
SwfTagBase ISwfTagVisitor <ISwfStreamReader, SwfTagBase> .Visit(MetadataTag tag, ISwfStreamReader reader) { tag.Metadata = reader.ReadString(); return(tag); }
/// <summary> /// Returns the set of listable tags for the current Tennant. /// </summary> /// <param name="tag">The tag whose children to list. If null, only toplevel tags will be returned.</param> /// <returns>The list of listable tags.</returns> public MetadataTags GetListableTags( MetadataTag tag ) { return GetListableTags( tag.Name ); }
/// <summary> /// Match messages using a saved search filter. /// </summary> /// <remarks> /// Matches messages using a saved search filter. /// </remarks> /// <returns>A <see cref="FilterSearchQuery"/>.</returns> /// <param name="filter">The name of the saved search.</param> public static SearchQuery Filter(MetadataTag filter) { return(new FilterSearchQuery(filter)); }
/// <summary> /// Lists all objects with the given tag. /// </summary> /// <param name="tag">Tag the tag to search for</param> /// <param name="options">Options for listing the objects. After calling ListObjects, be sure to check the value of the token property to see if there are additional results.</param> /// <returns>The list of objects with the given tag. If no objects are found the array will be empty.</returns> /// <exception cref="T:EsuApiLib.EsuException">if no objects are found (code 1003)</exception> public List<ObjectResult> ListObjects(MetadataTag tag, ListOptions options) { return ListObjects( tag.Name, options ); }
ITagFormatter ISwfTagVisitor <object, ITagFormatter> .Visit(MetadataTag tag, object arg) { return(new MetadataTagFormatter()); }
/// <summary> /// Adds new tag to the bitmap or updates its value in case it already exists. /// <see cref="FreeImageAPI.Metadata.MetadataTag.Key"/> will be used as key. /// </summary> /// <param name="tag">The tag to add or update.</param> /// <returns>Returns true on success, false on failure.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="tag"/> is null.</exception> /// <exception cref="ArgumentException"> /// The tags model differs from this instances model.</exception> public bool AddTag(MetadataTag tag) { if (tag == null) { throw new ArgumentNullException("tag"); } if (tag.Model != Model) { throw new ArgumentException("tag.Model"); } return tag.AddToImage(dib); }
public void TestArgumentExceptions() { Assert.Throws <ArgumentNullException> (() => SearchQuery.And(null, SearchQuery.All)); Assert.Throws <ArgumentNullException> (() => SearchQuery.And(SearchQuery.All, null)); Assert.Throws <ArgumentNullException> (() => SearchQuery.AnnotationsContain(null, AnnotationAttribute.Value, "value")); Assert.Throws <ArgumentNullException> (() => SearchQuery.AnnotationsContain(AnnotationEntry.AltSubject, null, "value")); Assert.Throws <ArgumentException> (() => SearchQuery.AnnotationsContain(AnnotationEntry.AltSubject, AnnotationAttribute.Size, "value")); Assert.Throws <ArgumentNullException> (() => SearchQuery.BccContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.BccContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.BodyContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.BodyContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.CcContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.CcContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.DoesNotHaveCustomFlag(null)); Assert.Throws <ArgumentException> (() => SearchQuery.DoesNotHaveCustomFlag(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.DoesNotHaveCustomFlags(null)); Assert.Throws <ArgumentException> (() => SearchQuery.DoesNotHaveCustomFlags(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.DoesNotHaveFlags(MessageFlags.None)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Filter(null)); Assert.Throws <ArgumentException> (() => SearchQuery.Filter(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.FromContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.FromContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Fuzzy(null)); Assert.Throws <ArgumentNullException> (() => SearchQuery.GMailRawSearch(null)); Assert.Throws <ArgumentException> (() => SearchQuery.GMailRawSearch(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasCustomFlag(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasCustomFlag(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasCustomFlags(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasCustomFlags(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.HasFlags(MessageFlags.None)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasKeyword(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasKeyword(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasKeywords(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasKeywords(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.HasKeywords(new string[] { "keyword", null })); Assert.Throws <ArgumentException> (() => SearchQuery.NotFlags(MessageFlags.None)); Assert.Throws <ArgumentNullException> (() => SearchQuery.NotKeyword(null)); Assert.Throws <ArgumentException> (() => SearchQuery.NotKeyword(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.NotKeywords(null)); Assert.Throws <ArgumentException> (() => SearchQuery.NotKeywords(new string[0])); Assert.Throws <ArgumentException> (() => SearchQuery.NotKeywords(new string [] { "keyword", null })); Assert.Throws <ArgumentNullException> (() => SearchQuery.HasGMailLabel(null)); Assert.Throws <ArgumentException> (() => SearchQuery.HasGMailLabel(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.HeaderContains(null, "text")); Assert.Throws <ArgumentException> (() => SearchQuery.HeaderContains(string.Empty, "text")); Assert.Throws <ArgumentNullException> (() => SearchQuery.HeaderContains("name", null)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.LargerThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.MessageContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.MessageContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Not(null)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.OlderThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Or(null, SearchQuery.All)); Assert.Throws <ArgumentNullException> (() => SearchQuery.Or(SearchQuery.All, null)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.SmallerThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.SubjectContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.SubjectContains(string.Empty)); Assert.Throws <ArgumentNullException> (() => SearchQuery.ToContains(null)); Assert.Throws <ArgumentException> (() => SearchQuery.ToContains(string.Empty)); Assert.Throws <ArgumentOutOfRangeException> (() => SearchQuery.YoungerThan(-1)); Assert.Throws <ArgumentNullException> (() => SearchQuery.All.And(null)); Assert.Throws <ArgumentNullException> (() => SearchQuery.All.Or(null)); Assert.Throws <ArgumentNullException> (() => new BinarySearchQuery(SearchTerm.And, null, SearchQuery.All)); Assert.Throws <ArgumentNullException> (() => new BinarySearchQuery(SearchTerm.And, SearchQuery.All, null)); Assert.Throws <ArgumentNullException> (() => new FilterSearchQuery(null)); Assert.Throws <ArgumentException> (() => new FilterSearchQuery(string.Empty)); Assert.Throws <ArgumentException> (() => new FilterSearchQuery(MetadataTag.Create("/dev/null"))); Assert.Throws <ArgumentNullException> (() => new HeaderSearchQuery(null, "text")); Assert.Throws <ArgumentException> (() => new HeaderSearchQuery(string.Empty, "text")); Assert.Throws <ArgumentNullException> (() => new HeaderSearchQuery("name", null)); Assert.Throws <ArgumentNullException> (() => new TextSearchQuery(SearchTerm.BodyContains, null)); Assert.Throws <ArgumentNullException> (() => new UidSearchQuery(null)); Assert.Throws <ArgumentException> (() => new UidSearchQuery(new UniqueIdSet())); Assert.Throws <ArgumentException> (() => new UidSearchQuery(UniqueId.Invalid)); Assert.Throws <ArgumentNullException> (() => new UnarySearchQuery(SearchTerm.Not, null)); }
/// <summary> /// Gets the specified metadata. /// </summary> /// <remarks> /// Gets the specified metadata. /// </remarks> /// <returns>The requested metadata value.</returns> /// <param name="tag">The metadata tag.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="ImapClient"/> has been disposed. /// </exception> /// <exception cref="ServiceNotConnectedException"> /// The <see cref="ImapClient"/> is not connected. /// </exception> /// <exception cref="ServiceNotAuthenticatedException"> /// The <see cref="ImapClient"/> is not authenticated. /// </exception> /// <exception cref="System.NotSupportedException"> /// The IMAP server does not support the METADATA extension. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The operation was canceled via the cancellation token. /// </exception> /// <exception cref="System.IO.IOException"> /// An I/O error occurred. /// </exception> /// <exception cref="ImapProtocolException"> /// The server's response contained unexpected tokens. /// </exception> /// <exception cref="ImapCommandException"> /// The server replied with a NO or BAD response. /// </exception> public override string GetMetadata (MetadataTag tag, CancellationToken cancellationToken = default (CancellationToken)) { CheckState (false, false); if ((Engine.Capabilities & ImapCapabilities.Metadata) == 0) throw new NotSupportedException ("The IMAP server does not support the METADATA extension."); var ic = new ImapCommand (Engine, cancellationToken, null, "GETMETADATA %F (%S)\r\n", this, tag.Id); ic.RegisterUntaggedHandler ("METADATA", UntaggedMetadata); var metadata = new MetadataCollection (); ic.UserData = metadata; Engine.QueueCommand (ic); Engine.Wait (ic); ProcessResponseCodes (ic, null); if (ic.Response != ImapCommandResponse.Ok) throw ImapCommandException.Create ("GETMETADATA", ic); for (int i = 0; i < metadata.Count; i++) { if (metadata[i].Tag.Id == tag.Id) return metadata[i].Value; } return null; }
public void AddTag() { Model.Tags.Add(Tag); Tag = new MetadataTag(); }