Пример #1
0
        public MetaPropertyInstruction(MetaPropertySetter setter, MetaEntityClassProperty _property)
        {
            name     = setter.name;
            property = _property;

            if (property == null)
            {
                value = setter.Value.toStringSafe();
            }
            else
            {
                if (property.type.HasFlag(MetaEntityClassPropertyType.collection))
                {
                    IList setterList = setter.Value as IList;

                    String valueInner = "";
                    foreach (var Value in setterList)
                    {
                        valueInner = valueInner.add(getValueString(Value, property), ", ");
                    }
                    value = "[ " + valueInner + " ]";
                }
                else
                {
                    value = getValueString(setter.Value, property);
                }
            }
        }
Пример #2
0
        public override IMetaEntityExpressionTarget SelectTarget(string expressionPathNode)
        {
            IMetaEntityExpressionTarget head = this;

            if (expressionPathNode.isNullOrEmpty())
            {
                return(head);
            }

            MetaEntityClassProperty property = this.EntityClassDefinition.Properties.FirstOrDefault(x => x.name.Equals(expressionPathNode));

            if (property.type.HasFlag(MetaEntityClassPropertyType.value))
            {
                head = Setters.FirstOrDefault(x => x.name == expressionPathNode);
            }
            else if (property.type.HasFlag(MetaEntityClassPropertyType.entity))
            {
                head = Items.FirstOrDefault(x => x.name == expressionPathNode);

                //if (property.type.HasFlag(MetaEntityClassPropertyType.collection))
                //{
                //    return property;
                //}
                //else
                //{

                //}
            }
            ;

            return(head);
        }
Пример #3
0
        protected String getValueString(Object _Value, MetaEntityClassProperty _property)
        {
            String output = "";

            if (_property.GetValueType().isNumber())
            {
                output = _Value.toStringSafe(_property.ValueFormat);
            }
            else
            {
                output = $"\"{_Value.toStringSafe()}\"";
            }
            return(output);
        }
Пример #4
0
        public MetaEntityClassProperty FindProperty(MetaTablePropertyAliasEntry propertyName)
        {
            MetaEntityClassProperty property = Properties.FirstOrDefault(x => x.name.Equals(propertyName.rootPropertyName, StringComparison.InvariantCultureIgnoreCase));

            if (property == null)
            {
                foreach (String variation in propertyName.aliasPropertyNames)
                {
                    property = Properties.FirstOrDefault(x => x.name.Equals(variation, StringComparison.InvariantCultureIgnoreCase));
                    if (property != null)
                    {
                        break;
                    }
                }
            }

            return(property);
        }
Пример #5
0
        public void SetSetter(String propertyName, Object value)
        {
            MetaEntityClassProperty property = this.EntityClassDefinition.FindProperty(propertyName); //.Properties.FirstOrDefault(x => x.name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase));

            var setter = Setters.FirstOrDefault(x => x.name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase));

            if (property.type.HasFlag(MetaEntityClassPropertyType.collection))
            {
                if (setter.Value is IList valueList)
                {
                    valueList.Add(value);
                }
            }
            else
            {
                setter.Value = value;
            }
        }
Пример #6
0
        public MetaEntityClassProperty AddProperty(MetaTableProperty property, Boolean throwException = true)
        {
            MetaEntityClassProperty newProperty = new MetaEntityClassProperty()
            {
                type         = MetaEntityClassPropertyType.value,
                PropertyName = property.PropertyName,
                DisplayName  = property.DisplayName
            };

            newProperty.Learn(property);

            if (AddProperty(newProperty, throwException))
            {
                return(newProperty);
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
        public MetaEntityClassProperty AddEntityProperty(String propertyName, String EntityClassName, Boolean isCollection = false)
        {
            var type = MetaEntityClassPropertyType.entity;

            if (isCollection)
            {
                type |= MetaEntityClassPropertyType.collection;
            }

            MetaEntityClassProperty newProperty = new MetaEntityClassProperty()
            {
                type             = type,
                PropertyTypeName = EntityClassName,
                name             = propertyName
            };

            AddProperty(newProperty);


            return(newProperty);
        }
Пример #8
0
 public Boolean AddProperty(MetaEntityClassProperty newProperty, Boolean throwException = true)
 {
     if (newProperty.name.isNullOrEmpty())
     {
         throw new ArgumentOutOfRangeException(nameof(newProperty), $"Property name is null or empty");
     }
     if (!Properties.Any(x => x.name == newProperty.name))
     {
         newProperty.Parent = this;
         Properties.Add(newProperty);
         return(true);
     }
     else
     {
         if (throwException)
         {
             throw new ArgumentOutOfRangeException(nameof(newProperty), $"Property {newProperty.name} already declared");
         }
     }
     return(false);
 }
Пример #9
0
        public MetaEntityClassProperty AddValueProperty(String propertyName, Type valueType)
        {
            var    ilistInterface    = valueType.GetInterface(nameof(IList));
            var    type              = MetaEntityClassPropertyType.value;
            String propertyValueType = valueType.Name;

            if (ilistInterface != null)
            {
                type |= MetaEntityClassPropertyType.collection;
                propertyValueType = valueType.GetGenericArguments().FirstOrDefault().Name;
            }
            MetaEntityClassProperty newProperty = new MetaEntityClassProperty()
            {
                type             = type,
                PropertyTypeName = propertyValueType,
                name             = propertyName
            };

            AddProperty(newProperty);


            return(newProperty);
        }
        public void SetSelection(IMetaEntityExpressionTarget target, Boolean isFirst = true)
        {
            if (target == null)
            {
                return;
            }

            if (isFirst)
            {
                SelectedClass               = null;
                SelectedNamespace           = null;
                SelectedNamespaceCollection = null;
                SelectedProperty            = null;
            }

            if (target is MetaEntityClassProperty targetProperty)
            {
                SelectedProperty = targetProperty;
            }
            else if (target is MetaEntityClass targetClass)
            {
                SelectedClass = targetClass;
            }
            else if (target is MetaEntityNamespace targetNamespace)
            {
                SelectedNamespace = targetNamespace;
            }
            else if (target is MetaEntityNamespaceCollection targetNamespaceCollection)
            {
                SelectedNamespaceCollection = targetNamespaceCollection;
            }

            if (target.Parent != null && target.Parent != target)
            {
                SetSelection(target.Parent, false);
            }
        }
Пример #11
0
        public override IMetaEntityExpressionTarget SelectTarget(string expressionPathNode)
        {
            if (MetaEntityTools.IsMultinodeExpressionPath(expressionPathNode))
            {
                return(Parent.SelectTargetByPath(expressionPathNode));
            }

            IMetaEntityExpressionTarget head = this;

            MetaEntityClassProperty property = this.Properties.FirstOrDefault(x => x.name == expressionPathNode);

            if (property == null)
            {
                property = new MetaEntityClassProperty()
                {
                    name = expressionPathNode,
                    type = MetaEntityClassPropertyType.none
                };

                AddProperty(property, false);
            }

            return(property);
        }
Пример #12
0
        public MetaEntityClassProperty FindProperty(String propertyName)
        {
            MetaEntityClassProperty property = Properties.FirstOrDefault(x => x.name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase));

            return(property);
        }