public void AssignDummy()//NullPtr pattern where we assign dummy valueless node with validity set as false { m_isvalid = false; data = new WeatherData(); data.AssignDummy(); }
/// <summary> /// Main interface to set weather information to be used later. /// If input is valid, we clear all current data and set new data /// </summary> /// <param name="future"></param> /// <param name="past"></param> public void SetWeather(LocalWeather future, PastWeather past = null) { lock (accesssynch) { if (future == null || future.data == null || future.data.weather == null) { HandleError(); return; } Clear(); if (past != null)//for historical data { List <premium.pastweather.Weather> pastweathers = past.data.weather; foreach (premium.pastweather.Weather weather in pastweathers) { //create input to usable and storable weatherdata object WeatherData data = fillDataPast(weather); data.m_location = past.data.request[0].query; data.m_rainchance = 0; //Create a doubly Linked list chain to store weather of each date Node node = new Node(); node.data = data; node.datetime = data.m_date; if (m_start == null) { m_start = node; m_left = node; } else { m_end.next = node; node.prev = m_end; } m_right = node; m_end = node; } } if (future.data.weather != null)//for future data { List <premium.localweather.Weather> localweathers = future.data.weather; foreach (premium.localweather.Weather weather in localweathers) { WeatherData data = fillDataFuture(weather); data.m_location = future.data.request[0].query; //Create a doubly Linked list chain to store weather of each date Node node = new Node(); node.data = data; node.datetime = data.m_date; if (m_today == null) { m_today = node; } if (m_start == null) { m_start = node; m_left = node; } else { m_end.next = node; node.prev = m_end; } m_right = node; m_end = node; } } } }