/// <summary> Property setter</summary> /// <param name="obj"> /// </param> /// <param name="identifier"> /// </param> /// <param name="arg"> /// </param> /// <param name="i"> /// </param> /// <returns> A Velocity Setter method. /// </returns> /// <throws> Exception </throws> public virtual IVelPropertySet GetPropertySet(object obj, string identifier, object arg, Info i) { if (obj == null) { return(null); } System.Type claz = obj.GetType(); /* * first try for a setFoo() type of property * (also setfoo() ) */ SetExecutor executor = new SetPropertyExecutor(log, introspector, claz, identifier, arg); /* * Let's see if we are a map... */ if (!executor.Alive) { executor = new MapSetExecutor(log, claz, identifier); } /* * if that didn't work, look for Put("foo", arg) */ if (!executor.Alive) { executor = new PutExecutor(log, introspector, claz, arg, identifier); } return((executor.Alive) ? new VelSetterImpl(executor) : null); }
public ExpressionPropertyAccessor(Type type, string propertyName) { var getMethod = type.GetMethod("get_" + propertyName); var setMethod = type.GetMethod("set_" + propertyName); if (getMethod == null && setMethod == null) throw new InvalidProgramException(); if (getMethod != null) getExecutor = new GetPropertyExecutor(getMethod); if (setMethod != null) setExecutor = new SetPropertyExecutor(setMethod); }