private PropertyBase CreateNewProperty(PersistentType ownerPersistentType, PropertyKind newPropertyKind)
        {
            int propertiesCount = 0;

            PropertyBase newProperty = null;

            switch (newPropertyKind)
            {
            case PropertyKind.Scalar:
                newProperty = new ScalarProperty(ownerPersistentType.Partition);
                ownerPersistentType.Properties.Add(newProperty);
                propertiesCount = ownerPersistentType.Properties.OfType <ScalarProperty>().Count();
                break;

            case PropertyKind.Structure:
                newProperty = new StructureProperty(ownerPersistentType.Partition);
                ownerPersistentType.Properties.Add(newProperty);
                propertiesCount = ownerPersistentType.Properties.OfType <StructureProperty>().Count();
                break;

            case PropertyKind.Navigation:
                newProperty = new NavigationProperty(ownerPersistentType.Partition);
                ownerPersistentType.NavigationProperties.Add((NavigationProperty)newProperty);
                propertiesCount = ownerPersistentType.NavigationProperties.OfType <NavigationProperty>().Count();
                break;
            }

            newProperty.Name = string.Format("{0}Property{1}", newPropertyKind, propertiesCount + 1);

            return(newProperty);
        }
示例#2
0
        protected override void OnCopy(Microsoft.VisualStudio.Modeling.ModelElement sourceElement)
        {
            base.OnCopy(sourceElement);

            StructureProperty sourceProperty = (StructureProperty)sourceElement;

            this.Type = sourceProperty.Type;
        }