Пример #1
0
 private void AddTextColumn(TextFieldData fieldData)
 {
     new TextField().CreateField(this, fieldData);
 }
Пример #2
0
        private void EvaluateColumnsForItem(ColumnCreationResult result, object item)
        {
            // First phase: Get the properties by using the metaclass
            var asElement = item as IElement;
            var metaClass = asElement?.metaclass;

            if (metaClass != null)
            {
                var dataLayer = _dataLayerLogic?.GetDataLayerOfObject(metaClass);
                var metaLayer = _dataLayerLogic?.GetMetaLayerFor(dataLayer);
                var uml = _dataLayerLogic?.Get<_UML>(metaLayer);

                if (uml != null && metaClass.isSet(_UML._Classification._Classifier.attribute))
                {
                    var properties = metaClass.get(_UML._Classification._Classifier.attribute) as IEnumerable;
                    if (properties != null)
                    {
                        foreach (var property in properties.Cast<IObject>())
                        {
                            var propertyName = property.get("name").ToString();
                            FieldData column;
                            if (!result.ColumnsOnProperty.TryGetValue(propertyName, out column))
                            {
                                column = new TextFieldData
                                {
                                    name = ConvertPropertyToColumnName(property),
                                    title = property.get(_UML._CommonStructure._NamedElement.name).ToString()
                                };

                                result.ColumnsOnProperty[propertyName] = column;
                            }
                        }
                    }
                }
            }

            // Second phase: Get properties by the object iself
            // This item does not have a metaclass and also no properties, so we try to find them by using the item
            var itemAsAllProperties = item as IObjectAllProperties;
            if (itemAsAllProperties != null)
            {
                var properties = itemAsAllProperties.getPropertiesBeingSet();

                foreach (var property in properties)
                {
                    FieldData column;
                    if (!result.ColumnsOnProperty.TryGetValue(property, out column))
                    {
                        column = new TextFieldData
                        {
                            name = ConvertPropertyToColumnName(property),
                            title =
                                _nameResolution == null ? property.ToString() : _nameResolution.GetName(property)
                        };

                        result.ColumnsOnProperty[property] = column;
                    }

                    var value = ((IObject) item).get(property);
                    column.isEnumeration |= value is IEnumerable && !(value is string);
                }
            }
        }