Ejemplo n.º 1
0
        public static PostbackAction ToPostbackAction(this IPostbackAction self)
        {
            if (self.Label == null)
            {
                throw new InvalidOperationException("The label cannot be null.");
            }

            if (self.Data == null)
            {
                throw new InvalidOperationException("The data cannot be null.");
            }

            if (self is PostbackAction postbackAction)
            {
                return(postbackAction);
            }

            return(new PostbackAction()
            {
                Label = self.Label,
                Data = self.Data,
                Text = self.Text
            });
        }
Ejemplo n.º 2
0
        internal static PostbackAction Convert(IPostbackAction action)
        {
            if (action.Label == null)
            {
                throw new InvalidOperationException("The label cannot be null.");
            }

            if (action.Data == null)
            {
                throw new InvalidOperationException("The data cannot be null.");
            }

            if (action is PostbackAction postbackAction)
            {
                return(postbackAction);
            }

            return(new PostbackAction()
            {
                Label = action.Label,
                Data = action.Data,
                Text = action.Text
            });
        }