text:
import copy

from nova.network.quantum import client
from nova import utils

#TODO(danwent): would be nice to have these functions raise QuantumIOErrors
# to make sure such errors are caught and reported properly

#  this is a fake quantum client that just stores all data in a nested dict
#
#  example:
#
#{'<tenant>':
# { '<net-uuid>' : { 'name' : "t1-net1",
#                    'ports' : [ { '<port-uuid'> :
#                                        {'state': 'Active',
#                                       'attachment': 'iface-id'},
#                                       { 'state': 'Down',
#                                         'attachment' : None}}]
#                      }
#   }
#  }

class FakeClient(object):
    """A fake Quantum Client for testing"""

    def __init__(self, logger=None, **kwargs):
        """Creates a new client to some service.
        :param logger: logging object to be used by client library
        """
        self.logger = logger
        self.tenant_map = {}

    def _get_tenant_nets(self, tenant):
        if tenant is None:
            raise Exception("'tenant' cannot be None")
        return self.tenant_map.setdefault(tenant, {})

    def _verify_net(self, network, nets):
        if network not in nets:
            raise client.QuantumNotFoundException("no network with uuid %s"
                                                                % network)

    def _verify_net_and_port(self, network, port, nets):
        if network not in nets:
            raise client.QuantumNotFoundException("no network with uuid %s"
                                                                % network)
        if port not in nets[network]['ports']:
            raise client.QuantumNotFoundException("no port with uuid %s"
                                                                   % port)

    def list_networks(self, tenant=None, filter_ops=None):
        """Fetches a list of all networks for a tenant"""
        nets = self._get_tenant_nets(tenant)
        if filter_ops:
            raise Exception("Need to implement filters %s in "
                        "quantum fake client" % filter_ops)
        return {"networks": [{"id": uuid} for uuid in nets.keys()]}

    def show_network_details(self, network, tenant=None):
        """Fetches the details of a certain network"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net(network, nets)
        return {"network": {"id": network, "name": nets[network]["name"]}}

    def create_network(self, body=None, tenant=None):
        """Creates a new network"""
        nets = self._get_tenant_nets(tenant)
        uuid = str(utils.gen_uuid())
        name = body["network"]["name"]
        nets[uuid] = {"ports": {}, "name": name}
        return {"network": {"id": uuid}}

    def update_network(self, network, body=None, tenant=None):
        """Updates a network"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net(network, nets)
        nets[network]['name'] = body["network"]["name"]
        return {"network": {"id": network, "name": nets[networks]["name"]}}

    def delete_network(self, network, tenant=None):
        """Deletes the specified network"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net(network, nets)
        del nets[network]

    def list_ports(self, network, filter_ops=None, tenant=None):
        """Fetches a list of ports on a given network"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net(network, nets)

        ports = nets[network]['ports'].items()
        if filter_ops and 'attachment' in filter_ops:
            a = filter_ops.pop('attachment')
            ports = [p for p in ports if p[1]['attachment'] == a]

        if filter_ops:
            raise Exception("Need to implement files %s in "
                        "quantum fake client" % filter_ops)

        return {"ports": [{'id': p[0]} for p in ports]}

    def show_port_details(self, network, port, tenant=None):
        """Fetches the details of a certain port"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net_and_port(network, port, nets)
        p = nets[network]['ports'][port]
        return {"port": {"state": p["state"], "id": port}}

    def create_port(self, network, body=None, tenant=None):
        """Creates a new port on a given network"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net(network, nets)
        uuid = str(utils.gen_uuid())
        nets[network]['ports'][uuid] = {'attachment': None,
                                        'state': body['port']['state']}
        return {"port": {"id": uuid}}

    def delete_port(self, network, port, tenant=None):
        """Deletes the specified port from a network"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net_and_port(network, port, nets)
        del nets[network]['ports'][port]

    def set_port_state(self, network, port, body=None, tenant=None):
        """Sets the state of the specified port"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net_and_port(network, port, nets)

        new_state = body['port']['state']
        nets[network]['ports'][port]['state'] = new_state
        return {"port": {"state": new_state}}

    def show_port_attachment(self, network, port, tenant=None):
        """Fetches the attachment-id associated with the specified port"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net_and_port(network, port, nets)
        p = nets[network]['ports'][port]
        if p['attachment'] is not None:
            return {"attachment": {"id": p['attachment']}}
        else:
            return {"attachment": {}}

    def attach_resource(self, network, port, body=None, tenant=None):
        nets = self._get_tenant_nets(tenant)
        self._verify_net_and_port(network, port, nets)
        nets[network]['ports'][port]['attachment'] = body['attachment']['id']

    def detach_resource(self, network, port, tenant=None):
        """Removes the attachment-id of the specified port"""
        nets = self._get_tenant_nets(tenant)
        self._verify_net_and_port(network, port, nets)
        nets[network]['ports'][port]['attachment'] = None


text:
You can repeat the next editor command any number of times
by pressing C+ENTER, followed by the desired repeat count.

redpajama_set_name: RedPajamaGithub


text:
<?php
/**
 * Option Management.
 *
 * @package WordPress\Plugins\Debug Bar Plugin Activation
 * @subpackage Option
 */

// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
	header( 'Status: 403 Forbidden' );
	header( 'HTTP/1.1 403 Forbidden' );
	exit();
}

if ( ! class_exists( 'Debug_Bar_Plugin_Activation_Option' ) ) {

	/**
	 * Debug Bar Plugin Activation Option Management.
	 */
	class Debug_Bar_Plugin_Activation_Option {

		/* *** DEFINE CLASS CONSTANTS *** */

		/**
		 * Name of options variable containing the plugin proprietary settings.
		 *
		 * @const string
		 */
		const NAME = 'debug_bar_plugin_activation';

		/* *** DEFINE CLASS PROPERTIES *** */

		/**
		 * Default option values.
		 *
		 * @var array
		 */
		protected $defaults = array(
			'version'    => null,
			'activate'   => array(),
			'deactivate' => array(),
			'uninstall'  => array(),
		);

		/* *** CLASS METHODS *** */

		/**
		 * Initialize our option and add all relevant actions and filters
		 */
		public function __construct() {
			/*
			 * Make sure the option will always get validated, independently of register_setting()
			 * which is only available in the back-end.
			 */
			add_filter( 'sanitize_option_' . self::NAME, array( $this, 'validate_option' ) );

			/* Add filters which get applied to get_options() results. */
			$this->add_default_filter();
			add_filter( 'option_' . self::NAME, array( $this, 'filter_option' ) );

			/*
			 * The option validation routines remove the default filters to prevent failing to insert
			 * an options if it's new. Let's add them back afterwards.
			 *
			 * {@internal This was needed due to bug #31047 and fixed with commit #31473 in WP 4.2.
			 * Should at some point in the future when the minimum WP version for the plugin gets
			 * upped, be removed.}}
			 */
			add_action( 'add_option', array( $this, 'add_default_filter' ) );
			add_action( 'update_option', array( $this, 'add_default_filter' ) );

			// Start buffering the output for those actions in which WP does not do so natively.
			add_action( 'deactivate_plugin', array( $this, 'start_output_buffer' ) );
			add_action( 'pre_uninstall_plugin', array( $this, 'start_output_buffer' ) );
			add_action( 'delete_plugin', array( $this, 'start_output_buffer' ) );

			// Save (de-)activation output to our option.
			add_action( 'activated_plugin', array( $this, 'save_activation_output' ) );
			add_action( 'deactivated_plugin', array( $this, 'save_deactivation_output' ) );
			add_action( 'deleted_plugin', array( $this, 'save_deletion_output' ) );

			// Remove plugin from our option on delete.
			add_action( 'deleted_plugin', array( $this, 'remove_plugin_data' ) );
		}

		/**
		 * Start the output buffer for deleting plugins.
		 *
		 * The plugin may or may not have an uninstall routine. If it does, the output
		 * buffering is started there (`pre_uninstall_plugin`). Otherwise it is started at
		 * the next earliest opportunity (`delete_plugin`).
		 *
		 * @param string $plugin The plugin being deleted.
		 */
		public function start_output_buffer( $plugin ) {
			static $plugins;

			if ( ! isset( $plugins[ $plugin ] ) ) {
				ob_start();
				$plugins[ $plugin ] = true;
			}
		}

		/**
		 * Save any output generated during plugin activation.
		 *
		 * @param string $plugin The plugin being activated.
		 */
		public function save_activation_output( $plugin ) {
			$this->update_option_with_output( $plugin, 'activate' );
		}

		/**
		 * Save any output generated during plugin deactivation and stop the output buffering.
		 *
		 * @param string $plugin The plugin being deactivated.
		 */
		public function save_deactivation_output( $plugin ) {
			$this->update_option_with_output( $plugin, 'deactivate' );
			ob_end_clean();
		}

		/**
		 * Save any output generated during plugin deletion and stop the output buffering.
		 *
		 * @param string $plugin The plugin being deleted.
		 */
		public function save_deletion_output( $plugin ) {
			$this->update_option_with_output( $plugin, 'uninstall' );
			ob_end_clean();
		}

		/**
		 * Save the output from the output buffer to our option.
		 *
		 * @param string $plugin The plugin currently being handled.
		 * @param string $action Which action was executed - either 'activate', 'deactivate'
		 *                       or 'uninstall'.
		 */
		protected function update_option_with_output( $plugin, $action ) {
			$option = get_option( self::NAME );
			$output = ob_get_contents();
			$output = trim( $output );
			if ( '' !== $output ) {
				$option[ $action ][ $plugin ] = $output;
				update_option( self::NAME, $option );
			}
		}

		/**
		 * Delete activation and deactivation output related to a plugin on deletion of
		 * that plugin - will be done automagically by the validation routine.
		 *
		 * @param string $plugin The plugin being deleted.
		 */
		public function remove_plugin_data( $plugin ) {
			update_option( self::NAME, get_option( self::NAME ) );
		}

		/**
		 * Add filtering of the option default values.
		 *
		 * @return void
		 */
		public function add_default_filter() {
			if ( false === has_filter( 'default_option_' . self::NAME, array( $this, 'filter_option_defaults' ) ) ) {
				add_filter( 'default_option_' . self::NAME, array( $this, 'filter_option_defaults' ) );
			};
		}

		/**
		 * Remove filtering of the option default values.
		 *
		 * This is needed to allow for inserting of the option if it doesn't exist.
		 * Should be called from our validation routine.
		 *
		 * @return void
		 */
		public function remove_default_filter() {
			remove_filter( 'default_option_' . self::NAME, array( $this, 'filter_option_defaults' ) );
		}

		/**
		 * Filter option defaults.
		 *
		 * This in effect means that get_option() will not return false if the option is not found,
		 * but will instead return our defaults. This way we always have all of our option values available.
		 *
		 * @return array
		 */
		public function filter_option_defaults() {
			return $this->defaults;
		}

		/**
		 * Filter option.
		 *
		 * This in effect means that get_option() will not just return our option from the database,
		 * but will instead return that option merged with our defaults.
		 * This way we always have all of our option values available. Even when we add new option
		 * values (to the defaults array) when the plugin is upgraded.
		 *
		 * @param array $options Current options.
		 *
		 * @return array
		 */
		public function filter_option( $options ) {
			return $this->array_filter_merge( $this->defaults, $options );
		}

		/* *** HELPER METHODS *** */

		/**
		 * Helper method - Combines a fixed array of default values with an options array
		 * while filtering out any keys which are not in the defaults array.
		 *
		 * @static
		 *
		 * @param array	$defaults Entire list of supported defaults.
		 * @param array	$options  Current options.
		 *
		 * @return array Combined and filtered options array.
		 */
		protected function array_filter_merge( $defaults, $options ) {
			$options = (array) $options;
			$return  = array();

			foreach ( $defaults as $name => $default ) {
				if ( array_key_exists( $name, $options ) ) {
					$return[ $name ] = $options[ $name ];
				} else {
					$return[ $name ] = $default;
				}
			}
			return $return;
		}

		/* *** OPTION VALIDATION *** */

		/**
		 * Validated the settings received from our options page.
		 *
		 * @param array $received The new option values.
		 *
		 * @return array Cleaned option to be saved to the db.
		 */
		public function validate_option( $received ) {

			/**
			 * {@internal This was needed due to bug #31047 and fixed with commit #31473 in WP 4.2.
			 * Should at some point in the future when the minimum WP version for the plugin gets
			 * upped, be removed.}}
			 */
			$this->remove_default_filter();

			/* Start off with the defaults. */
			$clean = $this->defaults;

			/*
			   Validate received values and add them to the $clean array if valid:
			   - plugin file should be a valid filename and exist (except for the 'uninstall' section).
			   - output should be a non-empty string.
			 */
			foreach ( $received as $type => $plugins ) {
				if ( 'version' === $type ) {
					continue;
				}

				if ( 'uninstall' !== $type ) {
					foreach ( $plugins as $plugin => $output ) {
						if ( $this->is_valid_plugin_file( $plugin ) && ( ! empty( $output ) && is_string( $output ) ) ) {
							$clean[ $type ][ $plugin ] = $output;
						}
					}
				} else {
					foreach ( $plugins as $plugin => $output ) {
						if ( ! empty( $output ) && is_string( $output ) ) {
							$clean[ $type ][ $plugin ] = $output;
						}
					}
				}
			}

			$clean['version'] = Debug_Bar_Plugin_Activation::VERSION;

			return $clean;
		}

		/**
		 * Validate whether a plugin filename in the form slug/filename.php or filename.php
		 * is a valid installed plugin.
		 *
		 * Based upon code from `wp_get_active_and_valid_plugins()` in `wp-includes/load.php`.
		 *
		 * @param string $plugin Plugin filename.
		 *
		 * @return bool
		 */
		protected function is_valid_plugin_file( $plugin ) {
			return ( 0 === validate_file( $plugin ) // $plugin must validate as file
					&& '.php' === substr( $plugin, -4 ) // $plugin must end with '.php'
					&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
					);
		}
	} /* End of class. */

} /* End of class exists wrapper. */


text:
package core.aws.util;

import org.slf4j.helpers.MessageFormatter;

/**
 * @author neo
 */
public final class Strings {
    public static byte[] bytes(String text) {
        return text.getBytes(Charsets.UTF_8);
    }

    public static String format(String pattern, Object... arguments) {
        return MessageFormatter.arrayFormat(pattern, arguments).getMessage();
    }

    public static int compare(String text1, String text2) {
        if (text1 == null && text2 == null)
            return 0;
        if (text1 != null && text2 == null) {
            return 1;
        }
        if (text1 == null) {
            return -1;
        }
        return text1.compareTo(text2);
    }

    public static boolean notEmpty(String text) {
        if (text == null)
            return false;
        for (int i = 0; i < text.length(); i++) {
            if (!Character.isWhitespace(text.charAt(i)))
                return true;
        }
        return false;
    }

    public static boolean equals(String text1, String text2) {
        if (text1 == null)
            return text2 == null;

        return text1.equals(text2);
    }

    public static String truncate(String text, int maxLength) {
        if (text == null)
            return null;
        if (text.length() <= maxLength)
            return text;
        return text.substring(0, maxLength);
    }

    public static String trim(String text) {
        if (text == null)
            return null;
        return text.trim();
    }
}


text:
<?php

?>

X

Clear

1 Movement Point

No Effect

                        Beach

1 Movement Point

No Effect

                        Forest

2 Movement Points

Shift one

                        Swamp

3 Movement Points

Shift one

                        Mountain

3 Movement (Mountain 2)

Shift two (shift one if mountain attacking)

                        Road hexside

1/2 if crossing road hexside

No Effect

                        Town

No Effect

Shift one

                        River

+1 Movement Point to cross

Shift one, if all attacking across river.

                        Ocean

Movement Prohibited

Combat Prohibited


text:
// Type definitions for react-toastify 4.0
// Project: https://github.com/fkhadra/react-toastify#readme
// Definitions by: icopp <https://github.com/icopp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6

import * as React from 'react';
import { Transition } from 'react-transition-group';

export type ToastCloseButton = React.ReactElement<any & { closeToast(): void }>;

export interface ToastAndToastContainerOptions {
    /**
     * @default 'top-right'
     */
    position?: 'top-right' | 'top-center' | 'top-left' | 'bottom-right' | 'bottom-center' | 'bottom-left';

    /**
     * Delay in ms to close the toast. If set to false, the notification needs
     * to be closed manually.
     * @default 5000
     */
    autoClose?: false | number;

    /**
     * A React Component to replace the default close button or false to
     * hide the button.
     */
    closeButton?: false | ToastCloseButton;

    /**
     * A reference to a valid react-transition-group/Transition component.
     */
    transition?: Transition;

    /**
     * Display or not the progress bar below the toast (remaining time).
     * @default false
     */
    hideProgressBar?: boolean;

    /**
     * Keep the timer running or not on hover.
     * @default true
     */
    pauseOnHover?: boolean;

    /**
     * Dismiss toast on click.
     * @default true
     */
    closeOnClick?: boolean;

    /**
     * Add optional classes to the toast body.
     */
    bodyClassName?: string;

    /**
     * Add optional classes to the progress bar.
     */
    progressClassName?: string;

    /**
     * Allow toast to be draggable.
     * @default true
     */
    draggable?: boolean;

    /**
     * The percentage of the toast's width it takes for a drag to dismiss a
     * toast (value between 0 and 100).
     * @default 80
     */
    draggablePercent?: number;
}

export interface ToastContainerProps extends ToastAndToastContainerOptions {
    /**
     * Support right to left content.
     * @default false
     */
    rtl?: boolean;

    /**
     * Display newest toast on top.
     * @default false
     */
    newestOnTop?: boolean;

    /**
     * Pause on document visibility change (resizing the window, for
     * instance).
     * @default true
     */
    pauseOnVisibilityChange?: boolean;

    /**
     * Add optional inline style to the container.
     */
    style?: React.CSSProperties;

    /**
     * Add optional classes to the container.
     */
    className?: string;

    /**
     * Add optional classes to the toast.
     */
    toastClassName?: string;
}

export interface ToastOptions extends ToastAndToastContainerOptions {
    /**
     * Kind of notification.
     * @default 'default'
     */
    type?: 'default' | 'success' | 'info' | 'warning' | 'error';

    /**
     * Called inside componentDidMount.
     */
    onOpen?(childrenProps: React.Props<any>): void;

    /**
     * Called inside componentWillUnmount.
     */
    onClose?(childrenProps: React.Props<any>): void;

    /**
     * Add optional classes to the toast.
     */
    className?: string;

    /**
     * String or React Element, only available when calling update.
     */
    render?: string | React.ReactElement<any>;
}

export interface Toast {
    /**
     * @return The ID of the toast, for future reference.
     */
    (content: React.ReactNode | ((props: { closeToast(): void }) => React.ReactNode), options?: ToastOptions): string;

    /**
     * Dismiss the toast with the given ID, or all toasts if no ID is given.
     */
    dismiss(toastId?: string): void;

    /**
     * Test if the toast with the given ID is active.
     */
    isActive(toastId?: string): boolean;

    /**
     * Shorthand for a toast with `type: toast.TYPE.SUCCESS`.
     */
    success(content: React.ReactNode, options?: ToastOptions): string;

    /**
     * Shorthand for a toast with `type: toast.TYPE.INFO`.
     */
    info(content: React.ReactNode, options?: ToastOptions): string;

    /**
     * Shorthand for a toast with `type: toast.TYPE.WARNING`.
     */
    warning(content: React.ReactNode, options?: ToastOptions): string;

    /**
     * Shorthand for a toast with `type: toast.TYPE.ERROR`.
     */
    error(content: React.ReactNode, options?: ToastOptions): string;

    /**
     * Update an existing toast by ID.
     */
    update(id: string, options: ToastOptions & { render: React.ReactNode }): void;

    POSITION: {
        TOP_LEFT: 'top-left'
        TOP_RIGHT: 'top-right'
        TOP_CENTER: 'top-center'
        BOTTOM_LEFT: 'bottom-left'
        BOTTOM_RIGHT: 'bottom-right'
        BOTTOM_CENTER: 'bottom-center'
    };

    TYPE: {
        INFO: 'info'
        SUCCESS: 'success'
        WARNING: 'warning'
        ERROR: 'error'
        DEFAULT: 'default'
    };
}

export interface CssTransitionOptions {
    /** The class name that will be used when the toast enters. */
    enter: string;
    /** The class name that will be used when the toast exits. */
    exit: string;
    /**
     * The transition duration in ms.
     * @default 750
     */
    duration?: number | number[];
    /**
     * Append or not the position to the class name:
     * yourClassName--top-right, yourClassName--bottom-left...
     * @default false
     */
    appendPosition?: boolean;
}

export function cssTransition(options: CssTransitionOptions): Transition;

export const ToastContainer: React.StatelessComponent<ToastContainerProps>;
export const toast: Toast;

export const Bounce: Transition;
export const Slide: Transition;
export const Zoom: Transition;
export const Flip: Transition;


text:
package com.gemstone.gemfire.internal.cache.partitioned;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.logging.log4j.Logger;

import com.gemstone.gemfire.CancelException;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.SystemFailure;
import com.gemstone.gemfire.cache.CacheException;
import com.gemstone.gemfire.cache.RegionDestroyedException;
import com.gemstone.gemfire.cache.query.Index;
import com.gemstone.gemfire.cache.query.IndexCreationException;
import com.gemstone.gemfire.cache.query.IndexType;
import com.gemstone.gemfire.cache.query.MultiIndexCreationException;
import com.gemstone.gemfire.cache.query.RegionNotFoundException;
import com.gemstone.gemfire.cache.query.internal.index.IndexCreationData;
import com.gemstone.gemfire.cache.query.internal.index.PartitionedIndex;
import com.gemstone.gemfire.distributed.internal.DM;
import com.gemstone.gemfire.distributed.internal.DistributionManager;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.distributed.internal.ReplyException;
import com.gemstone.gemfire.distributed.internal.ReplyMessage;
import com.gemstone.gemfire.distributed.internal.ReplyProcessor21;
import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
import com.gemstone.gemfire.internal.Version;
import com.gemstone.gemfire.internal.cache.ForceReattemptException;
import com.gemstone.gemfire.internal.cache.PartitionedRegion;
import com.gemstone.gemfire.internal.cache.PartitionedRegionException;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.logging.LogService;
import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
import com.gemstone.gemfire.internal.logging.log4j.LogMarker;

public class IndexCreationMsg extends PartitionMessage {
  private static final Logger logger = LogService.getLogger();

  HashSet<IndexCreationData> indexDefinitions;

  /**
   * Constructor for the index creation message to be sent over the wire
   * with all the relevant information.
   *
   * @param recipients
   *          members to which this message has to be sent
   * @param regionId
   *          partitioned region id
   * @param processor
   *          The processor to reply to
   * @param indexDefinitions
   *          definitions for the indexes
   *
   */

  IndexCreationMsg(Set recipients, int regionId,
      ReplyProcessor21 processor, HashSet<IndexCreationData> indexDefinitions) {
    super(recipients, regionId, processor);
    this.indexDefinitions = indexDefinitions;
  }

  /**
   * Empty default constructor.
   *
   */
  public IndexCreationMsg() {

  }

  /**
   * This message may be sent to nodes before the PartitionedRegion is
   * completely initialized due to the RegionAdvisor(s) knowing about the
   * existance of a partitioned region at a very early part of the
   * initialization
   */
  @Override
  protected final boolean failIfRegionMissing() {
    return false;
  }

  /**
   * This method actually operates on the partitioned region and creates given
   * list of indexes from a index creation message.
   *
   * @param dm
   *          distribution manager.
   * @param pr
   *          partitioned region on which to create an index.
   * @throws CacheException
   *           indicating a cache level error
   * @throws ForceReattemptException
   *           if the peer is no longer available
   */
  @Override
  protected boolean operateOnPartitionedRegion(DistributionManager dm,
      PartitionedRegion pr, long startTime) throws CacheException,
      ForceReattemptException {
    // region exists
    ReplyException replyEx = null;
    boolean result = false;
    List<Index> indexes = null;
    List<String> failedIndexNames = new ArrayList<String>();

    if (logger.isDebugEnabled()) {
      StringBuilder sb = new StringBuilder();
      for (IndexCreationData icd : indexDefinitions) {
        sb.append(icd.getIndexName()).append(" ");
      }
      logger.debug("Processing index creation message on this remote partitioned region vm for indexes: {}", sb);
    }

    try {
      indexes = pr.createIndexes(true, indexDefinitions);
    } catch (IndexCreationException e1) {
      replyEx = new ReplyException(
          LocalizedStrings.IndexCreationMsg_REMOTE_INDEX_CREAION_FAILED
              .toLocalizedString(),
          e1);
    } catch (MultiIndexCreationException exx) {
      failedIndexNames.addAll(exx.getExceptionsMap().keySet());

      if (logger.isDebugEnabled()) {
        StringBuffer exceptionMsgs = new StringBuffer();
        for(Exception ex: exx.getExceptionsMap().values()) {
          exceptionMsgs.append(ex.getMessage()).append("\n");
        }
        logger.debug("Got an MultiIndexCreationException with \n: {}", exceptionMsgs);
        logger.debug("{} indexes were created succesfully", failedIndexNames.size());
      }
      replyEx = new ReplyException(
          LocalizedStrings.IndexCreationMsg_REMOTE_INDEX_CREAION_FAILED
              .toLocalizedString(),
          exx);
    }

    if (null == replyEx) {
      result = true;
    }

    if (result) {
      Map<String, Integer> indexBucketsMap = new HashMap<String, Integer>();
      for(Index index : indexes) {
        PartitionedIndex prIndex = (PartitionedIndex)index;
        indexBucketsMap.put(prIndex.getName(), prIndex.getNumberOfIndexedBuckets());
      }
      sendReply(getSender(), getProcessorId(), dm, replyEx, result, indexBucketsMap, pr.getDataStore().getAllLocalBuckets().size());
    } else {
      // add the indexes that were successfully created to the map
      Map<String, Integer> indexBucketsMap = new HashMap<String, Integer>();
      for (IndexCreationData icd : indexDefinitions) {
        // if the index was successfully created
        if(!failedIndexNames.contains(icd.getIndexName())) {
          PartitionedIndex prIndex = (PartitionedIndex)pr.getIndex(icd.getIndexName());
          indexBucketsMap.put(icd.getIndexName(), prIndex.getNumberOfIndexedBuckets());
        }
      }
      sendReply(getSender(), getProcessorId(), dm, replyEx, result, indexBucketsMap, pr.getDataStore().getAllLocalBuckets().size());
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Multi Index creation completed on remote host and has sent the reply to the originating vm.");
    }
    return false;
  }

  /**
   * Process this index creation message on the receiver.
   */
  @Override
  public final void process(final DistributionManager dm) {

    final boolean isDebugEnabled = logger.isDebugEnabled();

    Throwable thr = null;
    boolean sendReply = true;
    PartitionedRegion pr = null;

    try {
      if (isDebugEnabled) {
        logger.debug("Trying to get pr with id: {}", this.regionId);
      }
      try {
        if (isDebugEnabled) {
          logger.debug("Again trying to get pr with id : {}", this.regionId);
        }
        pr = PartitionedRegion.getPRFromId(this.regionId);
        if (isDebugEnabled) {
          logger.debug("Index creation message got the pr {}", pr);
        }
        if (null == pr) {
          boolean wait = true;
          int attempts = 0;
          while (wait && attempts < 30) { // max 30 seconds of wait.
            dm.getCancelCriterion().checkCancelInProgress(null);
            if (isDebugEnabled) {
              logger.debug("Waiting for Partitioned Region to be intialized with id {}for processing index creation messages",
                  this.regionId);
            }
            try {
              boolean interrupted = Thread.interrupted();
              try {
                Thread.sleep(500);
              } catch (InterruptedException e) {
                interrupted = true;
                dm.getCancelCriterion().checkCancelInProgress(e);
              } finally {
                if (interrupted)
                  Thread.currentThread().interrupt();
              }

              pr = PartitionedRegion.getPRFromId(this.regionId);
              if (null != pr) {
                wait = false;
                if (isDebugEnabled) {
                  logger.debug("Indexcreation message got the pr {}", pr);
                }
              }
              attempts++;
            } catch (CancelException ignorAndLoopWait) {
              if (isDebugEnabled) {
                logger.debug("IndexCreationMsg waiting for pr to be properly created with prId : {}", this.regionId);
              }
            }
          }

        }
      } catch (CancelException letPRInitialized) {
        // Not sure if the CacheClosedException is still thrown in response
        // to the PR being initialized.
        if (logger.isDebugEnabled()) {
          logger.debug("Waiting for notification from pr being properly created on {}", this.regionId);
        }

        boolean wait = true;
        while (wait) {
          dm.getCancelCriterion().checkCancelInProgress(null);
          try {
            boolean interrupted = Thread.interrupted();
            try {
              Thread.sleep(500);
            } catch (InterruptedException e) {
              interrupted = true;
              dm.getCancelCriterion().checkCancelInProgress(e);
            } finally {
              if (interrupted)
                Thread.currentThread().interrupt();
            }
            pr = PartitionedRegion.getPRFromId(this.regionId);
            wait = false;
            if (logger.isDebugEnabled()) {
              logger.debug("Indexcreation message got the pr {}", pr);
            }
          } catch (CancelException ignorAndLoopWait) {
            if (logger.isDebugEnabled()) {
              logger.debug("IndexCreationMsg waiting for pr to be properly created with prId : {}", this.regionId);
            }
          }
        }

      }

      if (pr == null /* && failIfRegionMissing() */) {
        String msg = LocalizedStrings.IndexCreationMsg_COULD_NOT_GET_PARTITIONED_REGION_FROM_ID_0_FOR_MESSAGE_1_RECEIVED_ON_MEMBER_2_MAP_3
            .toLocalizedString(new Object[] { Integer.valueOf(this.regionId),
                this, dm.getId(), PartitionedRegion.dumpPRId() });
        throw new PartitionedRegionException(msg, new RegionNotFoundException(
            msg));
      }
      sendReply = operateOnPartitionedRegion(dm, pr, 0);

    } catch (PRLocallyDestroyedException pre) {
      if (isDebugEnabled) {
        logger.debug("Region is locally Destroyed ");
      }
      thr = pre;
    } catch (VirtualMachineError err) {
      SystemFailure.initiateFailure(err);
      // If this ever returns, rethrow the error. We're poisoned
      // now, so don't let this thread continue.
      throw err;
    } catch (Throwable t) {
      // Whenever you catch Error or Throwable, you must also
      // catch VirtualMachineError (see above). However, there is
      // _still_ a possibility that you are dealing with a cascading
      // error condition, so you also need to check to see if the JVM
      // is still usable:
      SystemFailure.checkFailure();
      // log the exception at fine level if there is no reply to the message
      if (this.processorId == 0) {
        logger.debug("{} exception while processing message:{}", this, t.getMessage(), t);
      } else if (logger.isDebugEnabled(LogMarker.DM) && (t instanceof RuntimeException)) {
        logger.debug(LogMarker.DM, "Exception caught while processing message: {}", t.getMessage(), t);
      }
      if (t instanceof RegionDestroyedException && pr != null) {
        if (pr.isClosed) {
          logger.info(LocalizedMessage.create(LocalizedStrings.IndexCreationMsg_REGION_IS_LOCALLY_DESTROYED_THROWING_REGIONDESTROYEDEXCEPTION_FOR__0, pr));
          thr = new RegionDestroyedException(
              LocalizedStrings.IndexCreationMsg_REGION_IS_LOCALLY_DESTROYED_ON_0
                  .toLocalizedString(dm.getId()), pr.getFullPath());
        }
      } else {
        thr = t;
      }
    } finally {
      if (sendReply && this.processorId != 0) {
        ReplyException rex = null;
        if (thr != null) {
          rex = new ReplyException(thr);
        }
        sendReply(getSender(), this.processorId, dm, rex, pr, 0);
      }
    }

  }

  /**
   * Methods that sends the actual index creation message to all the members.
   *
   * @param recipient
   *          set of members.
   * @param pr
   *          partitoned region associated with the index.
   * @param indexDefinitions
   *          set of index definitions
   * @return partitionresponse a response for the index creation
   */
  public static PartitionResponse send(InternalDistributedMember recipient,
      PartitionedRegion pr, HashSet<IndexCreationData> indexDefinitions) {

    RegionAdvisor advisor = (RegionAdvisor) (pr.getDistributionAdvisor());
    final Set<InternalDistributedMember> recipients;
    /*
     * Will only send create index to all the members storing data
     */
    if (null == recipient) {
      recipients = new HashSet(advisor.adviseDataStore());
    } else {
      recipients = new HashSet<InternalDistributedMember>();
      recipients.add(recipient);
    }

    for (InternalDistributedMember rec : recipients) {
      if (rec.getVersionObject().compareTo(Version.GFE_81) < 0) {
        throw new UnsupportedOperationException("Indexes should not be created during rolling upgrade");
      }
    }

    IndexCreationResponse processor = null;
    if (logger.isDebugEnabled()) {
      logger.debug("Will be sending create index msg to : {}", recipients.toString());
    }
    if (recipients.size() > 0) {
      processor = (IndexCreationResponse) (new IndexCreationMsg())
          .createReplyProcessor(pr, recipients);
    }

    IndexCreationMsg indMsg = new IndexCreationMsg(recipients,
        pr.getPRId(), processor, indexDefinitions);
    if (logger.isDebugEnabled()) {
      logger.debug("Sending index creation message: {}, to member(s) {}.", indMsg, recipients);
    }
    /* Set failures = */pr.getDistributionManager().putOutgoing(indMsg);
    // Set failures =r.getDistributionManager().putOutgoing(m);
    // if (failures != null && failures.size() > 0) {
    // throw new ForceReattemptException("Failed sending <" + indMsg + ">");
    // }
    return processor;
  }

  // override reply processor type from PartitionMessage
  @Override
  PartitionResponse createReplyProcessor(PartitionedRegion r, Set recipients) {
    return new IndexCreationResponse(r.getSystem(), recipients);
  }

  /**
   * Send a reply for index creation message.
   *
   * @param member
   *          representing the actual index creatro in the system
   * @param procId
   *          waiting processor
   * @param dm
   *          distribution manager to send the message
   * @param ex
   *          any exceptions
   * @param result
   *          represents index created properly or not.
   * @param indexBucketsMap
   *          Map of indexes created and number of buckets indexed
   * @param numTotalBuckets
   *          Number of total buckets in this vm
   */
  void sendReply(InternalDistributedMember member, int procId, DM dm,
      ReplyException ex, boolean result, Map<String, Integer> indexBucketsMap, int numTotalBuckets) {
    IndexCreationReplyMsg.send(member, procId, dm, ex, result,
        indexBucketsMap, numTotalBuckets);
  }

  public int getDSFID() {
    return PR_INDEX_CREATION_MSG;
  }

  @Override
  public final void fromData(DataInput in) throws IOException,
      ClassNotFoundException {
    super.fromData(in);
    this.indexDefinitions = DataSerializer.readHashSet(in);
  }

  @Override
  public Version[] getSerializationVersions() {
    return new Version[]{Version.GFE_81};
  }

  public final void fromDataPre_GFE_8_1_0_0(DataInput in) throws IOException,
      ClassNotFoundException {
    super.fromData(in);
    String name = in.readUTF();
    String fromClause = in.readUTF();
    String indexedExpression = in.readUTF();
    byte indexType = in.readByte();
    IndexType itype = null;
    if (0 == indexType) {
      itype = IndexType.PRIMARY_KEY;
    } else if (1 == indexType) {
      itype = IndexType.FUNCTIONAL;
    } else if (2 == indexType) {
      itype = IndexType.HASH;
    }
    boolean importsNeeded = in.readBoolean();
    String importStr = null;
    if (importsNeeded) {
      importStr = in.readUTF();
    }
    IndexCreationData icd = new IndexCreationData(name);
    icd.setIndexData(itype, fromClause, indexedExpression, importStr);
    this.indexDefinitions = new HashSet<IndexCreationData>();
    this.indexDefinitions.add(icd);
  }

  public final void toDataPre_GFE_8_1_0_0(DataOutput out) throws IOException {
  }

  @Override
  public final void toData(DataOutput out) throws IOException {
    super.toData(out);
    DataSerializer.writeHashSet(this.indexDefinitions, out);
  }

  /**
   * String representation of this message.
   */
  @Override
  public final String toString() {
    StringBuffer sb = new StringBuffer();
    for (IndexCreationData icd : indexDefinitions) {
      sb.append(icd.getIndexName()).append(" ");
    }
    return sb.toString();
  }

  /**
   * Class representing index creation response. This class has all the
   * information for successful or unsuccessful index creation on this member of
   * the partitioned region.
   *
   *
   */
  public static class IndexCreationResponse extends PartitionResponse {

    /** Map of indexes created and number of buckets indexed. */
    private Map<String, Integer> indexBucketsMap;

    /** Number of total bukets in this vm. */
    private int numTotalBuckets;

    /**
     * Construtor for index creation response message.
     *
     * @param ds
     *          distributed system for this member.
     * @param recipients
     *          all the member associated with the index
     */
    IndexCreationResponse(InternalDistributedSystem ds, Set recipients) {
      super(ds, recipients);
    }

    /**
     * Waits for the response from the members for index creation.
     *
     * @return IndexCreationResult for creation of  indexes
     * @throws CacheException
     *           indicating a cache level error
     * @throws ForceReattemptException
     *           if the peer is no longer available
     */
    public IndexCreationResult waitForResult() throws CacheException,
        ForceReattemptException {
      try {
        waitForCacheException();
      } catch (RuntimeException re) {
        if (re instanceof PartitionedRegionException) {
          if (re.getCause() instanceof RegionNotFoundException) {
            // Region may not be available at the receiver.
            // ignore the exception.
            // This will happen when the region on the remote end is still in
            // initialization mode and is not yet created the region ID.
          } else {
            throw re;
          }
        } else {
          throw re;
        }
      }
      return new IndexCreationResult(this.indexBucketsMap, this.numTotalBuckets);
    }

    /**
     * Sets the relevant information in the response.
     *
     * @param result
     *          true if index created properly
     * @param indexBucketsMap
     *          Map of indexes created and number of buckets indexed
     * @param numTotalBuckets
     *          Number of total buckets in this vm
     */
    public void setResponse(boolean result, Map<String, Integer> indexBucketsMap, int numTotalBuckets) {
      this.indexBucketsMap = indexBucketsMap;
      this.numTotalBuckets = numTotalBuckets;
    }
  }

  /**
   * Class representing index creation result.
   *
   *
   */
  public static class IndexCreationResult {
    /** Map of indexes created and number of buckets indexed. */
    private Map<String, Integer> indexBucketsMap;

    /** Number of total bukets in this vm. */
    private int numTotalBuckets;

    /**
     * Constructor for index creation result.
     *
     * @param indexBucketsMap
     *          Map of indexes created and number of buckets indexed
     * @param numTotalBuckets
     *          Number of total buckets in this vm
     */
    IndexCreationResult(Map<String, Integer> indexBucketsMap, int numTotalBuckets) {
      this.indexBucketsMap = indexBucketsMap;
      this.numTotalBuckets = numTotalBuckets;
    }

    /**
     * Returns a map of index names and number of buckets indexed
     *
     * @return indexBucketsMap
     */
    public Map<String, Integer> getIndexBucketsMap() {
      return this.indexBucketsMap;

    }

  }

  /**
   * Class for index creation reply. This class has the information about
   * successful index creation.
   *
   *
   */
  public static final class IndexCreationReplyMsg extends ReplyMessage {

    /** Index created or not. */
    private boolean result;

    /** Map of indexes created and number of buckets indexed. */
    private Map<String, Integer> indexBucketsMap;

    /** Number of total buckets in this vm. */
    private int numTotalBuckets;

    /** Boolean indicating weather its a data store. */
    private boolean isDataStore;

    public IndexCreationReplyMsg() {

    }

    /**
     * Constructor for index creation reply message.
     *
     * @param processorId
     *          processor id of the waiting processor
     * @param ex
     *          any exceptions
     * @param result
     *          true if index created properly else false
     * @param indexBucketsMap
     *          Map of indexes created and number of buckets indexed
     * @param numTotalBuckets
     *          Number of total buckets in this vm
     */
    IndexCreationReplyMsg(int processorId, ReplyException ex,
        boolean result, boolean isDataStore, Map<String, Integer> indexBucketsMap, int numTotalBuckets) {
      super();
      super.setException(ex);
      this.result = result;
      this.indexBucketsMap = indexBucketsMap;
      this.numTotalBuckets = numTotalBuckets;
      this.isDataStore = isDataStore;
      setProcessorId(processorId);
    }

    @Override
    public int getDSFID() {
      return PR_INDEX_CREATION_REPLY_MSG;
    }

    @Override
    public void fromData(DataInput in) throws IOException,
        ClassNotFoundException {
      super.fromData(in);
      this.result = in.readBoolean();
      this.indexBucketsMap = DataSerializer.readObject(in);
      this.numTotalBuckets = in.readInt();
      this.isDataStore = in.readBoolean();

    }

    @Override
    public void toData(DataOutput out) throws IOException {
      super.toData(out);
      out.writeBoolean(this.result);
      DataSerializer.writeObject(this.indexBucketsMap, out);
      out.writeInt(this.numTotalBuckets);
      out.writeBoolean(this.isDataStore);
    }

    /**
     * Actual method sending the index creation reply message.
     *
     * @param recipient
     *          the originator of index creation message
     * @param processorId
     *          waiting processor id
     * @param dm
     *          distribution manager
     * @param ex
     *          any exceptions
     * @param result
     *          true is index created successfully
     * @param indexBucketsMap
     *          Map of indexes created and number of buckets indexed
     * @param numTotalBuckets
     *          Number of total buckets in this vm
     */
    public static void send(InternalDistributedMember recipient,
        int processorId, DM dm, ReplyException ex, boolean result,
        Map<String, Integer> indexBucketsMap, int numTotalBuckets) {
      IndexCreationReplyMsg indMsg = new IndexCreationReplyMsg(
          processorId, ex, result, result, indexBucketsMap, numTotalBuckets);
      indMsg.setRecipient(recipient);
      dm.putOutgoing(indMsg);
    }

    /**
     * Processes the index creation result.
     *
     * @param dm
     *          distribution manager
     */
    @Override
    public final void process(final DM dm, final ReplyProcessor21 p) {
      if (logger.isDebugEnabled()) {
        logger.debug("Processor id is : {}", this.processorId);
      }
      IndexCreationResponse processor = (IndexCreationResponse) p;
      if (processor != null) {
        processor.setResponse(this.result, this.indexBucketsMap, this.numTotalBuckets);
        processor.process(this);
      }
    }

  }
}


text:
package com.scrachx.foodfacts.checker.di.component;

import com.scrachx.foodfacts.checker.di.module.ApplicationTestModule;

import javax.inject.Singleton;

import dagger.Component;

/**
 * Created by amitshekhar on 03/02/17.
 */
@Singleton
@Component(modules = ApplicationTestModule.class)
public interface TestComponent extends ApplicationComponent {
}


text:
namespace DavidVidmar.WindowsFader
{
    partial class OptionsForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OptionsForm));
            this.cancelButton = new System.Windows.Forms.Button();
            this.fadeOutGroupBox = new System.Windows.Forms.GroupBox();
            this.linkLabel1 = new System.Windows.Forms.LinkLabel();
            this.colorPanel = new System.Windows.Forms.Panel();
            this.colorlabel = new System.Windows.Forms.Label();
            this.endOpacityTextBox = new System.Windows.Forms.MaskedTextBox();
            this.endOpacityPercentLabel = new System.Windows.Forms.Label();
            this.endOpacityLabel = new System.Windows.Forms.Label();
            this.completeInSecondsLabel = new System.Windows.Forms.Label();
            this.completeInLabel = new System.Windows.Forms.Label();
            this.completeInTextBox = new System.Windows.Forms.MaskedTextBox();
            this.endOpacityTrackBar = new System.Windows.Forms.TrackBar();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
            this.okButton = new System.Windows.Forms.Button();
            this.colorDialog = new System.Windows.Forms.ColorDialog();
            this.fadeOutGroupBox.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.endOpacityTrackBar)).BeginInit();
            this.tableLayoutPanel1.SuspendLayout();
            this.tableLayoutPanel2.SuspendLayout();
            this.SuspendLayout();
            //
            // cancelButton
            //
            this.cancelButton.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.cancelButton.Location = new System.Drawing.Point(239, 3);
            this.cancelButton.Margin = new System.Windows.Forms.Padding(1, 3, 3, 3);
            this.cancelButton.Name = "cancelButton";
            this.cancelButton.Size = new System.Drawing.Size(75, 23);
            this.cancelButton.TabIndex = 1;
            this.cancelButton.Text = "Cancel";
            this.cancelButton.Click += new System.EventHandler(this.ButtonCancelClicked);
            //
            // fadeOutGroupBox
            //
            this.fadeOutGroupBox.Controls.Add(this.linkLabel1);
            this.fadeOutGroupBox.Controls.Add(this.colorPanel);
            this.fadeOutGroupBox.Controls.Add(this.colorlabel);
            this.fadeOutGroupBox.Controls.Add(this.endOpacityTextBox);
            this.fadeOutGroupBox.Controls.Add(this.endOpacityPercentLabel);
            this.fadeOutGroupBox.Controls.Add(this.endOpacityLabel);
            this.fadeOutGroupBox.Controls.Add(this.completeInSecondsLabel);
            this.fadeOutGroupBox.Controls.Add(this.completeInLabel);
            this.fadeOutGroupBox.Controls.Add(this.completeInTextBox);
            this.fadeOutGroupBox.Controls.Add(this.endOpacityTrackBar);
            this.fadeOutGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fadeOutGroupBox.Location = new System.Drawing.Point(3, 3);
            this.fadeOutGroupBox.Name = "fadeOutGroupBox";
            this.fadeOutGroupBox.Size = new System.Drawing.Size(318, 119);
            this.fadeOutGroupBox.TabIndex = 0;
            this.fadeOutGroupBox.TabStop = false;
            //
            // linkLabel1
            //
            this.linkLabel1.AutoSize = true;
            this.linkLabel1.Location = new System.Drawing.Point(156, 52);
            this.linkLabel1.Name = "linkLabel1";
            this.linkLabel1.Size = new System.Drawing.Size(44, 13);
            this.linkLabel1.TabIndex = 3;
            this.linkLabel1.TabStop = true;
            this.linkLabel1.Text = "default";
            this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.DefaultColorLinkClicked);
            //
            // colorPanel
            //
            this.colorPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.colorPanel.Cursor = System.Windows.Forms.Cursors.Hand;
            this.colorPanel.Location = new System.Drawing.Point(111, 47);
            this.colorPanel.Name = "colorPanel";
            this.colorPanel.Size = new System.Drawing.Size(38, 22);
            this.colorPanel.TabIndex = 2;
            this.colorPanel.TabStop = true;
            this.colorPanel.Click += new System.EventHandler(this.ColorPanelClicked);
            //
            // colorlabel
            //
            this.colorlabel.AutoSize = true;
            this.colorlabel.Location = new System.Drawing.Point(7, 52);
            this.colorlabel.Name = "colorlabel";
            this.colorlabel.Size = new System.Drawing.Size(78, 13);
            this.colorlabel.TabIndex = 7;
            this.colorlabel.Text = "Fade to color:";
            //
            // endOpacityTextBox
            //
            this.endOpacityTextBox.BackColor = System.Drawing.SystemColors.Control;
            this.endOpacityTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.endOpacityTextBox.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.endOpacityTextBox.Location = new System.Drawing.Point(111, 83);
            this.endOpacityTextBox.Name = "endOpacityTextBox";
            this.endOpacityTextBox.ReadOnly = true;
            this.endOpacityTextBox.Size = new System.Drawing.Size(25, 15);
            this.endOpacityTextBox.TabIndex = 4;
            this.endOpacityTextBox.TabStop = false;
            this.endOpacityTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            //
            // endOpacityPercentLabel
            //
            this.endOpacityPercentLabel.AutoSize = true;
            this.endOpacityPercentLabel.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.endOpacityPercentLabel.Location = new System.Drawing.Point(134, 83);
            this.endOpacityPercentLabel.Name = "endOpacityPercentLabel";
            this.endOpacityPercentLabel.Size = new System.Drawing.Size(17, 13);
            this.endOpacityPercentLabel.TabIndex = 5;
            this.endOpacityPercentLabel.Text = "%";
            //
            // endOpacityLabel
            //
            this.endOpacityLabel.AutoSize = true;
            this.endOpacityLabel.Location = new System.Drawing.Point(7, 83);
            this.endOpacityLabel.Name = "endOpacityLabel";
            this.endOpacityLabel.Size = new System.Drawing.Size(70, 13);
            this.endOpacityLabel.TabIndex = 3;
            this.endOpacityLabel.Text = "End opacity:";
            //
            // completeInSecondsLabel
            //
            this.completeInSecondsLabel.AutoSize = true;
            this.completeInSecondsLabel.Location = new System.Drawing.Point(156, 22);
            this.completeInSecondsLabel.Name = "completeInSecondsLabel";
            this.completeInSecondsLabel.Size = new System.Drawing.Size(49, 13);
            this.completeInSecondsLabel.TabIndex = 1;
            this.completeInSecondsLabel.Text = "seconds";
            //
            // completeInLabel
            //
            this.completeInLabel.AutoSize = true;
            this.completeInLabel.Location = new System.Drawing.Point(7, 22);
            this.completeInLabel.Name = "completeInLabel";
            this.completeInLabel.Size = new System.Drawing.Size(98, 13);
            this.completeInLabel.TabIndex = 0;
            this.completeInLabel.Text = "Complete fade in:";
            //
            // completeInTextBox
            //
            this.completeInTextBox.AllowPromptAsInput = false;
            this.completeInTextBox.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.completeInTextBox.Location = new System.Drawing.Point(111, 19);
            this.completeInTextBox.Name = "completeInTextBox";
            this.completeInTextBox.PromptChar = '*';
            this.completeInTextBox.Size = new System.Drawing.Size(38, 22);
            this.completeInTextBox.SkipLiterals = false;
            this.completeInTextBox.TabIndex = 0;
            this.completeInTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            //
            // endOpacityTrackBar
            //
            this.endOpacityTrackBar.LargeChange = 10;
            this.endOpacityTrackBar.Location = new System.Drawing.Point(153, 70);
            this.endOpacityTrackBar.Maximum = 100;
            this.endOpacityTrackBar.Name = "endOpacityTrackBar";
            this.endOpacityTrackBar.Size = new System.Drawing.Size(159, 45);
            this.endOpacityTrackBar.TabIndex = 6;
            this.endOpacityTrackBar.TickFrequency = 10;
            this.endOpacityTrackBar.TickStyle = System.Windows.Forms.TickStyle.Both;
            this.endOpacityTrackBar.Value = 100;
            this.endOpacityTrackBar.Scroll += new System.EventHandler(this.EndOpacityTrackBarScroll);
            //
            // tableLayoutPanel1
            //
            this.tableLayoutPanel1.ColumnCount = 1;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayoutPanel1.Controls.Add(this.fadeOutGroupBox, 0, 0);
            this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 1);
            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel1.Location = new System.Drawing.Point(9, 9);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 2;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(324, 160);
            this.tableLayoutPanel1.TabIndex = 6;
            //
            // tableLayoutPanel2
            //
            this.tableLayoutPanel2.ColumnCount = 3;
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 81F));
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 81F));
            this.tableLayoutPanel2.Controls.Add(this.cancelButton, 2, 0);
            this.tableLayoutPanel2.Controls.Add(this.okButton, 1, 0);
            this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 128);
            this.tableLayoutPanel2.Name = "tableLayoutPanel2";
            this.tableLayoutPanel2.RowCount = 1;
            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel2.Size = new System.Drawing.Size(318, 29);
            this.tableLayoutPanel2.TabIndex = 1;
            //
            // okButton
            //
            this.okButton.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.okButton.Location = new System.Drawing.Point(159, 3);
            this.okButton.Margin = new System.Windows.Forms.Padding(3, 3, 2, 3);
            this.okButton.Name = "okButton";
            this.okButton.Size = new System.Drawing.Size(75, 23);
            this.okButton.TabIndex = 0;
            this.okButton.Text = "OK";
            this.okButton.Click += new System.EventHandler(this.ButtonOkClicked);
            //
            // colorDialog
            //
            this.colorDialog.AnyColor = true;
            //
            // OptionsForm
            //
            this.AcceptButton = this.okButton;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.CancelButton = this.cancelButton;
            this.ClientSize = new System.Drawing.Size(342, 178);
            this.Controls.Add(this.tableLayoutPanel1);
            this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "OptionsForm";
            this.Padding = new System.Windows.Forms.Padding(9);
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "Windows Fader Screensaver Settings";
            this.fadeOutGroupBox.ResumeLayout(false);
            this.fadeOutGroupBox.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.endOpacityTrackBar)).EndInit();
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel2.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button cancelButton;
        private System.Windows.Forms.GroupBox fadeOutGroupBox;
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
        private System.Windows.Forms.TrackBar endOpacityTrackBar;
        private System.Windows.Forms.Label endOpacityPercentLabel;
        private System.Windows.Forms.Label endOpacityLabel;
        private System.Windows.Forms.Label completeInSecondsLabel;
        private System.Windows.Forms.Label completeInLabel;
        private System.Windows.Forms.MaskedTextBox completeInTextBox;
        private System.Windows.Forms.MaskedTextBox endOpacityTextBox;
        private System.Windows.Forms.Button okButton;
        private System.Windows.Forms.Panel colorPanel;
        private System.Windows.Forms.Label colorlabel;
        private System.Windows.Forms.ColorDialog colorDialog;
        private System.Windows.Forms.LinkLabel linkLabel1;
    }
}


text:
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using NUnit.Framework;
using Stream.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace StreamNetTests
{
    [TestFixture]
    public class AddActivityTests : TestBase
    {
        [Test]
        public async Task TestAddActivities()
        {
            var newActivities = new[]
            {
                new Activity("multi1", "test", "1"),
                new Activity("multi2", "test", "2"),
            };

            var response = (await this.UserFeed.AddActivitiesAsync(newActivities)).Activities;
            Assert.IsNotNull(response);
            Assert.AreEqual(2, response.Count());

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 2)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(2, activities.Count());

            Assert.AreEqual(response.Skip(1).First().Id, activities.First().Id);
            Assert.AreEqual(response.First().Id, activities.Skip(1).First().Id);
        }

        [Test]
        public async Task TestAddActivity()
        {
            var newActivity = new Activity("1", "test", "1");
            var response = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(response);

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual(response.Id, first.Id);
            Assert.AreEqual(response.Actor, first.Actor);
            Assert.AreEqual(response.Object, first.Object);
            Assert.AreEqual(response.Verb, first.Verb);
        }

        [Test]
        public async Task TestAddActivityWithTime()
        {
            var now = DateTime.UtcNow;
            var newActivity = new Activity("1", "test", "1") { Time = now };

            var response = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(response);

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual(response.Id, first.Id);

            // using long date string here to skip milliseconds
            //  "now" will have the milliseconds whereas the response or lookup wont
            Assert.AreEqual(now.ToString(), first.Time.Value.ToString());
        }

        [Test]
        public async Task TestAddActivityWithArray()
        {
            var newActivity = new Activity("1", "test", "1");
            newActivity.SetData("complex", new[] { "tommaso", "thierry", "shawn" });
            newActivity.SetData("special_json", new { StuffOneTwo = "thing" }, new JsonSerializer
            {
                ContractResolver = new DefaultContractResolver { NamingStrategy = new KebabCaseNamingStrategy() },
            });
            newActivity.SetData(new Dictionary<string, object>
            {
                { "dictkey", "dictvalue" },
            });
            var response = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(response);

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual(response.Id, first.Id);

            var complex = first.GetData<string[]>("complex");
            Assert.IsNotNull(complex);
            Assert.AreEqual(3, complex.Length);
            Assert.AreEqual("shawn", complex[2]);

            Assert.AreEqual("thing", first.GetData<JObject>("special_json")["stuff-one-two"].Value<string>());

            Assert.AreEqual("dictvalue", first.GetData<string>("dictkey"));
        }

        [Test]
        public async Task TestAddActivityWithString()
        {
            int second = 2;
            double third = 3;
            var newActivity = new Activity("1", "test", "1");
            newActivity.SetData("complex", "string");
            newActivity.SetData("second", second);
            newActivity.SetData("third", third);
            var response = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(response);

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual(response.Id, first.Id);

            var complex = first.GetData<string>("complex");
            Assert.IsNotNull(complex);
            Assert.AreEqual("string", complex);
        }

        [Test]
        public async Task TestAddActivityWithDictionary()
        {
            var dict = new Dictionary<string, string>()
            {
                { "test1", "shawn" },
                { "test2", "wedge" },
            };

            var newActivity = new Activity("1", "test", "1");
            newActivity.SetData("complex", dict);

            var response = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(response);

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual(response.Id, first.Id);

            var complex = first.GetData<Dictionary<string, string>>("complex");
            Assert.IsNotNull(complex);
            Assert.AreEqual(2, complex.Count);
            Assert.AreEqual("shawn", complex["test1"]);
        }

        public class CustomClass
        {
            public string TestString { get; set; }
            public int TestInt { get; set; }
            public double TestDouble { get; set; }
        }

        [Test]
        public async Task TestAddActivityWithDifferentVariables()
        {
            int second = 2;
            double third = 3;
            var dict = new Dictionary<string, object>()
            {
                { "test1", "shawn" },
                { "test2", "wedge" },
                { "test3", 42 },
            };

            var newActivity = new Activity("1", "test", "1");
            newActivity.SetData("complex", dict);
            newActivity.SetData("second", second);
            newActivity.SetData("third", third);
            newActivity.SetData("customc", new CustomClass
            {
                TestString = "string",
                TestInt = 123,
                TestDouble = 42.2,
            });

            var response = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(response);

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual(response.Id, first.Id);

            var complex = first.GetData<Dictionary<string, object>>("complex");
            Assert.IsNotNull(complex);
            Assert.AreEqual(3, complex.Count);
            Assert.AreEqual("shawn", complex["test1"]);
            Assert.AreEqual("wedge", complex["test2"]);
            Assert.AreEqual(42, complex["test3"]);

            Assert.AreEqual(2, first.GetData<int>("second"));

            Assert.AreEqual(3M, first.GetData<double>("third"));

            var customc = first.GetData<CustomClass>("customc");
            Assert.IsNotNull(customc);
            Assert.AreEqual("string", customc.TestString);
            Assert.AreEqual(123, customc.TestInt);
            Assert.AreEqual(42.2, customc.TestDouble);
        }

        [Test]
        public async Task TestAddActivityVariablesOldWayNewWay()
        {
            var newActivity = new Activity("1", "test", "1");
            newActivity.SetData<string>("stringint", "42");
            newActivity.SetData<string>("stringdouble", "42.2");
            newActivity.SetData<string>("stringcomplex", "{ \"test1\": 1, \"test2\": \"testing\" }");

            var response = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(response);

            var activities = (await this.UserFeed.GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual(response.Id, first.Id);

            Assert.AreEqual(42, first.GetData<int>("stringint"));

            Assert.AreEqual(42.2, first.GetData<double>("stringdouble"));

            var complex = first.GetData<Dictionary<string, object>>("stringcomplex");
            Assert.IsNotNull(complex);
        }

        [Test]
        public async Task TestAddActivityTo()
        {
            var newActivity = new Activity("multi1", "test", "1")
            {
                To = new List<string> { "flat:remotefeed1" },
            };
            var addedActivity = await this.UserFeed.AddActivityAsync(newActivity);
            Assert.IsNotNull(addedActivity);
            Assert.IsNotNull(addedActivity.To);
            Assert.AreEqual(1, addedActivity.To.CountOrFallback());
            Assert.AreEqual("flat:remotefeed1", addedActivity.To.First());

            var activities = (await Client.Feed("flat", "remotefeed1").GetActivitiesAsync(0, 1)).Results;
            Assert.IsNotNull(activities);
            Assert.AreEqual(1, activities.Count());

            var first = activities.First();
            Assert.AreEqual("multi1", first.Actor);
        }
    }
}