예제 #1
0
        // Registers entity types for styles, designs, projectData, templates and diagramControllers
        // with the cache.
        private void RegisterBaseLibraryTypes(bool create)
        {
            int version;

            // When creating a repository without a valid version, we use the last supported save version.
            if (create && repository.Version <= 0)
            {
                repository.Version = LastSupportedSaveVersion;
            }
            version = repository.Version;
            //
            repository.AddEntityType(new EntityType(CapStyle.EntityTypeName, EntityCategory.Style,
                                                    version, () => new CapStyle(), CapStyle.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(CharacterStyle.EntityTypeName, EntityCategory.Style,
                                                    version, () => new CharacterStyle(), CharacterStyle.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(ColorStyle.EntityTypeName, EntityCategory.Style,
                                                    version, () => new ColorStyle(), ColorStyle.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(FillStyle.EntityTypeName, EntityCategory.Style,
                                                    version, () => new FillStyle(), FillStyle.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(LineStyle.EntityTypeName, EntityCategory.Style,
                                                    version, () => new LineStyle(), LineStyle.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(ParagraphStyle.EntityTypeName, EntityCategory.Style,
                                                    version, () => new ParagraphStyle(), ParagraphStyle.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(Design.EntityTypeName, EntityCategory.Design,
                                                    version, () => new Design(), Design.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(ProjectSettings.EntityTypeName, EntityCategory.ProjectSettings,
                                                    version, () => new ProjectSettings(), ProjectSettings.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(Template.EntityTypeName, EntityCategory.Template,
                                                    version, () => new Template(), Template.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(Diagram.EntityTypeName, EntityCategory.Diagram,
                                                    version, () => new Diagram(""), Diagram.GetPropertyDefinitions(version)));
            // Register ModelMapping types
            // Create mandatory Model type
            repository.AddEntityType(new EntityType(Model.EntityTypeName, EntityCategory.Model,
                                                    version, () => new Model(), Model.GetPropertyDefinitions(version)));
            // Register mandatory ModelMapping types
            repository.AddEntityType(new EntityType(NumericModelMapping.EntityTypeName, EntityCategory.ModelMapping,
                                                    version, () => new NumericModelMapping(), NumericModelMapping.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(FormatModelMapping.EntityTypeName, EntityCategory.ModelMapping,
                                                    version, () => new FormatModelMapping(), FormatModelMapping.GetPropertyDefinitions(version)));
            repository.AddEntityType(new EntityType(StyleModelMapping.EntityTypeName, EntityCategory.ModelMapping,
                                                    version, () => new StyleModelMapping(), StyleModelMapping.GetPropertyDefinitions(version)));

            //
            // Create the mandatory shape types
            initializingLibrary = new Library(GetType().Assembly);
            ((IRegistrar)this).RegisterLibrary("Core", LastSupportedSaveVersion);
            ShapeType groupShapeType = new ShapeType(
                "ShapeGroup", "Core", "Core", ShapeGroup.CreateInstance, ShapeGroup.GetPropertyDefinitions, false);

            ((IRegistrar)this).RegisterShapeType(groupShapeType);
            // Create mandatory model object types
            ModelObjectType genericModelObjectType = new GenericModelObjectType(
                "GenericModelObject", "Core", "Core", GenericModelObject.CreateInstance, GenericModelObject.GetPropertyDefinitions, 4);

            ((IRegistrar)this).RegisterModelObjectType(genericModelObjectType);
            initializingLibrary = null;
            //
            // Register static model entity types
            foreach (ModelObjectType mot in modelObjectTypes)
            {
                RegisterModelObjectEntityType(mot, create);
            }
            // Register static shape entity types
            foreach (ShapeType st in shapeTypes)
            {
                RegisterShapeEntityType(st, create);
            }
        }