Пример #1
0
        public void ContentList_AvailableFields()
        {
            ContentType c = ContentType.GetByName("CT_Root");

            if (c != null)
            {
                ContentTypeInstaller.RemoveContentType(c);
            }
            ContentTypeManager.Reset();

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            installer.AddContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='CT_Root' parentType='GenericContent' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='InheritanceTest' type='Integer'>
							<Configuration><MinValue>-5</MinValue><MaxValue>7</MaxValue></Configuration>
						</Field>
					</Fields>
				</ContentType>"                );

            installer.AddContentType("<ContentType name='CT_A' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>0</MinValue><MaxValue>10</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_A_A' parentType='CT_A' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>1</MinValue><MaxValue>20</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>2</MinValue><MaxValue>30</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B_B' parentType='CT_B' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>3</MinValue><MaxValue>40</MaxValue></Configuration></Field></Fields></ContentType>");

            installer.ExecuteBatch();

            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";

            var b = new bool[21];

            ContentType  CT_Root = ContentType.GetByName("CT_Root");
            FieldSetting FS_Root = CT_Root.FieldSettings[0];

            ContentType  CT_A   = ContentType.GetByName("CT_A");
            ContentType  CT_B   = ContentType.GetByName("CT_B");
            FieldSetting FS_A   = CT_A.FieldSettings[0];
            ContentType  CT_A_A = ContentType.GetByName("CT_A_A");
            FieldSetting FS_A_A = CT_A_A.FieldSettings[0];

            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            var list = new ContentList(this.TestRoot);

            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes     = new[] { CT_A, CT_B };

            list.Save();

            b[0] = FS_Root.ParentFieldSetting == null;
            b[1] = FS_A.ParentFieldSetting == FS_Root;
            b[2] = FS_A_A.ParentFieldSetting == FS_A;

            var fields = list.GetAvailableFields();
        }
Пример #2
0
        public void ContentList_AvailableFields()
        {
            ContentType c = ContentType.GetByName("CT_Root");
            if (c != null)
                ContentTypeInstaller.RemoveContentType(c);
            ContentTypeManager.Reset();

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            installer.AddContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='CT_Root' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='InheritanceTest' type='Integer'>
							<Configuration><MinValue>-5</MinValue><MaxValue>7</MaxValue></Configuration>
						</Field>
					</Fields>
				</ContentType>");

            installer.AddContentType("<ContentType name='CT_A' parentType='CT_Root' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>0</MinValue><MaxValue>10</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_A_A' parentType='CT_A' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>1</MinValue><MaxValue>20</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B' parentType='CT_Root' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>2</MinValue><MaxValue>30</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B_B' parentType='CT_B' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>3</MinValue><MaxValue>40</MaxValue></Configuration></Field></Fields></ContentType>");

            installer.ExecuteBatch();

            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";

            var b = new bool[21];

            ContentType CT_Root = ContentType.GetByName("CT_Root");
            FieldSetting FS_Root = CT_Root.FieldSettings[0];

            ContentType CT_A = ContentType.GetByName("CT_A");
            ContentType CT_B = ContentType.GetByName("CT_B");
            FieldSetting FS_A = CT_A.FieldSettings[0];
            ContentType CT_A_A = ContentType.GetByName("CT_A_A");
            FieldSetting FS_A_A = CT_A_A.FieldSettings[0];

            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
            if (Node.Exists(path))
                Node.ForceDelete(path);

            var list = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes = new[] { CT_A, CT_B };

            list.Save();

            b[0] = FS_Root.ParentFieldSetting == null;
            b[1] = FS_A.ParentFieldSetting == FS_Root;
            b[2] = FS_A_A.ParentFieldSetting == FS_A;

            var fields = list.GetAvailableFields();
        }