コード例 #1
0
ファイル: Items.cs プロジェクト: 3F/vsCommandEvent
        /// <summary>
        /// Get item for type and identifier.
        /// </summary>
        /// <param name="type">Type of item.</param>
        /// <param name="ident">Identifier of item.</param>
        /// <returns>Unspecified common item.</returns>
        public IItem get(ItemType type, Ident ident)
        {
            bool isFull = (ident.guid != null && ident.item != null);
            switch(type)
            {
                case ItemType.EW:
                {
                    // check with part from identifier
                    IItem item = itemEW.FirstOrDefault(i => (isFull && ident.guid.CompareGuids(i.Key.guid) && ident.item == i.Key.item)
                                                                || (!isFull && ident.guid != null && ident.guid.CompareGuids(i.Key.guid))
                                                                || (!isFull && ident.item != null && ident.item == i.Key.item)
                                                      ).Value;

                    if(item == null && isFull) {
                        itemEW[ident] = new ItemEW();
                        return itemEW[ident];
                    }
                    else if(item == null && ident.item == Settings._.DefaultOWPItem) { //TODO:
                        return new ItemEW();
                    }
                    else if(item == null) {
                        throw new NotFoundException("OWP Items-EW: The '{0}:{1}' is not found.", ident.guid, ident.item);
                    }
                    return item;
                }
            }
            throw new NotFoundException("OWP Items: Type '{0}' is not supported.", type);
        }
コード例 #2
0
        /// <summary>
        /// Get item for type and identifier.
        /// </summary>
        /// <param name="type">Type of item.</param>
        /// <param name="ident">Identifier of item.</param>
        /// <returns>Unspecified common item.</returns>
        public IItem get(ItemType type, Ident ident)
        {
            bool isFull = (ident.guid != null && ident.item != null);

            switch (type)
            {
            case ItemType.EW:
            {
                // check with part from identifier
                IItem item = itemEW.FirstOrDefault(i => (isFull && ident.guid.CompareGuids(i.Key.guid) && ident.item == i.Key.item) ||
                                                   (!isFull && ident.guid != null && ident.guid.CompareGuids(i.Key.guid)) ||
                                                   (!isFull && ident.item != null && ident.item == i.Key.item)
                                                   ).Value;

                if (item == null && isFull)
                {
                    itemEW[ident] = new ItemEW();
                    return(itemEW[ident]);
                }
                else if (item == null && ident.item == Settings._.DefaultOWPItem)      //TODO:
                {
                    return(new ItemEW());
                }
                else if (item == null)
                {
                    throw new NotFoundException("OWP Items-EW: The '{0}:{1}' is not found.", ident.guid, ident.item);
                }
                return(item);
            }
            }
            throw new NotFoundException("OWP Items: Type '{0}' is not supported.", type);
        }
コード例 #3
0
ファイル: Items.cs プロジェクト: 3F/vsCommandEvent
 /// <summary>
 /// Get EW item for identifier.
 /// </summary>
 /// <param name="ident">Identifier of item.</param>
 /// <returns>EW item.</returns>
 public IItemEW getEW(Ident ident)
 {
     return (IItemEW)get(ItemType.EW, ident);
 }
コード例 #4
0
 /// <summary>
 /// Get EW item for identifier.
 /// </summary>
 /// <param name="ident">Identifier of item.</param>
 /// <returns>EW item.</returns>
 public IItemEW getEW(Ident ident)
 {
     return((IItemEW)get(ItemType.EW, ident));
 }