Exemple #1
0
        /// <summary>
        /// Set the value of the given dex field.
        /// </summary>
        protected virtual void SetFieldValue(DexLib.FieldDefinition dfield, FieldDefinition field)
        {
            var constant = field.Constant;

            if (constant != null)
            {
                var fieldType = field.FieldType;
                if (fieldType.IsByte())
                {
                    constant = XConvert.ToByte(constant);
                }
                else if (fieldType.IsUInt16())
                {
                    constant = XConvert.ToShort(constant);
                }
                else if (fieldType.IsUInt32())
                {
                    constant = XConvert.ToInt(constant);
                }
                else if (fieldType.IsUInt64())
                {
                    constant = XConvert.ToLong(constant);
                }
            }
            dfield.Value = constant;
        }
 public void SetProperty(Lucene.Net.Documents.Document doc)
 {
     if (doc != null)
     {
         this.SchoolId = XConvert.ToInt32(doc.Get("SchoolId"), -1);
         this.Type     = (SchoolType)XConvert.ToByte(doc.Get("Type"));
         this.Name     = doc.Get("Name");
         this.CnName   = doc.Get("CnName");
         this.Pinyin   = doc.Get("Pinyin");
         this.RegionId = XConvert.ToInt32(doc.Get("RegionId"), -1);
         this.StateId  = XConvert.ToInt32(doc.Get("StateId"), -1);
         this.CityId   = XConvert.ToInt32(doc.Get("CityId"), -1);
     }
 }
Exemple #3
0
 public static byte[] ConvertToByte(object o)
 {
     return(XConvert.ToByte(o));
 }