public void AddProperty(PropertyMapper pm) { ReadProperty rp = new ReadProperty(); rp.Mapper = pm; rp.Index = 0; mProperties.Add(rp); }
public ProcDataReader(Type type) { foreach (PropertyInfo p in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { ReadProperty rp = new ReadProperty(); rp.Handler = new PropertyHandler(p); rp.Cast = DBContext.GetCast(p.PropertyType); IDAttribute[] ida = Utils.GetPropertyAttributes <IDAttribute>(p, false); rp.Name = p.Name; if (ida.Length > 0) { if (!string.IsNullOrEmpty(ida[0].Name)) { rp.Name = ida[0].Name; } } else { ColumnAttribute[] cas = Utils.GetPropertyAttributes <ColumnAttribute>(p, false); if (cas.Length > 0) { if (!string.IsNullOrEmpty(cas[0].Name)) { rp.Name = cas[0].Name; } } } mProperties.Add(rp); } }
internal static List <HealthbillingKeyValue> loadHealthbilling(int year) { ReadProperty rp = new ReadProperty(); try { strSQL = string.Format(@"SELECT EInfo_id,Month,SUM([1C]+[1D]+[1E]+[1F]) AS RESULT FROM emp_Healthbilling WHERE Month BETWEEN 1 AND 12 AND Year = '{0}'GROUP BY EInfo_id, Month ORDER BY EInfo_id, CAST(Month AS INT)", year); List <HealthbillingKeyValue> obj = new List <HealthbillingKeyValue>(); int month = 0; using (SqlDataReader dr = SqlHelperIRS.ExecuteReader(CommandType.Text, strSQL)) { while (dr.Read()) { month = dr["Month"].ToInt(); obj.Add(new HealthbillingKeyValue() { EinfoID = dr["EInfo_id"].ToInt(), Month = dr["Month"].ToInt(), Value = dr["RESULT"].ToFloat(), TextField14 = string.Format("Text{0}", rp.code14[month - 1].ToString()), TextField15 = string.Format("Text{0}", rp.code15[month - 1].ToString()), TextField16 = string.Format("Text{0}", rp.code16[month - 1].ToString()), }); } } return(obj); } catch (Exception) { throw; } }
public ProcDataReader(Type type) { foreach (PropertyInfo p in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { ReadProperty rp = new ReadProperty(); rp.Handler = new PropertyHandler(p); rp.Cast = DBContext.GetCast(p.PropertyType); IDAttribute[] ida = Utils.GetPropertyAttributes<IDAttribute>(p, false); rp.Name = p.Name; if (ida.Length > 0) { if (!string.IsNullOrEmpty(ida[0].Name)) { rp.Name = ida[0].Name; } } else { ColumnAttribute[] cas = Utils.GetPropertyAttributes<ColumnAttribute>(p, false); if (cas.Length > 0) { if (!string.IsNullOrEmpty(cas[0].Name)) { rp.Name = cas[0].Name; } } } mProperties.Add(rp); } }
public Property(PropertyInfo propertyInfo) { mName = propertyInfo.Name; mTypeData = propertyInfo.PropertyType.GetTypeData(); mRead = propertyInfo.GetValue; mWrite = propertyInfo.SetValue; }
private void ReaderToProperty(System.Data.IDataReader reader, object obj, ReadProperty p) { object dbvalue=null; try { if (p.Index >= 0) { dbvalue = reader[p.Index]; if (dbvalue != DBNull.Value) { if (p.Cast != null) { dbvalue = p.Cast.ToProperty(dbvalue, p.Handler.Property.PropertyType, null); } p.Handler.Set(obj, Convert.ChangeType(dbvalue, p.Handler.Property.PropertyType)); } } } catch (Exception e_) { throw new PeanutException(string.Format(DataMsg.READER_TO_PROPERTY_ERROR, dbvalue, p.Handler.Property.Name), e_); } }
/// <summary> /// 判定属性是否是只读属性。 /// </summary> /// <param name="propertyName">表示属性名称。</param> /// <returns>返回属性是否是只读属性。</returns> public bool IsReadProperty(string propertyName) { if (ReadProperty.Contains(propertyName)) { return(true); } return(false); }
/// <summary> /// 将属性加入只读属性集合中。 /// </summary> /// <param name="propertyNames">属性名称集合字符串,以';'号隔开。</param> protected void AddReadPropertyRange(string propertyNames) { string[] propertyNameArray = propertyNames.Split(';'); foreach (string s in propertyNameArray) { ReadProperty.Add(s); } }
Statement AddToList(Property prop, Expression value) { if (prop.IsAttachedProperty()) { return(new NoOperation("attached list property not supported")); } var list = new ReadProperty(This, prop.GetMemberName()); return(new CallDynamicMethod(list, Add, value)); }
public void ReceivedReadProperty(BacNetRawMessage msg) { try { ReadProperty apdu = new ReadProperty(msg.Apdu); } catch (Exception ex) { if (ex.Message == "Reject.Missing_required_paramter") { //Отправляем сообщение об ошибке } throw; } }
private void ReaderToProperty(System.Data.IDataReader reader, object obj, ReadProperty rp, PropertyMapper pm,PropertyHandler handler) { try { object dbvalue = reader[rp.Index]; if (dbvalue != DBNull.Value) { if (pm.Cast != null) { dbvalue = pm.Cast.ToProperty(dbvalue, pm.Handler.Property.PropertyType, obj); } handler.Set(obj, Convert.ChangeType(dbvalue, pm.Handler.Property.PropertyType)); } } catch (Exception e_) { throw new PeanutException(string.Format(DataMsg.READER_TO_PROPERTY_ERROR, pm.ColumnName, pm.Handler.Property.Name), e_); } }
private void ReaderToProperty(System.Data.IDataReader reader, object obj, ReadProperty rp, PropertyMapper pm, PropertyHandler handler) { try { object dbvalue = reader[rp.Index]; if (dbvalue != DBNull.Value) { if (pm.Cast != null) { dbvalue = pm.Cast.ToProperty(dbvalue, pm.Handler.Property.PropertyType, obj); } handler.Set(obj, Convert.ChangeType(dbvalue, pm.Handler.Property.PropertyType)); } } catch (Exception e_) { throw new PeanutException(string.Format(DataMsg.READER_TO_PROPERTY_ERROR, pm.ColumnName, pm.Handler.Property.Name), e_); } }
public void ReaderToObject(System.Data.IDataReader reader, object obj) { if (!mLoadColumnIndex) { SetColumnIndex(reader); } for (int i = 0; i < Properties.Count; i++) { ReadProperty rp = Properties[i]; if (!Proxy) { ReaderToProperty(reader, obj, rp, rp.Mapper, rp.Mapper.Handler); } else { ReaderToProperty(reader, obj, rp, rp.Mapper, ProxyProperties[i]); } } }
private void ReaderToProperty(System.Data.IDataReader reader, object obj, ReadProperty p) { object dbvalue = null; try { if (p.Index >= 0) { dbvalue = reader[p.Index]; if (dbvalue != DBNull.Value) { p.Handler.Set(obj, Convert.ChangeType(dbvalue, p.Handler.Property.PropertyType)); } } } catch (Exception e_) { throw new Exception($"{p.Name} convert error {dbvalue} to {p.Handler.Property.PropertyType}"); } }
private void ReaderToProperty(System.Data.IDataReader reader, object obj, ReadProperty p) { object dbvalue = null; try { if (p.Index >= 0) { dbvalue = reader[p.Index]; if (dbvalue != DBNull.Value) { if (p.Cast != null) { dbvalue = p.Cast.ToProperty(dbvalue, p.Handler.Property.PropertyType, null); } p.Handler.Set(obj, Uility.ChangeType(dbvalue, p.Handler.Property.PropertyType)); } } } catch (Exception e_) { throw new PeanutException(string.Format(DataMsg.READER_TO_PROPERTY_ERROR, dbvalue, p.Handler.Property.Name), e_); } }
object Evaluate(ReadProperty e) { return(_reflection.GetPropertyValue(Evaluate(e.Object), e.Property.Name)); }
public ArrayList ReadProperty(UInt16 destinationAddress, BacNetObject bacNetObject, BacNetEnums.BACNET_PROPERTY_ID propertyId) { var apdu = new ReadProperty(bacNetObject, propertyId); var npdu = new BacNetIpNpdu(); npdu.ExpectingReply = true; BacNetRemoteDevice remote = null; foreach (BacNetRemoteDevice remoteDevice in BacNetDevice.Instance.Remote) if (remoteDevice.InstanceNumber == destinationAddress) remote = remoteDevice; if (remote != null) { npdu.Destination = remote.BacAddress; BacNetDevice.Instance.Services.Execute(npdu, apdu, remote.EndPoint); BacNetDevice.Instance.Waiter = apdu.InvokeId; return WaitForResponce(apdu.InvokeId) as ArrayList; } return null; }
public BacNetProperty ReadProperty(string address, BacNetEnums.BACNET_PROPERTY_ID propId = BacNetEnums.BACNET_PROPERTY_ID.PROP_PRESENT_VALUE) { string[] addrArray = address.Split('.'); if (addrArray.Length != 2) { _logger.Warn("Wrong address: " + address); return null; } BacNetRemoteDevice remote = BacNetDevice.Instance.SearchRemote(BacNetRemoteDevice.Get(addrArray[0])); if (remote == null) { return null; } BacNetObject tmpObj; try { tmpObj = new BacNetObject(addrArray[1]); } catch (Exception ex) { _logger.Warn(ex.Message); return new BacNetProperty { PropertyId = new BacNetUInt{ Value = (uint)propId}, Values = new ArrayList {new BacNetString("Error")} }; //return null; } BacNetObject obj = remote.Objects.FirstOrDefault(s => s.ObjectId == tmpObj.ObjectId && s.ObjectType == tmpObj.ObjectType); if (obj == null) { remote.Objects.Add(tmpObj); obj = tmpObj; } var apdu = new ReadProperty(obj, propId); var npdu = new BacNetIpNpdu {ExpectingReply = true, Destination = remote.BacAddress}; BacNetDevice.Instance.Waiter = apdu.InvokeId; BacNetDevice.Instance.Services.Execute(npdu, apdu, remote.EndPoint); ArrayList valueList = WaitForResponce(apdu.InvokeId) as ArrayList; BacNetProperty property = obj.Properties.FirstOrDefault(s => s.PropertyId.Value == (uint) propId); if (property != null) property.Values = valueList ?? new ArrayList(); else { property = new BacNetProperty { PropertyId = new BacNetUInt { Value = (uint)propId }, Values = valueList ?? new ArrayList() }; obj.Properties.Add(property); } return property; }
public ExcludeValueListPropertyTranslator(Type implementationType, PropertyInfo entityPropertyInfo) { _propertyName = entityPropertyInfo.Name; _property = new WriteProperty <TEntity, ValueList <TPropertyEntity> >(implementationType, _propertyName); _readProperty = new ReadProperty <TEntity, ValueList <TPropertyEntity> >(implementationType, _propertyName); }