public void WriteValue(object from, BinaryWriter w, byte[] mask) { mask[m_maskIndex] |= m_maskValue; w.Write((float)m_memberValue.GetValue(from)); }
private void FillLazyObjectRelations(DataObject DataObject, bool Autoload) { try { Type myType = DataObject.GetType(); String tableName = DataObject.TableName; DataTableHandler handler = (DataTableHandler)tableDatasets[tableName]; foreach (MemberValue value in handler.Relations) { Common.Attributes.Relation relation = (Common.Attributes.Relation)value.Attribute; if (relation.AutoLoad == false && Autoload == true) { continue; } PropertyInfo prop = myType.GetProperty(relation.LocalField, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); object val = 0; if (prop != null) { val = prop.GetValue(DataObject, null); } else { FieldInfo field = myType.GetField(relation.LocalField, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); if (field != null) { val = field.GetValue(DataObject); } else { MemberValue member = handler.GetColumnByName(relation.LocalField); val = member.GetValue(DataObject); } } Type type = value.GetValueType(); if (type.IsArray) { type = type.GetElementType(); } DataObject[] Elements = null; if (val != null) { Elements = SelectObjects(type, relation.RemoteField + " = '" + val.ToString() + "'"); } if (Elements != null && Elements.Length > 0) { if (value.GetValueType().IsArray) { object[] args = { Elements.Length }; object[] array = (object[])Activator.CreateInstance(value.GetValueType(), args);; for (int i = 0; i < Elements.Length; i++) { array[i] = Elements[i]; } value.SetValue(DataObject, array); } else { value.SetValue(DataObject, Elements[0]); } } } } catch (Exception e) { throw new DatabaseException("Resolving Relations failed !", e); } }