Exemplo n.º 1
0
        private Dictionary <DataSourceEvent, object> MakeDataSourceEvents(Dictionary <DataSourceEvent, object> recivedEvents, Helpers.CoreKendoGrid.Settings.Features.ClientEvent clEvent)
        {
            var finalEventDic = new Dictionary <DataSourceEvent, object>();

            //if (clEvent != null)
            //{
            //    if (!string.IsNullOrEmpty(clEvent.OnInit))
            //    {
            //        recivedEvents.Add(DataSourceEvent.OnRequestStart, clEvent.OnInit);
            //    }
            //}
            if (recivedEvents.Any(itm => itm.Value.ToString() != string.Empty))
            {
                //list of Events which their implementations have to be defined as Default.
                //var tobeDefineAsDefault = defEvents.Keys.Where(k => list.Any(lk => lk != k)).ToList();

                foreach (var item in recivedEvents)
                {
                    switch (item.Key)
                    {
                    case DataSourceEvent.OnError:
                        BuildCustomOnErrorEvent(finalEventDic, item.Value.ToString());
                        break;

                    case DataSourceEvent.OnRequestStart:
                        BuildCustomOnRequestStartEvent(finalEventDic, item.Value.ToString());
                        break;

                    case DataSourceEvent.OnRequestEnd:
                        BuildCustomOnRequestEndEvent(finalEventDic, item.Value.ToString());
                        break;

                    case DataSourceEvent.Sync:
                        BuildCustomOnSyncEvent(finalEventDic, item.Value.ToString());
                        break;

                    case DataSourceEvent.OnChange:
                        BuildCustomOnChangeEvent(finalEventDic, item.Value.ToString());
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                MakePredefinedEventHandlers(finalEventDic);
            }
            return(finalEventDic);
        }
Exemplo n.º 2
0
        public Dictionary <DataSourceEvent, object> AssignDsEvents(Dictionary <DataSourceEvent, object> dictionary, Helpers.CoreKendoGrid.Settings.Features.ClientEvent clientEvent)
        {
            if (dictionary.Any(k => k.Value.ToString() != string.Empty))
            {
                var tobeAppendToCustomHandlers  = dictionary.Where(item => item.Value.ToString() != string.Empty).ToList();
                var tobeAppendToDefaultHandlers = this.GetListOfPredefinedEvents().Where(item => tobeAppendToCustomHandlers.Any(it => it.Key != item.Key)).ToList();
                var refinedDic = new Dictionary <DataSourceEvent, object>();
                if (tobeAppendToCustomHandlers.Count > 0)
                {
                    tobeAppendToCustomHandlers.ForEach(itm => { refinedDic.Add(itm.Key, itm.Value); });
                    dictionary = MakeDataSourceEvents(refinedDic, clientEvent);
                }
                tobeAppendToDefaultHandlers.ForEach(itm =>
                {
                    switch (itm.Key)
                    {
                    case DataSourceEvent.OnError:
                        dictionary.Add(DataSourceEvent.OnError, BuildDefaultOnErrorEvent(string.Empty));
                        break;

                    case DataSourceEvent.OnRequestStart:
                        dictionary.Add(DataSourceEvent.OnRequestStart, BuildDefaultOnRequestStartEvent(string.Empty));
                        break;

                    case DataSourceEvent.OnRequestEnd:
                        dictionary.Add(DataSourceEvent.OnRequestEnd, BuildDefaultOnRequestEndEvent(string.Empty));
                        break;

                    case DataSourceEvent.Sync:
                        dictionary.Add(DataSourceEvent.Sync, BuildDefaultOnSyncEvent(string.Empty));
                        break;

                    case DataSourceEvent.OnChange:
                        dictionary.Add(DataSourceEvent.OnChange, BuildDefaultOnChangeEvent(string.Empty));
                        break;

                    default:
                        break;
                    }
                });
            }
            else
            {
                dictionary = MakeDataSourceEvents(dictionary, clientEvent);
            }
            return(dictionary);
        }