Microsoft.Samples.KMoore.WPFSamples.DateControls.MonthCalendar.UpdateDataSource C# (CSharp) Method

UpdateDataSource() private method

private UpdateDataSource ( ) : void
return void
        private void UpdateDataSource()
        {
            if (_dictDataSource == null)
            {
                _dictDataSource = new Dictionary<DateTime, object>();
            }
            else
            {
                bool bUpdate = _dictDataSource.Count > 0;
                _dictDataSource.Clear();
                if (bUpdate)
                {
                    UpdateDataSourceToCalendarDates();
                }
            }

            // Generate the data source dictionary with DataSource and DataSourceDatePath/XPath,
            // And update the data in the dictionary to the specific date
            if (DataSource != null && (DataSourceDatePath != null || (DataSourceDateXPath != null && DataSourceDateXPath.Length != 0)))
            {
                foreach (object obj in DataSource)
                {
                    DateTime? key = GetKeyFromDataSourceItem(obj);
                    if (key.HasValue && !_dictDataSource.ContainsKey(key.Value))
                    {
                        _dictDataSource.Add(key.Value, obj);
                    }
                }

                UpdateDataSourceToCalendarDates();
            }
        }