コード例 #1
0
        /// <summary>
        ///   Reads the specified object.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Obj has other than ID type.</exception>
        public static ID Read(ClrObject obj)
        {
            if (obj.IsNullObj)
            {
                return(null);
            }

            obj.ReEvaluateType();

            if (obj.Type == null)
            {
                return(null);
            }

            if (!obj.Type.Name.Equals(typeof(ID).FullName, StringComparison.Ordinal))
            {
                throw new ArgumentException("Obj has wrong " + obj.Type.Name + " instead of ID");
            }
            ClrObject guidObject = obj.GetValueFld("_guid", false);

            if (guidObject.IsNullObj)
            {
                return(null);
            }
            return(new ID(ClrObjectValuesReader.ReadGuidValue(guidObject)));
        }
コード例 #2
0
        public object Read(ClrObject obj, string fldName)
        {
            ClrObject guidObject = obj.GetValueFld(fldName, false);

            // TOOD: Ensure this code works.
            return(ClrObjectValuesReader.ReadGuidValue(guidObject));
        }
コード例 #3
0
 public static bool CanRead(ClrObject obj, string fld)
 {
     try
     {
         var clrFld = obj.Type.GetFieldByName(fld);
         if (clrFld == null)
         {
             return(false);
         }
         var val = obj.GetValueFld(fld);
         if (val.IsNullObj)
         {
             return(false);
         }
         var ticksFld = val.Type.GetFieldByName("_ticks");
         return(ticksFld != null);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #4
0
        /// <summary>
        ///   Reads date from object field.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <param name="fldName">Name of the field.</param>
        /// <returns></returns>
        public static DateTime FromObjToDate(ClrObject obj, string fldName)
        {
            ClrObject val = obj.GetValueFld(fldName);

            return(FromObjToDate(val));
        }
コード例 #5
0
        public static TimeSpan Read(ClrObject obj, string fldName)
        {
            ClrObject rs = obj.GetValueFld(fldName);

            return(Read(rs));
        }