public static string get_Text(this API_EtherpadLite etherPad)
        {
            etherPad.ensure_Pad_Exists();
            var result = etherPad.EtherpadLite.GetText(etherPad.CurrentPad);

            if (result.Code == EtherpadReturnCodeEnum.Ok)
            {
                etherPad.LastKnownText = result.Data.Text;
                return(etherPad.LastKnownText);
            }
            "[API_EtherpadLite][get_Text]: {0}".error(result.Message);
            return(null);
        }
        public static API_EtherpadLite create_Pad(this API_EtherpadLite etherPad, string padName)
        {
            "[API_EtherpadLite] creating pad: {0}".info(padName);
            var result = etherPad.EtherpadLite.CreatePad(padName);

            if (result.Code != EtherpadReturnCodeEnum.Ok)
            {
                "[API_EtherpadLite][createPad]: {0}".error(result.Message);
            }
            {
                etherPad.CurrentPad = padName;
                etherPad.PadExists  = true;
            }
            return(etherPad);
        }
        public static API_EtherpadLite set_Text(this API_EtherpadLite etherPad, string text)
        {
            if (etherPad.LastKnownText == text)
            {
                "[API_EtherpadLite][set_Text]: skiping update since the content is the same".info();
            }
            //text = text.fixCRLF();
            etherPad.ensure_Pad_Exists();
            "[API_EtherpadLite][set_Text]: updating pad with text with size: {0}".info(text.size());
            var result = etherPad.EtherpadLite.SetText(etherPad.CurrentPad, text);

            if (result.Code != EtherpadReturnCodeEnum.Ok)
            {
                "[API_EtherpadLite][set_Text]: {0}".error(result.Message);
            }
            else
            {
                etherPad.LastKnownText = text;
            }
            return(etherPad);
        }
        public static API_EtherpadLite ensure_Pad_Exists(this API_EtherpadLite etherPad, string padName)
        {
            if (etherPad.PadExists)
            {
                return(etherPad);
            }
            var result = etherPad.EtherpadLite.GetText(padName);

            if (result.Message == "padID does not exist")
            {
                etherPad.create_Pad(padName);
            }
            else
            if (result.Code == EtherpadReturnCodeEnum.Ok)
            {
                etherPad.CurrentPad = padName;
                etherPad.PadExists  = true;
            }
            else
            {
                "[API_EtherpadLite][ensure_Pad_Exists] unsupported response code: {0}".error(result.Code);
            }
            return(etherPad);
        }
 public static API_EtherpadLite ensure_Pad_Exists(this API_EtherpadLite etherPad)
 {
     return(etherPad.ensure_Pad_Exists(etherPad.CurrentPad));
 }
 public static API_EtherpadLite open_Pad(this API_EtherpadLite etherPad, string padName)
 {
     return(etherPad.ensure_Pad_Exists(padName));
 }
 public static API_EtherpadLite open(this API_EtherpadLite etherPad, string padName)
 {
     return(etherPad.open_Pad(padName));
 }
 public static string pad_Url(this API_EtherpadLite etherPad)
 {
     return("http://{0}/p/{1}".format(etherPad.Host, etherPad.CurrentPad));
 }
 public static API_EtherpadLite contents(this API_EtherpadLite etherPad, string text)
 {
     return(etherPad.set_Text(text));
 }
 public static string contents(this API_EtherpadLite etherPad)
 {
     return(etherPad.get_Text());
 }