コード例 #1
0
ファイル: Bar.cs プロジェクト: gkrylov/WpfPrototype
        private void ProcessIntridientsChange()
        {
            List<BarIngridient> result = new List<BarIngridient>();
            var ingredientNodes = this.Ingridients as IEnumerable<XmlNode>;
            if (ingredientNodes != null)
            {
                foreach (XmlNode ingridient in ingredientNodes)
                {
                    string IdString = ingridient.Attributes["ID"].Value;
                    int Id;
                    if (int.TryParse(IdString, out Id))
                    {
                        BarIngridient barIngridient = new BarIngridient();
                        barIngridient.Id = Id;
                        barIngridient.IsInBar = true;
                        result.Add(barIngridient);
                    }
                }

            }

            var ingredients = this.Ingridients as ObservableCollection<Ingredient>;
            if (ingredients != null)
                foreach (Ingredient ingredient in ingredients)
                    result.Add(new BarIngridient() { Id = ingredient.Id, IsInBar = true });

            BarIngridients = result.ToArray();

            var handler = PropertyChanged;
            if (handler != null)
                PropertyChanged(this, new PropertyChangedEventArgs(BarIngridientsProperty.Name));
        }