SetPropertyValue() public method

Sets a property value.
public SetPropertyValue ( IExpression propertyExpression, object val ) : void
propertyExpression IExpression /// The property expression that should be used to set the property value. ///
val object The new value.
return void
        /// <summary>
        /// Post Domain轉DTO
        /// </summary>
        /// <param name="postList">PostDomain</param>
        /// <returns>ReportPostVO</returns>
        public static IList<ReportPostVO> ToDataTransferObjects(IList<PostVO> postList, int columnSize)
        {
            if (postList == null || columnSize < 1) return null;

            IList<ReportPostVO> result = new List<ReportPostVO>();

            ReportPostVO currentReportPostVO = new ReportPostVO();
            for (int i = 0; i < postList.Count; i++)
            {
                if (i == 0)
                {
                    currentReportPostVO = new ReportPostVO();
                    currentReportPostVO.Post1 = postList[i];
                }
                else
                {
                    //取餘數
                    int mod = i % columnSize;

                    if (mod == 0)
                    {
                        result.Add(currentReportPostVO);
                        currentReportPostVO = new ReportPostVO();
                        currentReportPostVO.Post1 = postList[i];
                    }
                    else
                    {
                        ObjectWrapper ow = new ObjectWrapper(currentReportPostVO);
                        ow.SetPropertyValue(string.Format("Post{0}", mod + 1), postList[i]);
                    }
                }
            }

            //將最後的加入
            if (currentReportPostVO != null)
            {
                result.Add(currentReportPostVO);
            }

            return result;
        }
        /// <summary>
        /// Convert QueryResults by generate decorate serializable class with transformed values.
        /// </summary>
        /// <param name="dynamicPageService"></param>
        /// <param name="results"></param>
        /// <returns></returns>
        private static IEnumerable ConvertQueryResults(IDynamicPage dynamicPageService, IEnumerable results)
        {
            IEnumerable<object> originalObjects = results.Cast<object>();
            if (originalObjects.Count() == 0) return results;

            IEnumerable<PropertyDefinition> propertyDecorateConfigs = CreatePropertyDecorateConfigs(dynamicPageService);
            IEnumerable<object> convertResults = null;

            try
            {
                convertResults = ClassDecorator.CreateDecorateObjects(originalObjects, propertyDecorateConfigs.ToArray()).Cast<object>();
            }
            catch (CompileException exp)
            {
                string loggingMessage = string.Format(CultureInfo.InvariantCulture, "There has errors to compile a dynamic class from dynamic page configuration to render UI grid of the dynamic page with object id equals to \"{0}\".", QueryStringUtility.ObjectId);
                Logger.Instance(typeof(DynamicPageDataServiceHandler)).Error(loggingMessage, exp);
                throw;
            }

            ObjectWrapper convertResultObjectWrapper = new ObjectWrapper(convertResults.First().GetType());
            for (int i = 0; i < originalObjects.Count(); i++)
            {
                object originalObject = originalObjects.ElementAt(i);
                GridRowControlBindEventArgs arg = new GridRowControlBindEventArgs(originalObject);
                dynamicPageService.OnGridRowControlsBind(arg);
                convertResultObjectWrapper.WrappedInstance = convertResults.ElementAt(i);

                // set visibility of checkbox
                bool showCheckBoxColumn = (bool)convertResultObjectWrapper.GetPropertyValue(DynamicPageDataServiceHandler.ShowCheckBoxColumnPropertyName);
                convertResultObjectWrapper.SetPropertyValue(DynamicPageDataServiceHandler.ShowCheckBoxColumnPropertyName, showCheckBoxColumn && arg.ShowCheckBoxColumn);

                // set visibility of edit button
                string permissionValue = string.Format(CultureInfo.InvariantCulture, "{0}.Update", dynamicPageService.Configuration.PermissionValue);
                bool hasUpdatePermission = permissionBridge.HasPermission(permissionValue);
                bool showEditButtonColumn = (bool)convertResultObjectWrapper.GetPropertyValue(DynamicPageDataServiceHandler.ShowEditButtonColumnPropertyName);
                convertResultObjectWrapper.SetPropertyValue(DynamicPageDataServiceHandler.ShowEditButtonColumnPropertyName, showEditButtonColumn && arg.ShowEditButton && hasUpdatePermission);

                // set visibility of view button
                bool showViewButtonColumn = (bool)convertResultObjectWrapper.GetPropertyValue(DynamicPageDataServiceHandler.ShowViewButtonColumnPropertyName);
                convertResultObjectWrapper.SetPropertyValue(DynamicPageDataServiceHandler.ShowViewButtonColumnPropertyName, showViewButtonColumn && arg.ShowViewButton);

                // set visibility of delete button
                permissionValue = string.Format(CultureInfo.InvariantCulture, "{0}.Delete", dynamicPageService.Configuration.PermissionValue);
                bool hasDeletePermission = permissionBridge.HasPermission(permissionValue);
                bool showDeleteButtonColumn = (bool)convertResultObjectWrapper.GetPropertyValue(DynamicPageDataServiceHandler.ShowDeleteButtonColumnPropertyName);
                convertResultObjectWrapper.SetPropertyValue(DynamicPageDataServiceHandler.ShowDeleteButtonColumnPropertyName, showDeleteButtonColumn && arg.ShowDeleteButton && hasDeletePermission);
            }

            return convertResults;
        }