Beispiel #1
0
        private void Parse(XmlReader reader, bool nestedElement)
        {
            if (reader.MoveToFirstAttribute())
            {
                do
                {
                    if (!nestedElement)
                    {
                        if (reader.LocalName?.Equals("xmlns", StringComparison.OrdinalIgnoreCase) == true)
                        {
                            continue;
                        }
                        if (reader.Prefix?.Equals("xsi", StringComparison.OrdinalIgnoreCase) == true)
                        {
                            continue;
                        }
                        if (reader.Prefix?.Equals("xmlns", StringComparison.OrdinalIgnoreCase) == true)
                        {
                            continue;
                        }
                    }

                    if (!AttributeValues.ContainsKey(reader.LocalName))
                    {
                        AttributeValues.Add(reader.LocalName, reader.Value);
                    }
                    else
                    {
                        string message = $"Duplicate attribute detected. Attribute name: [{reader.LocalName}]. Duplicate value:[{reader.Value}], Current value:[{AttributeValues[reader.LocalName]}]";
                        _parsingErrors.Add(message);
                    }
                }while (reader.MoveToNextAttribute());
                reader.MoveToElement();
            }

            LocalName = reader.LocalName;

            if (!reader.IsEmptyElement)
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    if (reader.NodeType == XmlNodeType.CDATA || reader.NodeType == XmlNodeType.Text)
                    {
                        Value += reader.Value;
                        continue;
                    }

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        Children.Add(new NLogXmlElement(reader, true));
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void AddAttributeValue(Guid attributeValueId)
        {
            if (AttributeValues.Any(x => x.AttributeId == attributeValueId))
            {
                AttributeValues.RemoveAll(x => x.AttributeId == attributeValueId);
            }

            AttributeValues.Add(new ProductAttribute(Id, attributeValueId));
        }
 /// <summary>
 /// 添加属性
 /// </summary>
 /// <param name="values"></param>
 public void AddAttribute(string[] values)
 {
     for (int i = 0; i < values.Length; i++)
     {
         if (i < CfgRedlineTxt.BlockFields.Count)
         {
             if (!values[i].Contains("@"))
             {
                 AttributeValues.Add(values[i]);
             }
         }
         else
         {
             break;
         }
     }
 }
Beispiel #4
0
        private void Parse(XmlReader reader)
        {
            if (reader.MoveToFirstAttribute())
            {
                do
                {
                    if (!AttributeValues.ContainsKey(reader.LocalName))
                    {
                        AttributeValues.Add(reader.LocalName, reader.Value);
                    }
                    else
                    {
                        string message = $"Duplicate attribute detected. Attribute name: [{reader.LocalName}]. Duplicate value:[{reader.Value}], Current value:[{AttributeValues[reader.LocalName]}]";
                        _parsingErrors.Add(message);
                    }
                }while (reader.MoveToNextAttribute());
                reader.MoveToElement();
            }

            LocalName = reader.LocalName;

            if (!reader.IsEmptyElement)
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    if (reader.NodeType == XmlNodeType.CDATA || reader.NodeType == XmlNodeType.Text)
                    {
                        Value += reader.Value;
                        continue;
                    }

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        Children.Add(new NLogXmlElement(reader));
                    }
                }
            }
        }
Beispiel #5
0
        private void Parse(XmlReader reader)
        {
            if (reader.MoveToFirstAttribute())
            {
                do
                {
                    AttributeValues.Add(reader.LocalName, reader.Value);
                } while (reader.MoveToNextAttribute());

                reader.MoveToElement();
            }

            LocalName = reader.LocalName;

            if (!reader.IsEmptyElement)
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    if (reader.NodeType == XmlNodeType.CDATA || reader.NodeType == XmlNodeType.Text)
                    {
                        Value += reader.Value;
                        continue;
                    }

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        Children.Add(new NLogXmlElement(reader));
                    }
                }
            }
        }
Beispiel #6
0
        private void ParseAttributes(XmlReader reader, bool nestedElement)
        {
            if (reader.MoveToFirstAttribute())
            {
                do
                {
                    if (!nestedElement && IsSpecialXmlAttribute(reader))
                    {
                        continue;
                    }

                    if (!AttributeValues.ContainsKey(reader.LocalName))
                    {
                        AttributeValues.Add(reader.LocalName, reader.Value);
                    }
                    else
                    {
                        string message = $"Duplicate attribute detected. Attribute name: [{reader.LocalName}]. Duplicate value:[{reader.Value}], Current value:[{AttributeValues[reader.LocalName]}]";
                        _parsingErrors.Add(message);
                    }
                }while (reader.MoveToNextAttribute());
                reader.MoveToElement();
            }
        }
Beispiel #7
0
 public void AddAttributeValue(ProductAttributeValue attributeValue)
 {
     attributeValue.Product = this;
     AttributeValues.Add(attributeValue);
 }
Beispiel #8
0
 public virtual void ReadFrom(XElement xE)
 {
     FeedId                  = null;
     FeedItemId              = null;
     Status                  = null;
     StartTime               = null;
     EndTime                 = null;
     AttributeValues         = null;
     PolicyData              = null;
     DevicePreference        = null;
     Scheduling              = null;
     CampaignTargeting       = null;
     AdGroupTargeting        = null;
     KeywordTargeting        = null;
     GeoTargeting            = null;
     GeoTargetingRestriction = null;
     UrlCustomParameters     = null;
     foreach (var xItem in xE.Elements())
     {
         var localName = xItem.Name.LocalName;
         if (localName == "feedId")
         {
             FeedId = long.Parse(xItem.Value);
         }
         else if (localName == "feedItemId")
         {
             FeedItemId = long.Parse(xItem.Value);
         }
         else if (localName == "status")
         {
             Status = FeedItemStatusExtensions.Parse(xItem.Value);
         }
         else if (localName == "startTime")
         {
             StartTime = xItem.Value;
         }
         else if (localName == "endTime")
         {
             EndTime = xItem.Value;
         }
         else if (localName == "attributeValues")
         {
             if (AttributeValues == null)
             {
                 AttributeValues = new List <FeedItemAttributeValue>();
             }
             var attributeValuesItem = new FeedItemAttributeValue();
             attributeValuesItem.ReadFrom(xItem);
             AttributeValues.Add(attributeValuesItem);
         }
         else if (localName == "policyData")
         {
             if (PolicyData == null)
             {
                 PolicyData = new List <FeedItemPolicyData>();
             }
             var policyDataItem = new FeedItemPolicyData();
             policyDataItem.ReadFrom(xItem);
             PolicyData.Add(policyDataItem);
         }
         else if (localName == "devicePreference")
         {
             DevicePreference = new FeedItemDevicePreference();
             DevicePreference.ReadFrom(xItem);
         }
         else if (localName == "scheduling")
         {
             Scheduling = new FeedItemScheduling();
             Scheduling.ReadFrom(xItem);
         }
         else if (localName == "campaignTargeting")
         {
             CampaignTargeting = new FeedItemCampaignTargeting();
             CampaignTargeting.ReadFrom(xItem);
         }
         else if (localName == "adGroupTargeting")
         {
             AdGroupTargeting = new FeedItemAdGroupTargeting();
             AdGroupTargeting.ReadFrom(xItem);
         }
         else if (localName == "keywordTargeting")
         {
             KeywordTargeting = new Keyword();
             KeywordTargeting.ReadFrom(xItem);
         }
         else if (localName == "geoTargeting")
         {
             GeoTargeting = new Location();
             GeoTargeting.ReadFrom(xItem);
         }
         else if (localName == "geoTargetingRestriction")
         {
             GeoTargetingRestriction = new FeedItemGeoRestriction();
             GeoTargetingRestriction.ReadFrom(xItem);
         }
         else if (localName == "urlCustomParameters")
         {
             UrlCustomParameters = new CustomParameters();
             UrlCustomParameters.ReadFrom(xItem);
         }
     }
 }
Beispiel #9
0
    public override bool Doable(AreaInteractable interactable, out string message)
    {
        switch (actionType)
        {
        case Type.WashDishes:
            if (room.dishesWashed)
            {
                message = string.Format($"<color={GameAction.errorColor}>Dishes are already washed.");
                return(false);
            }
            break;

        case Type.EatMeal:
            if (room.meals <= 0)
            {
                message = string.Format($"<color={GameAction.errorColor}>There are no meals.");
                return(false);
            }
            if (!room.dishesWashed)
            {
                message = string.Format($"<color={GameAction.errorColor}>All the dishes are dirty.");
                return(false);
            }
            break;

        case Type.EatIngredients:
            AttributeValues.RemoveAll(e => (e.type == Person.AttributeTypes.Hunger));
            Required req = new Required();
            req.type      = Person.AttributeTypes.Hunger;
            req.netAmount = room.CheckIngredientsConsumption();

            if (req.netAmount <= 0)
            {
                message = string.Format($"<color={GameAction.errorColor}>No ingredients in the kitchen.");
                return(false);
            }

            AttributeValues.Add(req);
            break;

        case Type.PrepareMeal:
            if (room.meals >= room.maxMeals)
            {
                message = string.Format($"<color={GameAction.errorColor}>Meals are at full capacity. [{room.meals}/{room.maxMeals}]");
            }
            if (room.ingredients < mealCost)
            {
                message = string.Format($"<color={GameAction.errorColor}>Not enough ingredients for a meal. [{room.ingredients}/{mealCost}]");
                return(false);
            }
            break;

        case Type.AddIngredients:
            FoodIngredient ingredient = interactable as FoodIngredient;
            if (ingredient)
            {
                int waste;
                if ((waste = room.CheckIngredients(ingredient.nutritionValue)) > 0)
                {
                    if (ingredient.nutritionValue - waste <= 0)
                    {
                        message = string.Format($"<color={GameAction.errorColor}>Full food ingredient capacity [{room.ingredients}/{room.maxIngredients}]");
                        return(false);
                    }

                    message  = string.Format($"<color={GameAction.okColor}>{ingredient.foodName} +{ingredient.nutritionValue-waste} ingredients.");
                    message += string.Format($"<color={GameAction.errorColor}> \n -{waste} Wasted");
                }
                else
                {
                    message = string.Format($"<color={GameAction.okColor}>{ingredient.foodName} +{ingredient.nutritionValue} food ingredients.");
                }
                return(true);
            }
            break;

        default:
            break;
        }
        return(base.Doable(interactable, out message));
    }