text:
// grindtrick import pstream
// grindtrick import boost_locale
// grindtrick import boost_filesystem
// grindtrick import boost_system

#include <algorithm>
#include <iostream>
#include <iterator>
#include <fstream>
#include <vector>
#include <regex>
#include <set>
#include <boost/range/algorithm/count_if.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/locale/encoding.hpp>
#include <boost/filesystem.hpp>

#include <pstream.h>

using namespace boost::property_tree;
using namespace boost::locale::conv;
using namespace boost::algorithm;
using namespace boost::range;
using namespace boost::filesystem;
using namespace std;

#include "base64.cpp"

wstring g_sphere_tag;

wstring const SUBJECT_FIELD_NAME(L"Sujet");
wstring const TAG_FIELD_NAME(L"\u00C9tiquettes");

class check_error
{
public:
    check_error(wstring const & msg) : msg_(msg) {}

    wstring msg_;

    wstring user_message() const
    {
        return msg_;
    }
};

wptree replace_nbsp(wptree const & n)
{
    auto d = n.data();
    replace_all(d, L" ", L" ");

    auto r = wptree(d);

    for(auto child: n)
    {
        auto no_nbsp = replace_nbsp(child.second);
        r.push_back( make_pair(child.first, no_nbsp ) );
    }

    return r;
}

wstring to_html(wptree const & enote, wstring const & title)
{
    // nbsp are preserved by read_xml.
    // The data in the nodes have been decoded, except
    // nbsp.  If the original enote contained "<",
    // data is "<", but " " are left as-is.

    // We do not care ofr nbspaces and we do not want
    // the string " " to appear as regular text
    // in our output.  So we remove them.

    auto copy = replace_nbsp(enote);

    wostringstream os;
    write_xml(os, copy);

    wstring encoded_title(title);
    if( encoded_title.size() )
    {
        replace_all(encoded_title, L"<", L"<");
        replace_all(encoded_title, L">", L">");
        replace_all(encoded_title, L"&", L"&");

        encoded_title = L"<title>" + encoded_title + L"</title>\n";
    }

    auto r = os.str();

    erase_all(r, L"<?xml version=\"1.0\" encoding=\"utf-8\"?>");

    r = L"<!DOCTYPE html>\n"
        L"\n"
        L"<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n"
        + encoded_title +
        L"\n"
        + r +
        L"\n"
    ;

    return r;
}

wstring to_markdown(wstring const & content)
{
    using namespace redi;

    vector<string> args;
    args.push_back("html2text");
    args.push_back("-nobs");
    args.push_back("-style");
    args.push_back("pretty");
    args.push_back("-width");
    args.push_back("99");

    pstream in("html2text", args, pstreambuf::pstdin | pstreambuf::pstdout);

    string utf8 = utf_to_utf<char, wchar_t>(content.c_str());

    //std::ofstream ifs("to_markdown_input");
    //ifs << utf8;

    in << utf8;

    peof(in); // close stdin so client knows to finish

    //ofstream of("to_markdown_result");

    string line;
    string markdown;
    while( getline(in, line) )
    {
        markdown = markdown + line + "\n";
        //of << line << '\n';
    }

    in.close();
    if( !in.rdbuf()->exited() )
    {
        throw check_error(L"html2text failed to exit");
    }

    if( in.rdbuf()->status() != 0 )
    {
        throw check_error(L"html2text exited with non-zero status");
    }

    auto r = utf_to_utf<wchar_t, char>(markdown.c_str());

    replace_all(r, L" ", L" ");

    return r;
}

class Attachment
{
public:
    wstring data_;
    wstring encoding_;
    wstring filename_;
};

class Note
{
public:
    wstring title_;
    wstring content_;
    wstring content_as_html_;
    set<wstring> tags_;
    wstring project_;
    vector<Attachment> attachments_;
    wstring basename_;
};

Attachment resource(wptree const & pt)
{
    Attachment a;

    auto data_node = pt.get_child(L"data");

    a.data_ = data_node.get_value<wstring>();

    for(auto v: data_node)
    {
        if( v.first == L"<xmlattr>" )
        {
            for(auto v: v.second)
            {
                if( v.first == L"encoding" )
                {
                    a.encoding_ = v.second.get_value<wstring>();
                }
            }
        }
    }

    auto opt_res_attr = pt.get_child_optional(L"resource-attributes");
    if( opt_res_attr )
    {
        auto res_attr = *opt_res_attr;
        auto opt_fn = res_attr.get_optional<wstring>(L"file-name");
        if( opt_fn ) a.filename_ = *opt_fn;
    }

    return a;
}

bool is_valid_fn_char(wchar_t c)
{
    if( c < 32 ) return false;
    wstring invalids = L"<>:\"/\\|?*";
    if( count(invalids.begin(), invalids.end(), c) != 0 ) return false;
    return true;
}

void check_for_valid_tag(wstring const & t)
{
    if( t.empty() ) throw check_error(L"tag cannot be empty string");
    if( count( t.begin(), t.end(), L'#' ) != 0 ) throw check_error(L"Evernote tag cannot contain hash");
    if( count_if( t, iswspace ) ) throw check_error(L"tag must be a single word");
    if( ! all_of(t.begin(), t.end(), is_valid_fn_char) ) throw check_error(L"tag contains invalid characters");
}

void repair_title(wstring & t)
{
    wstring r;
    copy_if(t.begin(), t.end(), back_inserter(r), is_valid_fn_char);
    t = r;
    trim(t);
}

void check_for_valid_title(wstring const & t)
{
    if( ! all_of(t.begin(), t.end(), is_valid_fn_char) ) throw check_error(L"title contains invalid characters");
}

void write_attachment(boost::filesystem::wpath const & annex_path, Attachment const & a, int & counter)
{
    auto afn = a.filename_;

    if( afn.empty() )
    {
        wostringstream afn_os;
        afn_os << setw(5) << setfill(L'0')  << counter;
        ++ counter;
        afn = afn_os.str();
    }

    boost::filesystem::wpath path = annex_path / afn;

    if( a.encoding_ != L"base64" )
    {
        throw check_error(L"unsupported attachment encoding: " + a.encoding_);
    }

    string data;
    data.resize(a.data_.size());

    /*
    Note: copy wchar_t down to char.  This is OK
    because the string is base64 encoded data, so
    no character is beyond 127.
    */
    copy(a.data_.begin(), a.data_.end(), data.begin());

    erase_all(data, "\n");
    erase_all(data, "\r");

    auto dec = b64decode(data);
    auto fn = path.string<string>();
    std::ofstream os(fn, ios::binary);
    os.exceptions(~ios::goodbit);
    os << dec;
}

void write_note(Note const & n)
{
    wstring wnote_fn = n.basename_ + L".md";
    string note_fn = from_utf(wnote_fn, "UTF-8") ;

    std::wofstream os(note_fn);

    os << SUBJECT_FIELD_NAME << ": " << n.title_ << '\n';

    os << TAG_FIELD_NAME << ": ";

    for(auto t: n.tags_)
    {
        os << L'#' << t << L' ';
    }
    os << '\n';

    os << '\n';

    os << n.content_;

    if( !n.attachments_.empty() )
    {
        boost::filesystem::wpath annex_fn(n.basename_);
        annex_fn += L".annexes";
        create_directory(annex_fn);
        int counter = 1;
        for(auto a: n.attachments_)
        {
            write_attachment(annex_fn, a, counter);
        }
    }
}

void write_html_content(Note const & n)
{
    wstring whtml_fn = n.basename_ + L".html";
    string html_fn = from_utf(whtml_fn, "UTF-8") ;

    std::wofstream os(html_fn);

    os << n.content_as_html_;
}

void print_tree(wptree const & t, int indent=0)
{
    wstring ide(indent*2, ' ');

    std::wcout << ide;
    std::wcout << t.data() << "\n";

    for(auto c: t)
    {
        std::wcout << ide;
        std::wcout << "<" << c.first << ">\n";

        print_tree(c.second, indent+1);
    }
}

void note(wptree const & pt)
{
    Note n;

    for(auto v: pt)
    {
        if( v.first == L"title" )
        {
            n.title_ = v.second.get_value<wstring>();
            trim(n.title_);
            repair_title(n.title_);
            check_for_valid_title(n.title_);
        }
        else if( v.first == L"content")
        {
            wstring en_note = v.second.get_value<wstring>();
            // en_note is an XML document until we get
            // inside the <en-note> tag.  In there is HMTL.

            wptree en_note_ptree;
            wistringstream is(en_note);
            read_xml(is, en_note_ptree);

            auto enote = en_note_ptree.get_child(L"en-note");

            n.content_as_html_ = to_html(enote, n.title_);

            auto pre_opt = enote.get_child_optional(L"pre");
            if( pre_opt )
            {
                n.content_ = (*pre_opt).get_value<wstring>();
            }
            else
            {
                n.content_ = to_markdown( n.content_as_html_ );
            }
        }
        else if( v.first == L"tag")
        {
            auto tag = v.second.get_value<wstring>();
            trim(tag);
            check_for_valid_tag(tag);
            n.tags_.insert(tag);
        }
        else if( v.first == L"resource")
        {
            n.attachments_.push_back( resource(v.second) );
        }
    }

    n.tags_.insert(g_sphere_tag);

    n.project_ = L"imported";
    for(auto v: n.tags_)
    {
        if( v != g_sphere_tag )
        {
            n.project_ = v;
            break;
        }
    }

    n.tags_.insert(L"imported");

    n.basename_ = g_sphere_tag + L" " + n.project_ + L" " + n.title_;

    write_note(n);
    write_html_content(n);
}

int main(int argc, char ** argv)
{
    // Load the system locale.
    setlocale(LC_ALL, "");

    try
    {
        g_sphere_tag = L"inro";

        if( argc >= 2 )
        {
            g_sphere_tag = to_utf<wchar_t>(argv[1], "UTF-8");
        }

        regex wc("[0-9]*\\.xml");
        smatch mo;

        for(auto e: directory_iterator("."))
        {
            if( !is_regular_file(e) ) continue;

            string fn = e.path().filename().string();

            if( !regex_match(fn, mo, wc) ) continue;

            std::wifstream note_file(e.path().string());
            note_file.exceptions(~ios::goodbit);

            wptree pt;
            read_xml(note_file, pt);

            cout << fn << '\n';

            try
            {
                note(pt);
                remove(e.path());
            }
            catch(exception const & ex)
            {
                cerr << "exception: " << ex.what() << '\n';
            }
            catch(check_error const & ex)
            {
                wcerr << fn << ": " << ex.user_message() << '\n';
            }
        }
    }
    catch(exception const & ex)
    {
        cerr << "exception: " << ex.what() << '\n';
        return 1;
    }
    catch(check_error const & ex)
    {
        wcerr << ex.user_message() << '\n';
        return 1;
    }

    return 0;
}


text:
package com.cloudant.se.loader.file;

import com.beust.jcommander.Parameter;
import com.cloudant.se.app.BaseAppOptions;

public class AppOptions extends BaseAppOptions {
    @Parameter(names = { "-watch" }, description = "Enables watching the configured source directory")
    public boolean watch = false;
}

redpajama_set_name: RedPajamaGithub


text:
"use strict";

define(["./plistmanager"], function(PListManager) {
  /**
   * Manages the Queue of players waiting.
   */
  function QueueManager(services, element) {
    this.services = services;
    this.launching_ = [];
    this.queue_ = [];
    this.timer_ = 0;
    this.element_ = element;
    this.plist = new PListManager();

  //  this.rowHeight_ = 40;
  //  this.canvas_ = $("queue-canvas");
  //  this.ctx_ = this.canvas_.getContext("2d");
  //  this.resize();
  };

  QueueManager.prototype.createQueueLine = function(player, color) {
    return this.plist.createElement(player, color);
  };

  QueueManager.prototype.deleteQueueLine = function(queueLine) {
    this.plist.deleteElement(queueLine);
  };

  //QueueManager.prototype.resize = function() {
  //  Misc.resize(this.canvas);
  //};
  //
  //QueueManager.prototype.draw = function() {
  //  this.resize();
  //  var ctx = this.ctx_;
  //  var canvas = this.canvas_;
  //  var height = this.canvas_.height;
  //  ctx.clearRect(0, 0, this.canvas_.width, this.canvas_.height);
  //  // draw launching players
  //  var y = 0;
  //  var count = 0;
  //  for (var ii = 0; y < height && ii < this.launching_.length; ++ii) {
  //    var player = this.launching_[ii];
  //    this.drawPlayer(player, y, count, true);
  //    y += this.rowHeight_;
  //    ++count;
  //  }
  //  // draw queued players.
  //  for (var ii = 0; y < height && ii < this.queue_.length; ++ii) {
  //    var player = this.queue_[ii];
  //    this.drawPlayer(player, y, count, false);
  //    y += this.rowHeight_;
  //    ++count;
  //  }
  //};
  //
  //QueueManager.prototype.drawPlayer = function(player, y, count, launching) {
  //  var ctx = this.ctx_;
  //  var canvas = this.canvas_;
  //  var width = this.canvas_.width;
  //  ctx.fillStyle = count % 2 ? "#006" : "#00A";
  //  var color = player.color.canvasColor;
  //  if (launching) {
  //    var cl = Math.floor(player.timer * 16);
  //    switch (cl % 4) {
  //    case 0:
  //      color = "#f00";
  //      break;
  //    case 2:
  //      color = "#ff0";
  //    }
  //  }
  //  ctx.fillRect(0, 0, width, this.rowHeight_);
  //  drawShip(
  //      ctx,
  //      this.rowHeight_ / 2,
  //      y + this.rowHeight_ / 2,
  //      player.direction,
  //      color);
  //};

  QueueManager.prototype.draw = function() {
    // remove all the elements.
    while (this.element_.firstChild) {
      this.element_.removeChild(this.element_.firstChild);
    }
    this.num = 0;
    this.setElements_(0, this.launching_, true);
    this.setElements_(this.launching_.length, this.queue_, false);
  };

  QueueManager.prototype.setElements_ = function(index, players, launching) {
    for (var ii = 0; ii < players.length; ++ii) {
      this.setElement_(players[ii], launching, "");
    }
  };

  QueueManager.prototype.setElement_ = function(player, launching, msg) {
    var globals = this.services.globals;
    var s = player.queueLine.name.style;
    if (launching) {
      s.color = "#f00";
    } else {
      s.color = "#ff0";
    }
    if (this.num < 8) {
      ++this.num;
      this.element_.appendChild(player.queueLine.line);
    }
  };

  QueueManager.prototype.sendPlaceInQueue = function(player) {
    if (player.showPlaceInQueue) {
      player.sendCmd('queue', {
        count: player.placeInQueue
      });
    }
  };

  QueueManager.prototype.sendPlaces = function() {
    for (var ii = 0; ii < this.queue_.length; ++ii) {
      var player = this.queue_[ii];
      player.placeInQueue = ii;
      this.sendPlaceInQueue(player);
    }
  };

  QueueManager.prototype.addToQueue = function(player) {
    player.placeInQueue = this.queue_.length;
    this.queue_.push(player);
    this.draw();
  };

  QueueManager.prototype.removeFromQueue = function(player) {
    var index = this.queue_.indexOf(player);
    if (index >= 0) {
      this.queue_.splice(index, 1);
      this.draw();
    this.sendPlaces();
      return;
    }
    var index = this.launching_.indexOf(player);
    if (index >= 0) {
      this.launching_.splice(index, 1);
      this.draw();
      return;
    }
  };

  QueueManager.prototype.process = function() {
    var globals = this.services.globals;
    if (this.timer_ > 0) {
      this.timer_ -= globals.elapsedTime;
    } else {
      if (this.queue_.length > 0 &&
          this.services.playerManager.getNumActivePlayers() + this.launching_.length < this.services.globals.maxActivePlayers) {
        var player = this.queue_.shift()
        player.countdown();
        this.launching_.push(player);
        this.sendPlaces();
        this.timer_ = 1;  // don't start another for at least 1 second.
        this.draw();
      }
    }
  };

  return QueueManager;
});


text:
function setup_puppet {
  systemctl stop puppet
  puppet agent --enable
  puppet agent --test
}

###############
# Set up ruby #
###############
function setup_ruby {
  echo "gem: --no-document" > ~/.gemrc
  apt-get install ruby-full -y
  /opt/puppetlabs/puppet/bin/gem install puppet-lint
  # unable to find this gem?
  #/opt/puppetlabs/puppet/bin/gem install puppet-bolt
  return 0
} # //setup_ruby

# this is to stop the msgpack errors
function fix_msgpack {
  /opt/puppetlabs/puppet/bin/gem install msgpack
  sed -i '/main/a      preferred_serialization_format =  msgpack' /etc/puppetlabs/puppet/puppet.conf

  return 0

} # //fix_msgpack

# We need terraform on this host so we can provision other hosts
# from it.
function install_terraform {

  wget -P /tmp https://releases.hashicorp.com/terraform/0.11.1/terraform_0.11.1_linux_amd64.zip
  apt-get install -y zip unzip
  /usr/bin/unzip /tmp/terraform_0.11.1_linux_amd64.zip
  mv /tmp/terraform /usr/local/bin
  return 0
} # //install_terraform

function mount_data {

  apt-get -y  install udisks2
  mkfs -t ext4 /dev/sda
  udisksctl mount -b /dev/sda
  # add symlink to this thing?
  return 0
} # //mount_data

function main {
  setup_puppet
  setup_ruby
  fix_msgpack
  install_terraform
  /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
  apt-get -y install "build-essential"
  # could we config disks with cloud init?
  #apt-get -y install cloud-init
  # get this one working so it auto-mounts
  #mount_data
}

if [ -z "$ARGS" ] ; then
  main $@
else
  main $ARGS
fi


text:
package cas

import (
	"net/url"
	"path"
)

// URLScheme creates the url which are required to handle the cas protocol.
type URLScheme interface {
	Login() (*url.URL, error)
	Logout() (*url.URL, error)
	Validate() (*url.URL, error)
	ServiceValidate() (*url.URL, error)
	RestGrantingTicket() (*url.URL, error)
	RestServiceTicket(tgt string) (*url.URL, error)
	RestLogout(tgt string) (*url.URL, error)
}

// NewDefaultURLScheme creates a URLScheme which uses the cas default urls
func NewDefaultURLScheme(base *url.URL) *DefaultURLScheme {
	return &DefaultURLScheme{
		base:                base,
		LoginPath:           "login",
		LogoutPath:          "logout",
		ValidatePath:        "validate",
		ServiceValidatePath: "serviceValidate",
		RestEndpoint:        path.Join("v1", "tickets"),
	}
}

// DefaultURLScheme is a configurable URLScheme. Use NewDefaultURLScheme to create DefaultURLScheme with the default cas
// urls.
type DefaultURLScheme struct {
	base                *url.URL
	LoginPath           string
	LogoutPath          string
	ValidatePath        string
	ServiceValidatePath string
	RestEndpoint        string
}

// Login returns the url for the cas login page
func (scheme *DefaultURLScheme) Login() (*url.URL, error) {
	return scheme.createURL(scheme.LoginPath)
}

// Logout returns the url for the cas logut page
func (scheme *DefaultURLScheme) Logout() (*url.URL, error) {
	return scheme.createURL(scheme.LogoutPath)
}

// Validate returns the url for the request validation endpoint
func (scheme *DefaultURLScheme) Validate() (*url.URL, error) {
	return scheme.createURL(scheme.ValidatePath)
}

// ServiceValidate returns the url for the service validation endpoint
func (scheme *DefaultURLScheme) ServiceValidate() (*url.URL, error) {
	return scheme.createURL(scheme.ServiceValidatePath)
}

// RestGrantingTicket returns the url for requesting an granting ticket via rest api
func (scheme *DefaultURLScheme) RestGrantingTicket() (*url.URL, error) {
	return scheme.createURL(scheme.RestEndpoint)
}

// RestServiceTicket returns the url for requesting an service ticket via rest api
func (scheme *DefaultURLScheme) RestServiceTicket(tgt string) (*url.URL, error) {
	return scheme.createURL(path.Join(scheme.RestEndpoint, tgt))
}

// RestLogout returns the url for destroying an granting ticket via rest api
func (scheme *DefaultURLScheme) RestLogout(tgt string) (*url.URL, error) {
	return scheme.createURL(path.Join(scheme.RestEndpoint, tgt))
}

func (scheme *DefaultURLScheme) createURL(urlPath string) (*url.URL, error) {
	return scheme.base.Parse(path.Join(scheme.base.Path, urlPath))
}


text:
package example.user;

import javax.inject.Inject;

import io.baratine.core.Lookup;
import io.baratine.core.Modify;
import io.baratine.core.OnLoad;
import io.baratine.core.OnLookup;
import io.baratine.core.OnSave;
import io.baratine.core.Result;
import io.baratine.core.Service;
import io.baratine.core.ServiceRef;
import io.baratine.store.Store;

@Service("/_user")
public class UserManagerServiceImpl implements UserManagerService
{
  @Inject @Lookup("/_user")
  private transient ServiceRef _meRef;

  @Inject @Lookup("store://_user")
  private transient ServiceRef _storeRef;

  private long _count;

  @OnLookup
  public UserService onLookup(String url)
  {
    Store<User> userStore = _storeRef.lookup(url).as(Store.class);

    return new UserServiceImpl(url, userStore);
  }

  @Modify
  public void create(String firstName, String lastName,
                     Result<User> result)
  {
    long id = _count++;

    UserService user = _meRef.lookup("/" + id).as(UserService.class);

    user.create(id, firstName, lastName, result);
  }

  public void delete(long id, Result<Boolean> result)
  {
    UserService user = _meRef.lookup("/" + id).as(UserService.class);

    user.delete(result);
  }

  @OnLoad
  public void onLoad(Result<Boolean> result)
  {
    Store<Long> store = _storeRef.as(Store.class);

    store.get("count", count -> {
       if (count == null) {
         count = 0L;
       }

       _count = count;

       result.complete(true);
    });
  }

  @OnSave
  public void onSave(Result<Boolean> result)
  {
    Store<Long> store = _storeRef.as(Store.class);

    store.put("count", _count, Void -> result.complete(true));
  }
}


text:
namespace NLog
{
    using System;
    using System.Linq;
    using NLog.Internal;

    /// <summary>
    /// Nested Diagnostics Context - a thread-local structure that keeps a stack
    /// of strings and provides methods to output them in layouts
    /// </summary>
    [Obsolete("Replaced by ScopeContext.PushNestedState or Logger.PushScopeNested using ${scopenested}. Marked obsolete on NLog 5.0")]
    public static class NestedDiagnosticsContext
    {
        /// <summary>
        /// Gets the top NDC message but doesn't remove it.
        /// </summary>
        /// <returns>The top message. .</returns>
        [Obsolete("Replaced by ScopeContext.PeekNestedState. Marked obsolete on NLog 5.0")]
        public static string TopMessage => FormatHelper.ConvertToString(TopObject, null);

        /// <summary>
        /// Gets the top NDC object but doesn't remove it.
        /// </summary>
        /// <returns>The object at the top of the NDC stack if defined; otherwise <c>null</c>.</returns>
        [Obsolete("Replaced by ScopeContext.PeekNestedState. Marked obsolete on NLog 5.0")]
        public static object TopObject => PeekObject();

        /// <summary>
        /// Pushes the specified text on current thread NDC.
        /// </summary>
        /// <param name="text">The text to be pushed.</param>
        /// <returns>An instance of the object that implements IDisposable that returns the stack to the previous level when IDisposable.Dispose() is called. To be used with C# using() statement.</returns>
        [Obsolete("Replaced by ScopeContext.PushNestedState or Logger.PushScopeNested using ${scopenested}. Marked obsolete on NLog 5.0")]
        public static IDisposable Push(string text)
        {
            return ScopeContext.PushNestedState(text);
        }

        /// <summary>
        /// Pushes the specified object on current thread NDC.
        /// </summary>
        /// <param name="value">The object to be pushed.</param>
        /// <returns>An instance of the object that implements IDisposable that returns the stack to the previous level when IDisposable.Dispose() is called. To be used with C# using() statement.</returns>
        [Obsolete("Replaced by ScopeContext.PushNestedState or Logger.PushScopeNested using ${scopenested}. Marked obsolete on NLog 5.0")]
        public static IDisposable Push(object value)
        {
            return ScopeContext.PushNestedState(value);
        }

        /// <summary>
        /// Pops the top message off the NDC stack.
        /// </summary>
        /// <returns>The top message which is no longer on the stack.</returns>
        [Obsolete("Replaced by dispose of return value from ScopeContext.PushNestedState or Logger.PushScopeNested. Marked obsolete on NLog 5.0")]
        public static string Pop()
        {
            return Pop(null);
        }

        /// <summary>
        /// Pops the top message from the NDC stack.
        /// </summary>
        /// <param name="formatProvider">The <see cref="IFormatProvider"/> to use when converting the value to a string.</param>
        /// <returns>The top message, which is removed from the stack, as a string value.</returns>
        [Obsolete("Replaced by dispose of return value from ScopeContext.PushNestedState or Logger.PushScopeNested. Marked obsolete on NLog 5.0")]
        public static string Pop(IFormatProvider formatProvider)
        {
            return FormatHelper.ConvertToString(PopObject() ?? string.Empty, formatProvider);
        }

        /// <summary>
        /// Pops the top object off the NDC stack.
        /// </summary>
        /// <returns>The object from the top of the NDC stack, if defined; otherwise <c>null</c>.</returns>
        [Obsolete("Replaced by dispose of return value from ScopeContext.PushNestedState or Logger.PushScopeNested. Marked obsolete on NLog 5.0")]
        public static object PopObject()
        {
            return ScopeContext.PopNestedContextLegacy();
        }

        /// <summary>
        /// Peeks the first object on the NDC stack
        /// </summary>
        /// <returns>The object from the top of the NDC stack, if defined; otherwise <c>null</c>.</returns>
        [Obsolete("Replaced by ScopeContext.PeekNestedState. Marked obsolete on NLog 5.0")]
        public static object PeekObject()
        {
            return ScopeContext.PeekNestedState();
        }

        /// <summary>
        /// Clears current thread NDC stack.
        /// </summary>
        [Obsolete("Replaced by ScopeContext.Clear. Marked obsolete on NLog 5.0")]
        public static void Clear()
        {
            ScopeContext.ClearNestedContextLegacy();
        }

        /// <summary>
        /// Gets all messages on the stack.
        /// </summary>
        /// <returns>Array of strings on the stack.</returns>
        [Obsolete("Replaced by ScopeContext.GetAllNestedStates. Marked obsolete on NLog 5.0")]
        public static string[] GetAllMessages()
        {
            return GetAllMessages(null);
        }

        /// <summary>
        /// Gets all messages from the stack, without removing them.
        /// </summary>
        /// <param name="formatProvider">The <see cref="IFormatProvider"/> to use when converting a value to a string.</param>
        /// <returns>Array of strings.</returns>
        [Obsolete("Replaced by ScopeContext.GetAllNestedStates. Marked obsolete on NLog 5.0")]
        public static string[] GetAllMessages(IFormatProvider formatProvider)
        {
            var stack = GetAllObjects();
            if (stack.Length == 0)
                return ArrayHelper.Empty<string>();
            else
                return stack.Select((o) => FormatHelper.ConvertToString(o, formatProvider)).ToArray();
        }

        /// <summary>
        /// Gets all objects on the stack.
        /// </summary>
        /// <returns>Array of objects on the stack.</returns>
        [Obsolete("Replaced by ScopeContext.GetAllNestedStates. Marked obsolete on NLog 5.0")]
        public static object[] GetAllObjects()
        {
            return ScopeContext.GetAllNestedStates();
        }
    }
}