当前位置: 首页>>代码示例>>C#>>正文


C# IItem.GetType方法代码示例

本文整理汇总了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);
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:14,代码来源:SolutionMessageBuilder.cs

示例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;
        }
开发者ID:OOP-Team-Tapani,项目名称:RPG-Game,代码行数:12,代码来源:Inventory.cs

示例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);
     }
 }
开发者ID:AmplaTools,项目名称:ProjectCreate,代码行数:19,代码来源:HierarchyWriterCommand.cs

示例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;
 }
开发者ID:brunomlopes,项目名称:ILoveLucene,代码行数:14,代码来源:GetDefaultActionBasedOnAttributeForType.cs

示例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;
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:5,代码来源:ItemTask.cs

示例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;
 }
开发者ID:nieve,项目名称:AutoTest.Net,代码行数:9,代码来源:FeedbackWindow.cs

示例7: GetItemType

 private static string GetItemType(IItem item)
 {
     string type = item.GetType().ToString();
     string[] itemMeta = type.Split('.');
     return itemMeta[itemMeta.Length - 1];
 }
开发者ID:ivnikolov,项目名称:RPG-Teamwork,代码行数:6,代码来源:PlayerInventory.cs

示例8: Result

 public Result(string name, IItem value)
   : base(name) {
   this.dataType = value == null ? typeof(IItem) : value.GetType();
   this.value = value;
   Initialize();
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:6,代码来源:Result.cs

示例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);
 }
开发者ID:nieve,项目名称:AutoTest.Net,代码行数:7,代码来源:FeedbackView.cs

示例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());
        }
开发者ID:DovetailSoftware,项目名称:dovetail-bootstrap,代码行数:10,代码来源:HistoryItemHtmlRenderer.cs

示例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);
 }
开发者ID:jonmholt,项目名称:thoughtworks,代码行数:9,代码来源:ItemFactoryTests.cs

示例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());
        }
开发者ID:donblas,项目名称:magecrawl,代码行数:33,代码来源:Player.cs

示例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);
 }
开发者ID:OOP-Team-Tapani,项目名称:RPG-Game,代码行数:4,代码来源:Item.cs

示例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);
        }
开发者ID:ChrisBrandhorst,项目名称:Touchee_HTTPServer,代码行数:42,代码来源:Library.cs

示例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;
        }
开发者ID:varindersingh,项目名称:DynamicNavigationControl,代码行数:11,代码来源:NavigationLayout.cs


注:本文中的IItem.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。