Ejemplo n.º 1
0
        private void AddItemsToList()
        {
            var stringBuilder = new StringBuilder();

            var items = (IList)_propertyValue.GetType().GetProperty("Items").GetValue(_propertyValue, null);

            if (items != null)
            {
                foreach (var item in items)
                {
                    var property           = (PropertyData)item;
                    var serializedProperty = SerializeProperty(property);
                    var exerpt             = property.Preview;

                    if (!string.IsNullOrEmpty(serializedProperty))
                    {
                        serializedProperty = Uri.EscapeUriString(serializedProperty);
                    }

                    stringBuilder.AppendFormat("<li class=\"btn btn-default collection-item\" data-value=\"{0}\"><a href=\"#\" onclick=\"top.propertyEditor.collection.editField(this);return false;\" class=\"pull-right\"><i class=\"icon icon-edit\"></i> edit</a><i class=\"icon icon-sort\"></i> {1}</li>", serializedProperty, exerpt);
                }
            }

            Items.InnerHtml = stringBuilder.ToString();
        }
 protected override void HandleSetterAccessor(IInvocation invocation, PropertyData propertyData)
 {
     IPropertyDataInterceptor propertyInterceptor = _contentDataInterceptorHandler.GetPropertyInterceptor(propertyData.GetType());
     if (propertyInterceptor != null)
     {
         Type parameterType = invocation.Method.GetParameters()[0].ParameterType;
         propertyInterceptor.SetValue(propertyData, parameterType, invocation.Arguments[0]);
     }
     else
     {
         propertyData.Value = invocation.Arguments[0];
     }
 }
 protected override void HandleGetterAccessor(IInvocation invocation, PropertyData propertyData)
 {
     IPropertyDataInterceptor propertyInterceptor = _contentDataInterceptorHandler.GetPropertyInterceptor(propertyData.GetType());
     if (propertyInterceptor != null)
     {
         invocation.ReturnValue = propertyInterceptor.GetValue(propertyData, invocation.Method.ReturnType);
     }
     else if ((propertyData.Value == null) && invocation.Method.ReturnType.IsValueType)
     {
         invocation.ReturnValue = Activator.CreateInstance(invocation.Method.ReturnType);
     }
     else
     {
         invocation.ReturnValue = propertyData.Value;
     }
 }
        protected override void HandleSetterAccessor(IInvocation invocation, PropertyData propertyData)
        {
            IPropertyDataInterceptor propertyInterceptor = _contentDataInterceptorHandler.GetPropertyInterceptor(propertyData.GetType());

            if (propertyInterceptor != null)
            {
                Type parameterType = invocation.Method.GetParameters()[0].ParameterType;
                propertyInterceptor.SetValue(propertyData, parameterType, invocation.Arguments[0]);
            }
            else
            {
                propertyData.Value = invocation.Arguments[0];
            }
        }
        protected override void HandleGetterAccessor(IInvocation invocation, PropertyData propertyData)
        {
            IPropertyDataInterceptor propertyInterceptor = _contentDataInterceptorHandler.GetPropertyInterceptor(propertyData.GetType());

            if (propertyInterceptor != null)
            {
                invocation.ReturnValue = propertyInterceptor.GetValue(propertyData, invocation.Method.ReturnType);
            }
            else if ((propertyData.Value == null) && invocation.Method.ReturnType.IsValueType)
            {
                invocation.ReturnValue = Activator.CreateInstance(invocation.Method.ReturnType);
            }
            else
            {
                invocation.ReturnValue = propertyData.Value;
            }
        }