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


C# Configuration.SitecoreProperty类代码示例

本文整理汇总了C#中Glass.Sitecore.Mapper.Configuration.SitecoreProperty的典型用法代码示例。如果您正苦于以下问题:C# SitecoreProperty类的具体用法?C# SitecoreProperty怎么用?C# SitecoreProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SitecoreProperty类属于Glass.Sitecore.Mapper.Configuration命名空间,在下文中一共展示了SitecoreProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

        public void Setup()
        {
            _handler = new SitecoreLinkedHandler();
            _database = global::Sitecore.Configuration.Factory.GetDatabase("master");
            _target = _database.GetItem("/sitecore/content/Glass/ItemLinksTest");

            SitecoreProperty idProperty =  new SitecoreProperty(){
                            Attribute = new SitecoreIdAttribute(),
                            Property = typeof(SitecoreLinkedHandlerFixtureNS.LinkedTestClass).GetProperty("Id")
                        };
            SitecoreIdDataHandler idHandler = new SitecoreIdDataHandler();
            idHandler.ConfigureDataHandler(idProperty);
                 

            var context = new InstanceContext(
              (new SitecoreClassConfig[]{
                   new SitecoreClassConfig(){
                       ClassAttribute = new SitecoreClassAttribute(),
                       Properties = new SitecoreProperty[]{
                           idProperty                       
                       },
                       Type = typeof(SitecoreLinkedHandlerFixtureNS.LinkedTestClass),
                       DataHandlers = new AbstractSitecoreDataHandler []{
                            idHandler
                       }
                   }
               }).ToDictionary(), new AbstractSitecoreDataHandler[] { });


        

            _service = new SitecoreService(_database, context);

        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:34,代码来源:SitecoreLinkedHandlerFixture.cs

示例2: GetValue_SingleLineText_GetsRawString

        public void GetValue_SingleLineText_GetsRawString()
        {
            //Assign
            string value= "test single line text";
            SitecoreProperty property = new SitecoreProperty()
            {
                Attribute = new SitecoreFieldAttribute(),
                Property = new FakePropertyInfo(typeof(string), "SingleLineText")
            };
            _handler.ConfigureDataHandler(property);

            using (new SecurityDisabler())
            {
                _item.Editing.BeginEdit();
                _item["SingleLineText"] = value;

                //Act
                var result = _handler.GetValue(_item, null);

                //Assert
                Assert.AreEqual(value, result);

                _item.Editing.CancelEdit();
            }

        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:26,代码来源:SitecoreFieldStringHandlerFixture.cs

示例3: ConfigureDataHandler

    internal override void ConfigureDataHandler(SitecoreProperty scProperty)
    {
 
        base.ConfigureDataHandler(scProperty);
        IsLazy = (Setting & SitecoreFieldSettings.DontLoadLazily) != SitecoreFieldSettings.DontLoadLazily;
        InferType = (Setting & SitecoreFieldSettings.InferType) == SitecoreFieldSettings.InferType;
    }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:7,代码来源:SitecoreFieldClassHandler.cs

示例4: GetValue

        public void GetValue()
        {
            //Assign
            Item item = _db.GetItem(new ID(_itemId));
            SitecoreProperty property = new SitecoreProperty()
            {
                Attribute = new SitecoreFieldAttribute(),
                Property = new FakePropertyInfo(typeof(Stream), "Attachment")
            };



            _handler.ConfigureDataHandler(property);

            using (new SecurityDisabler())
            {
                string testString = "Hello World" + DateTime.Now.ToString();
                MemoryStream stream = new MemoryStream();
                byte[] data = UTF8Encoding.UTF8.GetBytes(testString);
                stream.Write(data, 0, data.Length);

                item.Editing.BeginEdit();
                item.Fields["Attachment"].SetBlobStream(stream);

                //Act
                Stream result = _handler.GetValue(item, null) as Stream;


                //Assert
                Assert.IsNotNull(result);

                item.Editing.CancelEdit();
            }
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:34,代码来源:SitecoreFieldStreamHandlerFixture.cs

示例5: GetValue_ReturnsValidImage

        public void GetValue_ReturnsValidImage()
        {
            //Assign
            Item item = _db.GetItem(new ID(_itemId));
            SitecoreProperty property = new SitecoreProperty()
                {
                    Attribute = new SitecoreFieldAttribute(),
                    Property = new FakePropertyInfo(typeof(Image), "Image")
                };

            _handler.ConfigureDataHandler(property);

            //Act
            var result = _handler.GetValue(item,
                 null) as Image;

            //Assert

            Assert.IsNotNull(result);
            Assert.IsFalse(result.Alt.IsNullOrEmpty());


            Assert.AreEqual(540, result.Height);
            Assert.AreEqual(50, result.HSpace);
            Assert.IsFalse(result.Src.IsNullOrEmpty());
            Assert.AreEqual(60, result.VSpace);
            Assert.AreEqual(720, result.Width);

            // Unsure how to test below
            // result.Border 
            // result.Class
            // result.MediaItem

        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:34,代码来源:SitecoreFieldImageHandlerFixture.cs

示例6: ConfigureDataHandler

        public override void ConfigureDataHandler(SitecoreProperty scProperty)
        {
            SitecoreChildrenAttribute attr = scProperty.Attribute as SitecoreChildrenAttribute;
            IsLazy = attr.IsLazy;
            InferType = attr.InferType;

            base.ConfigureDataHandler(scProperty);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:8,代码来源:SitecoreChildrenHandler.cs

示例7: ConfigureDataHandler

        internal override void ConfigureDataHandler(SitecoreProperty scProperty)
        {
            SitecoreParentAttribute attr = scProperty.Attribute as SitecoreParentAttribute;
            this.IsLazy = attr.IsLazy;
            this.InferType = attr.InferType;

            base.ConfigureDataHandler(scProperty);
        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:8,代码来源:SitecoreParentHandler.cs

示例8: Setup

 public void Setup()
 {
     _handler = new SitecoreFieldEnumHandler();
     _property = new SitecoreProperty()
     {
         Attribute = new SitecoreFieldAttribute(),
         Property = typeof(TestClass).GetProperty("Enum")
     };
 }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:9,代码来源:SitecoreFieldEnumHandlerFixture.cs

示例9: ConfigureDataHandler

        internal override void ConfigureDataHandler(SitecoreProperty scProperty)
        {
            SitecoreFieldAttribute attr = scProperty.Attribute as SitecoreFieldAttribute;
            
            if (attr != null && !attr.FieldName.IsNullOrEmpty()) FieldName = attr.FieldName;
            else FieldName = scProperty.Property.Name;

            ReadOnly = attr.ReadOnly;

            Setting = attr.Setting;
            
            base.ConfigureDataHandler(scProperty);
        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:13,代码来源:AbstractSitecoreField.cs

示例10: WillHandler_ReturnsTrue

        public void WillHandler_ReturnsTrue()
        {
            //Assign
            SitecoreProperty property= new SitecoreProperty()
            {
                Attribute = new SitecoreInfoAttribute(SitecoreInfoType.ContentPath)
            };

            //Act
            var result = _handler.WillHandle(property, null, null);

            //Assert
            Assert.IsTrue(result);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:14,代码来源:SitecoreInfoHandlerFixture.cs

示例11: WillHandle_HandlesParentAttribute_ReturnsTrue

        public void WillHandle_HandlesParentAttribute_ReturnsTrue()
        {
            //Assign
            SitecoreProperty property = new SitecoreProperty()
            {
                Attribute = new SitecoreParentAttribute()
            };

            //Act
            var result = _handler.WillHandle(property, _service.InstanceContext.Datas, _service.InstanceContext.Classes);

            //Assert

            Assert.IsTrue(result);
        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:15,代码来源:SitecoreParentHandlerFixture.cs

示例12: WillHandle

        public void WillHandle()
        {
            //Assign
            SitecoreProperty property = new SitecoreProperty(){
                Attribute = new SitecoreLinkedAttribute(),
                Property = new FakePropertyInfo(typeof(IEnumerable<LinkTemplate>))
            };


            //Act
            var result =_handler.WillHandle(property, null, null);

            //Assert
            Assert.IsTrue(result);
        }
开发者ID:pworst,项目名称:Glass.Sitecore.Mapper,代码行数:15,代码来源:SitecoreLinkedHandlerFixture.cs

示例13: ConfigureHandler_SetIsLazy_True

        public void ConfigureHandler_SetIsLazy_True()
        {
            //Assign
            SitecoreFieldAttribute attr = new SitecoreFieldAttribute();
            SitecoreProperty property = new SitecoreProperty()
            {
                Attribute = attr,
                Property = new FakePropertyInfo(typeof(string))//this can be anything                
            };

            //Act
            _handler.ConfigureDataHandler(property);

            //Assert
            Assert.IsTrue(_handler.IsLazy);
        }
开发者ID:simonproctor,项目名称:Glass.Sitecore.Mapper,代码行数:16,代码来源:SitecoreFieldClassHandlerFixture.cs

示例14: GetValue_ContentPath

        public void GetValue_ContentPath()
        {
            //Assign
            SitecoreProperty property= new SitecoreProperty()
            {
                Attribute = new SitecoreInfoAttribute(SitecoreInfoType.ContentPath)
            };
            _handler.ConfigureDataHandler(property);


            //Act
            var result = _handler.GetValue( _item, null);

            //Assert
            Assert.AreEqual(_item.Paths.ContentPath, result as string);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:16,代码来源:SitecoreInfoHandlerFixture.cs

示例15: WillHandle_ReturnsFalse_WrongAttribute

        public void WillHandle_ReturnsFalse_WrongAttribute()
        {
            //Assign
            SitecoreProperty property = new SitecoreProperty()
            {
                Attribute = new SitecoreFieldAttribute(),
                Property = new FakePropertyInfo(typeof(Guid))
            };

            //Act
            var result = _handler.WillHandle(property, null, null);

            //Assert
            Assert.IsFalse(result);

        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:16,代码来源:SitecoreIdDataHandlerFixture.cs


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