private void CheckOperators(List <dynamic> items)
 {
     for (var i = 0; i < items.Count; i++)
     {
         items[i].Operators = DynamicWrapperExtensions.ToDynamicList(items[i].Operators.ToString());
     }
 }
示例#2
0
        private void repositoryItemButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Kind == ButtonPredefines.Delete)
            {
                ((BaseEdit)sender).EditValue = new DynamicWrapper().ToString();
            }
            else if (e.Button.Kind == ButtonPredefines.Glyph)
            {
                var value = ((BaseEdit)sender).EditValue;
                var form  = new ValueEdit();
                form.Value = value != null?value.ToString() : string.Empty;

                form.ShowDialog();
            }
            else if (e.Button.Kind == ButtonPredefines.Ellipsis)
            {
                var instance = _dataSource.ToArray()[PropertiesView.FocusedRowHandle];
                CollectionProperty property = _rows[instance];

                //если разбираем свойство являющееся объектом
                var valueProperty = property.Properties[PropertiesView.FocusedColumn.FieldName] as ObjectProperty;


                dynamic propertyValue = null;
                try
                {
                    propertyValue =
                        DynamicWrapperExtensions.ToDynamic(
                            (string)
                            ObjectHelper.GetProperty(instance, PropertiesView.FocusedColumn.FieldName).ToString());
                    DesignerExtensions.SetSimplePropertiesFromInstance(valueProperty.SimpleProperties, propertyValue);
                    DesignerExtensions.SetCollectionPropertiesFromInstance(valueProperty.CollectionProperties,
                                                                           propertyValue);
                }
                catch (Exception)
                {
                    propertyValue =
                        DynamicWrapperExtensions.ToDynamicList(
                            (string)
                            ObjectHelper.GetProperty(instance, PropertiesView.FocusedColumn.FieldName).ToString());
                }


                if (valueProperty != null)
                {
                    SelectObjectProperty(sender, valueProperty);
                }

                var collectionProperty =
                    property.Properties[PropertiesView.FocusedColumn.FieldName] as CollectionProperty;

                if (collectionProperty != null)
                {
                    SelectCollectionProperty(sender, collectionProperty);
                }
            }
        }
        public dynamic GetLayout()
        {
            dynamic instanceLayout = new DynamicWrapper();

            instanceLayout.Items = DynamicWrapperExtensions.ToDynamicList(_properties["Items"].Value.ToString());

            foreach (var simpleProperty in _properties)
            {
                var objectProperty = simpleProperty.Value as ObjectProperty;

                instanceLayout[simpleProperty.Key] =
                    objectProperty != null ? objectProperty.Value : simpleProperty.Value.Value;
            }


            return(instanceLayout);
        }
示例#4
0
        private List <dynamic> ConvertDataSourceToDataTable(IEnumerable <dynamic> items)
        {
            //из-за того, что для Grid используется DataTable( грид не может показывать динамические объекты)
            //приходится выполнять обратное преобразование при возврате элементов коллекции
            var result = new List <dynamic>();

            foreach (var o in items)
            {
                dynamic instance = new DynamicWrapper();
                _rows.Add(instance, _collectionProperty.Clone(true));


                foreach (var property in _rows[instance].Properties)
                {
                    var objectProperty = property.Value as ObjectProperty;
                    if (objectProperty != null)
                    {
                        var propertyValue = ObjectHelper.GetProperty(o, property.Key) ?? new DynamicWrapper();
                        throw new ArgumentException("Необходим рефакторинг");
                        //objectProperty.SimpleProperties.SetSimplePropertiesFromInstance(propertyValue);
                        //objectProperty.CollectionProperties.SetCollectionPropertiesFromInstance(propertyValue);

                        instance[property.Key] = propertyValue;
                        continue;
                    }


                    var collectionProperty = property.Value as CollectionProperty;
                    if (collectionProperty != null)
                    {
                        var arr =
                            DynamicWrapperExtensions.ToDynamicList(ObjectHelper.GetProperty(o, property.Key).ToString());
                        collectionProperty.Items = arr.ToList();
                        instance[property.Key]   = ObjectHelper.GetProperty(o, property.Key).ToString();
                    }
                    else
                    {
                        instance[property.Key] = ObjectHelper.GetProperty(o, property.Key);
                    }
                }
                result.Add(instance);
            }
            return(result);
        }