本文整理汇总了C#中DetailCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# DetailCollection.Add方法的具体用法?C# DetailCollection.Add怎么用?C# DetailCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DetailCollection
的用法示例。
在下文中一共展示了DetailCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: 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));
}
}
示例3: ReadDetail
protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
{
Dictionary<string, string> attributes = GetAttributes(navigator);
Type type = Utility.TypeFromName(attributes["typeName"]);
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));
}
else
{
journal.Register(referencedItemID, (item) =>
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
item));
});
}
}
else if (type == typeof(Enum))
{
if (attributes.ContainsKey("meta"))
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, Type.GetType(attributes["meta"]))));
}
}
else if (type == typeof(IMultipleValue))
{
detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name).AddTo(collection);
}
else
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, type)));
}
}
示例4: CanClone_Collection
public void CanClone_Collection()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
DetailCollection cloned = collection.Clone();
Assert.That(cloned.Contains("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_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"));
}
示例7: 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));
}
示例8: 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"));
}
示例9: 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));
}
示例10: ReadDetail
protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
{
Dictionary<string, string> attributes = GetAttributes(navigator);
Type type = Utility.TypeFromName(attributes["typeName"]);
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));
}
else
{
journal.ItemAdded += delegate(object sender, ItemEventArgs e)
{
if (e.AffectedItem.ID == referencedItemID)
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
e.AffectedItem));
}
};
}
}
else if (type == typeof(IMultipleValue))
{
detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name).AddTo(collection);
}
else
{
collection.Add(ContentDetail.New(
collection.EnclosingItem,
attributes["name"],
Parse(navigator.Value, type)));
}
}
示例11: CanCopyToArray
public void CanCopyToArray()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
string[] array = new string[1];
collection.CopyTo(array, 0);
Assert.That(array[0], Is.EqualTo("hello"));
}
示例12: UpdatedEnclosingItem_UpdatesDetails
public void UpdatedEnclosingItem_UpdatesDetails()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
var item = new Content.AnItem();
collection.EnclosingItem = item;
Assert.That(collection.EnclosingItem, Is.EqualTo(item));
Assert.That(collection.Details[0].EnclosingItem, Is.EqualTo(item));
}
示例13: ClonedCollection_IdentifierIsCleared
public void ClonedCollection_IdentifierIsCleared()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
DetailCollection cloned = collection.Clone();
Assert.That(cloned.ID, Is.EqualTo(0));
}
示例14: Contains_IsTrue_ForContainedString
public void Contains_IsTrue_ForContainedString()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
Assert.That(collection.Contains("hello"));
}
示例15: IndexOf_NotFoundItem_IsNegativeOne
public void IndexOf_NotFoundItem_IsNegativeOne()
{
DetailCollection collection = new DetailCollection();
collection.Add("hello");
collection.Add("world");
Assert.That(collection.IndexOf("sweden"), Is.EqualTo(-1));
}