Esempio n. 1
0
        /// <summary>
        /// Determines if this object and another object are equal.
        /// </summary>
        /// <param name="obj">The object to compare.</param>
        /// <returns><b>true</b> if this instance and another object are equal; otherwise <b>false</b>.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || !(obj is DataFieldInfo)) return false;

            var other = (DataFieldInfo)obj;
            return Value.Equals(other.Value) && _propKey.Equals(other._propKey);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets data for a specific property.
        /// </summary>
        /// <param name="key">The <see cref="PropertyKey"/> of the property to be retrieved.</param>
        /// <returns>The data for the specified property or null if the item does not have the property.</returns>
        public object GetValue(PropertyKey key)
        {
            IntPtr pv    = IntPtr.Zero;
            object value = null;

            try
            {
                pv = Marshal.AllocCoTaskMem(32); // Structure is 16 bytes in 32-bit windows and 24 bytes in 64-bit but we leave a few more bytes for good measure.
                m_IPropertyStore.GetValue(key, pv);
                value = PropVariant.GetObjectFromPropVariant(pv);

#if !RAW_PROPERTY_STORE
                // PropertyStore returns all DateTimes in UTC. However, DateTaken certain fields are stored in local time.
                // The conversion to UTC will not be correct unless the timezone on the camera, when the
                // photo was taken, is the same as the timezone on the computer when the value is retrieved.
                // We fix this up by converting back to local time using the computer's current timezone
                // (the same timezone that was used to convert to UTC moments earlier).
                // This works well because unlike the source FILETIME (which should always be UTC), The
                // managed DateTime format has a property that indicates whether the time is local or UTC.
                // Callers should still take care to interpret the time as local to where the photo was taken
                // and not local to where the computer is at present.
                if (value != null &&
                    ((string.Equals(m_contentType, "image/jpeg") &&
                      (key.Equals(s_pkItemDate) || key.Equals(s_pkDateTaken))) ||
                     (string.Equals(m_contentType, "video/avi") &&
                      (key.Equals(s_pkItemDate) || key.Equals(s_pkDateEncoded)))))
                {
                    DateTime dt = (DateTime)value;
                    Debug.Assert(dt.Kind == DateTimeKind.Utc);
                    value = dt.ToLocalTime();
                }
#endif
            }
            finally
            {
                if (pv != IntPtr.Zero)
                {
                    try
                    {
                        PropVariant.PropVariantClear(pv);
                    }
                    catch
                    {
                        Debug.Fail("VariantClear failure");
                    }
                    Marshal.FreeCoTaskMem(pv);
                    pv = IntPtr.Zero;
                }
            }
            return(value);
        }
Esempio n. 3
0
        /// <summary>
        /// Determines if this object and another object are equal.
        /// </summary>
        /// <param name="obj">The object to compare.</param>
        /// <returns><b>true</b> if this instance and another object are equal; otherwise <b>false</b>.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (!(obj is DataFieldInfo))
            {
                return(false);
            }

            DataFieldInfo other = (DataFieldInfo)obj;

            return(_value.Equals(other._value) && _propKey.Equals(other._propKey));
        }
Esempio n. 4
0
        } // ValueType

        public bool Equals(PropertyDescription pd)
        {
            if (pd == null)
            {
                return(false);
            }
            return(m_propertyKey.Equals(pd.m_propertyKey));
        }
Esempio n. 5
0
 /// <summary>
 /// Gets the specified property value.
 /// </summary>
 /// <param name="pKey">The key identifying requested property.</param>
 public void GetValue(ref PropertyKey pKey, out PROPVARIANT pValue)
 {
     pValue = new PROPVARIANT();
     if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_ADDRESS1))
     {
         pValue.SetValue(_address1);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_ADDRESS2))
     {
         pValue.SetValue(_address2);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_CITY))
     {
         pValue.SetValue(_city);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_STATE_PROVINCE))
     {
         pValue.SetValue(_StateProvince);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_POSTALCODE))
     {
         pValue.SetValue(_PostalCode);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_TIMESTAMP))
     {
         pValue.SetFileTime(_timestamp);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_COUNTRY_REGION))
     {
         pValue.SetValue(_CountryRegion);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Gets the specified property value.
 /// </summary>
 /// <param name="pKey">The key of the requested property.</param>
 public void GetValue(ref PropertyKey pKey, out PROPVARIANT pValue)
 {
     pValue = new PROPVARIANT();
     if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_LATITUDE_DEGREES))
     {
         pValue.SetValue(_latitude);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_LONGITUDE_DEGREES))
     {
         pValue.SetValue(_longitude);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_ERROR_RADIUS_METERS))
     {
         pValue.SetValue(_errorRadius);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_ALTITUDE_ELLIPSOID_METERS))
     {
         pValue.SetValue(_altitude);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_ALTITUDE_ELLIPSOID_ERROR_METERS))
     {
         pValue.SetValue(_altitudeError);
     }
     else if (pKey.Equals(SensorPropertyKeys.SENSOR_DATA_TYPE_TIMESTAMP))
     {
         pValue.SetFileTime(_timeStamp);
     }
 }
Esempio n. 7
0
        static string ValueToString(object value, PropertyKey pk)
        {
            if (value == null)
            {
                return("(null)");
            }

            {
                var array = value as Array;
                if (array != null)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (object obj in array)
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append("; ");
                        }
                        sb.Append(obj.ToString());
                    }
                    return(sb.ToString());
                }
            }

            if (value is DateTime)
            {
                var dt = (DateTime)value;
                if (dt.Kind == DateTimeKind.Local)
                {
                    dt = DateTime.SpecifyKind(dt, DateTimeKind.Unspecified); // Prevent reporting local timezone on output string.
                }
                return(dt.ToString("o"));
            }

            if (pk.Equals(s_pkDuration))
            {
                var ts = TimeSpan.FromTicks((long)(UInt64)value);
                return(ts.ToString("c"));
            }

            return(value.ToString());
        }
Esempio n. 8
0
 public bool Equals(Property other)
 {
     return(mKey.Equals(other.mKey));
 }
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            RelationshipConstraintDefinition that = ( RelationshipConstraintDefinition )o;

            return(RelationshipTypeConflict.name().Equals(that.RelationshipTypeConflict.name()) && PropertyKey.Equals(that.PropertyKey));
        }