public static Type GetPropertyType(PropertyTag tag) { switch (tag) { case PropertyTag.ImageWidth: case PropertyTag.ImageHeight: return typeof(int); case PropertyTag.ImageDescription: case PropertyTag.EquipMake: case PropertyTag.EquipModel: case PropertyTag.SoftwareUsed: case PropertyTag.ExifUserComment: return typeof(string); case PropertyTag.Orientation: return typeof(RotateFlipType); case PropertyTag.ExifLightSource: return typeof(LightSource); case PropertyTag.ExifDTOrig: case PropertyTag.ExifDTDigitized: return typeof(DateTime); case PropertyTag.ExifISOSpeed: return typeof(short); } return typeof(object); }
public FixPropValue(PropertyTag propertyTag) : base() { _fixedPropType = FTFactory.Instance.CreateFixedPropType(); _propInfo = FTFactory.Instance.CreatePropInfo(propertyTag); _fixedSizeValue = FTFactory.Instance.CreateFixedSizeValue(_fixedPropType, propertyTag.PropType); Children.Add(_fixedPropType); Children.Add(_propInfo); Children.Add(_fixedSizeValue); }
private static PropertyGetter <FractionUInt32[]> ReadFractionUInt32Array(PropertyTag tag, int?count = null) { return((Image img, out FractionUInt32[] value) => { if (ReadProperty(img, tag, PropertyTagType.URational, count * 2 * sizeof(uint), out value)) { return true; } value = default; return false; }); }
private static PropertyGetter <string> ReadString(PropertyTag tag) { return((Image img, out string value) => { if (ReadProperty(img, tag, PropertyTagType.ASCII, null, out byte[] encoded)) { value = Encoding.UTF8.GetString(encoded).TrimEnd('\0'); return true; } value = default; return false; });
public virtual FArchive Serialize(FArchive archive) { foreach (var tag in PropertyTag.ReadToEnd(archive)) { Vars.Add(new TaggedItem(tag.Name, PropertyFactory.Get(archive.SubStream(tag.Size), tag))); if (archive.Tell() != tag.PropertyEnd) { Debug.WriteLine($"Needed to move by {tag.PropertyEnd - archive.Tell()} for {tag.Name} {(tag.TypeEnum == PropertyTag.PropertyType.StructProperty ? tag.StructName : tag.Type)}"); archive.Seek(tag.PropertyEnd); } } return(archive); }
/// <summary> /// Adds a property when it not exists, otherwise it is replaced /// </summary> /// <param name="mapiTag">The <see cref="PropertyTag" /></param> /// <param name="obj">The value for the mapi tag</param> /// <param name="flags"> /// the flags to set on the property, default <see cref="PropertyFlags.PROPATTR_READABLE" /> /// and <see cref="PropertyFlags.PROPATTR_WRITABLE" /> /// </param> /// <exception cref="ArgumentNullException">Raised when <paramref name="obj" /> is <c>null</c></exception> internal void AddOrReplaceProperty(PropertyTag mapiTag, object obj, PropertyFlags flags = PropertyFlags.PROPATTR_READABLE | PropertyFlags.PROPATTR_WRITABLE) { var index = FindIndex(m => m.Id == mapiTag.Id); if (index >= 0) { RemoveAt(index); } AddProperty(mapiTag, obj, flags); }
public override bool IsTagRight(PropertyTag propertyTag) { if (propertyTag.Data == _fxDelTag) { HasData = true; return true; } else { HasData = false; return false; } }
public override FArchive Serialize(FArchive reader, PropertyTag tag) { ObjectReference?declaredIn = default; reader.Read(ref declaredIn); if (declaredIn.Resource != null) { EFunctionFlags flags = default; reader.ReadUnsafe(ref flags); reader.Read(ref _value); } return(reader); }
internal static PropertyTag[] ConvertFromMapiPropTags(PropTag[] mapiPropTags) { if (mapiPropTags == null) { return(null); } PropertyTag[] array = new PropertyTag[mapiPropTags.Length]; for (int i = 0; i < mapiPropTags.Length; i++) { array[i] = ConvertHelper.ConvertFromMapiPropTag(mapiPropTags[i]); } return(array); }
public static PropertyTag[] MoMTPtaFromPta(PropTag[] pta) { if (pta == null) { return(null); } PropertyTag[] array = new PropertyTag[pta.Length]; for (int i = 0; i < pta.Length; i++) { array[i] = PstMailbox.MoMTPtagFromPtag(pta[i]); } return(array); }
public virtual Stream SetPropertyStream(PropertyTag propertyTag, long dataSizeEstimate) { IProperty property = null; if (!this.iPstPropertyBag.Properties.TryGetValue((ushort)propertyTag.PropertyId, out property)) { property = this.iPstPropertyBag.AddProperty(propertyTag); } if (property == null) { throw new NullReferenceException("Cannot SetPropertyStream on a null pstProperty"); } return(new PSTPropertyStream(false, property)); }
public VarPropValue(PropertyTag propertyTag) : base() { PropTag = propertyTag; _varPropType = FTFactory.Instance.CreateVarPropType(); _propInfo = FTFactory.Instance.CreatePropInfo(propertyTag); _length = FTFactory.Instance.CreatePropValueLength(); _varSizeValue = FTFactory.Instance.CreateVarSizeValue(_varPropType, _length, propertyTag.PropType); Children.Add(_varPropType); Children.Add(_propInfo); Children.Add(_length); Children.Add(_varSizeValue); }
public MvPropValue(PropertyTag propertyTag) : base() { PropTag = propertyTag; _mvPropType = FTFactory.Instance.CreateMvPropType(); _propInfo = FTFactory.Instance.CreatePropInfo(propertyTag); _length = FTFactory.Instance.CreatePropValueLength(); _SizeValue = FTFactory.Instance.CreateSizeValue(propertyTag, _length); Children.Add(_mvPropType); Children.Add(_propInfo); Children.Add(_length); Children.Add(_SizeValue); }
/// <summary> /// Find a folder ID in the specified folder and with specified display name. /// </summary> /// <param name="parentFolderId">ID of the parent Folder.</param> /// <param name="logonHandle">The logon object handle.</param> /// <param name="folderName">The folder display name.</param> /// <returns>The folder ID.</returns> protected ulong GetSubfolderIDByName(ulong parentFolderId, uint logonHandle, string folderName) { ulong folderId = 0; uint parentFolderHandle = 0; this.OpenFolder(logonHandle, parentFolderId, ref parentFolderHandle); RopGetHierarchyTableRequest getHierarchyTableRequest = new RopGetHierarchyTableRequest { RopId = (byte)RopId.RopGetHierarchyTable, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, TableFlags = (byte)FolderTableFlags.Depth }; RopGetHierarchyTableResponse getHierarchyTableResponse = this.Adapter.GetHierarchyTable(getHierarchyTableRequest, parentFolderHandle, ref this.responseHandles); uint tableHandle = this.responseHandles[0][getHierarchyTableResponse.OutputHandleIndex]; PropertyTag[] properties = new PropertyTag[] { new PropertyTag() { PropertyId = (ushort)FolderPropertyId.PidTagDisplayName, PropertyType = (ushort)PropertyType.PtypString }, new PropertyTag() { PropertyId = (ushort)FolderPropertyId.PidTagFolderId, PropertyType = (ushort)PropertyType.PtypInteger64 } }; List <PropertyRow> propertyRows = this.GetTableRowValue(tableHandle, (ushort)getHierarchyTableResponse.RowCount, properties); if (propertyRows != null) { foreach (PropertyRow propertyRow in propertyRows) { byte[] displayNameInBytes = propertyRow.PropertyValues[0].Value; string displayName = Encoding.Unicode.GetString(displayNameInBytes, 0, displayNameInBytes.Length); if (displayName.Equals(folderName, StringComparison.CurrentCultureIgnoreCase)) { byte[] folderIdInBytes = propertyRow.PropertyValues[1].Value; folderId = (ulong)BitConverter.ToInt64(folderIdInBytes, 0); break; } } } return(folderId); }
public FArchive Serialize(FArchive archive) { foreach (var tag in PropertyTag.ReadToEnd(archive)) { // TODO: Implement overriding processing? if (tag.Name.ToString() == "BindingIdToReferences") { int x = 0; archive.Read(ref x); archive.Read(ref BindingIdToReferences); } } return(archive); }
/// <summary> /// Compare whether two AddressBookPropValueLists are equal. /// </summary> /// <param name="addressBookPropValueList1">The first AddressBookPropValueList used to compare.</param> /// <param name="addressBookPropValueList2">The second AddressBookPropValueList used to compare.</param> /// <returns>Returns true if they are equal; otherwise false.</returns> public static bool AreTwoAddressBookPropValueListEqual(AddressBookPropValueList addressBookPropValueList1, AddressBookPropValueList addressBookPropValueList2) { if (addressBookPropValueList1.PropertyValueCount != addressBookPropValueList2.PropertyValueCount) { site.Log.Add( LogEntryKind.Debug, "The length the two AddressBookPropValueList are not equal. The length of addressBookPropValueList1 is {0}, the length of addressBookPropValueList2 is {1}.", addressBookPropValueList1.PropertyValueCount, addressBookPropValueList2.PropertyValueCount); return(false); } else { TaggedPropertyValue[] propertyValues1 = addressBookPropValueList1.PropertyValues; TaggedPropertyValue[] propertyValues2 = addressBookPropValueList2.PropertyValues; for (int i = 0; i < propertyValues1.Length; i++) { PropertyTag propertyTag1 = propertyValues1[i].PropertyTag; PropertyTag propertyTag2 = propertyValues2[i].PropertyTag; if (propertyTag1.PropertyId != propertyTag2.PropertyId) { site.Log.Add( LogEntryKind.Debug, "The property ID of property {0} in the two property tag array are not equal. The property ID of propertyTag1 is {1}, the property ID of propertyTag2 is {2}", i, propertyTag1.PropertyId, propertyTag2.PropertyId); return(false); } else if (propertyTag1.PropertyType != propertyTag2.PropertyType) { site.Log.Add( LogEntryKind.Debug, "The property type of property {0} in the two property tag array are not equal. The property type of propertyTag1 is {1}, the property type of propertyTag2 is {2}", i, propertyTag1.PropertyType, propertyTag2.PropertyType); return(false); } } } return(true); }
public override FArchive Serialize(FArchive reader, PropertyTag tag) { ObjectReference?declaredIn = default; reader.Read(ref declaredIn); if (tag.Size > 4) { reader.Read(ref _value); } else { Debugger.Break(); } return(reader); }
private static bool ReadProperty <T>(Image img, PropertyTag tag, PropertyTagType type, int?length, out T value) { if (Array.IndexOf(img.PropertyIdList, (int)tag) != -1) { var property = img.GetPropertyItem((int)tag); if (property.Type == (short)type && ParseValue(type, length, property.Value, out var obj) && obj is T asT) { value = asT; return(true); } } value = default; return(false); }
public override void Deserialize(FArchive reader, PropertyTag tag) { base.Deserialize(reader, tag); var info = tag; if (tag.InnerTypeEnum == PropertyTag.PropertyType.StructProperty) { reader.Read(out info); } if ((tag.InnerTypeEnum == PropertyTag.PropertyType.ByteProperty && tag.EnumName is null) || tag.InnerTypeEnum == PropertyTag.PropertyType.BoolProperty) { reader.Read(out Memory <byte> bytes, Count); _value = bytes.ToArray(); }
/// <summary> /// Read a TaggedPropertyValue structure from buffer. /// </summary> /// <param name="buffer">Buffer contain TaggedPropertyValue instance</param> /// <returns>A TaggedPropertyvalue structure</returns> public static TaggedPropertyValue ReadTaggedProperty(byte[] buffer) { TaggedPropertyValue tagValue = new TaggedPropertyValue(); BufferReader bufferReader = new BufferReader(buffer); PropertyTag newPropertyTag = new PropertyTag { PropertyType = bufferReader.ReadUInt16(), PropertyId = bufferReader.ReadUInt16() }; tagValue.PropertyTag = newPropertyTag; tagValue.Value = ReadValueByType(tagValue.PropertyTag.PropertyType, bufferReader.ReadToEnd()); return(tagValue); }
public override FArchive Serialize(FArchive reader, PropertyTag tag) { base.Serialize(reader, tag); var info = tag; if (tag.InnerTypeEnum == PropertyTag.PropertyType.StructProperty) { reader.Read(ref info); } if ((tag.InnerTypeEnum == PropertyTag.PropertyType.ByteProperty && tag.EnumName is null) || tag.InnerTypeEnum == PropertyTag.PropertyType.BoolProperty) { byte[]? bytes = default; reader.Read(ref bytes, Count); _value = bytes.ToArray(); }
public override void Deserialize(FArchive reader, PropertyTag tag) { reader.Read(out int unknown); base.Deserialize(reader, tag); if (tag.InnerTypeEnum.TryGetAttribute(out LinkedTypeAttribute? attrib)) { _value = new HashSet <IProperty>(Count); var func = PropertyFactory.Get(attrib.LinkedType); for (int i = 0; i < Count; i++) { var prop = func(); prop.Deserialize(reader, tag); _value.Add(prop); } } }
private Tuple <PropertyId, BinaryData> AllocatePropertyOnSubnode( PropertyTag propertyTag, PropertyValue propertyValue, InternalNIDAllocator nidAllocator, List <Tuple <NID, BID> > propertiesAllocatedOnSubnodes) { var dataTreeRootBlockId = dataTreeAllocator.Allocate(new[] { propertyValue.Value }); var nid = nidAllocator.New(); var hnid = new HNID(nid); propertiesAllocatedOnSubnodes.Add(Tuple.Create(nid, dataTreeRootBlockId)); return(Tuple.Create(propertyTag.Id, hnidEncoder.Encode(hnid))); }
AnnotatedPropertyValue IPropertyBag.GetAnnotatedProperty(PropertyTag propertyTag) { NamedProperty namedProperty = null; object obj = this[propertyTag]; PropertyValue propertyValue = (obj != null) ? new PropertyValue(propertyTag, obj) : PropertyValue.Error(propertyTag.PropertyId, (ErrorCode)2147746063U); if (propertyTag.IsNamedProperty) { this.session.TryResolveToNamedProperty(propertyTag, out namedProperty); if (namedProperty == null) { propertyValue = PropertyValue.Error(propertyTag.PropertyId, (ErrorCode)2147746063U); } } return(new AnnotatedPropertyValue(propertyTag, propertyValue, namedProperty)); }
internal object this[PropertyTag propertyTag] { get { object result; if (!this.values.TryGetValue(propertyTag, out result)) { return(null); } return(result); } set { this.values[propertyTag] = value; } }
/// <summary> /// PropertyTag for the message. /// </summary> /// <returns>Array of PropertyTag</returns> private PropertyTag[] CreateMessageSamplePropertyTags() { PropertyTag[] propertyTags = new PropertyTag[1]; PropertyTag tag = new PropertyTag { PropertyId = this.propertyDictionary[PropertyNames.PidTagLastModificationTime].PropertyId, PropertyType = this.propertyDictionary[PropertyNames.PidTagLastModificationTime].PropertyType }; // PidTagLastModificationTime // PtypTime propertyTags[0] = tag; return(propertyTags); }
/// <summary> /// Deserialized byte array to a TagActionData instance /// </summary> /// <param name="buffer">Byte array contains data of an ActionData instance.</param> /// <returns>Bytes count that deserialized in buffer.</returns> public uint Deserialize(byte[] buffer) { BufferReader bufferReader = new BufferReader(buffer); PropertyTag propertyTag = new PropertyTag { PropertyType = bufferReader.ReadUInt16(), PropertyId = bufferReader.ReadUInt16() }; this.PropertyTag = propertyTag; uint size = bufferReader.Position; this.PropertyValue = AdapterHelper.ReadValueByType(this.PropertyTag.PropertyType, bufferReader.ReadToEnd()); size += (uint)this.PropertyValue.Length; return(size); }
public static string GetPropertyString(this Image image, PropertyTag property) { if (!image.HasProperty(property)) { return(string.Empty); } PropertyItem item = image.GetPropertyItem((Int32)property); if (item.Type != (short)PropertyType.AsciiString) { return(string.Empty); } byte[] buffer = item.Value; return(Encoding.ASCII.GetString(buffer).Trim('\0')); }
public static UInt16 GetPropertyUInt16(this Image image, PropertyTag property) { if (!image.HasProperty(property)) { return(0); } PropertyItem item = image.GetPropertyItem((Int32)property); if (item.Type != (short)PropertyType.UnsignedShort) { return(0); } byte[] buffer = item.Value; return(BitConverter.ToUInt16(buffer, 0)); }
public IEnumerable <AnnotatedPropertyValue> GetAnnotatedProperties() { foreach (KeyValuePair <PropertyDefinition, object> prop in ((IEnumerable <KeyValuePair <PropertyDefinition, object> >) this.propertyBag)) { KeyValuePair <PropertyDefinition, object> keyValuePair = prop; if (!PropertyError.IsPropertyError(keyValuePair.Value)) { KeyValuePair <PropertyDefinition, object> keyValuePair2 = prop; PropertyTag propertyTag = new PropertyTag(((PropertyTagPropertyDefinition)keyValuePair2.Key).PropertyTag); PropertyTag propertyTag2 = propertyTag; PropertyTag propertyTag3 = propertyTag; KeyValuePair <PropertyDefinition, object> keyValuePair3 = prop; yield return(new AnnotatedPropertyValue(propertyTag2, new PropertyValue(propertyTag3, keyValuePair3.Value), null)); } } yield break; }
private Tuple <PropertyId, BinaryData> AllocatePropertyOnTheHN( PropertyTag propertyTag, PropertyValue propertyValue, IHeapOnNodeGenerator hnGenerator) { var propertyValueInHN = BinaryDataGenerator .New() .Append((short)propertyTag.Type.Value) .Append(propertyValue.Value) .GetData(); var hid = hnGenerator.AllocateItem(propertyValueInHN); var hnid = new HNID(hid); return(Tuple.Create(propertyTag.Id, hnidEncoder.Encode(hnid))); }
/// <summary> /// Adds the given multivalue propertyTag to the message, any already existing <see cref="PropertyTag" /> is /// overwritten. /// </summary> /// <param name="propertyTag">List of <see cref="PropertyTag" /></param> /// <param name="values">The values</param> /// <returns></returns> /// <exception cref="MKInvalidProperty"> /// Raised when the <paramref name="propertyTag" /> is not of the type /// <see cref="PropertyType.PT_MV_STRING8" /> or <see cref="PropertyType.PT_MV_UNICODE" /> /// </exception> internal void AddStrings(PropertyTag propertyTag, List <string> values) { // “__substg1.0_<tag>-00000000”, “__substg1.0_<tag>-00000001”, etc… var index = 0; var name = propertyTag.Name + "-" + index.ToString().PadLeft(8, '0'); var stream = CompoundFile.RootStorage.TryGetStream(name); while (stream != null) { index += 1; name = propertyTag.Name + "-" + index.ToString().PadLeft(8, '0'); stream = CompoundFile.RootStorage.TryGetStream(name); CompoundFile.RootStorage.Delete(name); } index = 0; foreach (var value in values) { name = propertyTag.Name + "-" + index.ToString().PadLeft(8, '0'); stream = CompoundFile.RootStorage.TryGetStream(name); if (stream != null) { switch (propertyTag.Type) { case PropertyType.PT_MV_STRING8: case PropertyType.PT_MV_UNICODE: stream.SetData(Encoding.Unicode.GetBytes(value)); break; default: throw new MKInvalidProperty("The property is not of the type PT_MV_STRING8 or PT_MV_UNICODE"); } } else { stream = CompoundFile.RootStorage.AddStream(propertyTag.Name); stream.SetData(Encoding.Unicode.GetBytes(value)); } index += 1; } }
private void AddMultiValueStreams(PropertyTag mapiTag, object obj, PropertyFlags flags) { var values = (string[])obj; var singleValueType = GetSingleTypeFromMultiValueType(mapiTag.Type); var index = 0; foreach (var val in values) { var nullTerm = nullTerminator(singleValueType); Add(new Property( mapiTag.Id, mapiTag.Type, flags, asBytes(singleValueType, val).Concat(nullTerm).ToArray(), index)); index++; } }
public bool TryResolveToNamedProperty(PropertyTag propertyTag, out NamedProperty namedProperty) { namedProperty = null; INamedProperty namedProperty2 = null; if (!propertyTag.IsNamedProperty || !this.pstMailbox.IPst.ReadNamedPropertyTable().TryGetValue((ushort)propertyTag.PropertyId, out namedProperty2)) { return(false); } try { namedProperty = (namedProperty2.IsString ? new NamedProperty(namedProperty2.Guid, namedProperty2.Name) : new NamedProperty(namedProperty2.Guid, namedProperty2.Id)); } catch (ArgumentException ex) { throw new ExArgumentException(ex.Message, ex); } return(true); }
/// <summary> /// Create Permission PropertyTags /// </summary> /// <returns>Return propertyTag array</returns> private PropertyTag[] CreatePermissionPropertyTags() { // The following sample tags is from MS-OXCPERM 4.1 PropertyTag[] propertyTags = new PropertyTag[4]; // PidTagMemberId propertyTags[0] = this.propertyDictionary[PropertyNames.PidTagMemberId]; // PidTagMemberName propertyTags[1] = this.propertyDictionary[PropertyNames.PidTagMemberName]; // PidTagMemberRights propertyTags[2] = this.propertyDictionary[PropertyNames.PidTagMemberRights]; // PidTagEntryId propertyTags[3] = this.propertyDictionary[PropertyNames.PidTagEntryId]; return(propertyTags); }
private static Property createProperty(PropertyTag art, string name, Type type) { switch (art) { case PropertyTag.Simple: return new SimpleProperty(name, type); case PropertyTag.Complex: return new ComplexProperty(name, type); case PropertyTag.Collection: return new CollectionProperty(name, type); case PropertyTag.Dictionary: return new DictionaryProperty(name, type); case PropertyTag.SingleArray: return new SingleDimensionalArrayProperty(name, type); case PropertyTag.MultiArray: return new MultiDimensionalArrayProperty(name, type); case PropertyTag.Null: return new NullProperty(name); default: return null; } }
public static object GetPropertyValue(Image image, PropertyTag tag) { if (image == null) { throw new ArgumentNullException(); } try { return GetPropertyValue(image.GetPropertyItem((int) tag)); } catch (ArgumentException) { return null; } }
public static PropertyItem GetPropertyItem( this Image image, PropertyTag property ) => image.GetPropertyItem( (int)property );
public override bool IsTagRight(PropertyTag propertyTag) { return propertyTag.Data == _fxDelTag; }
public static string GetPropertyString(this Image image, PropertyTag property) { if (!image.HasProperty(property)) return string.Empty; PropertyItem item = image.GetPropertyItem((Int32)property); if (item.Type != (short)PropertyType.AsciiString) return string.Empty; byte[] buffer = item.Value; return Encoding.ASCII.GetString(buffer).Trim('\0'); }
private Property deserialize(XmlReader reader, PropertyTag propertyTag, Type expectedType) { // Establish the property name string propertyName = getNameAttribute(reader); // Establish the property type Type propertyType = getTypeAttribute(reader); // id propertyType is not defined, we'll take the expectedType if (propertyType == null) { propertyType = expectedType; } // create the property var property = createProperty(propertyTag, propertyName, propertyType); if (property == null) return property; // is it simple property? var simpleProperty = property as SimpleProperty; if (simpleProperty != null) { parseSimpleProperty(reader, simpleProperty); return simpleProperty; } var multiDimensionalArrayProperty = property as MultiDimensionalArrayProperty; if (multiDimensionalArrayProperty != null) { parseMultiDimensionalArrayProperty(reader, multiDimensionalArrayProperty); return multiDimensionalArrayProperty; } var singleDimensionalArrayProperty = property as SingleDimensionalArrayProperty; if (singleDimensionalArrayProperty != null) { parseSingleDimensionalArrayProperty(reader, singleDimensionalArrayProperty); return singleDimensionalArrayProperty; } var dictionaryProperty = property as DictionaryProperty; if (dictionaryProperty != null) { parseDictionaryProperty(reader, dictionaryProperty); return dictionaryProperty; } var collectionProperty = property as CollectionProperty; if (collectionProperty != null) { parseCollectionProperty(reader, collectionProperty); return collectionProperty; } var complexProperty = property as ComplexProperty; if (complexProperty != null) { parseComplexProperty(reader, complexProperty); return complexProperty; } return property; }
public override bool IsTagRight(PropertyTag propertyTag) { if (propertyTag.Data != AttachmentNumberTagValue) throw new ArgumentException(string.Format("AttachmentNumber tag data is wrong:{0}.", propertyTag.Data.ToString("X8"))); return true; }
public static bool HasProperty(this Image image, PropertyTag property) { return Array.IndexOf(image.PropertyIdList, (Int32)property) > -1; }
public static Rational GetPropertyRational(this Image image, PropertyTag property) { if (!image.HasProperty(property)) return Rational.Zero; PropertyItem item = image.GetPropertyItem((Int32)property); if (item.Type != (short)PropertyType.UnsignedLongPair) return Rational.Zero; byte[] buffer = item.Value; Int32 numerator = BitConverter.ToInt32(buffer, 0); Int32 denominator = BitConverter.ToInt32(buffer, 4); Rational rational = new Rational(numerator, denominator); return rational; }
public static UInt16 GetPropertyUInt16(this Image image, PropertyTag property) { if (!image.HasProperty(property)) return 0; PropertyItem item = image.GetPropertyItem((Int32)property); if (item.Type != (short)PropertyType.UnsignedShort) return 0; byte[] buffer = item.Value; return BitConverter.ToUInt16(buffer, 0); }
private string Write8_PropertyTag(PropertyTag v) { switch (v) { case PropertyTag.GpsVer: return "GpsVer"; case PropertyTag.GpsLatitudeRef: return "GpsLatitudeRef"; case PropertyTag.GpsLatitude: return "GpsLatitude"; case PropertyTag.GpsLongitudeRef: return "GpsLongitudeRef"; case PropertyTag.GpsLongitude: return "GpsLongitude"; case PropertyTag.GpsAltitudeRef: return "GpsAltitudeRef"; case PropertyTag.GpsAltitude: return "GpsAltitude"; case PropertyTag.GpsGpsTime: return "GpsGpsTime"; case PropertyTag.GpsGpsSatellites: return "GpsGpsSatellites"; case PropertyTag.GpsGpsStatus: return "GpsGpsStatus"; case PropertyTag.GpsGpsMeasureMode: return "GpsGpsMeasureMode"; case PropertyTag.GpsGpsDop: return "GpsGpsDop"; case PropertyTag.GpsSpeedRef: return "GpsSpeedRef"; case PropertyTag.GpsSpeed: return "GpsSpeed"; case PropertyTag.GpsTrackRef: return "GpsTrackRef"; case PropertyTag.GpsTrack: return "GpsTrack"; case PropertyTag.GpsImgDirRef: return "GpsImgDirRef"; case PropertyTag.GpsImgDir: return "GpsImgDir"; case PropertyTag.GpsMapDatum: return "GpsMapDatum"; case PropertyTag.GpsDestLatRef: return "GpsDestLatRef"; case PropertyTag.GpsDestLat: return "GpsDestLat"; case PropertyTag.GpsDestLongRef: return "GpsDestLongRef"; case PropertyTag.GpsDestLong: return "GpsDestLong"; case PropertyTag.GpsDestBearRef: return "GpsDestBearRef"; case PropertyTag.GpsDestBear: return "GpsDestBear"; case PropertyTag.GpsDestDistRef: return "GpsDestDistRef"; case PropertyTag.GpsDestDist: return "GpsDestDist"; case PropertyTag.NewSubfileType: return "NewSubfileType"; case PropertyTag.SubfileType: return "SubfileType"; case PropertyTag.ImageWidth: return "ImageWidth"; case PropertyTag.ImageHeight: return "ImageHeight"; case PropertyTag.BitsPerSample: return "BitsPerSample"; case PropertyTag.Compression: return "Compression"; case PropertyTag.PhotometricInterp: return "PhotometricInterp"; case PropertyTag.ThreshHolding: return "ThreshHolding"; case PropertyTag.CellWidth: return "CellWidth"; case PropertyTag.CellHeight: return "CellHeight"; case PropertyTag.FillOrder: return "FillOrder"; case PropertyTag.DocumentName: return "DocumentName"; case PropertyTag.ImageDescription: return "ImageDescription"; case PropertyTag.EquipMake: return "EquipMake"; case PropertyTag.EquipModel: return "EquipModel"; case PropertyTag.StripOffsets: return "StripOffsets"; case PropertyTag.Orientation: return "Orientation"; case PropertyTag.SamplesPerPixel: return "SamplesPerPixel"; case PropertyTag.RowsPerStrip: return "RowsPerStrip"; case PropertyTag.StripBytesCount: return "StripBytesCount"; case PropertyTag.MinSampleValue: return "MinSampleValue"; case PropertyTag.MaxSampleValue: return "MaxSampleValue"; case PropertyTag.XResolution: return "XResolution"; case PropertyTag.YResolution: return "YResolution"; case PropertyTag.PlanarConfig: return "PlanarConfig"; case PropertyTag.PageName: return "PageName"; case PropertyTag.XPosition: return "XPosition"; case PropertyTag.YPosition: return "YPosition"; case PropertyTag.FreeOffset: return "FreeOffset"; case PropertyTag.FreeByteCounts: return "FreeByteCounts"; case PropertyTag.GrayResponseUnit: return "GrayResponseUnit"; case PropertyTag.GrayResponseCurve: return "GrayResponseCurve"; case PropertyTag.T4Option: return "T4Option"; case PropertyTag.T6Option: return "T6Option"; case PropertyTag.ResolutionUnit: return "ResolutionUnit"; case PropertyTag.PageNumber: return "PageNumber"; case PropertyTag.TransferFunction: return "TransferFunction"; case PropertyTag.SoftwareUsed: return "SoftwareUsed"; case PropertyTag.DateTime: return "DateTime"; case PropertyTag.Artist: return "Artist"; case PropertyTag.HostComputer: return "HostComputer"; case PropertyTag.Predictor: return "Predictor"; case PropertyTag.WhitePoint: return "WhitePoint"; case PropertyTag.PrimaryChromaticities: return "PrimaryChromaticities"; case PropertyTag.ColorMap: return "ColorMap"; case PropertyTag.HalftoneHints: return "HalftoneHints"; case PropertyTag.TileWidth: return "TileWidth"; case PropertyTag.TileLength: return "TileLength"; case PropertyTag.TileOffset: return "TileOffset"; case PropertyTag.TileByteCounts: return "TileByteCounts"; case PropertyTag.InkSet: return "InkSet"; case PropertyTag.InkNames: return "InkNames"; case PropertyTag.NumberOfInks: return "NumberOfInks"; case PropertyTag.DotRange: return "DotRange"; case PropertyTag.TargetPrinter: return "TargetPrinter"; case PropertyTag.ExtraSamples: return "ExtraSamples"; case PropertyTag.SampleFormat: return "SampleFormat"; case PropertyTag.SMinSampleValue: return "SMinSampleValue"; case PropertyTag.SMaxSampleValue: return "SMaxSampleValue"; case PropertyTag.TransferRange: return "TransferRange"; case PropertyTag.JPEGProc: return "JPEGProc"; case PropertyTag.JPEGInterFormat: return "JPEGInterFormat"; case PropertyTag.JPEGInterLength: return "JPEGInterLength"; case PropertyTag.JPEGRestartInterval: return "JPEGRestartInterval"; case PropertyTag.JPEGLosslessPredictors: return "JPEGLosslessPredictors"; case PropertyTag.JPEGPointTransforms: return "JPEGPointTransforms"; case PropertyTag.JPEGQTables: return "JPEGQTables"; case PropertyTag.JPEGDCTables: return "JPEGDCTables"; case PropertyTag.JPEGACTables: return "JPEGACTables"; case PropertyTag.YCbCrCoefficients: return "YCbCrCoefficients"; case PropertyTag.YCbCrSubsampling: return "YCbCrSubsampling"; case PropertyTag.YCbCrPositioning: return "YCbCrPositioning"; case PropertyTag.REFBlackWhite: return "REFBlackWhite"; case PropertyTag.Gamma: return "Gamma"; case PropertyTag.ICCProfileDescriptor: return "ICCProfileDescriptor"; case PropertyTag.SRGBRenderingIntent: return "SRGBRenderingIntent"; case PropertyTag.ImageTitle: return "ImageTitle"; case PropertyTag.ResolutionXUnit: return "ResolutionXUnit"; case PropertyTag.ResolutionYUnit: return "ResolutionYUnit"; case PropertyTag.ResolutionXLengthUnit: return "ResolutionXLengthUnit"; case PropertyTag.ResolutionYLengthUnit: return "ResolutionYLengthUnit"; case PropertyTag.PrintFlags: return "PrintFlags"; case PropertyTag.PrintFlagsVersion: return "PrintFlagsVersion"; case PropertyTag.PrintFlagsCrop: return "PrintFlagsCrop"; case PropertyTag.PrintFlagsBleedWidth: return "PrintFlagsBleedWidth"; case PropertyTag.PrintFlagsBleedWidthScale: return "PrintFlagsBleedWidthScale"; case PropertyTag.HalftoneLPI: return "HalftoneLPI"; case PropertyTag.HalftoneLPIUnit: return "HalftoneLPIUnit"; case PropertyTag.HalftoneDegree: return "HalftoneDegree"; case PropertyTag.HalftoneShape: return "HalftoneShape"; case PropertyTag.HalftoneMisc: return "HalftoneMisc"; case PropertyTag.HalftoneScreen: return "HalftoneScreen"; case PropertyTag.JPEGQuality: return "JPEGQuality"; case PropertyTag.GridSize: return "GridSize"; case PropertyTag.ThumbnailFormat: return "ThumbnailFormat"; case PropertyTag.ThumbnailWidth: return "ThumbnailWidth"; case PropertyTag.ThumbnailHeight: return "ThumbnailHeight"; case PropertyTag.ThumbnailColorDepth: return "ThumbnailColorDepth"; case PropertyTag.ThumbnailPlanes: return "ThumbnailPlanes"; case PropertyTag.ThumbnailRawBytes: return "ThumbnailRawBytes"; case PropertyTag.ThumbnailSize: return "ThumbnailSize"; case PropertyTag.ThumbnailCompressedSize: return "ThumbnailCompressedSize"; case PropertyTag.ColorTransferFunction: return "ColorTransferFunction"; case PropertyTag.ThumbnailData: return "ThumbnailData"; case PropertyTag.ThumbnailImageWidth: return "ThumbnailImageWidth"; case PropertyTag.ThumbnailImageHeight: return "ThumbnailImageHeight"; case PropertyTag.ThumbnailBitsPerSample: return "ThumbnailBitsPerSample"; case PropertyTag.ThumbnailCompression: return "ThumbnailCompression"; case PropertyTag.ThumbnailPhotometricInterp: return "ThumbnailPhotometricInterp"; case PropertyTag.ThumbnailImageDescription: return "ThumbnailImageDescription"; case PropertyTag.ThumbnailEquipMake: return "ThumbnailEquipMake"; case PropertyTag.ThumbnailEquipModel: return "ThumbnailEquipModel"; case PropertyTag.ThumbnailStripOffsets: return "ThumbnailStripOffsets"; case PropertyTag.ThumbnailOrientation: return "ThumbnailOrientation"; case PropertyTag.ThumbnailSamplesPerPixel: return "ThumbnailSamplesPerPixel"; case PropertyTag.ThumbnailRowsPerStrip: return "ThumbnailRowsPerStrip"; case PropertyTag.ThumbnailStripBytesCount: return "ThumbnailStripBytesCount"; case PropertyTag.ThumbnailResolutionX: return "ThumbnailResolutionX"; case PropertyTag.ThumbnailResolutionY: return "ThumbnailResolutionY"; case PropertyTag.ThumbnailPlanarConfig: return "ThumbnailPlanarConfig"; case PropertyTag.ThumbnailResolutionUnit: return "ThumbnailResolutionUnit"; case PropertyTag.ThumbnailTransferFunction: return "ThumbnailTransferFunction"; case PropertyTag.ThumbnailSoftwareUsed: return "ThumbnailSoftwareUsed"; case PropertyTag.ThumbnailDateTime: return "ThumbnailDateTime"; case PropertyTag.ThumbnailArtist: return "ThumbnailArtist"; case PropertyTag.ThumbnailWhitePoint: return "ThumbnailWhitePoint"; case PropertyTag.ThumbnailPrimaryChromaticities: return "ThumbnailPrimaryChromaticities"; case PropertyTag.ThumbnailYCbCrCoefficients: return "ThumbnailYCbCrCoefficients"; case PropertyTag.ThumbnailYCbCrSubsampling: return "ThumbnailYCbCrSubsampling"; case PropertyTag.ThumbnailYCbCrPositioning: return "ThumbnailYCbCrPositioning"; case PropertyTag.ThumbnailRefBlackWhite: return "ThumbnailRefBlackWhite"; case PropertyTag.ThumbnailCopyRight: return "ThumbnailCopyRight"; case PropertyTag.LuminanceTable: return "LuminanceTable"; case PropertyTag.ChrominanceTable: return "ChrominanceTable"; case PropertyTag.FrameDelay: return "FrameDelay"; case PropertyTag.LoopCount: return "LoopCount"; case PropertyTag.GlobalPalette: return "GlobalPalette"; case PropertyTag.IndexBackground: return "IndexBackground"; case PropertyTag.IndexTransparent: return "IndexTransparent"; case PropertyTag.PixelUnit: return "PixelUnit"; case PropertyTag.PixelPerUnitX: return "PixelPerUnitX"; case PropertyTag.PixelPerUnitY: return "PixelPerUnitY"; case PropertyTag.PaletteHistogram: return "PaletteHistogram"; case PropertyTag.Copyright: return "Copyright"; case PropertyTag.ExifExposureTime: return "ExifExposureTime"; case PropertyTag.ExifFNumber: return "ExifFNumber"; case PropertyTag.ExifExposureProg: return "ExifExposureProg"; case PropertyTag.ExifSpectralSense: return "ExifSpectralSense"; case PropertyTag.GpsIFD: return "GpsIFD"; case PropertyTag.ExifISOSpeed: return "ExifISOSpeed"; case PropertyTag.ExifOECF: return "ExifOECF"; case PropertyTag.ICCProfile: return "ICCProfile"; case PropertyTag.ExifIFD: return "ExifIFD"; case PropertyTag.ExifVer: return "ExifVer"; case PropertyTag.ExifDTOrig: return "ExifDTOrig"; case PropertyTag.ExifDTDigitized: return "ExifDTDigitized"; case PropertyTag.ExifCompConfig: return "ExifCompConfig"; case PropertyTag.ExifCompBPP: return "ExifCompBPP"; case PropertyTag.ExifShutterSpeed: return "ExifShutterSpeed"; case PropertyTag.ExifAperture: return "ExifAperture"; case PropertyTag.ExifBrightness: return "ExifBrightness"; case PropertyTag.ExifExposureBias: return "ExifExposureBias"; case PropertyTag.ExifMaxAperture: return "ExifMaxAperture"; case PropertyTag.ExifSubjectDist: return "ExifSubjectDist"; case PropertyTag.ExifMeteringMode: return "ExifMeteringMode"; case PropertyTag.ExifLightSource: return "ExifLightSource"; case PropertyTag.ExifFlash: return "ExifFlash"; case PropertyTag.ExifFocalLength: return "ExifFocalLength"; case PropertyTag.ExifDTSubsec: return "ExifDTSubsec"; case PropertyTag.ExifDTOrigSS: return "ExifDTOrigSS"; case PropertyTag.ExifDTDigSS: return "ExifDTDigSS"; case PropertyTag.ExifUserComment: return "ExifUserComment"; case PropertyTag.ExifMakerNote: return "ExifMakerNote"; case PropertyTag.ExifFPXVer: return "ExifFPXVer"; case PropertyTag.ExifColorSpace: return "ExifColorSpace"; case PropertyTag.ExifPixXDim: return "ExifPixXDim"; case PropertyTag.ExifPixYDim: return "ExifPixYDim"; case PropertyTag.ExifRelatedWav: return "ExifRelatedWav"; case PropertyTag.ExifInterop: return "ExifInterop"; case PropertyTag.ExifFlashEnergy: return "ExifFlashEnergy"; case PropertyTag.ExifSpatialFR: return "ExifSpatialFR"; case PropertyTag.ExifFocalXRes: return "ExifFocalXRes"; case PropertyTag.ExifFocalYRes: return "ExifFocalYRes"; case PropertyTag.ExifFocalResUnit: return "ExifFocalResUnit"; case PropertyTag.ExifSubjectLoc: return "ExifSubjectLoc"; case PropertyTag.ExifExposureIndex: return "ExifExposureIndex"; case PropertyTag.ExifSensingMethod: return "ExifSensingMethod"; case PropertyTag.ExifFileSource: return "ExifFileSource"; case PropertyTag.ExifSceneType: return "ExifSceneType"; case PropertyTag.ExifCfaPattern: return "ExifCfaPattern"; } long num = (long) v; throw base.CreateInvalidEnumValueException(num.ToString(CultureInfo.InvariantCulture), "Nomad.Commons.PropertyTag"); }
public static DateTime GetPropertyDateTime(this Image image, PropertyTag property) { if (!image.HasProperty(property)) return DateTime.MinValue; string value = GetPropertyString(image, property); // If first char is blank or string is empty no DateTime is present if (value == string.Empty || value[0] == ' ') return DateTime.MinValue; // DateTime is written as YYYY:MM:DD HH:MM:SS // and needs to be converted to YYYY-MM-DD HH:MM:SS // to be convertable to a .Net DateTime string datePart = value.Substring(0, 10).Replace(':', '-'); string timePart = value.Substring(11); return Convert.ToDateTime(datePart + ' ' + timePart); }