本文整理汇总了C#中DetailCollection类的典型用法代码示例。如果您正苦于以下问题:C# DetailCollection类的具体用法?C# DetailCollection怎么用?C# DetailCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DetailCollection类属于命名空间,在下文中一共展示了DetailCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanClone_Collection
public void CanClone_Collection()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
DetailCollection cloned = collection.Clone();
Assert.That(cloned.Contains("hello"));
}
示例2: CanAddRange
public void CanAddRange()
{
DetailCollection collection = new DetailCollection();
collection.AddRange(new[] {"hello", "world"});
Assert.That(collection[0], Is.EqualTo("hello"));
Assert.That(collection[1], Is.EqualTo("world"));
}
示例3: CanRemove_AtIndex
public void CanRemove_AtIndex()
{
DetailCollection collection = new DetailCollection(null, null, "hello", "world");
collection.RemoveAt(0);
Assert.That(collection.Count, Is.EqualTo(1));
Assert.That(collection[0], Is.EqualTo("world"));
}
示例4: CanAdd_StringDetail
public void CanAdd_StringDetail()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
Assert.That(collection[0], Is.EqualTo("hello"));
Assert.That(collection.Details[0], Is.TypeOf(typeof(StringDetail)));
Assert.That(collection.Details[0].Value, Is.EqualTo("hello"));
}
示例5: CanClear_DetailCollection
public void CanClear_DetailCollection()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
collection.Clear();
Assert.That(collection.Count, Is.EqualTo(0));
}
示例6: CanAdd_IntDetail
public void CanAdd_IntDetail()
{
DetailCollection collection = new DetailCollection();
collection.Add(1);
Assert.That(collection[0], Is.EqualTo(1));
Assert.That(collection.Details[0], Is.TypeOf(typeof(IntegerDetail)));
Assert.That(collection.Details[0].Value, Is.EqualTo(1));
}
示例7: CanFind_IndexOfInteger
public void CanFind_IndexOfInteger()
{
DetailCollection collection = new DetailCollection();
collection.Add(1);
collection.Add(2);
Assert.That(collection.IndexOf(1), Is.EqualTo(0));
Assert.That(collection.IndexOf(2), Is.EqualTo(1));
}
示例8: CanInsert_IntoCollection
public void CanInsert_IntoCollection()
{
DetailCollection collection = new DetailCollection();
collection.Insert(0, "hello");
collection.Insert(0, "world");
Assert.That(collection.IndexOf("hello"), Is.EqualTo(1));
Assert.That(collection.IndexOf("world"), Is.EqualTo(0));
}
示例9: CanAdd_StringDetail
public void CanAdd_StringDetail()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
Assert.That(collection[0], Is.EqualTo("hello"));
Assert.That(collection.Details[0].ValueType, Is.EqualTo(typeof(string)));
Assert.That(collection.Details[0].ValueTypeKey, Is.EqualTo(ContentDetail.TypeKeys.StringType));
Assert.That(collection.Details[0].Value, Is.EqualTo("hello"));
}
示例10: GetCurrentTags
List<ITag> GetCurrentTags(IGroup group, DetailCollection links)
{
List<ITag> tags = new List<ITag>();
foreach (ContentItem link in links)
{
if(link.Parent != null && link.Parent.Equals(group))
tags.Add(link as ITag);
}
return tags;
}
示例11: CanAdd_IntDetail
public void CanAdd_IntDetail()
{
DetailCollection collection = new DetailCollection();
collection.Add(1);
Assert.That(collection[0], Is.EqualTo(1));
Assert.That(collection.Details[0].ValueType, Is.EqualTo(typeof(int)));
Assert.That(collection.Details[0].ValueTypeKey, Is.EqualTo(ContentDetail.TypeKeys.IntType));
Assert.That(collection.Details[0].Value, Is.EqualTo(1));
}
示例12: ReadDetail
protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
{
Dictionary<string, string> attributes = GetAttributes(navigator);
Type type = Utility.TypeFromName(attributes["typeName"]);
string meta = attributes.ContainsKey("meta") ? attributes["meta"] : null;
if (type == typeof(ContentItem))
{
int referencedItemID = int.Parse(navigator.Value);
ContentItem referencedItem = journal.Find(referencedItemID);
if (referencedItem != null)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
referencedItem,
meta));
}
else
{
journal.Register(referencedItemID, (item) =>
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
item,
meta));
}, relationType: "collectionlink");
}
}
else if (type == typeof(Enum))
{
if (meta != null)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, Type.GetType(meta))));
}
}
else if (type == typeof(IMultipleValue))
{
var detail = detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name);
detail.Meta = meta;
detail.AddTo(collection);
}
else
{
object value = Parse(navigator.Value, type);
if (value is string)
value = detailReader.PrepareStringDetail(collection.EnclosingItem, collection.Name, value as string, attributes.ContainsKey("encoded") && Convert.ToBoolean(attributes["encoded"]));
collection.Add(ContentDetail.New(collection.EnclosingItem, attributes["name"], value, meta));
}
}
示例13: CanConvert_ToArray
public void CanConvert_ToArray()
{
DetailCollection collection = new DetailCollection();
collection.AddRange(new[] { 1, 2, 3 });
int[] array = collection.ToArray<int>();
Assert.That(array.Length, Is.EqualTo(3));
Assert.That(array[0], Is.EqualTo(1));
Assert.That(array[2], Is.EqualTo(3));
}
示例14: WriteDetailCollection
protected virtual void WriteDetailCollection(ContentItem item, XmlTextWriter writer, DetailCollection collection)
{
using (ElementWriter collectionElement = new ElementWriter("collection", writer))
{
collectionElement.WriteAttribute("name", collection.Name);
foreach (ContentDetail detail in collection.Details)
{
WriteDetail(item, detail, writer);
}
}
}
示例15: CanConvert_ToList
public void CanConvert_ToList()
{
DetailCollection collection = new DetailCollection();
collection.AddRange(new[] { 1, 2, 3 });
IList<int> list = collection.ToList<int>();
Assert.That(list.Count, Is.EqualTo(3));
Assert.That(list[0], Is.EqualTo(1));
Assert.That(list[2], Is.EqualTo(3));
}