Beispiel #1
0
        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);
        }