本文整理汇总了C#中IItem.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IItem.GetType方法的具体用法?C# IItem.GetType怎么用?C# IItem.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IItem
的用法示例。
在下文中一共展示了IItem.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToMessage
public void AddToMessage(IItem item, string name, SolutionMessage.Builder builder) {
if (dispatcher == null) BuildDispatcher();
Type itemType = item.GetType();
while (!dispatcher.ContainsKey(itemType)) {
if (itemType.BaseType != null) itemType = itemType.BaseType;
else break;
}
if (itemType.BaseType == null && !dispatcher.ContainsKey(itemType)) {
IEnumerable<Type> interfaces = item.GetType().GetInterfaces().Where(x => dispatcher.ContainsKey(x));
if (interfaces.Count() != 1) throw new ArgumentException(Name + ": No converter for type " + itemType.FullName + " defined.", "item");
else itemType = interfaces.Single();
}
dispatcher[itemType](item, name, builder);
}
示例2: SameTypeIndex
public int SameTypeIndex(IItem item)
{
foreach (var inventoryItem in this.Items)
{
if (inventoryItem.GetType() == item.GetType())
{
return this.Items.IndexOf(inventoryItem);
}
}
return -1;
}
示例3: WriteItems
/// <summary>
/// Writes the items.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="depth">The depth.</param>
private void WriteItems(IItem item, int depth)
{
List<string> row = new List<string> {Convert.ToString(depth), item.GetType().Name, string.Empty};
for (int i = 1; i < depth; i++)
{
row.Add(string.Empty);
}
row.Add(item.Name);
WorksheetWriter.WriteRow(row);
foreach (IItem child in item.GetItems())
{
WriteItems(child, depth + 1);
}
}
示例4: DefaultForItem
public IActOnItem DefaultForItem(IItem item)
{
var defaultActionAttribute = (DefaultActionAttribute)
item.GetType()
.GetCustomAttributes(typeof (DefaultActionAttribute), true)
.SingleOrDefault();
if (defaultActionAttribute == null)
{
return null;
}
if (_actions.ContainsKey(defaultActionAttribute.ActionType))
return _actions[defaultActionAttribute.ActionType];
return null;
}
示例5: GetItemTaskForItem
public static ItemTask GetItemTaskForItem(IItem item) {
Type itemType = item.GetType();
Type hiveTaskType = GetHiveTaskType(itemType);
return Activator.CreateInstance(hiveTaskType, new object[] { item }) as ItemTask;
}
示例6: addFeedbackItem
private void addFeedbackItem(string type, string message, Color colour, IItem tag, IItem selected)
{
var item = listViewFeedback.Items.Add(type);
item.SubItems.Add(message);
item.ForeColor = colour;
item.Tag = tag;
if (selected != null && tag.GetType().Equals(selected.GetType()) && tag.Equals(selected))
item.Selected = true;
}
示例7: GetItemType
private static string GetItemType(IItem item)
{
string type = item.GetType().ToString();
string[] itemMeta = type.Split('.');
return itemMeta[itemMeta.Length - 1];
}
示例8: Result
public Result(string name, IItem value)
: base(name) {
this.dataType = value == null ? typeof(IItem) : value.GetType();
this.value = value;
Initialize();
}
示例9: GoToMessageReference
public void GoToMessageReference(IItem item)
{
if (item.GetType().Equals(typeof(BuildItem)))
goToBuildItemReference((BuildItem)item);
if (item.GetType().Equals(typeof(TestItem)))
goToTestItemReference((TestItem)item);
}
示例10: renderItem
private static void renderItem(IItem item, StringBuilder output)
{
if (!item.GetType().CanBeCastTo<IRenderHtml>())
{
throw new ArgumentException("IItem {0} type has no HTML rendering mechanism".ToFormat(item.GetType()));
}
var htmlRenderer = (IRenderHtml) item;
output.AppendLine(htmlRenderer.RenderHtml());
}
示例11: CompareItems
//Convenience methods
private void CompareItems(IItem item1, IItem item2)
{
Assert.AreEqual(item1.Description, item2.Description);
Assert.AreEqual(item1.Price, item2.Price);
Assert.AreEqual(item1.ShelfPrice, item2.ShelfPrice);
Assert.IsInstanceOfType(item1, item2.GetType());
Assert.AreEqual(item1.Tax, item2.Tax);
}
示例12: Unequip
internal IItem Unequip(IItem item)
{
if (item is IWeapon)
return UnequipWeapon();
if (item is IArmor)
{
IArmor itemAsArmor = (IArmor)item;
IItem previousArmor = null;
switch (itemAsArmor.Type)
{
case "ChestArmor":
previousArmor = ChestArmor;
ChestArmor = null;
break;
case "Helm":
previousArmor = Headpiece;
Headpiece = null;
break;
case "Gloves":
previousArmor = Gloves;
Gloves = null;
break;
case "Boots":
previousArmor = Boots;
Boots = null;
break;
}
ResetMaxStaminaIfNowOver();
return previousArmor;
}
throw new System.InvalidOperationException("Don't know how to unequip - " + item.GetType());
}
示例13: IsItemBetter
public static bool IsItemBetter(IItem input)
{
return Field.Hero.Inventory.Items.Where(item => item.GetType().Name == input.GetType().Name).Any(item => (int)input.ItemType > (int)item.ItemType);
}
示例14: queue_IndexChanged
/// <summary>
/// Called when the index of the current queue is changed. Starts playing the next track
/// </summary>
/// <param name="queue">The queue whos index has changed</param>
/// <param name="previous">The previous item that was played</param>
/// <param name="current">The item that is about the be played</param>
void queue_IndexChanged(Queue queue, IItem previous, IItem current)
{
// If we have a different type to play, start the correct player and stop colliding players
if (previous == null || previous.GetType() != current.GetType()) {
// Get the player for the current item
var newPlayer = GetPlayerForItem(current);
// None found
if (newPlayer == null) {
Log("No player found for item with type " + current.GetType().ToString(), Logger.LogLevel.Error);
StopQueue(queue);
return;
}
// Stop queues and players that collide with the new one
var queues = Queue.Where(q => q != queue).ToList();
foreach (var q in queues) {
if (q.CurrentPlayer is IAudioPlayer && newPlayer is IAudioPlayer)
StopQueue(q);
else if (q.CurrentPlayer is IVisualPlayer && newPlayer is IVisualPlayer)
StopQueue(q);
}
// If we are using an other player, stop the old one and set the necessary callbacks
if (newPlayer != queue.CurrentPlayer) {
StopPlayer(queue.CurrentPlayer);
newPlayer.PlaybackFinished += player_PlaybackFinished;
queue.CurrentPlayer = newPlayer;
}
}
// Play the current item
queue.CurrentPlayer.Play(current);
}
示例15: BuildXmlElement
private XmlElement BuildXmlElement(XmlDocument document, IItem item)
{
XmlElement node = document.CreateElement(item.GetType().Name);
node.SetAttribute("title", item.Title);
//node.SetAttribute("count", item.Count.ToString());
node.SetAttribute("visible", item.Visible.ToString().ToLower());
node.SetAttribute("icon-class", item.IconClass);
return node;
}