public void UpdateCache()
        {
            try { _cachedComponent = target.GetComponent(componentName); } catch { _cachedComponent = null; }
            try { _cachedMember = _cachedComponent.GetType().GetMember(memberName)[0]; } catch { _cachedMember = null; }
            PropertyOrFieldInfo propertyOrField = new PropertyOrFieldInfo(_cachedMember);
            object obj = propertyOrField.GetValue(_cachedComponent);

            _cachedCollection              = (ICollection)obj;
            _cachedElementType             = _cachedMember == null ? null : propertyOrField.Type.GetGenericArguments()[0];
            _cachedCollectionTarget        = target;
            _cachedCollectionComponentName = componentName;
            _cachedCollectionMemberName    = memberName;
        }
Esempio n. 2
0
        protected override void OnButtonClicked()
        {
            object     obj          = new PropertyOrFieldInfo(table.targetCollection.GetMember()).GetValue(table.targetCollection.GetComponent());
            MethodInfo deleteMethod = obj.GetType().GetMethod("RemoveAt");

            if (deleteMethod != null)
            {
                deleteMethod.Invoke(obj, new object[] { elmtIndex });
            }
            else
            {
                Debug.LogError("There is no RemoveAt method on this collection.");
            }

            table.UpdateContent();
        }
        protected override void OnButtonClicked()
        {
            object          obj         = new PropertyOrFieldInfo(table.targetCollection.GetMember()).GetValue(table.targetCollection.GetComponent());
            MethodInfo      addMethod   = obj.GetType().GetMethod("Add");
            ConstructorInfo constructor = table.ElementType.GetConstructor(new System.Type[] { });

            if (constructor == null)
            {
                Debug.LogError("There is no default constructor on the collection's element type.");
                return;
            }
            object newElmt = constructor.Invoke(new object[] { });

            if (addMethod == null)
            {
                Debug.LogError("There is no Add method on this collection.");
                return;
            }
            addMethod.Invoke(obj, new object[] { newElmt });

            table.UpdateContent();
        }
        public override bool IsCompatibleWithMember(MemberInfo member)
        {
            Type type = PropertyOrFieldInfo.GetPropertyOrFieldType(member);

            return(IsIntegerType(type) || IsDecimalType(type) || IsStringType(type));
        }
Esempio n. 5
0
 protected static bool IsOfCompatibleType(MemberInfo member, params Type[] compatibleTypes)
 {
     return(compatibleTypes != null && compatibleTypes.Any(t => t.IsAssignableFrom(PropertyOrFieldInfo.GetPropertyOrFieldType(member))));
 }
        public override bool IsCompatibleWithMember(MemberInfo member)
        {
            Type propType = PropertyOrFieldInfo.GetPropertyOrFieldType(member);

            return(propType != null && propType.IsEnum);
        }
        public object KeySelector(object elmt)
        {
            PropertyOrFieldInfo property = new PropertyOrFieldInfo(elmt.GetType().GetMember(sortingColumn.fieldName)[0]);

            return(property.GetValue(elmt));
        }