Represents an attribute storing the name for the entity
Inheritance: TypedAttribute
示例#1
0
        /// <summary>
        /// Create some properties for a TypedEntity
        /// </summary>
        /// <param name="assignIds"></param>
        /// <param name="callback"></param>
        private static void CreateMockTypedEntityProperties(
            bool assignIds,
            Action <EntitySchema, TypedAttribute[]> callback)
        {
            //create a tab

            var groupDefinition = CreateAttributeGroup("tab-1", "Tab 1", 0);

            if (assignIds)
            {
                groupDefinition.Id = new HiveId(Guid.NewGuid());
            }
            var generalGroup = FixedGroupDefinitions.GeneralGroup;

            //create some data types

            var typeDefinition = CreateAttributeType(TypeAlias1,
                                                     "test-type-name",
                                                     "test-type-description");

            if (assignIds)
            {
                typeDefinition.Id = new HiveId(Guid.NewGuid());
            }

            var typeDefinition2 = CreateAttributeType(TypeAlias2,
                                                      "test-type-name2",
                                                      "test-type-description2");

            if (assignIds)
            {
                typeDefinition2.Id = new HiveId(Guid.NewGuid());
            }

            //create some documenttype properties

            var attribDef1 = CreateAttributeDefinition(DefAlias1WithType1, "name-1", "test-description", typeDefinition, groupDefinition);

            if (assignIds)
            {
                attribDef1.Id = new HiveId(Guid.NewGuid());
            }

            var attribDef2 = CreateAttributeDefinition(DefAlias2WithType1, "name-2", "test-description", typeDefinition, groupDefinition);

            if (assignIds)
            {
                attribDef2.Id = new HiveId(Guid.NewGuid());
            }

            var attribDef3 = CreateAttributeDefinition("def-alias-3-with-type2", "name-3", "test-description", typeDefinition2, groupDefinition);

            if (assignIds)
            {
                attribDef3.Id = new HiveId(Guid.NewGuid());
            }

            var attribDef4 = CreateAttributeDefinition("def-alias-4-with-type2", "name-4", "test-description", typeDefinition2, groupDefinition);

            if (assignIds)
            {
                attribDef4.Id = new HiveId(Guid.NewGuid());
            }

            var nodeNameAttributeDefinition = new NodeNameAttributeDefinition(generalGroup);

            if (assignIds)
            {
                nodeNameAttributeDefinition.Id = new HiveId(Guid.NewGuid());
            }

            var selectedTemplateDefinition = new SelectedTemplateAttributeDefinition(generalGroup);

            if (assignIds)
            {
                selectedTemplateDefinition.Id = new HiveId(Guid.NewGuid());
            }

            //create the document type

            var schema = CreateEntitySchema("test-doctype-alias", "test-doctype-name",
                                            new[] { attribDef1, attribDef2, attribDef3, attribDef4, nodeNameAttributeDefinition, selectedTemplateDefinition });

            if (assignIds)
            {
                schema.Id = new HiveId(Guid.NewGuid());
            }

            //create some content properties

            var attribute1 = CreateAttribute(attribDef1, "my-test-value1");

            if (assignIds)
            {
                attribute1.Id = new HiveId(Guid.NewGuid());
            }

            var attribute2 = CreateAttribute(attribDef2, "my-test-value2");

            if (assignIds)
            {
                attribute2.Id = new HiveId(Guid.NewGuid());
            }

            var attribute3 = CreateAttribute(attribDef3, "my-test-value3");

            if (assignIds)
            {
                attribute3.Id = new HiveId(Guid.NewGuid());
            }

            var attribute4 = CreateAttribute(attribDef4, "5");

            if (assignIds)
            {
                attribute4.Id = new HiveId(Guid.NewGuid());
            }

            var nodeNameAttribute = new NodeNameAttribute("my-test-name", generalGroup)
            {
                AttributeDefinition = nodeNameAttributeDefinition
            };

            if (assignIds)
            {
                nodeNameAttribute.Id = new HiveId(Guid.NewGuid());
            }

            var selectedTemplateAttribute = new SelectedTemplateAttribute(new HiveId(Guid.NewGuid()), generalGroup)
            {
                AttributeDefinition = selectedTemplateDefinition
            };

            if (assignIds)
            {
                selectedTemplateAttribute.Id = new HiveId(Guid.NewGuid());
            }

            callback(schema, new[] { attribute1, attribute2, attribute3, attribute4, nodeNameAttribute, selectedTemplateAttribute });
        }
        /// <summary>
        /// Create some properties for a TypedEntity
        /// </summary>
        /// <param name="assignIds"></param>
        /// <param name="callback"></param>
        private static void CreateMockTypedEntityProperties(
            bool assignIds,
            Action<EntitySchema, TypedAttribute[]> callback)
        {

            //create a tab

            var groupDefinition = CreateAttributeGroup("tab-1", "Tab 1", 0);
            if (assignIds) groupDefinition.Id = new HiveId(Guid.NewGuid());
            var generalGroup = FixedGroupDefinitions.GeneralGroup;

            //create some data types

            var typeDefinition = CreateAttributeType(TypeAlias1,
                                                                          "test-type-name",
                                                                          "test-type-description");
            if (assignIds) typeDefinition.Id = new HiveId(Guid.NewGuid());

            var typeDefinition2 = CreateAttributeType(TypeAlias2,
                                                                           "test-type-name2",
                                                                           "test-type-description2");
            if (assignIds) typeDefinition2.Id = new HiveId(Guid.NewGuid());

            //create some documenttype properties

            var attribDef1 = CreateAttributeDefinition(DefAlias1WithType1, "name-1", "test-description", typeDefinition, groupDefinition);
            if (assignIds) attribDef1.Id = new HiveId(Guid.NewGuid());

            var attribDef2 = CreateAttributeDefinition(DefAlias2WithType1, "name-2", "test-description", typeDefinition, groupDefinition);
            if (assignIds) attribDef2.Id = new HiveId(Guid.NewGuid());

            var attribDef3 = CreateAttributeDefinition("def-alias-3-with-type2", "name-3", "test-description", typeDefinition2, groupDefinition);
            if (assignIds) attribDef3.Id = new HiveId(Guid.NewGuid());

            var attribDef4 = CreateAttributeDefinition("def-alias-4-with-type2", "name-4", "test-description", typeDefinition2, groupDefinition);
            if (assignIds) attribDef4.Id = new HiveId(Guid.NewGuid());

            var nodeNameAttributeDefinition = new NodeNameAttributeDefinition(generalGroup);
            if (assignIds) nodeNameAttributeDefinition.Id = new HiveId(Guid.NewGuid());

            var selectedTemplateDefinition = new SelectedTemplateAttributeDefinition(generalGroup);
            if (assignIds) selectedTemplateDefinition.Id = new HiveId(Guid.NewGuid());

            //create the document type

            var schema = CreateEntitySchema("test-doctype-alias", "test-doctype-name",
                                                                    new[] { attribDef1, attribDef2, attribDef3, attribDef4, nodeNameAttributeDefinition, selectedTemplateDefinition });

            if (assignIds) schema.Id = new HiveId(Guid.NewGuid());

            //create some content properties

            var attribute1 = CreateAttribute(attribDef1, "my-test-value1");
            if (assignIds) attribute1.Id = new HiveId(Guid.NewGuid());

            var attribute2 = CreateAttribute(attribDef2, "my-test-value2");
            if (assignIds) attribute2.Id = new HiveId(Guid.NewGuid());

            var attribute3 = CreateAttribute(attribDef3, "my-test-value3");
            if (assignIds) attribute3.Id = new HiveId(Guid.NewGuid());

            var attribute4 = CreateAttribute(attribDef4, "5");
            if (assignIds) attribute4.Id = new HiveId(Guid.NewGuid());

            var nodeNameAttribute = new NodeNameAttribute("my-test-name", generalGroup) { AttributeDefinition = nodeNameAttributeDefinition };
            if (assignIds) nodeNameAttribute.Id = new HiveId(Guid.NewGuid());

            var selectedTemplateAttribute = new SelectedTemplateAttribute(new HiveId(Guid.NewGuid()), generalGroup) { AttributeDefinition = selectedTemplateDefinition };
            if (assignIds) selectedTemplateAttribute.Id = new HiveId(Guid.NewGuid());

            callback(schema, new[] { attribute1, attribute2, attribute3, attribute4, nodeNameAttribute, selectedTemplateAttribute });

        }