本文整理汇总了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);
}
示例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();
}
}
示例3: ConfigureDataHandler
internal override void ConfigureDataHandler(SitecoreProperty scProperty)
{
base.ConfigureDataHandler(scProperty);
IsLazy = (Setting & SitecoreFieldSettings.DontLoadLazily) != SitecoreFieldSettings.DontLoadLazily;
InferType = (Setting & SitecoreFieldSettings.InferType) == SitecoreFieldSettings.InferType;
}
示例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();
}
}
示例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
}
示例6: ConfigureDataHandler
public override void ConfigureDataHandler(SitecoreProperty scProperty)
{
SitecoreChildrenAttribute attr = scProperty.Attribute as SitecoreChildrenAttribute;
IsLazy = attr.IsLazy;
InferType = attr.InferType;
base.ConfigureDataHandler(scProperty);
}
示例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);
}
示例8: Setup
public void Setup()
{
_handler = new SitecoreFieldEnumHandler();
_property = new SitecoreProperty()
{
Attribute = new SitecoreFieldAttribute(),
Property = typeof(TestClass).GetProperty("Enum")
};
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}