本文整理汇总了C#中Glass.Sitecore.Mapper.Configuration.SitecoreProperty类的典型用法代码示例。如果您正苦于以下问题:C# SitecoreProperty类的具体用法?C# SitecoreProperty怎么用?C# SitecoreProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SitecoreProperty类属于Glass.Sitecore.Mapper.Configuration命名空间,在下文中一共展示了SitecoreProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: CanSetValue_FieldIsWritable_ReturnsTrue
public void CanSetValue_FieldIsWritable_ReturnsTrue()
{
//Assign
SitecoreProperty property = new SitecoreProperty(){
Property = new FakePropertyInfo(typeof(string)),
Attribute = new SitecoreFieldAttribute(){
}
};
testClass.ConfigureDataHandler(property);
//Act
var result = testClass.CanSetValue;
//Assert
Assert.IsTrue(result);
}
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:16,代码来源:AbstractSitecoreFieldFixture.cs
示例17: GetValue_ReturnsValidLink_External
public void GetValue_ReturnsValidLink_External()
{
//Assign
Item item = _db.GetItem(new ID(_itemId));
SitecoreProperty property = new SitecoreProperty()
{
Attribute = new SitecoreFieldAttribute(),
Property = new FakePropertyInfo(typeof(Link), "GeneralLink")
};
_handler.ConfigureDataHandler(property);
using (new SecurityDisabler())
{
item.Editing.BeginEdit();
item["GeneralLink"] = "<link text=\"TestDesc\" querystring=\"TestQuery\" linktype=\"external\" url=\"http://www.google.com\" anchor=\"TestAnchor\" title=\"TestAlt\" class=\"TestClass\" target=\"_blank\" />";
//Act
Link result = _handler.GetValue(item, null) as Link;
Assert.AreEqual("TestAnchor", result.Anchor);
Assert.AreEqual("TestClass", result.Class);
Assert.AreEqual("TestQuery", result.Query);
Assert.AreEqual("_blank", result.Target);
Assert.AreEqual(Guid.Empty, result.TargetId);
Assert.AreEqual("TestDesc", result.Text);
Assert.AreEqual("TestAlt", result.Title);
Assert.AreEqual(LinkType.External, result.Type);
Assert.AreEqual("http://www.google.com", result.Url);
item.Editing.CancelEdit();
}
//Assert
}
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:46,代码来源:SitecoreFieldLinkHandlerFixture.cs
示例18: GetDataHandler
/// <summary>
///
/// </summary>
/// <param name="property"></param>
public AbstractSitecoreDataHandler GetDataHandler(SitecoreProperty property)
{
AbstractSitecoreDataHandler handler = Datas.FirstOrDefault(x => x.WillHandle(property, Datas, Classes));
if (handler == null)
throw new NotSupportedException("No data handler for: \n\r Class: {0} \n\r Member: {1} \n\r Attribute: {2}"
.Formatted(
property.Property.ReflectedType.FullName,
property.Property.Name,
property.Attribute.GetType().FullName
));
var newHandler = handler.Clone() as AbstractSitecoreDataHandler;
newHandler.ConfigureDataHandler(property);
return newHandler;
}
开发者ID:deeja,项目名称:Glass.Sitecore.Mapper,代码行数:21,代码来源:InstanceContext.cs
示例19: 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);
//Act
Stream stream = _handler.GetValue( item, null) as Stream;
//Assert
Assert.IsNull(stream);
}
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:18,代码来源:SitecoreFieldStreamHandlerFixture.cs
示例20: GetFieldValue_NoHandler_ThrowsException
public void GetFieldValue_NoHandler_ThrowsException()
{
//Assign
string value = "45|535|22|";
SitecoreProperty property = new SitecoreProperty()
{
Property = new FakePropertyInfo(typeof(IEnumerable<TestType>)),
Attribute = new SitecoreFieldAttribute()
};
_handler.ConfigureDataHandler(property);
//Act
var result = _handler.GetFieldValue(value, null, _service);
//Assert
//Exception thrown
}
开发者ID:photomoose,项目名称:Glass.Sitecore.Mapper,代码行数:18,代码来源:SitecoreFieldIEnumerableHandlerFixture.cs
注:本文中的Glass.Sitecore.Mapper.Configuration.SitecoreProperty类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论