public void Failure_InvalidNameGeneratesException()
        {
            // Setup
            var factory = new ItemFactory(new Dictionary <string, StockManagementStrategy>()
            {
                { "This is a valid object", new StockManagementStrategy(QualityStrategy.Stable, ShelfLifeStrategy.Stable) },
            });

            // Execution
            Assert.ThrowsException <InvalidStockObjectNameException>(() => factory.Create("Invalid Object", 99, 66));
        }
Beispiel #2
0
        public IItem Remove(ushort itemId, byte count, out bool wasPartial)
        {
            wasPartial = false;

            var slot = Inventory.Keys.FirstOrDefault(k => Inventory[k].Item1.Type.TypeId == itemId);

            if (slot != default(Slot))
            {
                var found = Inventory[slot].Item1;

                if (found.Count < count)
                {
                    return(null);
                }

                // remove the whole item
                if (found.Count == count)
                {
                    Inventory.Remove(slot);
                    found.SetHolder(null, default(Location));

                    // update the slot.
                    Game.Instance.NotifySinglePlayer(
                        Owner as IPlayer,
                        conn => new GenericNotification(
                            conn,
                            new InventoryClearSlotPacket {
                        Slot = slot
                    }));

                    return(found);
                }

                IItem newItem = ItemFactory.Create(found.Type.TypeId);

                newItem.SetAmount(count);
                found.SetAmount((byte)(found.Amount - count));

                // update the remaining item in the slot.
                Game.Instance.NotifySinglePlayer(
                    Owner as IPlayer,
                    conn => new GenericNotification(
                        conn,
                        new InventorySetSlotPacket {
                    Slot = slot, Item = found
                }));

                wasPartial = true;
                return(newItem);
            }

            // TODO: exhaustive search of container items here.
            return(null);
        }
        public string Execute(string[] inputArgs)
        {
            string itemType = inputArgs[2];

            ItemFactory itemFactory = new ItemFactory();
            var         item        = itemFactory.Create(itemType);

            LoadUtilities.LoadItemRepository().Add(item);

            return($"Successful create new Item {itemType}");
        }
        protected virtual ParseItem CreateDefaultChild(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            ParseItem newChild = itemFactory.Create <Declaration>(this);

            if (!newChild.Parse(itemFactory, text, tokens))
            {
                newChild = UnknownItem.ParseUnknown(this, itemFactory, text, tokens, ParseErrorType.DeclarationExpected);
            }

            return(newChild);
        }
Beispiel #5
0
        protected virtual ParseItem CreateDefaultChild(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            ParseItem child = itemFactory.Create <KeyFramesRuleSet>(this);

            if (!child.Parse(itemFactory, text, tokens))
            {
                child = UnknownItem.ParseUnknown(this, itemFactory, text, tokens, ParseErrorType.UnexpectedParseError);
            }

            return(child);
        }
        protected virtual ParseItem ParseDefaultChild(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            ParseItem newChild = itemFactory.Create <RuleSet>(this);

            if (!newChild.Parse(itemFactory, text, tokens))
            {
                newChild = UnknownItem.ParseUnknown(this, itemFactory, text, tokens, ParseErrorType.UnexpectedToken);
            }

            return(newChild);
        }
    public string AddItemToHero(IList <string> arguments)
    {
        string result   = string.Empty;
        string heroName = arguments[1];

        IItem newItem = itemFactory.Create(arguments);

        this.heroes[heroName].AddItem(newItem);

        result = string.Format(Constants.ItemCreateMessage, newItem.Name, heroName);
        return(result);
    }
Beispiel #8
0
 private void HandleMessage(Message message)
 {
     using (var reader = message.GetReader())
     {
         var facadeId = reader.ReadUInt16();
         if (_info.Type == CharacterType.Player && _info.IsLocal && _info.Id == facadeId)
         {
             var itemId   = reader.ReadInt16();
             var instance = _factory.Create(ItemType.Module, itemId);
             _inventory.AddItem(instance);
         }
     }
 }
        protected override async void OnClick()
        {
            string folderPath   = @"C:\ProSDkWorkshop\Data\MXDs";
            var    fcItem       = ItemFactory.Create(folderPath, ItemFactory.ItemType.PathItem);
            var    projectItems = await Project.Current.AddAsync(fcItem);

            //FolderConnectionProjectItem
            var folderProjectItem = projectItems.First();

            var mxds = await folderProjectItem.SearchAsync(".mxd");

            await Project.Current.AddAsync(mxds.First());
        }
        public bool UpdateItem(ItemDTO item)
        {
            AItem exist = _iq.GetItemById(item.Id);

            if (exist != null)
            {
                return(_ic.UpdateItem(ItemFactory.Create(item)));
            }
            else
            {
                return(false);
            }
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                btnCreate.Text = "Add Item";

                item = ItemFactory.Create();
                po   = POFactory.Create();

                double itemPrice = Convert.ToDouble(txtPrice.Text);
                orderPrice += itemPrice;

                item.ItemName      = txtName.Text;
                item.Description   = txtDesc.Text;
                item.Quantity      = Convert.ToInt32(txtQty.Text);
                item.Price         = itemPrice;
                item.Location      = txtLocation.Text;
                item.Justification = txtJustification.Text;

                po.Items = new List <Types.IItem>();
                po.Items.Add(item);
                po.OrderNumber = Convert.ToInt32(lblOrderNumber.Text);
                po.EmpId       = emp[0].EmpID;

                int orderNumber = CUDMethods.CreatPO(po);

                lblSubNum.Text   = "$" + (orderPrice).ToString("F");
                lblTaxNum.Text   = "$" + (orderPrice * 0.15).ToString("F");
                lblTotalNum.Text = "$" + (orderPrice * 1.15).ToString("F");

                lblOrderNumber.Text         = orderNumber.ToString();
                lblOrderNumber.Visible      = true;
                lblOrderNumberLabel.Visible = true;

                if (lstItems.Items.Contains(item.ItemName))
                {
                    return;
                }
                else
                {
                    lstItems.Items.Add(item.ItemName);
                }

                clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //errorProvider1.SetError(sender, ex.Message);
            }
        }
Beispiel #12
0
 /// <summary>
 /// Generates a full item list with all possible items
 /// </summary>
 private void NewItemList()
 {
     try
     {
         XDocument     xml        = NetworkingUtil.NetworkLoad(itemListPath);
         List <string> stringList = (from itemName in xml.Root.Elements("item") select(string) itemName).ToList();
         itemList = (from itemName in stringList select ItemFactory.Create(itemName)).ToList();
     }
     catch (Exception e)
     {
         UnityEngine.Debug.Log(e);
         throw new Exception(String.Format("Item list parse error ({0})", itemListPath));
     }
 }
Beispiel #13
0
        public static void Create(IThing atThing, ushort itemId, byte unknown)
        {
            IThing item       = ItemFactory.Create(itemId);
            var    targetTile = atThing.Tile;

            if (item == null || targetTile == null)
            {
                return;
            }

            targetTile.AddThing(ref item);

            Game.Instance.NotifySpectatingPlayers(conn => new TileUpdatedNotification(conn, targetTile.Location, Game.Instance.GetMapTileDescription(conn.PlayerId, targetTile.Location)), targetTile.Location);
        }
Beispiel #14
0
 public bool GiveItem(string[] arr)
 {
     if (arr.Length == 1)
     {
         string itemName = arr[0];
         try { game.GetPlayerAttributes().ApplyItem(game, ItemFactory.Create(itemName)); }
         catch { Reply(String.Format("{0} does not exist in lookup.", itemName)); }
     }
     else
     {
         Reply("GiveItem itemName");
     }
     return(true);
 }
Beispiel #15
0
        public async Task CreateItemAsync(CreateItemCommand createItemCommand, CancellationToken cancellationToken) // Stworznie nowego Itemu
        {
            var item = ItemFactory.Create(
                createItemCommand.Name,
                createItemCommand.Description,
                createItemCommand.CategoryId,
                createItemCommand.QualityLevel,
                createItemCommand.Quantity,
                createItemCommand.OwnerId);

            await _itemRepository.CreateAsync(item, cancellationToken);

            await _itemRepository.SaveAsync(cancellationToken);
        }
        public void Failure_ExceptionOnNullName()
        {
            // Setup
            var factory = new ItemFactory(new Dictionary <string, StockManagementStrategy>()
            {
                { "SomeObject", new StockManagementStrategy(QualityStrategy.Stable, ShelfLifeStrategy.Stable) },
            });

            // Execution
            const int sellIn  = 99;
            const int quality = 66;

            Assert.ThrowsException <ArgumentNullException>(() => factory.Create(null, sellIn, quality));
        }
        protected override ParseItem CreateDefaultChild(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            // http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems?id=468547 - The contents of unknown directives could be rules or declarations.
            // Make a good guess for which one to create.

            int       startTokenPosition = tokens.Position;
            bool      childIsDeclaration = true;
            ParseItem newChild;

            for (bool done = false; !done && !tokens.CurrentToken.IsBlockTerminator();)
            {
                // If I see a curly brace before a semicolon, then this child is probably a RuleSet

                switch (tokens.CurrentToken.TokenType)
                {
                case CssTokenType.OpenCurlyBrace:
                    childIsDeclaration = false;
                    done = true;
                    break;

                case CssTokenType.Semicolon:
                    done = true;
                    break;

                default:
                    tokens.AdvanceToken();
                    break;
                }
            }

            tokens.Position = startTokenPosition;

            if (childIsDeclaration)
            {
                newChild = base.CreateDefaultChild(itemFactory, text, tokens);
            }
            else
            {
                newChild = itemFactory.Create <RuleSet>(this);

                if (!newChild.Parse(itemFactory, text, tokens))
                {
                    newChild = UnknownItem.ParseUnknown(this, itemFactory, text, tokens, ParseErrorType.UnexpectedToken);
                }
            }

            Debug.Assert(newChild != null);
            return(newChild);
        }
Beispiel #18
0
        public static void ChangeOnMap(Location location, ushort fromItemId, ushort toItemId, byte unknown)
        {
            var    targetTile = Game.Instance.GetTileAt(location);
            IThing newThing   = ItemFactory.Create(toItemId);

            if (targetTile == null || newThing == null)
            {
                return;
            }

            targetTile.BruteRemoveItemWithId(fromItemId);
            targetTile.AddThing(ref newThing);

            Game.Instance.NotifySpectatingPlayers(conn => new TileUpdatedNotification(conn, location, Game.Instance.GetMapTileDescription(conn.PlayerId, location)), targetTile.Location);
        }
        /// <summary>
        /// Opens a web map item in a map pane.
        /// </summary>
        /// <param name="item"></param>
        private async void OpenWebMapAsync(object item)
        {
            if (item is WebMapItem)
            {
                WebMapItem clickedWebMapItem = (WebMapItem)item;
                //Open WebMap
                var currentItem = ItemFactory.Create(clickedWebMapItem.ID, ItemFactory.ItemType.PortalItem);
                if (MapFactory.CanCreateMapFrom(currentItem))
                {
                    var newMap = await MapFactory.CreateMapAsync(currentItem);

                    await FrameworkApplication.Panes.CreateMapPaneAsync(newMap);
                }
            }
        }
Beispiel #20
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="node">対象Node</param>
        /// <param name="semanticModel">対象ソースのsemanticModel</param>
        /// <param name="parent">親IAnalyzeItem</param>
        /// <param name="container">イベントコンテナ</param>
        public ItemSwitch(SwitchStatementSyntax node, SemanticModel semanticModel, IAnalyzeItem parent, EventContainer container) : base(parent, node, semanticModel, container)
        {
            ItemType = ItemTypes.MethodStatement;

            var operation = semanticModel.GetOperation(node) as ISwitchOperation;

            // 条件設定
            Conditions.AddRange(OperationFactory.GetExpressionList(operation.Value, container));

            // Caseリスト設定
            foreach (var item in operation.Cases)
            {
                Cases.Add(ItemFactory.Create(item.Syntax, semanticModel, container, this));
            }
        }
Beispiel #21
0
 public void UpdateQuality()
 {
     for (var i = 0; i < Items.Count; i++)
     {
         try
         {
             var itemWrapper = ItemFactory.Create(Items[i]);
             Items[i] = itemWrapper.UpdateQuality();
         }
         catch (ArgumentOutOfRangeException e)
         {
             continue;
         }
     }
 }
 protected virtual void ParseSelectorCombineOperator(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
 {
     if (IdReferenceOperator.IsAtIdReferenceOperator(tokens))
     {
         ParseItem combineOperator = itemFactory.Create <IdReferenceOperator>(this);
         if (combineOperator.Parse(itemFactory, text, tokens))
         {
             SelectorCombineOperator = combineOperator;
             Children.Add(combineOperator);
         }
     }
     else
     {
         SelectorCombineOperator = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.SelectorCombineOperator);
     }
 }
Beispiel #23
0
        private void MergeDataset(IDataset datasetProxy, IDataset dataset)
        {
            for (int i = 0; i < dataset.Count; i++)
            {
                var item   = ItemFactory.Create();
                var source = dataset[i];

                item.Position = source.Position;
                item.Rotation = source.Rotation;
                item.Scale    = source.Scale;

                item.SetData(source.GetData());

                datasetProxy.Add(item);
            }
        }
Beispiel #24
0
        public static void Load()
        {
            double      startTime   = Global.GetTimestampMs();
            ItemFactory itemFactory = new ItemFactory();

            using (Database.Database db = new Database.Database())
            {
                foreach (Item entry in db.Items.ToList())
                {
                    ItemEntity itemEntity = itemFactory.Create(entry);
                    Items.Add(itemEntity);
                }
            }
            Modules.Log.ConsoleLog("ITEMS-NEW",
                                   $"Załadowano przedmioty ({Items.Count}) | {Global.GetTimestampMs() - startTime}ms");
        }
Beispiel #25
0
        private static void ACTION_RANDACTION(YiObj target, YiObj attacker, cq_action cqaction, SquigglyContext db)
        {
            var nextIds = cqaction.param.Trim().Split(' ');

            var nextIndex = SafeRandom.Next(nextIds.Length);

            var nextId = long.Parse(nextIds[nextIndex]);

            cqaction = db.cq_action.Find(nextId);
            //Output.WriteLine($"Mob Action -> Data: {cqaction.data} Param: {cqaction.param.Trim()}",ConsoleColor.Green);

            var dropId = cqaction.param.Trim().Split(' ')[1];
            var item   = ItemFactory.Create(int.Parse(dropId));

            FloorItemSystem.Drop(attacker, target, item);
        }
Beispiel #26
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="node">対象Node</param>
        /// <param name="semanticModel">対象ソースのsemanticModel</param>
        /// <param name="parent">親IAnalyzeItem</param>
        /// <param name="container">イベントコンテナ</param>
        public ItemProperty(PropertyDeclarationSyntax node, SemanticModel semanticModel, IAnalyzeItem parent, EventContainer container) : base(parent, node, semanticModel, container)
        {
            ItemType = ItemTypes.Property;

            var declaredSymbol = semanticModel.GetDeclaredSymbol(node);

            // プロパティの型設定
            var parts = ((IPropertySymbol)declaredSymbol).Type.ToDisplayParts(SymbolDisplayFormat.MinimallyQualifiedFormat);

            foreach (var part in parts)
            {
                // スペースの場合は型設定に含めない
                if (part.Kind == SymbolDisplayPartKind.Space)
                {
                    continue;
                }

                var name = Expression.GetSymbolName(part, true);
                var type = Expression.GetSymbolTypeName(part.Symbol);
                if (part.Kind == SymbolDisplayPartKind.ClassName)
                {
                    // 外部ファイル参照イベント発行
                    RaiseOtherFileReferenced(node, part.Symbol);
                }

                PropertyTypes.Add(new Expression(name, type));
            }

            // アクセサ設定
            if (node.AccessorList is null)
            {
                AccessorList.Add(ItemFactory.Create(node.ExpressionBody, semanticModel, container, this));
            }
            else
            {
                AccessorList.AddRange(node.AccessorList.Accessors.Select(accessor => ItemFactory.Create(accessor, semanticModel, container, this)));
            }

            // デフォルト設定
            if (node.Initializer == null)
            {
                return;
            }
            var propertyInitializer = semanticModel.GetOperation(node.Initializer.Value);

            DefaultValues.AddRange(OperationFactory.GetExpressionList(propertyInitializer, container));
        }
        protected async override void OnClick()
        {
            try
            {
                /// Read a file for line-delinated directory paths, and attempt to add them to the Project's Folder Connections
                OpenItemDialog openDialog = new OpenItemDialog();
                openDialog.Title       = "Select a Folder Connections file";
                openDialog.MultiSelect = false;
                openDialog.Filter      = ItemFilters.textFiles;

                /// If the user clicks OK in the dialog, load the listed directories from the file to the Project's Folder Connections
                if (openDialog.ShowDialog() == true)
                {
                    IEnumerable <Item> selectedItem = openDialog.Items;
                    foreach (Item i in selectedItem)
                    {
                        System.IO.StreamReader file = new System.IO.StreamReader(i.Path);
                        string line;
                        while ((line = file.ReadLine()) != null)
                        {
                            /// Add all folder connections to the current Project's folder connections
                            string notFound = "";
                            if (Directory.Exists(line))
                            {
                                var folderToAdd = ItemFactory.Create(line);
                                await Project.Current.AddAsync(folderToAdd);
                            }
                            else
                            {
                                notFound += "\r\n" + line;
                            }

                            /// Report any folder connections that could not be found
                            if (notFound != "")
                            {
                                MessageBox.Show("The following directories were not found and could not be added to the Folder Connections: " + notFound);
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Error adding a folder to the project: " + ex.ToString());
            }
        }
        private async Task <string> QueryImpl()
        {
            // Create EsriHttpClient object
            var httpClient = new EsriHttpClient();
            var portalUrl  = ArcGISPortalManager.Current.GetActivePortal().PortalUri.ToString();

            string userName = ArcGISPortalManager.Current.GetActivePortal().GetSignOnUsername();
            string query    = $@"q=owner:{userName} tags:""UploadVtpkToAgol Demo"" type:""Vector Tile Service"" ";

            // Once uploaded make another REST call to search for the uploaded data
            var searchUrl = new UriBuilder(portalUrl)
            {
                Path  = "sharing/rest/search",
                Query = $@"{query}&f=json"
            };

            var searchResults = httpClient.Get(searchUrl.Uri.ToString());

            dynamic resultItems = JObject.Parse(await searchResults.Content.ReadAsStringAsync());

            long numberOfTotalItems = resultItems.total.Value;

            if (numberOfTotalItems == 0)
            {
                return($@"Unable to find uploaded item with query: {query}");
            }

            var resultItemList = new List <dynamic>();

            resultItemList.AddRange(resultItems.results);
            //get the first result
            dynamic item = resultItemList[0];

            // Create an item from the search results

            string itemId      = item.id;
            var    currentItem = ItemFactory.Create(itemId, ItemFactory.ItemType.PortalItem);

            // Finally add the feature service to the map
            // if we have an item that can be turned into a layer
            // add it to the map
            if (LayerFactory.CanCreateLayerFrom(currentItem))
            {
                LayerFactory.CreateLayer(currentItem, MapView.Active.Map);
            }
            return($@"Downloaded this item: {item.name} [Type: {item.type}] to ArcGIS Online and added the item to the Map");
        }
Beispiel #29
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="node">対象Node</param>
        /// <param name="semanticModel">対象ソースのsemanticModel</param>
        /// <param name="parent">親IAnalyzeItem</param>
        /// <param name="container">イベントコンテナ</param>
        public ItemDo(DoStatementSyntax node, SemanticModel semanticModel, IAnalyzeItem parent, EventContainer container) : base(parent, node, semanticModel, container)
        {
            ItemType = ItemTypes.MethodStatement;

            // 条件設定
            var condition = semanticModel.GetOperation(node.Condition);

            Conditions.AddRange(OperationFactory.GetExpressionList(condition, container));

            // 内部処理設定
            var block = node.Statement as BlockSyntax;

            foreach (var statement in block.Statements)
            {
                Members.Add(ItemFactory.Create(statement, semanticModel, container, this));
            }
        }
Beispiel #30
0
        public IItem Remove(ushort itemId, byte count, out bool wasPartial)
        {
            wasPartial = false;
            bool removed = false;
            var  slot    = inventory.Keys.FirstOrDefault(k => inventory[k].Item1.Type.TypeId == itemId);

            try
            {
                var found = inventory[slot].Item1;

                if (found.Count < count)
                {
                    return(null);
                }

                // remove the whole item
                if (found.Count == count)
                {
                    inventory.Remove(slot);
                    found.SetHolder(null, default(Location));

                    removed = true;
                    return(found);
                }

                IItem newItem = ItemFactory.Create(found.Type.TypeId);

                newItem.SetAmount(count);
                found.SetAmount((byte)(found.Amount - count));

                wasPartial = true;
                removed    = true;
                return(newItem);
            }
            catch
            {
                return(null);
            }
            finally
            {
                if (removed)
                {
                    inventory = new Dictionary <byte, Tuple <IItem, ushort> >(inventory);
                }
            }
        }
Beispiel #31
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            world = new World(this);

            ItemFactory itemFactory = new ItemFactory(world, @"Items");

            EnemyFactory factory = new EnemyFactory(world, @"Enemy");
            world.EnemyFactory = factory;

            Map dungeonOne = MapLoader.Load("Content/Maps/DungeonOne_top.txt", "Content/Maps/DungeonOne_bottom.txt", "Content/Maps/DungeonOne_enemy.txt", world);
            world.CurrentDungeon = dungeonOne;

            Item item = itemFactory.Create("Super Awesome Potion");
            item.Position = new Vector2(70, 70);
            world.item = item;

            Animation animation = new Animation(1, 32, 32, 0, 0);
            Animation animation2 = new Animation(1, 256, 256, 0, 0);

            AnimatedSprite sprite = new AnimatedSprite(Content.Load<Texture2D>(@"Items\Weapons\Fireball"), new Dictionary<AnimationKey, Animation> { { AnimationKey.Right, animation } });
            AnimatedSprite light = new AnimatedSprite(Content.Load<Texture2D>(@"Enemy\LightBugAttack"), new Dictionary<AnimationKey, Animation> { { AnimationKey.Right, animation2 } });

            world.Player.Inventory.TempaQuips.Add(new Sword(Content.Load<Texture2D>(@"Gui\SwordIcon"), "Sword"));

            world.Player.Inventory.TempaQuips.Add((Gun)itemFactory.Create("Bobs Gun"));
            world.Player.Inventory.SelectRelativeTempaQuip(world.Player, 0);

            world.Player.Inventory.TempaQuips.Add(new Zapper(Content.Load<Texture2D>(@"Gui\GogglesIcon"), "BobsZapper", light));

            world.Player.Inventory.TempaQuips.Add(new SomeConeWeapon(Content.Load<Texture2D>(@"Gui\GravityBootsIcon"), "BobsCone", sprite.Clone()));

            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Fire"));
            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Ice"));
            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Lightning"));
        }