text:
package nl.gridline.zieook.data.hbase;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;

import java.io.IOException;

import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HBaseManagerTest
{
	private static final Logger LOG = LoggerFactory.getLogger(HBaseManagerTest.class);

	private HBaseManager manager;

	private static final String testtable = "TEST_ZIEOOK_HBASEMANAGER_TESTTABLE_1";
	private static final String testtable2 = "TEST_ZIEOOK_HBASEMANAGER_TESTTABLE_2";
	private static final byte[] testc1 = Bytes.toBytes("test_column1");
	private static final byte[] testc2 = Bytes.toBytes("test_column2");

	private static final String TEST_TABLE = "ZIEOOK_HBASE_COLUMN_TEST_TABLE";
	private static final String TEST_COLUMN_1 = "ZIEOOK_HBASE_TEST_COLUMN_1";
	private static final String TEST_COLUMN_2 = "ZIEOOK_HBASE_TEST_COLUMN_ADD";

	@Before
	public void setUp() throws Exception
	{
		manager = HBaseManager.getInstance("mulisch");
	}

	@After
	public void tearDown() throws Exception
	{
		// manager.shutdown();

		if (manager.exists(testtable))
		{
			manager.disableTable(testtable);
			manager.dropTable(testtable);
		}

		if (manager.exists(testtable2))
		{
			manager.disableTable(testtable2);
			manager.dropTable(testtable2);
		}
		if (manager.exists("TESTTABLE"))
		{
			manager.disableTable("TESTTABLE");
			manager.dropTable("TESTTABLE");
		}
		if (manager.exists(TEST_TABLE))
		{
			manager.disableTable(TEST_TABLE);
			manager.dropTable(TEST_TABLE);
		}

	}

	@Ignore
	private void createTable2() throws IOException
	{
		LOG.info("creating table");
		HTableDescriptor testTable = new HTableDescriptor(testtable2);
		HColumnDescriptor c1 = new HColumnDescriptor(testc1);
		HColumnDescriptor c2 = new HColumnDescriptor(testc2);
		testTable.addFamily(c1);
		testTable.addFamily(c2);

		manager.createTable(testTable);

	}

	@Ignore
	private void dropTable2() throws IOException
	{

		manager.disableTable(testtable2);
		manager.dropTable(testtable2);

	}

	@Test
	/**
	 * A simple create / drop table tests, this will fail if there are any connection or configuration issues.
	 */
	public final void testCreateDropTable() throws IOException
	{
		// table descriptor:
		HTableDescriptor testTable = new HTableDescriptor(testtable);
		HColumnDescriptor c1 = new HColumnDescriptor(testc1);
		HColumnDescriptor c2 = new HColumnDescriptor(testc2);
		testTable.addFamily(c1);
		testTable.addFamily(c2);

		if (!manager.exists(testtable))
		{
			manager.createTable(testTable);
		}
		else
		{
			LOG.warn("Warning: the table already existed, only test drop!");
		}

		manager.disableTable(testtable);
		manager.dropTable(testtable);

	}

	@Test
	public final void testPutGetMany2() throws IOException
	{
		createTable2();

		LOG.info("putting 1000 rows with 200 columns in 2 families");
		long start = System.currentTimeMillis();
		try
		{
			HTableInterface table = manager.getTable(testtable2);
			try
			{
				for (int i = 0; i < 5000; i++)
				{
					if (i % 200 == 0)
					{
						LOG.info("current row {}", i);
					}

					// create put:
					Put put = new Put(Bytes.toBytes(i));
					for (int j = 0; j < 100; j++)
					{
						put.add(testc1, Bytes.toBytes("q" + j), Bytes.toBytes(j));
					}
					for (int j = 100; j < 200; j++)
					{
						put.add(testc2, Bytes.toBytes("q2" + j), Bytes.toBytes(j));
					}
					table.put(put);
				}
			}
			finally
			{
				manager.putTable(table);

			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
			fail(e.getMessage());
		}

		LOG.info("putget2: done in " + (System.currentTimeMillis() - start) + "ms");

		LOG.info("getting 1000 rows with 200 columns in 2 families");
		start = System.currentTimeMillis();

		try
		{
			HTableInterface table = manager.getTable(testtable2);
			try
			{
				for (int i = 0; i < 5000; i++)
				{
					if (i % 100 == 0)
					{
						LOG.info("current row {}", i);
					}
					Get get = new Get(Bytes.toBytes(i));
					Result result = table.get(get);
					if (result.isEmpty())
					{
						fail("could not retrieve result: " + i);
					}
				}
			}
			finally
			{
				manager.putTable(table);
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
			fail("failed to write data");
		}

		LOG.info("putget2: done in " + (System.currentTimeMillis() - start) + "ms");

		dropTable2();
	}

	@Test
	public final void testPutGetMany1() throws IOException
	{
		createTable2();
		LOG.info("putting 1000 rows with 200 collumns in 2 families");
		long start = System.currentTimeMillis();
		for (int i = 0; i < 5000; i++)
		{
			if (i % 100 == 0)
			{
				LOG.info("current row {}", i);
			}

			// create put:
			Put put = new Put(Bytes.toBytes(i));
			for (int j = 0; j < 100; j++)
			{
				put.add(testc1, Bytes.toBytes("q" + j), Bytes.toBytes(j));
			}
			for (int j = 100; j < 200; j++)
			{
				put.add(testc2, Bytes.toBytes("q2" + j), Bytes.toBytes(j));
			}

			try
			{
				HTableInterface table = manager.getTable(testtable2);
				try
				{
					table.put(put);
				}
				finally
				{
					manager.putTable(table);
				}
			}
			catch (IOException e)
			{
				e.printStackTrace();
				fail(e.getMessage());
			}
		}
		LOG.info("putget1: done in " + (System.currentTimeMillis() - start) + "ms");

		LOG.info("getting 1000 rows with 200 columns in 2 families");
		start = System.currentTimeMillis();
		for (int i = 0; i < 5000; i++)
		{
			if (i % 200 == 0)
			{
				LOG.info("current row {}", i);
			}
			Get get = new Get(Bytes.toBytes(i));
			try
			{
				HTableInterface table = manager.getTable(testtable2);
				try
				{
					Result result = table.get(get);
					if (result.isEmpty())
					{
						fail("could not retrieve result: " + i);
					}
				}
				finally
				{
					manager.putTable(table);
				}
			}
			catch (IOException e)
			{
				e.printStackTrace();
				fail("failed to write data");
			}
		}
		LOG.info("putget1: done in " + (System.currentTimeMillis() - start) + "ms");

		dropTable2();
	}

	@Test
	public final void testPutGet()
	{
		// prepare a table:
		HTableDescriptor testTable = new HTableDescriptor(testtable2);
		HColumnDescriptor c1 = new HColumnDescriptor(testc1);
		HColumnDescriptor c2 = new HColumnDescriptor(testc2);
		testTable.addFamily(c1);
		testTable.addFamily(c2);

		// prepare a put:
		byte[] testrow = Bytes.toBytes("testrow");
		byte[] q1 = Bytes.toBytes("qualifier-1");
		byte[] q2 = Bytes.toBytes("qualifier-2");
		byte[] v1 = Bytes.toBytes("value-1");
		byte[] v2 = Bytes.toBytes("value-2");
		Put put = new Put(testrow);
		put.add(testc1, q1, v1);
		put.add(testc2, q2, v2);

		// prepare a get:
		Get get = new Get(testrow);

		// create a table:
		try
		{

			manager.createTable(testTable);
		}
		catch (IOException e)
		{
			e.printStackTrace();
			fail("failed to create table");
		}

		HTableInterface table = null;
		try
		{
			table = manager.getTable(testtable2);
		}
		catch (IOException e)
		{
			e.printStackTrace();
			fail("failed to get table");
		}

		// put data:
		try
		{
			table.put(put);
		}
		catch (IOException e)
		{
			e.printStackTrace();
			fail("failed to put data");
		}

		// get data:
		Result result = null;
		try
		{
			result = table.get(get);
		}
		catch (IOException e)
		{
			e.printStackTrace();
			fail("failed to write data");
		}

		// test results:
		assertEquals(Bytes.toString(v1), Bytes.toString(result.getValue(testc1, q1)));
		assertEquals(Bytes.toString(v2), Bytes.toString(result.getValue(testc2, q2)));

		// droptable:
		try
		{
			manager.disableTable(testtable2);
			manager.dropTable(testtable2);
		}
		catch (IOException e)
		{
			e.printStackTrace();
			fail("failed to drop table");
		}

	}

	@Test
	public void updateTableTestAddColumn() throws IOException
	{
		// create a discriptor:
		// table descriptor:

		// create single column table:
		HTableDescriptor descriptor = new HTableDescriptor(TEST_TABLE);
		descriptor.addFamily(new HColumnDescriptor(TEST_COLUMN_1));
		manager.createTable(descriptor);

		// test table:
		HTableDescriptor existingDescriptor = manager.getTable(TEST_TABLE).getTableDescriptor();
		assertNotNull(existingDescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_1)));
		assertNull(existingDescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_2)));

		// create new descriptor:
		HTableDescriptor updates = new HTableDescriptor(TEST_TABLE);
		updates.addFamily(new HColumnDescriptor(TEST_COLUMN_1));
		updates.addFamily(new HColumnDescriptor(TEST_COLUMN_2));

		// update table:
		manager.disableTable(TEST_TABLE);
		manager.updateTable(updates);
		manager.enableTable(TEST_TABLE);

		// test if column where added
		HTableInterface table = manager.getTable(TEST_TABLE);
		HTableDescriptor newdescriptor = table.getTableDescriptor();
		assertNotNull(newdescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_1)));
		assertNotNull(newdescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_2)));

	}

	@Test
	public void updateTableTestRemoveColumn() throws IOException
	{
		// create a discriptor:
		// table descriptor:

		// create two column table:
		HTableDescriptor descriptor = new HTableDescriptor(TEST_TABLE);
		descriptor.addFamily(new HColumnDescriptor(TEST_COLUMN_1));
		descriptor.addFamily(new HColumnDescriptor(TEST_COLUMN_2));
		manager.createTable(descriptor);

		// test table:
		HTableDescriptor existingDescriptor = manager.getTable(TEST_TABLE).getTableDescriptor();
		assertNotNull(existingDescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_1)));
		assertNotNull(existingDescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_1)));

		// create new descriptor (one column)
		HTableDescriptor updates = new HTableDescriptor(TEST_TABLE);
		updates.addFamily(new HColumnDescriptor(TEST_COLUMN_1));

		// update table:
		manager.disableTable(TEST_TABLE);
		manager.updateTable(updates);
		manager.enableTable(TEST_TABLE);

		// test results:
		HTableInterface table = manager.getTable(TEST_TABLE);
		HTableDescriptor newdescriptor = table.getTableDescriptor();
		assertNotNull(newdescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_1)));
		assertNull(newdescriptor.getFamily(Bytes.toBytes(TEST_COLUMN_2)));

	}
}


text:
/**
 * Support and FAQ: visit Atmel Support
 */

#include <avr32/io.h>
#include "compiler.h"
#include "conf_clocks.h"
#include "power_clocks_lib.h" // Used for embedded includes.

//_____ D E F I N I T I O N S ______________________________________________

#if UC3L
// Low footprint implementation (preprocessor computed parameters)
int conf_clocks_uc3l(void);
int conf_clocks_uc3l(void)
{
  scif_dfll_closedloop_conf_t DfllConfig;
  // Configure and start the DFLL main reference generic clock (CLK_DFLLIF_REF).
  AVR32_SCIF.gcctrl[AVR32_SCIF_GCLK_DFLL0_REF] = ((0 << AVR32_SCIF_GCCTRL_DIV_OFFSET)&AVR32_SCIF_GCCTRL_DIV_MASK)
                            |((0 << AVR32_SCIF_GCCTRL_DIVEN_OFFSET)&AVR32_SCIF_GCCTRL_DIVEN_MASK)
                            |((SCIF_GCCTRL_SLOWCLOCK << AVR32_SCIF_GCCTRL_OSCSEL_OFFSET)&AVR32_SCIF_GCCTRL_OSCSEL_MASK)
                            |(AVR32_SCIF_GCCTRL_CEN_MASK);

  // Configure the DFLL.
  // The coarse value (= (dfll_f - SCIF_DFLL_MINFREQ_KHZ)*255/(SCIF_DFLL_MAXFREQ_KHZ - SCIF_DFLL_MINFREQ_KHZ))
  DfllConfig.coarse = ((unsigned long long)(TARGET_DFLL_FREQ_HZ - SCIF_DFLL_MINFREQ_HZ)*255)/(SCIF_DFLL_MAXFREQ_HZ - SCIF_DFLL_MINFREQ_HZ);

  // imul = (fDFLL)/fref,
  // fmul = (fDFLL*2^16)/fref - imul*2^16,
  // with fref being the frequency of the DFLL main reference generic clock
  // and fDFLL being the target frequency of the DFLL
  DfllConfig.imul = ((unsigned long long)TARGET_DFLL_FREQ_HZ)/SCIF_SLOWCLOCK_FREQ_HZ;
  DfllConfig.fmul = ((unsigned long long)TARGET_DFLL_FREQ_HZ<<16)/SCIF_SLOWCLOCK_FREQ_HZ - ((unsigned long long)(DfllConfig.imul)<<16);

  // The fine and coarse maxstep values
  DfllConfig.finemaxstep = 0x0000004;
  DfllConfig.coarsemaxstep = 0x0000004;

  // Note: Dithering disabled.

  // Configure and start the DFLL0 in closed loop mode.
  if(scif_dfll0_closedloop_start(&DfllConfig))
    return FAIL;

  //#
  //# Set the Synchronous clock division ratio for each clock domain
  //#
  pm_set_all_cksel(TARGET_DFLL_FREQ_HZ, TARGET_CPU_FREQ_HZ, TARGET_PBA_FREQ_HZ, TARGET_PBB_FREQ_HZ);

  //#
  //# Set the Flash wait state and the speed read mode (depending on the target CPU frequency).
  //#
  flashcdw_set_flash_waitstate_and_readmode(TARGET_CPU_FREQ_HZ);

  //#
  //# Switch the main clock source to the selected clock.
  //#
  pm_set_mclk_source(PM_CLK_SRC_DFLL0);

  return PASS;
}

//! \brief Undo the settings performed by conf_clocks_uc3l().
//
void stop_clocks_uc3l(void);
void stop_clocks_uc3l(void)
{
  //# Switch the main clock source to the RCSYS clock.
  pm_set_mclk_source(PM_CLK_SRC_SLOW);

  //# Set the Flash wait state and the speed read mode (depending on the new CPU frequency).
  flashcdw_set_flash_waitstate_and_readmode(SCIF_SLOWCLOCK_FREQ_HZ);

  //# Set the Synchronous clock division ratio for each clock domain
  pm_set_all_cksel( SCIF_SLOWCLOCK_FREQ_HZ, SCIF_SLOWCLOCK_FREQ_HZ,
                    SCIF_SLOWCLOCK_FREQ_HZ, SCIF_SLOWCLOCK_FREQ_HZ );

  //# Disable the DFLL (reset the SCIF.DFLLOCONF register to its reset default value)
  AVR32_ENTER_CRITICAL_REGION( );
  SCIF_UNLOCK(AVR32_SCIF_DFLL0CONF);
  AVR32_SCIF.dfll0conf = AVR32_SCIF_DFLL0CONF_RESETVALUE;
  AVR32_LEAVE_CRITICAL_REGION( );

  //# Reset the SCIF.DFLL0MUL register to its reset default value
  AVR32_ENTER_CRITICAL_REGION( );
#if AVR32_SCIF_H_VERSION < 110
  SCIF_UNLOCK(AVR32_SCIF_DFLL0FMUL);
  AVR32_SCIF.dfll0fmul = AVR32_SCIF_DFLL0FMUL_RESETVALUE;
#else
  SCIF_UNLOCK(AVR32_SCIF_DFLL0MUL);
  AVR32_SCIF.dfll0mul = AVR32_SCIF_DFLL0MUL_RESETVALUE;
#endif
  AVR32_LEAVE_CRITICAL_REGION( );

  //# Reset the SCIF.DFLL0STEP register to its reset default value
  AVR32_ENTER_CRITICAL_REGION( );
  SCIF_UNLOCK(AVR32_SCIF_DFLL0STEP);
  AVR32_SCIF.dfll0step = AVR32_SCIF_DFLL0STEP_RESETVALUE;
  AVR32_LEAVE_CRITICAL_REGION( );

  //# Stop the DFLL main reference generic clock (CLK_DFLLIF_REF) and reset its
  //# SCIF control register to its reset default value.
  AVR32_SCIF.gcctrl[AVR32_SCIF_GCLK_DFLL0_REF] = AVR32_SCIF_GCCTRL_RESETVALUE;
}

#elif UC3A || UC3B || UC3C

int conf_clocks_uc3_extosc0(void)
{
    int cpu_freq_hz, mul;
  const int freq_hz[] = { 8000000, 12000000, 16000000 };
  const struct autobaud_cfg_osc_cmp_t autobaud_cfg = {
    .osc_ref_freq_hz = 115000,
    .osc_ref_counter_reset = osc_rtc_counter_reset,
    .osc_ref_counter_value = osc_rtc_counter_value,
    .osc_target_counter_reset = osc_isp_counter_reset,
    .osc_target_counter_value = osc_isp_counter_value,
    .convergence_rate = 10000
  };
  const struct autobaud_matching_freq_t match_freq = {
    .freq_hz = freq_hz,
    .nb_entries = sizeof(freq_hz)/sizeof(freq_hz[0])
  };
  bool sav_glob_int_en;

  #define MAX_OSC_FREQ    16000000

  //##
  //## 1) External Oscillator Frequency Automatic Identification
  //##
  // Switch to OSC ISP
  // Set max startup time to make sure any crystal will be supported
  // We cannot use a TC to measure this OSC frequency because the master clock must be faster than the clock selected by the TC
  pcl_switch_to_osc(PCL_OSC##ISP_OSC, MAX_OSC_FREQ, ATPASTE3(AVR32_PM_OSCCTRL, ISP_OSC, _STARTUP_16384_RCOSC));
  // Intialize the RTC with the internal RC oscillator
  // RTC will count at the frequency of 115KHz/2
  rtc_init(&AVR32_RTC, RTC_OSC_RC, 0);
  rtc_enable(&AVR32_RTC);

  // Calculate the frequency
  if (!(cpu_freq_hz = autobaud_detect_osc_cmp(&autobaud_cfg)))
    cpu_freq_hz = 12000000;
  cpu_freq_hz = autobaud_match_frequency(cpu_freq_hz, &match_freq);

  switch (cpu_freq_hz)
  {
    case 8000000:
      mul = 5;
      break;
    case 12000000:
      mul = 3;
      break;
    case 16000000:
      mul = 2;
      break;
    default:
      mul = 3;
  }

  //##
  //## 2) Set up CPU freq & PBx freq to 12MHz
  //##
#if UC3A || UC3B
  // Set PLL0 VCO @ 96 MHz
  pm_pll_setup(PM, 0,                         // pll
                   mul,                       // mul
                   0,                         // div
                   ISP_OSC,                   // osc
                   63);                       // lockcount

  AVR32_ENTER_CRITICAL_REGION();

  // Set PLL0 @ 48 MHz
  pm_pll_set_option(PM, 0,  // pll
                    1,      // pll_freq
                    1,      // pll_div2
                    0);     // pll_wbwdisable

  // Enable PLL0
  pm_pll_enable(PM, 0);

  // Wait for PLL0 locked with a 10-ms time-out
  pm_wait_for_pll0_locked(PM);

  // Use 1 flash wait state
  flashc_set_wait_state(1);

  // Switch the main clock to PLL0
  pm_switch_to_clock(PM, AVR32_PM_MCCTRL_MCSEL_PLL0);

  // fPBA: 12 MHz
  // fPBB: 12 MHz
  // fHSB: 12 MHz
  pm_cksel(PM, 1,   // pbadiv
               1,   // pbasel
               1,   // pbbdiv
               1,   // pbbsel
               1,   // hsbdiv
               1);  // hsbsel

  // Use 0 flash wait state
  flashc_set_wait_state(0);

  AVR32_LEAVE_CRITICAL_REGION();
#elif UC3C
  scif_pll_opt_t opt;

  opt.osc = SCIF_OSC0,     // Sel Osc0 or Osc1
  opt.lockcount = 16,      // lockcount in main clock for the PLL wait lock
  opt.div = 0,
  opt.mul = mul,
  opt.pll_div2 = 1,        // pll_div2 Divide the PLL output frequency by 2 (this settings does not change the FVCO value)
  opt.pll_wbwdisable = 0,  //pll_wbwdisable 1 Disable the Wide-Bandith Mode (Wide-Bandwith mode allow a faster startup time and out-of-lock time). 0 to enable the Wide-Bandith Mode.
  opt.pll_freq = (pll_freq < AVR32_PM_PLL_VCO_RANGE0_MIN_FREQ) ? 1 : 0,        // Set to 1 for VCO frequency range 80-180MHz, set to 0 for VCO frequency range 160-240Mhz.

  scif_pll_setup(SCIF_PLL0, &opt); // lockcount in main clock for the PLL wait lock

  /* Enable PLL0 */
  scif_pll_enable(SCIF_PLL0);

  /* Wait for PLL0 locked */
  scif_wait_for_pll_locked(SCIF_PLL0) ;

  pm_set_clk_domain_div(PM_CLK_DOMAIN_0, (pm_divratio_t) 1); // CPU
  pm_set_clk_domain_div(PM_CLK_DOMAIN_1, (pm_divratio_t) 1); // HSB
  pm_set_clk_domain_div(PM_CLK_DOMAIN_3, (pm_divratio_t) 1); // PBB
  pm_set_clk_domain_div(PM_CLK_DOMAIN_2, (pm_divratio_t) 1); // PBA
  pm_set_clk_domain_div(PM_CLK_DOMAIN_4, (pm_divratio_t) 1); // PBC

  // Set Flashc Wait State
  flashc_set_flash_waitstate_and_readmode(12000000);

  // Set the main clock source as being PLL0.
  pm_set_mclk_source(PM_CLK_SRC_PLL0);
#endif
}

int stop_clocks_uc3_extosc0(void)
{
  // TODO
}

#endif

redpajama_set_name: RedPajamaGithub


text:
import {jsdom} from 'jsdom';

global.document = jsdom();
global.window = document.defaultView;
global.navigator = window.navigator;


text:
using System;
using System.Reflection;
using Gallio.Common.Reflection;
using Gallio.Framework.Pattern;

namespace MbUnit.Framework
{
    /// <summary>
    /// Creates a dependency from this test assembly, test fixture or test method on some other test
    /// fixture or test method.
    /// </summary>
    /// <remarks>
    /// <para>
    /// If the other test fixture or test method fails then this test
    /// will not run.  Moreover, the dependency forces this test to run after those
    /// it depends upon.
    /// </para>
    /// <para>
    /// This attribute can be repeated multiple times if there are multiple dependencies.
    /// </para>
    /// </remarks>
    [AttributeUsage(PatternAttributeTargets.Test, AllowMultiple = true, Inherited = true)]
    public class DependsOnAttribute : TestDependencyPatternAttribute
    {
        private readonly Type testFixtureType;
        private readonly string testMethodName;

        /// <summary>
        /// Creates a dependency from this test on another test fixture.
        /// </summary>
        /// <param name="testFixtureType">The dependent test fixture type.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="testFixtureType"/> is null.</exception>
        public DependsOnAttribute(Type testFixtureType)
        {
            if (testFixtureType == null)
                throw new ArgumentNullException("testFixtureType");

            this.testFixtureType = testFixtureType;
        }

        /// <summary>
        /// Creates a dependency from this test on a particular test method within another test fixture.
        /// </summary>
        /// <param name="testFixtureType">The dependent test fixture type.</param>
        /// <param name="testMethodName">The dependent test method name.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="testFixtureType"/> or <paramref name="testMethodName"/> is null.</exception>
        public DependsOnAttribute(Type testFixtureType, string testMethodName)
            : this(testFixtureType)
        {
            if (testMethodName == null)
                throw new ArgumentNullException("testMethodName");

            this.testMethodName = testMethodName;
        }

        /// <summary>
        /// Creates a dependency from this test on another test method within this test fixture.
        /// </summary>
        /// <param name="testMethodName">The dependent test method name.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="testMethodName"/> is null.</exception>
        public DependsOnAttribute(string testMethodName)
        {
            if (testMethodName == null)
                throw new ArgumentNullException("testMethodName");

            this.testMethodName = testMethodName;
        }

        /// <summary>
        /// Gets the dependent test fixture type, or null if the dependency is on another
        /// test method of this test fixture.
        /// </summary>
        public Type TestFixtureType
        {
            get { return testFixtureType; }
        }

        /// <summary>
        /// Gets the dependent test method name, or null if the dependency
        /// is on the whole test fixture.
        /// </summary>
        public string TestMethodName
        {
            get { return testMethodName; }
        }

        /// <inheritdoc />
        protected override ICodeElementInfo GetDependency(IPatternScope scope, ICodeElementInfo codeElement)
        {
            ITypeInfo resolvedFixtureType;
            if (testFixtureType != null)
            {
                resolvedFixtureType = Reflector.Wrap(testFixtureType);
            }
            else
            {
                resolvedFixtureType = ReflectionUtils.GetType(codeElement);
                if (resolvedFixtureType == null)
                    ThrowUsageErrorException(String.Format("Could not resolve dependency on test method '{0}' because the declaring fixture type is not known.", testMethodName));
            }

            if (testMethodName == null)
                return resolvedFixtureType;

            IMethodInfo resolvedMethod = resolvedFixtureType.GetMethod(testMethodName, BindingFlags.Public | BindingFlags.Instance);
            if (resolvedMethod == null)
                ThrowUsageErrorException(String.Format("Could not resolve dependency on test method '{0}' of test fixture type '{1}' because the method was not found.",
                    testMethodName, resolvedFixtureType));
            return resolvedMethod;
        }
    }
}


text:
using System;
using System.Runtime.ExceptionServices;
using Avalonia.Utilities;

namespace Avalonia.Data.Core.Plugins
{
    /// <summary>
    /// Reads a property from a <see cref="AvaloniaObject"/>.
    /// </summary>
    public class AvaloniaPropertyAccessorPlugin : IPropertyAccessorPlugin
    {
        /// <inheritdoc/>
        public bool Match(object obj, string propertyName)
        {
            if (obj is AvaloniaObject o)
            {
                return LookupProperty(o, propertyName) != null;
            }

            return false;
        }

        /// <summary>
        /// Starts monitoring the value of a property on an object.
        /// </summary>
        /// <param name="reference">A weak reference to the object.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>
        /// An <see cref="IPropertyAccessor"/> interface through which future interactions with the
        /// property will be made.
        /// </returns>
        public IPropertyAccessor? Start(WeakReference<object?> reference, string propertyName)
        {
            _ = reference ?? throw new ArgumentNullException(nameof(reference));
            _ = propertyName ?? throw new ArgumentNullException(nameof(propertyName));

            if (!reference.TryGetTarget(out var instance) || instance is null)
                return null;

            var o = (AvaloniaObject)instance;
            var p = LookupProperty(o, propertyName);

            if (p != null)
            {
                return new Accessor(new WeakReference<AvaloniaObject>(o), p);
            }
            else if (instance != AvaloniaProperty.UnsetValue)
            {
                var message = $"Could not find AvaloniaProperty '{propertyName}' on '{instance}'";
                var exception = new MissingMemberException(message);
                return new PropertyError(new BindingNotification(exception, BindingErrorType.Error));
            }
            else
            {
                return null;
            }
        }

        private static AvaloniaProperty? LookupProperty(AvaloniaObject o, string propertyName)
        {
            return AvaloniaPropertyRegistry.Instance.FindRegistered(o, propertyName);
        }

        private class Accessor : PropertyAccessorBase, IWeakEventSubscriber<AvaloniaPropertyChangedEventArgs>
        {
            private readonly WeakReference<AvaloniaObject> _reference;
            private readonly AvaloniaProperty _property;

            public Accessor(WeakReference<AvaloniaObject> reference, AvaloniaProperty property)
            {
                _reference = reference ?? throw new ArgumentNullException(nameof(reference));
                _property = property ?? throw new ArgumentNullException(nameof(property));
            }

            public AvaloniaObject? Instance
            {
                get
                {
                    _reference.TryGetTarget(out var result);
                    return result;
                }
            }

            public override Type? PropertyType => _property?.PropertyType;
            public override object? Value => Instance?.GetValue(_property);

            public override bool SetValue(object? value, BindingPriority priority)
            {
                if (!_property.IsReadOnly)
                {
                    Instance?.SetValue(_property, value, priority);
                    return true;
                }

                return false;
            }

            void IWeakEventSubscriber<AvaloniaPropertyChangedEventArgs>.
                OnEvent(object? notifyPropertyChanged, WeakEvent ev, AvaloniaPropertyChangedEventArgs e)
            {
                if (e.Property == _property)
                {
                    SendCurrentValue();
                }
            }

            protected override void SubscribeCore()
            {
                SubscribeToChanges();
                SendCurrentValue();
            }

            protected override void UnsubscribeCore()
            {
                var instance = Instance;

                if (instance != null)
                    WeakEvents.AvaloniaPropertyChanged.Unsubscribe(instance, this);
            }

            private void SendCurrentValue()
            {
                try
                {
                    var value = Value;
                    PublishValue(value);
                }
                catch { }
            }

            private void SubscribeToChanges()
            {
                var instance = Instance;

                if (instance != null)
                    WeakEvents.AvaloniaPropertyChanged.Subscribe(instance, this);
            }
        }
    }
}


text:
define(function(require, exports, module) {

    /**
     * A class to add and remove a chain of modifiers
     *   at a single point in the render tree
     *
     * @class ModifierChain
     * @constructor
     */
    function ModifierChain() {
        this._chain = [];
        if (arguments.length) this.addModifier.apply(this, arguments);
    }

    /**
     * Add a modifier, or comma separated modifiers, to the modifier chain.
     *
     * @method addModifier
     *
     * @param {...Modifier*} varargs args list of Modifiers
     */
    ModifierChain.prototype.addModifier = function addModifier(varargs) {
        Array.prototype.push.apply(this._chain, arguments);
    };

    /**
     * Remove a modifier from the modifier chain.
     *
     * @method removeModifier
     *
     * @param {Modifier} modifier
     */
    ModifierChain.prototype.removeModifier = function removeModifier(modifier) {
        var index = this._chain.indexOf(modifier);
        if (index < 0) return;
        this._chain.splice(index, 1);
    };

    /**
     * Return render spec for this Modifier, applying to the provided
     *    target component.  This is similar to render() for Surfaces.
     *
     * @private
     * @method modify
     *
     * @param {Object} input (already rendered) render spec to
     *    which to apply the transform.
     * @return {Object} render spec for this Modifier, including the
     *    provided target
     */
    ModifierChain.prototype.modify = function modify(input) {
        var chain  = this._chain;
        var result = input;
        for (var i = 0; i < chain.length; i++) {
            result = chain[i].modify(result);
        }
        return result;
    };

    module.exports = ModifierChain;
});


text:
import { combineReducers } from 'redux'
import * as types from '../constants/ActionTypes'

function byId(state = {}, action) {
  if (action.type === types.LOAD_SEASONS_FINISHED) {
    return action.payload.entities.season
  }
  return state
}

function all(state = [], action) {
  if (action.type === types.LOAD_SEASONS_FINISHED) {
    return action.payload.result
  }
  return state
}

function ui(state = {
  loading: false
}, action) {
  switch (action.type) {
    case types.LOAD_SEASONS_STARTED:
      return {
        loading: true
      }
    case types.LOAD_SEASONS_FINISHED:
    case types.LOAD_SEASONS_FAILED:
      return {
        loading: false
      }
    default:
      return state
  }
}

export default combineReducers({
  all,
  byId,
  ui
})

export const getSeason = (state, id) => state.ladb.season.byId[id]

export const getSeasons = state => state.ladb.season.all.map(id => getSeason(state, id))

export const isLoading = state => state.ladb.season.ui.loading


text:
<?php
/**
 * Created by PhpStorm.
 * User: fredd
 * Date: 25/01/2017
 * Time: 08:38
 */

namespace AppBundle\Services;

use Symfony\Component\DependencyInjection\ContainerInterface;

class Emails
{
    private $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function sendActivation($emailTo, $emailFrom, $name, $active_hash)
    {
        $email = '';
        if(!empty($emailFrom)){
            $email .= $emailFrom;
        } else{
            $email .= 'noreply@noreply.com';
        }
        $message = \Swift_Message::newInstance()
            ->setSubject('Activate Account')
            ->setFrom($email)
            ->setTo($emailTo)
            ->setBody(
                $this->container->get('templating')->render(
                    $this->container->getParameter('theme_name').'/emails/registration.html.twig',
                    ['name' => $name, 'active_hash'=> $active_hash] ),
                'text/html'
            );

        $this->container->get('mailer')->send($message);
    }

    public function sendResetPasswordLink($emailTo, $emailFrom, $name, $token)
    {
        $email = '';
        if(!empty($emailFrom)){
            $email .= $emailFrom;
        } else{
            $email .= 'noreply@noreply.com';
        }
        $message = \Swift_Message::newInstance()
            ->setSubject('Reset Password')
            ->setFrom($email)
            ->setTo($emailTo)
            ->setBody(
                $this->container->get('templating')->render(
                    $this->container->getParameter('theme_name').'/emails/reset_link.html.twig',
                    ['name' => $name, 'token'=> $token] ),
                'text/html'
            );

        $this->container->get('mailer')->send($message);
    }

}


text:
using System;
using System.Collections;
using Castle.ActiveRecord;
using NHibernate;
using NHibernate.Criterion;

namespace Rhino.Commons
{
	public class ActiveRecordCriteriaBatch : CriteriaBatch, IActiveRecordQuery<IList>
	{
		private Type rootType = null;

		public Type RootType
		{
			get { return rootType; }
		}

		public override CriteriaBatch Add(DetachedCriteria criteria)
		{
			EnsureRootTypeIsAvailable(criteria);
			return base.Add(criteria);
		}

		public override CriteriaBatch Add(DetachedCriteria criteria,
		                                  Order order)
		{
			EnsureRootTypeIsAvailable(criteria);
			return base.Add(criteria, order);
		}

		public override IList Execute()
		{
			return (IList) ActiveRecordBase.ExecuteQuery(this);
		}

		IList IActiveRecordQuery<IList>.Execute(ISession session)
		{
			return base.Execute(session);
		}

		public new object Execute(ISession session)
		{
			return ((IActiveRecordQuery<IList>) this).Execute(session);
		}

		public IEnumerable Enumerate(ISession session)
		{
			return ((IActiveRecordQuery<IList>) this).Execute(session);
		}

		private void EnsureRootTypeIsAvailable(DetachedCriteria criteria)
		{
			if (rootType == null)
			{
				rootType = criteria.GetRootEntityTypeIfAvailable();
			}
		}
	}
}