private void InternalSetValue(string fileName, int fieldIndex, int unitIndex, object value, int flags)
        {
            ttimeformat ttimeformat;
            int fieldType = this.Fields[fieldIndex].FieldType;
            switch (fieldType)
            {
                case 1:
                    this.InternalSetObject(fileName, fieldIndex, unitIndex, fieldType, Convert.ToInt32(value), flags);
                    return;

                case 2:
                    this.InternalSetObject(fileName, fieldIndex, unitIndex, fieldType, Convert.ToInt64(value), flags);
                    return;

                case 3:
                    this.InternalSetObject(fileName, fieldIndex, unitIndex, fieldType, Convert.ToDouble(value), flags);
                    return;

                case 4:
                {
                    tdateformat tdateformat = new tdateformat();
                    DateTime time = Convert.ToDateTime(value);
                    tdateformat.wYear = (ushort) time.Year;
                    tdateformat.wMonth = (ushort) time.Month;
                    tdateformat.wDay = (ushort) time.Day;
                    this.InternalSetObject(fileName, fieldIndex, unitIndex, fieldType, tdateformat, flags);
                    return;
                }
                case 5:
                {
                    ttimeformat = new ttimeformat();
                    if (!(value is TimeSpan))
                    {
                        DateTime time2 = Convert.ToDateTime(value);
                        ttimeformat.wHour = (ushort) time2.Hour;
                        ttimeformat.wMinute = (ushort) time2.Minute;
                        ttimeformat.wSecond = (ushort) time2.Second;
                        break;
                    }
                    TimeSpan span = (TimeSpan) value;
                    ttimeformat.wHour = (ushort) span.Hours;
                    ttimeformat.wMinute = (ushort) span.Minutes;
                    ttimeformat.wSecond = (ushort) span.Seconds;
                    break;
                }
                case 6:
                    this.InternalSetObject(fileName, fieldIndex, unitIndex, fieldType, Convert.ToInt32(Convert.ToBoolean(value)), flags);
                    return;

                case 8:
                case 11:
                    this.InternalSetString(fileName, fieldIndex, unitIndex, fieldType, Convert.ToString(value), flags);
                    return;

                case 10:
                    this.InternalSetObject(fileName, fieldIndex, unitIndex, fieldType, Convert.ToDateTime(value).ToFileTimeUtc(), flags);
                    return;

                default:
                    throw new InvalidOperationException();
            }
            this.InternalSetObject(fileName, fieldIndex, unitIndex, fieldType, ttimeformat, flags);
        }
 private void Write62_ttimeformat(string n, string ns, ttimeformat o, bool needType)
 {
     if (!needType && (o.GetType() != typeof(ttimeformat)))
     {
         throw base.CreateUnknownTypeException(o);
     }
     base.WriteStartElement(n, ns, o, false, null);
     if (needType)
     {
         base.WriteXsiType("ttimeformat", "");
     }
     base.WriteElementStringRaw("wHour", "", XmlConvert.ToString(o.wHour));
     base.WriteElementStringRaw("wMinute", "", XmlConvert.ToString(o.wMinute));
     base.WriteElementStringRaw("wSecond", "", XmlConvert.ToString(o.wSecond));
     base.WriteEndElement(o);
 }