コード例 #1
0
        private Node _CreateAutomobile(string name)
        {
            var automobileNode = new AutomobileHandler(_testRoot);

            automobileNode.Name = name;
            return(automobileNode);
        }
コード例 #2
0
        public void Content_UsingFields_WriteNodeAttribute()
        {
            string contentTypeDef = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='Automobile' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='Name' type='ShortText' />
						<Field name='Path' type='ShortText' />
						<Field name='Created' type='WhoAndWhen'>
							<Bind property='CreatedBy' />
							<Bind property='CreationDate' />
						</Field>
						<Field name='Modified' type='WhoAndWhen'>
							<Bind property='ModifiedBy' />
							<Bind property='ModificationDate' />
						</Field>
						<Field name='Manufacturer' type='ShortText' />
						<Field name='Driver' type='ShortText' />
					</Fields>
				</ContentType>"                ;

            ContentTypeInstaller.InstallContentType(contentTypeDef);

            Node automobileNode = Node.LoadNode(String.Concat(_testRoot.Path, "/Automobile12"));

            if (automobileNode != null)
            {
                automobileNode.ForceDelete();
            }


            automobileNode                 = new AutomobileHandler(_testRoot);
            automobileNode.Name            = "Automobile12";
            automobileNode["Manufacturer"] = "Honda";
            automobileNode["Driver"]       = "Gyeby";
            automobileNode.Save();

            string path = automobileNode.Path;

            SNC.Content automobileContent = SNC.Content.Create(automobileNode);
            automobileContent["Index"] = 987;
            automobileContent.Save();

            automobileNode = Node.LoadNode(path);
            int index = automobileNode.Index;

            automobileNode.ForceDelete();

            Assert.IsTrue(index == 987);
        }