示例#1
0
        protected virtual void FillFrom(string responseText, Func <CommandParameterGroup, CommandParameterGroup, T> parseMethod, params object[] additionalStates)
        {
            CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText);

            if (list.Count == 0 || ((additionalStates == null || additionalStates.Length == 0) && parseMethod == null))
            {
                Values = new List <T>();
                return;
            }

            if (parseMethod != null)
            {
                CommandParameterGroup first = list.Count == 0 ? null : list[0];
                Values = list.Select(x => parseMethod(x, first)).ToList();
            }
            else
            {
                Values = list.Select(cpg => cpg.GetParameterValue(additionalStates[0].ToString()).ChangeTypeInvariant(default(T))).ToList();
            }
        }
        public ChannelDeletedEventArgs(CommandParameterGroupList commandParameterGroupList)
        {
            if (commandParameterGroupList == null)
            {
                throw new ArgumentNullException(nameof(commandParameterGroupList));
            }

            List <int> channelIds = commandParameterGroupList.Select(pg => pg.GetParameterValue <int>("cid")).ToList();

            ChannelId        = channelIds.Count > 0 ? (int?)channelIds.Last() : null;
            InvokerId        = commandParameterGroupList.GetParameterValue <int?>("invokerid");
            InvokerName      = commandParameterGroupList.GetParameterValue <string>("invokername");
            SubChannelIdList = channelIds.GetRange(0, Math.Max(0, channelIds.Count - 1));
        }