internal static Boolean ObjectHasAssignedAction(Object AnObject, PropertyInfo[] PropList, int Count, out Object ActionProperty) { PropertyInfo PropInfo; Object Obj; Boolean Result = false; ActionProperty = null; for (int I = 0; !Result && I < Count; I++) { PropInfo = PropList[I]; if (PropInfo.GetIndexParameters().Length != 0) { continue; } // check property type with reflection, before we try to get the value if (Type.GetTypeCode(PropInfo.PropertyType) == TypeCode.Object && typeof(TBasicAction).IsAssignableFrom(PropInfo.PropertyType)) { try { Obj = PropInfo.GetValue(AnObject, null); // possibly throws exceptions } catch { Obj = null; } Result = Obj != null;//is TBasicAction; if (Result) { ActionProperty = Obj; } } } return(Result); }
public override object GetValue(object component) { CheckComponentType(component); if (this.ComponentType == component.GetType()) { return(PropInfo.IsNull() ? null : PropInfo.GetValue(component, null)); } PropertyInfo[] propInfos = component.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); //This code is copied from http://www.sql.ru/forum/actualthread.aspx?tid=579972 // and i have no idea what the following code is trying to achieve. //It looks like it might be trying to deal with the prop info being // on a customer e.g. when a PropInfo for CustomerName on Customer when the component is Order. foreach (PropertyInfo mypropinfo in propInfos) { object obj = mypropinfo.GetValue(component, null); PropertyInfo[] nestedpropsInfo = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo mynestedpropinfo in nestedpropsInfo) { if (PropInfo.Name == mynestedpropinfo.Name) { return(mynestedpropinfo.GetValue(obj, null)); } } } return(null); }
public object GetValue() { return (IsAccessDisallowed ? string.Format("<PROPERTY ACCESS OF '{0}' IS DISALLOWED>", Name) : PropInfo.GetValue(SettingsInstance, null)); }
public override bool DoCommand() { _oldValue = PropInfo.GetValue(ModelObject, null); PropInfo.SetValue(ModelObject, _newValue, null); return(true); }
public int Compare(T value1, T value2) { return ( (SortDir == ListSortDirection.Ascending) ? Comparer.Default.Compare(PropInfo.GetValue(value1, null), PropInfo.GetValue(value2, null)) : Comparer.Default.Compare(PropInfo.GetValue(value2, null), PropInfo.GetValue(value1, null)) ); }
private static void FillData(OBJS.Data DataSet, Type BaseType, object Item) { List <PropertyInfo> Props = GetProprites(OBJS.Types.Prop, BaseType); List <OBJS.Data.DataValue> DataValues = new List <OBJS.Data.DataValue>(); foreach (PropertyInfo Prop in Props) { object ItemObject = Prop.GetValue(Item, null); string ItemValue = (ItemObject != null) ? ItemObject.ToString() : ""; OBJS.Data.DataValue DataValue = new OBJS.Data.DataValue(); DataValue.Name = Prop.Name; DataValue.Value = ItemValue; DataValues.Add(DataValue); } List <PropertyInfo> AttributePop = GetProprites(OBJS.Types.Attribute, BaseType); foreach (PropertyInfo PropInfo in AttributePop) { OBJS.XMLDatabaseRetriveItem XMLDatabaseRetriveItem = (OBJS.XMLDatabaseRetriveItem)PropInfo.GetCustomAttributes(typeof(OBJS.XMLDatabaseRetriveItem), true).FirstOrDefault(); object ItemObject = PropInfo.GetValue(Item, null); string ItemValue = (ItemObject != null) ? ItemObject.ToString() : ""; OBJS.Data.DataValue DataValue = DataValues.Find(A => A.Name == XMLDatabaseRetriveItem.NodeName); if (DataValue != null) { DataValue.Attributes.Add(new OBJS.Data.DataValue() { Name = XMLDatabaseRetriveItem.AttributeName, Value = ItemValue }); } else { DataValue = new OBJS.Data.DataValue(); DataValue.Name = XMLDatabaseRetriveItem.NodeName; DataValue.Attributes.Add(new OBJS.Data.DataValue() { Name = XMLDatabaseRetriveItem.AttributeName, Value = ItemValue }); DataValues.Add(DataValue); } } DataValues.ForEach(T => { DataSet.AddData(T); }); }
// Return an array of SqlParameter's by using reflection on ParamObject private static SqlParameter[] GetParametersFromObject(object ParamObject) { var Params = new List <SqlParameter>(); foreach (var PropInfo in ParamObject.GetType().GetProperties()) { Params.Add(new SqlParameter(PropInfo.Name, PropInfo.GetValue(ParamObject, null))); } return(Params.ToArray()); }
public static IDictionary <string, object> AsDictionary(this object Source, BindingFlags BindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.ExactBinding) { return(Source.GetType() .GetProperties(BindingAttr) .ToDictionary ( PropInfo => PropInfo.Name, PropInfo => PropInfo.GetValue(Source, null) )); }
public int Compare(T x, T y) { var _X = PropInfo.GetValue(x, null); var _Y = PropInfo.GetValue(y, null); if (Direction == System.ComponentModel.ListSortDirection.Ascending) { return(System.Collections.Comparer.Default.Compare(_X, _Y)); } else { return(System.Collections.Comparer.Default.Compare(_Y, _X)); } }
internal void Serialize(object o, BinaryWriter writer, SerializationMethod serializationMethod) { MsgPackIO.SerializeValue(PropInfo.GetValue(o, EmptyObjArgs), writer, serializationMethod); }
public void DoCommand() { OldValue = PropInfo.GetValue(ModelObject, null); Redo(); }