Пример #1
0
 //==========================================================================================
 /// <summary>
 /// </summary>
 /// <param name="other">
 /// </param>
 /// <returns>
 /// </returns>
 //==========================================================================================
 public bool Equals(ImaqdxEnumAttributeItem other)
 {
     return((_enumItem.Name == other._enumItem.Name) &&
            (_value == other._value));
 }
Пример #2
0
        //==========================================================================================
        /// <summary>
        /// Sets the value for a camera attribute.
        /// </summary>
        /// <param name="value">
        /// The value to set the camera attribute to.
        /// </param>
        /// <exception cref="System.ObjectDisposedException">
        /// The session has been disposed.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        ///     <paramref name="value"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// The type of the value is invalid or not supported.
        /// </exception>
        //==========================================================================================
        public void SetValue(object value)
        {
            _session.ValidateSessionHandle();
            if (value == null)
            {
                throw ExceptionBuilder.ArgumentNull("value");
            }

            Type dataType = value.GetType();

            if (dataType == typeof(sbyte))
            {
                sbyte sbyteValue = (sbyte)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)sbyteValue);
            }
            else if (dataType == typeof(byte))
            {
                byte byteValue = (byte)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)byteValue);
            }
            else if (dataType == typeof(short))
            {
                short shortValue = (short)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)shortValue);
            }
            else if (dataType == typeof(ushort))
            {
                ushort ushortValue = (ushort)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)ushortValue);
            }
            else if (dataType == typeof(int))
            {
                int intValue = (int)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (uint)intValue);
            }
            else if (dataType == typeof(uint))
            {
                uint uintValue = (uint)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, uintValue);
            }
            else if (dataType == typeof(long))
            {
                long longValue = (long)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, longValue);
            }
            else if (dataType == typeof(ulong))
            {
                ulong ulongValue = (ulong)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (long)ulongValue);
            }
            else if (dataType == typeof(decimal))
            {
                decimal decimalValue = (decimal)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (double)decimalValue);
            }
            else if (dataType == typeof(float))
            {
                float floatValue = (float)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, (double)floatValue);
            }
            else if (dataType == typeof(double))
            {
                double doubleValue = (double)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, doubleValue);
            }
            else if (dataType == typeof(string))
            {
                string stringValue = (string)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, stringValue);
            }
            else if (dataType == typeof(ImaqdxEnumAttributeItem))
            {
                ImaqdxEnumAttributeItem enumItemValue = (ImaqdxEnumAttributeItem)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, enumItemValue);
            }
            else if (dataType == typeof(bool))
            {
                bool boolValue = (bool)value;
                ImaqdxAttributeManager.SetAttribute(_session.Handle, _name, boolValue);
            }
            else
            {
                throw ExceptionBuilder.UnknownDataType();
            }
        }