예제 #1
0
        public MetaEntity CreateEntity(MetaEntityNamespace classCollection, String entityName = "")
        {
            MetaEntity output = new MetaEntity();

            output.EntityClassDefinition = this;
            output.EntityClassName       = name;
            output.name = entityName;

            MetaEntityItemSelection itemSelector = new MetaEntityItemSelection();


            foreach (var property in Properties)
            {
                if (property.type.HasFlag(MetaEntityClassPropertyType.value))
                {
                    if (property.type.HasFlag(MetaEntityClassPropertyType.collection))
                    {
                        output.Setters.Add(new MetaPropertySetter()
                        {
                            Parent = output, name = property.name, Value = new List <Object>()
                        });
                    }
                    else
                    {
                        output.Setters.Add(new MetaPropertySetter()
                        {
                            Parent = output, name = property.name
                        });
                    }
                }
                else if (property.type.HasFlag(MetaEntityClassPropertyType.entity))
                {
                    // itemSelector.SetSelection(classCollection.SelectTarget(property.PropertyTypeName));

                    var entityClass = classCollection.FindClass(property.PropertyTypeName);  // itemSelector.SelectedClass;

                    var subEntity = entityClass.CreateEntity(classCollection, property.name);
                    subEntity.Parent = output;

                    output.Items.Add(subEntity);

                    //classCollection.CreateEntity(property.name));
                }
            }

            return(output);
        }
예제 #2
0
        public Boolean AcceptData(MetaTable table)
        {
            var interpretation  = table.description.Interpretation;
            var EntitySelector  = table.description.MetaEntitySetterExpression;
            var EntityClassName = table.description.MetaEntityClassName.or(Settings.RootEntityClassNamepath);


            MetaEntity selectedEntity = CurrentEntity.SelectTarget(EntitySelector) as MetaEntity;

            selectedEntity.CheckClassDefinition(Namespaces, EntityClassName);

            if (selectedEntity.EntityClassDefinition == RootEntityClassSelection.SelectedClass)
            {
                interpretation = MetaTableInterpretation.singleEntity;
            }

            MetaEntityItemSelection ReflectionSelection = new MetaEntityItemSelection(selectedEntity.EntityClassDefinition);

            switch (interpretation)
            {
            case MetaTableInterpretation.singleEntity:
                MetaTableEntry firstEntry = table.entries.items.FirstOrDefault();
                selectedEntity.AcceptEntryProperties(firstEntry);
                break;

            case MetaTableInterpretation.multiEntities:

                foreach (var entry in table.entries.items)
                {
                    var subentity = selectedEntity.EntityClassDefinition.CreateEntity(ReflectionSelection.SelectedNamespace, "");
                    subentity.AcceptEntryProperties(entry);
                    selectedEntity.Items.Add(subentity);
                }
                break;

            default:
            case MetaTableInterpretation.triplets:
                return(false);

                break;
            }
            return(true);
        }