本文整理汇总了C#中Class2.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Class2.SetProperty方法的具体用法?C# Class2.SetProperty怎么用?C# Class2.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class2
的用法示例。
在下文中一共展示了Class2.SetProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SupportDynamicProperties_1
public void SupportDynamicProperties_1()
{
ContentTypeInstaller.InstallContentType(@"<ContentType name='Class2' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields /></ContentType>");
//-- Checks the contettype and indexing subsystem usability. Do not remove!
var x = SenseNet.Search.ContentQuery.Query("Name:*admin* .SORT:Id .TOP:100");
string contentString1before = null;
int contentInteger1before = 0;
string contentString2before = null;
int contentInteger2before = 0;
DataType contentEnumBefore = DataType.Binary;
string handlerString1after = null;
int handlerInteger1after = 0;
DataType handlerEnumAfter = DataType.Binary;
string handlerString2after = null;
int handlerInteger2after = 0;
try
{
var handler = new Class2(TestRoot);
handler.DynamicString = "Startup value";
handler.DynamicInteger = 12;
handler.SetProperty("VeryDynamicString", "Initial");
handler.SetProperty("VeryDynamicInteger", 34);
handler.RepoDataType = DataType.Int;
var content = Content.Create(handler);
contentString1before = (string)content["DynamicString"];
contentInteger1before = (int)content["DynamicInteger"];
contentEnumBefore = (DataType)Enum.Parse(typeof(DataType), ((List<string>)content["RepoDataType"])[0]);
contentString2before = (string)content["VeryDynamicString"];
contentInteger2before = (int)content["VeryDynamicInteger"];
content["DynamicString"] = "New value";
content["DynamicInteger"] = 98;
content["RepoDataType"] = new List<string>(new string[] { ((int)DataType.DateTime).ToString() });
content["VeryDynamicString"] = "Modified";
content["VeryDynamicInteger"] = 76;
content.Save();
handlerString1after = handler.DynamicString;
handlerInteger1after = handler.DynamicInteger;
handlerEnumAfter = handler.RepoDataType;
handlerString2after = (string)handler.PropertyBag["VeryDynamicString"];
handlerInteger2after = (int)handler.PropertyBag["VeryDynamicInteger"];
}
finally
{
ContentTypeInstaller.RemoveContentType("Class2");
}
Assert.IsTrue(contentString1before == "Startup value", "#1");
Assert.IsTrue(contentInteger1before == 12, "#2");
Assert.IsTrue(contentEnumBefore == DataType.Int, "#3");
Assert.IsTrue(contentString2before == "Initial", "#4");
Assert.IsTrue(contentInteger2before == 34, "#5");
Assert.IsTrue(handlerString1after == "New value", "#6");
Assert.IsTrue(handlerInteger1after == 98, "#7");
Assert.IsTrue(handlerEnumAfter == DataType.DateTime, "#8");
Assert.IsTrue(handlerString2after == "Modified", "#9");
Assert.IsTrue(handlerInteger2after == 76, "#10");
}