示例#1
0
        public override void ProcessCarrier(ICarrier carrier)
        {
            FullInfo fullInfo;

            // Duck-typing!
            if (!zipcodeInfoMap.TryGetValue(carrier.Signal.Zipcode, out fullInfo))
            {
                fullInfo = new FullInfo();
                zipcodeInfoMap[carrier.Signal.Zipcode] = fullInfo;
            }

            if (carrier.Protocol.DeclTypeName == "WeatherInfo")
            {
                fullInfo.WeatherInfo = carrier.Signal;
            }

            if (carrier.Protocol.DeclTypeName == "Location")
            {
                fullInfo.LocationInfo = carrier.Signal;
            }

            if (fullInfo.Completed)
            {
                string conditions = ProcessConditions(fullInfo.WeatherInfo);
                string hazards    = ProcessHazards(fullInfo.WeatherInfo);
                Say("Here is the weather for " + fullInfo.LocationInfo.City + " " + fullInfo.LocationInfo.State + ". ");
                Say("The low is " + fullInfo.WeatherInfo.Low + ".");
                Say("The high is " + fullInfo.WeatherInfo.High + ".");
                Say("The weather is: " + fullInfo.WeatherInfo.Summary + ".");
                Say(conditions);
                Say(hazards);
            }
        }
示例#2
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			try
			{
				FullInfo fullInfo;

				// Duck-typing! -- Both USLocation and WeatherInfo have a Zip5 member.
				if (!zipcodeInfoMap.TryGetValue(carrier.Signal.Zip5.Value, out fullInfo))
				{
					fullInfo = new FullInfo();
					zipcodeInfoMap[carrier.Signal.Zip5.Value] = fullInfo;
				}

				if (carrier.Protocol.DeclTypeName == "WeatherInfo")
				{
					fullInfo.WeatherInfo = carrier.Signal;
				}

				if (carrier.Protocol.DeclTypeName == "USLocation")
				{
					fullInfo.LocationInfo = carrier.Signal;
				}

				if (fullInfo.Completed)
				{
					string conditions = ProcessConditions(fullInfo.WeatherInfo);
					string hazards = ProcessHazards(fullInfo.WeatherInfo);
					Say("Here is the weather for " + fullInfo.LocationInfo.City.Value + " " + fullInfo.LocationInfo.USState.Value + ". ");
					Say("The low is " + fullInfo.WeatherInfo.Low + ".");
					Say("The high is " + fullInfo.WeatherInfo.High + ".");
					Say("The weather is: " + fullInfo.WeatherInfo.Summary + ".");
					Say(conditions);
					Say(hazards);
				}
			}
			catch (Exception ex)
			{
				EmitException(ex);
			}
		}
示例#3
0
        public override void ProcessCarrier(ICarrier carrier)
        {
            try
            {
                FullInfo fullInfo;

                // Duck-typing! -- Both USLocation and WeatherInfo have a Zip5 member.
                if (!zipcodeInfoMap.TryGetValue(carrier.Signal.Zip5.Value, out fullInfo))
                {
                    fullInfo = new FullInfo();
                    zipcodeInfoMap[carrier.Signal.Zip5.Value] = fullInfo;
                }

                if (carrier.Protocol.DeclTypeName == "WeatherInfo")
                {
                    fullInfo.WeatherInfo = carrier.Signal;
                }

                if (carrier.Protocol.DeclTypeName == "USLocation")
                {
                    fullInfo.LocationInfo = carrier.Signal;
                }

                if (fullInfo.Completed)
                {
                    string conditions = ProcessConditions(fullInfo.WeatherInfo);
                    string hazards    = ProcessHazards(fullInfo.WeatherInfo);
                    Say("Here is the weather for " + fullInfo.LocationInfo.City.Value + " " + fullInfo.LocationInfo.USState.Value + ". ");
                    Say("The low is " + fullInfo.WeatherInfo.Low + ".");
                    Say("The high is " + fullInfo.WeatherInfo.High + ".");
                    Say("The weather is: " + fullInfo.WeatherInfo.Summary + ".");
                    Say(conditions);
                    Say(hazards);
                }
            }
            catch (Exception ex)
            {
                EmitException(ex);
            }
        }