当前位置: 首页>>代码示例>>C#>>正文


C# Class2.SetProperty方法代码示例

本文整理汇总了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");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:63,代码来源:RuntimeContentTest.cs


注:本文中的Class2.SetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。