text:
package com.proto;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFSheet;

/**
 * @author BA354098
 *
 */
public class Workbook
{

	/**
	 *
	 */
	public static XSSFWorkbook wb;

	/**
	 * @param args
	 * @throws IOException
	 * @throws TikaException
	 */

	public static void main(String[] args) throws IOException, TikaException
	{
		wb = new XSSFWorkbook();
		createShipToSummary(new File("d:\\test\\ship_to_summary.txt"));
		createProductSummary(new File("d:\\test\\product_summary.txt"));
		FileOutputStream fileOut1 = new FileOutputStream("d:\\workbook.xlsx");
		wb.write(fileOut1);
		fileOut1.close();
	}

	@SuppressWarnings(
	{ "deprecation" })
	private static void createProductSummary(File file) throws IOException, TikaException
	{
		int rows = 1, index = 0;
		StringBuilder formula = new StringBuilder("SUM(");
		List<String> fileDatas = getFileDatas(file);
		XSSFSheet sheet = wb.createSheet(file.getName().replace(" ", "_").substring(0, file.getName().indexOf('.')));
		Row tempRow = null;
		while (index != 6)
		{
			tempRow = sheet.createRow((short) rows++);
			createCell(tempRow, 1, 8, CellStyle.ALIGN_CENTER, CellType.STRING, fileDatas.get(index++));
			if (index < 4)
				createCell(tempRow, 9, 11, CellStyle.ALIGN_LEFT, CellType.STRING, fileDatas.get(index++));
		}
		rows++;
		for (; index < fileDatas.size(); rows++)
		{
			tempRow = sheet.createRow((short) rows);
			if (fileDatas.get(index).split(",").length != 1)
			{
				String colData[] = fileDatas.get(index++).split(",");
				for (int i = 0; i < colData.length; i++)
				{
					if (i == 0)
						createCell(tempRow, i + 1, 4, CellStyle.ALIGN_GENERAL, CellType.STRING, colData[i]);
					else
					{
						String details = createCell(tempRow, tempRow.getPhysicalNumberOfCells() + 3 + i,
								tempRow.getPhysicalNumberOfCells() + 4 + i, CellStyle.ALIGN_GENERAL, CellType.STRING, colData[i]);

						if (i == 1)
						{
							String detailsArr[] = details.split(",");
							try
							{
								Float.parseFloat(detailsArr[0]);
								formula.append(detailsArr[1].trim() + ",");
							}
							catch (Exception e)
							{
								//System.err.println(e.getMessage());
							}
						}
					}
				}
			}
			else
			{
				if (rows != fileDatas.size() - 1)
					createCell(tempRow, 1, 8, CellStyle.ALIGN_LEFT, CellType.STRING, fileDatas.get(index++));
				else
				{
					formula.deleteCharAt(formula.lastIndexOf(","));
					formula.append(')');
					createCell(tempRow, 1, 4, CellStyle.ALIGN_RIGHT, CellType.STRING, "Total");
					createCell(tempRow, 5, 6, CellStyle.ALIGN_GENERAL, CellType.FORMULA, formula.toString());
					tempRow = sheet.createRow((short) ++rows);
					createCell(tempRow, 1, 11, CellStyle.ALIGN_CENTER, CellType.STRING, fileDatas.get(index++));

				}

			}

		}

	}

	@SuppressWarnings(
	{ "deprecation" })
	private static void createShipToSummary(File file) throws IOException, TikaException
	{
		int rows = 1, index = 0;
		String divName = "";
		List<String> fileDatas = getFileDatas(file);
		List<String> cellAddress = new ArrayList<String>();
		XSSFSheet sheet = wb.createSheet(file.getName().replace(" ", "_").substring(0, file.getName().indexOf('.')));
		Row tempRow = null;
		while (index != 5)
		{
			tempRow = sheet.createRow((short) rows++);
			createCell(tempRow, 1, 14, CellStyle.ALIGN_CENTER, CellType.STRING, fileDatas.get(index++));
			if (index < 4)
				createCell(tempRow, 15, 17, CellStyle.ALIGN_LEFT, CellType.STRING, fileDatas.get(index++));
		}
		rows++;
		for (; index < fileDatas.size(); rows++)
		{
			tempRow = sheet.createRow((short) rows);
			if (fileDatas.get(index).split(",").length != 1)
			{
				String colData[] = fileDatas.get(index++).split(",");
				StringBuilder s = null;
				for (int i = 0; i < colData.length; i++)
				{
					if (i <= 3)
						createCell(tempRow, i + 1, -1, CellStyle.ALIGN_GENERAL, CellType.STRING, colData[i]);
					else if (i == 4)
					{
						try
						{
							Float.parseFloat(colData[i].matches("-") ? "0" : colData[i]);
							s = new StringBuilder(tempRow.getCell(i).getAddress().toString());
							s.setCharAt(0, (char) (s.charAt(0) + 2));
							s.append(":" + (char) (s.charAt(0) + 11) + s.substring(1, s.length()));
							s.append(')');
							s.insert(0, "SUM(");
							String tempAdd = createCell(tempRow, i + 1, -1, CellStyle.ALIGN_GENERAL, CellType.FORMULA, s.toString());
							s = new StringBuilder();
							s.append(tempAdd.split(",")[1] + ",");
							tempAdd = createCell(tempRow, i + 2, -1, CellStyle.ALIGN_GENERAL, CellType.FORMULA, colData[i]);
							s.append(tempAdd.split(",")[1]);
						}
						catch (Exception e)
						{
							createCell(tempRow, i + 1, -1, CellStyle.ALIGN_GENERAL, CellType.STRING, "Total_MSF_Shipped");
							createCell(tempRow, i + 2, -1, CellStyle.ALIGN_GENERAL, CellType.STRING, colData[i]);
						}

					}
					else
					{
						String tempAdd = createCell(tempRow, i + 2, -1, CellStyle.ALIGN_GENERAL, CellType.STRING, colData[i]);
						try
						{
							Float.parseFloat(colData[i].contains("-") ? "0" : colData[i]);
							s.append("," + tempAdd.split(",")[1]);
						}
						catch (Exception e)
						{
							//System.err.println(e);
						}
					}
				}
				if (s != null)
					cellAddress.add(s.toString());
			}
			else
			{
				if (divName != "")
				{
					Iterator<String> it = cellAddress.iterator();
					String[] formulas = new String[cellAddress.get(0).split(",").length];
					while (it.hasNext())
					{
						String eachAdd[] = it.next().split(",");
						int i;
						for (i = 0; i < eachAdd.length; i++)
							if (formulas[i] == null)
								formulas[i] = "SUM(" + eachAdd[i];
							else
								formulas[i] += "," + eachAdd[i];
					}
					createCell(tempRow, 1, 4, CellStyle.ALIGN_RIGHT, CellType.STRING, "Total_for_TX");

					for (String eachFormula : formulas)
						createCell(tempRow, tempRow.getPhysicalNumberOfCells() + 4, -1, CellStyle.ALIGN_RIGHT, CellType.FORMULA,
								eachFormula + ")");

					tempRow = sheet.createRow((short) ++rows);
					createCell(tempRow, 1, 4, CellStyle.ALIGN_RIGHT, CellType.STRING, "Total_for_" + divName.replaceAll(" ", "_"));

					for (String eachFormula : formulas)
						createCell(tempRow, tempRow.getPhysicalNumberOfCells() + 4, -1, CellStyle.ALIGN_RIGHT, CellType.FORMULA,
								eachFormula + ")");

					cellAddress.clear();
					tempRow = sheet.createRow((short) ++rows);
				}
				divName = fileDatas.get(index);
				createCell(tempRow, 1, 17, index == fileDatas.size() - 1 ? CellStyle.ALIGN_CENTER : CellStyle.ALIGN_LEFT,
						CellType.STRING, fileDatas.get(index++));
			}
		}
	}

	private static List<String> getFileDatas(File file) throws IOException, TikaException
	{
		List<String> list = new LinkedList<String>();
		System.err.println("Reading the File " + file.getName());
		Tika tika = new Tika();
		String filecontent = tika.parseToString(file);
		String data[] = filecontent.toString().split("\n");
		for (String s : data)
			list.add(s);
		return list;
	}

	@SuppressWarnings("deprecation")
	private static String createCell(Row row, int col, int colend, short halign, CellType type, String data)
	{
		data = data.trim().equals("-") ? "0" : data.trim();
		Cell cell = row.createCell(col);
		if (type == CellType.FORMULA)
		{
			cell.setCellFormula(data);
		}
		else
		{
			try
			{
				cell.setCellValue(Float.parseFloat(data));
			}
			catch (Exception e)
			{
				try
				{
					cell.setCellValue(Integer.parseInt(data));
				}
				catch (Exception e1)
				{
					cell.setCellValue(data);
				}
			}
		}
		CellStyle cellStyle = wb.createCellStyle();
		cellStyle.setAlignment(halign);
		cell.setCellStyle(cellStyle);
		if (colend != -1)
			row.getSheet().addMergedRegion(new CellRangeAddress(row.getRowNum(), //first row (0-based)
					row.getRowNum(), //last row  (0-based)
					col, //first column (0-based)
					colend //last column  (0-based)
			));
		row.getSheet().autoSizeColumn(col);
		//System.out.println("Data : " + data + " Cell : " + cell.getAddress() + " Row : " + (row.getRowNum()));
		return data + "," + cell.getAddress() + "," + (row.getRowNum());
	}

}


text:
#ifndef Wiring_h
#define Wiring_h

#include <avr/io.h>
#include <stdlib.h>
#include "binary.h"

#ifdef __cplusplus
extern "C"{
#endif

#define HIGH 0x1
#define LOW  0x0

#define INPUT 0x0
#define OUTPUT 0x1

#define true 0x1
#define false 0x0

#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398
#define TWO_PI 6.283185307179586476925286766559
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define RAD_TO_DEG 57.295779513082320876798154814105

#define SERIAL  0x0
#define DISPLAY 0x1

#define LSBFIRST 0
#define MSBFIRST 1

#define CHANGE 1
#define FALLING 2
#define RISING 3

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define INTERNAL1V1 2
#define INTERNAL2V56 3
#else
#define INTERNAL 3
#endif
#define DEFAULT 1
#define EXTERNAL 0

// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif

#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))

#define interrupts() sei()
#define noInterrupts() cli()

#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )

#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))

#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))

typedef unsigned int word;

#define bit(b) (1UL << (b))

typedef uint8_t boolean;
typedef uint8_t byte;

void init(void);

void pinMode(uint8_t, uint8_t);
void digitalWrite(uint8_t, uint8_t);
int digitalRead(uint8_t);
int analogRead(uint8_t);
void analogReference(uint8_t mode);
void analogWrite(uint8_t, int);

unsigned long millis(void);
unsigned long micros(void);

#ifndef DuinOS__h
// DuinOS overrides this:
void delay(unsigned long);
#endif

void delayMicroseconds(unsigned int us);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);

void attachInterrupt(uint8_t, void (*)(void), int mode);
void detachInterrupt(uint8_t);

void setup(void);
void loop(void);

#ifdef __cplusplus
} // extern "C"
#endif

#endif

redpajama_set_name: RedPajamaGithub


text:
@implementation ASObject

@synthesize type=m_type, properties=m_properties, isExternalizable=m_isExternalizable, data=m_data;

#pragma mark -
#pragma mark Initialization & Deallocation

- (id)init{
	if (self = [super init]){
		m_properties = nil;
		m_data = nil;
		m_type = nil;
		m_isExternalizable = NO;
	}
	return self;
}

+ (ASObject *)asObjectWithDictionary:(NSDictionary *)dict{
	ASObject *obj = [[[ASObject alloc] init] autorelease];
	NSMutableDictionary *mutableCopy = [dict mutableCopy];
	obj.properties = mutableCopy;
	[mutableCopy release];
	return obj;
}

- (void)dealloc{
	[m_type release];
	[m_properties release];
	[m_data release];
	[super dealloc];
}

- (BOOL)isEqual:(id)obj{
	if (![obj isKindOfClass:[ASObject class]]){
		return NO;
	}
	ASObject *asObj = (ASObject *)obj;
	return ((asObj.type == nil && m_type == nil) || [asObj.type isEqual:m_type]) &&
		asObj.isExternalizable == m_isExternalizable &&
		(m_isExternalizable
			? [asObj.data isEqual:m_data]
			: [asObj.properties isEqual:m_properties]);
}

#pragma mark -
#pragma mark Public methods

- (void)setValue:(id)value forKey:(NSString *)key{
	if (m_properties == nil)
		m_properties = [[NSMutableDictionary alloc] init];
	[m_properties setValue:value forKey:key];
}

- (id)valueForKey:(NSString *)key{
	return [m_properties valueForKey:key];
}

- (void)addObject:(id)obj{
	if (m_data == nil){
		m_data = [[NSMutableArray alloc] init];
		m_isExternalizable = YES;
	}
	[m_data addObject:obj];
}

- (NSUInteger)count{
	return m_isExternalizable ? [m_data count] : [m_properties count];
}

- (NSString *)description{
	return [NSString stringWithFormat:@"<%@ = 0x%08X | type: %@>\n%@\ndata: %@",
		[self class], (long)self, m_type, m_properties, m_data];
}

@end


text:
from OCC.Core.BRep import BRep_Tool_Curve
from OCC.Display.SimpleGui import init_display
from tigl3.geometry import curve_network_to_surface
from tigl3.occ_helpers.containers import geomcurve_vector

from tigl3.occ_helpers.topology import read_brep, iter_edges

def main():
    # load curves from files
    guides_shape = read_brep("data/wing_guides.brep")
    profiles_shape = read_brep("data/wing_profiles.brep")

    # Create array of curves
    guide_curves = []
    for edge in iter_edges(guides_shape):
        curve, _, _ = BRep_Tool_Curve(edge)
        guide_curves.append(curve)

    profile_curves = []
    for edge in iter_edges(profiles_shape):
        curve, _, _ = BRep_Tool_Curve(edge)
        profile_curves.append(curve)

    # create the gordon surface
    surface = curve_network_to_surface(geomcurve_vector(profile_curves), geomcurve_vector(guide_curves), 1.e-4)

    # display curves and resulting surface
    display, start_display, add_menu, add_function_to_menu = init_display()
    display.Context.SetDeviationCoefficient(0.0001)

    for curve in guide_curves:
        display.DisplayShape(curve)

    for curve in profile_curves:
        display.DisplayShape(curve)

    display.DisplayShape(surface)
    display.FitAll()

    start_display()

if __name__ == "__main__":
    main()


text:
Windows 10 x64 (18362.86)

_SECURITY_IMPERSONATION_LEVEL

   SecurityAnonymous = 0n0

   SecurityIdentification = 0n1

   SecurityImpersonation = 0n2

   SecurityDelegation = 0n3


text:
var jsx = require('../index');
var React = require('react/addons');
var assert = require('assert');

describe('#withContext', function() {
    it('gives child context', function () {
        var ContextUser = React.createClass({
            contextTypes: {
                method: React.PropTypes.func
            },
            render: function () {
                return React.createElement('span', null, this.context.method());
            }
        });

        var context = {
            method: function () {
                return 'Awesome String!';
            }
        };

        jsx.assertRender(jsx.withContext(ContextUser, context), {}, 'Awesome String!');
    });

    it('passes props through context wrapper to child', function () {
        var ContextUser = React.createClass({
            render: function () {
                return React.createElement('span', null, this.props.str);
            }
        });

        jsx.assertRender(jsx.withContext(ContextUser, {}), {str: 'Awesome String!'}, 'Awesome String!');
    });

    it('allows calling methods from underlying component', function () {
        var UnderlyingComponent = React.createClass({
            underlyingMethod: function (n1, n2) {
                return n1 + n2;
            },
            render: function () {
                return null;
            }
        });

        var wrapper = jsx.renderComponent(jsx.withContext(UnderlyingComponent, {}));
        assert.equal(wrapper.runChildMethod('underlyingMethod', [1, 2]), 3);
    });

    it('creates a readable displayName using Component.displayName', function () {
        var NamedComponent = jsx.stubComponent('Name');
        assert.equal(jsx.withContext(NamedComponent, {}).displayName, 'Name:withContext');
    });

    it('creates a readable displayName even if Component did not have one', function () {
        var UnnamedComponent = React.createClass({
            render: function () {return null;}
        });

        assert.equal(jsx.withContext(UnnamedComponent, {}).displayName, 'UnnamedComponent:withContext');
    });
});


text:
%%%%%%%%%%%%%%%%%%%%%
%
% Author: Wachter Johannes
% Date: 17.01.2014
% File: template/settings.tex
%
% Document Settings

\newcommand{\mypapersize}{A4}
% e.g., "A4", "letter", "legal", "executive", ...
% The size of the paper of the resulting PDF file.

\newcommand{\mytype}{true}
% e.g. true=print, false=screen
% optimize output for this type

\newcommand{\mylaterality}{twoside}
% "oneside" or "twoside"
% Either you are creating a document which is printed on both, left pages
% and right pages (twoside) or you create a document which is printed
% on right pages only (oneside).

\newcommand{\mydraft}{false}
% "true" or "false"
% Use draft mode? If true, included graphics are replaced by empty
% rectangles (of same size) and overfull boxes (in margin space) are
% marked with black box (-> easy to spot!)

\newcommand{\myparskip}{half}
% e.g., "no", "full", "half", ...
% How to separate paragraphs: indention ("no") or spacing ("half",
% "full", ...).

\newcommand{\myBCOR}{0mm}
% Inner binding correction. This value depends on the method which is
% being used to bind your printed result. Some techniques do not
% require a binding correction at all ("0mm"), other require for
% example "5mm". Refer to KOMA script documentation for a detailed
% explanation what a binding correction is and how to measure it.

\newcommand{\myfontsize}{12pt}
% e.g., 10pt, 11pt, 12pt
% The font size of the main text in pt (points).

\newcommand{\mylinespread}{1.25}
% e.g., 1.0, 1.5, 2.0
% Line spacing in %/100. For example 1.5 means 150% of the usual line
% spacing. Please use with caution: 100% ("1.0") is fine because the
% font was designed for it.

\newcommand{\mylanguage}{ngerman}
% "english,ngerman", "ngerman,english", ...
% NOTE: The *last* language is the active one!
% See babel documentation for further details.

\newcommand{\mytodonotesoptions}{}
% e.g., "" (empty), "disable", ...
% Options for the todonotes-package. If "disable", all todonotes will
% be hidden (including listoftodos).

\newcommand{\mytitlepage}{title/titlepage}
% e.g. title/titlepage
% define your titlepage

\newcommand{\myleft}{2.5cm}
\newcommand{\myright}{2.5cm}
\newcommand{\mytop}{2.5cm}
\newcommand{\mybottom}{2.5cm}
% e.g. 1cm
% define page borders, for twosided left != right, will be alternated every page

\newcommand{\myaddtitle}{true}
\newcommand{\myaddabstract}{true}
\newcommand{\myaddtoc}{true}
\newcommand{\myaddtol}{true} % table of listings
\newcommand{\myaddtof}{true} % table of figures
\newcommand{\myaddlistoftodos}{true}
\newcommand{\myaddsummary}{true}
\newcommand{\myaddreferences}{true}
% e.g. true / false
% should it be displayed

% listings
\newcommand{\mylstframe}{true}
% e.g. true/false
% frame around listings
\newcommand{\mylstframeleftmargin}{1.5em}
\newcommand{\mylstleftmargin}{2.0em}
% e.g. 1.5em
% margin for frame and code
\newcommand{\mylstlanguage}{perl}
% e.g. perl/c++/php ...
% set default language

\newcommand{\chapternumber}{0}
% starting number of chapter

\newcommand{\codelabelprefix}{code}
\newcommand{\imglabelprefix}{img}
\newcommand{\algolabelprefix}{algo}
% label prefixes


text:
//---------------------------------------------------------------------------
//
// File: RootBrowserWindow.cs
//
// Description: This class will implement the hosting and bridging logic
//              between the browser and Avalon.  This will be the top
//              level "frame" that hosts all content in IE.  This class
//              will not be public.
//
// Created: 04/28/03
//
// Copyright (C) 2001 by Microsoft Corporation.  All rights reserved.
//
//  History:
//      hamidm  06/11/03    moved over to wcp tree
//---------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Navigation;
using MS.Internal.Commands;
using MS.Internal.Controls;
using MS.Win32;

//In order to avoid generating warnings about unknown message numbers and
//unknown pragmas when compiling your C# source code with the actual C# compiler,
//you need to disable warnings 1634 and 1691. (Presharp Documentation)
#pragma warning disable 1634, 1691

namespace MS.Internal.AppModel
{

    /// <summary>
    ///
    /// </summary>
    internal sealed class RootBrowserWindow : NavigationWindow, IWindowService, IJournalNavigationScopeHost
    {
        //----------------------------------------------
        //
        // Constructors
        //
        //----------------------------------------------
        #region Constructors

        static RootBrowserWindow()
        {
            CommandHelpers.RegisterCommandHandler(typeof(RootBrowserWindow), ApplicationCommands.Print,
                    new ExecutedRoutedEventHandler(OnCommandPrint), new CanExecuteRoutedEventHandler(OnQueryEnabledCommandPrint));
        }

        /// <summary>
        ///
        /// </summary>
        /// <SecurityNote>
        ///     Critical:Calls base class constructor that is only present for RBW scenario
        /// </SecurityNote>
        [SecurityCritical]
        private RootBrowserWindow():base(true)
        {
            // Allow tabbing out to the browser - see KeyInputSite and OnKeyDown().

            // IE 6 doesn't provide the necessary support; notice IsDownlevelPlatform covers Firefox too,
            // hence the additional IsHostedInIE check.
            // By checking for the negative top-level case, we allow to tab out of XBAPs hosted in an iframe;
            // this support is enabled regardless of the browser we're on (to avoid browser-specifics here).
            bool isIE6 = IsDownlevelPlatform && BrowserInteropHelper.IsHostedInIEorWebOC;
            if (!(isIE6 && BrowserInteropHelper.IsAvalonTopLevel))
            {
                SetValue(KeyboardNavigation.TabNavigationProperty, KeyboardNavigationMode.Continue);
                SetValue(KeyboardNavigation.ControlTabNavigationProperty, KeyboardNavigationMode.Continue);
            }
        }
        #endregion Constructors

        //----------------------------------------------
        //
        // Protected Methods
        //
        //----------------------------------------------
        #region Protected Methods

        /// <summary>
        /// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
        /// </summary>
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            return new RootBrowserWindowAutomationPeer(this);
        }

        /// <SecurityNote>
        ///     Critical - Hooks up the event handler that sets the status bar text (OnRequestSetStatusBar_Hyperlink).
        ///     TreatAsSafe - Safe to set up the handler over here; OnRequestSetStatusBar_Hyperlink is connected to
        ///                   RequestSetStatusBarEvent which is supposed to be raised only by Hyperlink which has the
        ///                   anti-spoofing mitigations in place. The RequestSetStatusBarEventArgs used in the event
        ///                   is protected as well.
        /// </SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        protected override void OnInitialized(EventArgs args)
        {
            AddHandler(Hyperlink.RequestSetStatusBarEvent, new RoutedEventHandler(OnRequestSetStatusBar_Hyperlink));
            base.OnInitialized(args);
        }

        protected override Size MeasureOverride(Size constraint)
        {
            return base.MeasureOverride(GetSizeInLogicalUnits());
        }

        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            // Get the size of the avalon window and pass it to
            // the base implementation. The return value tells the Size
            // that we are occupying.  Since, we are RBW we will occupy the
            // entire available size and thus we don't care what our child wants.
            base.ArrangeOverride(GetSizeInLogicalUnits());
            return arrangeBounds;
        }

        protected override void OnStateChanged(EventArgs e)
        {
        }

        protected override void OnLocationChanged(EventArgs e)
        {
        }

        protected override void OnClosing(CancelEventArgs e)
        {
        }

        protected override void OnClosed(EventArgs e)
        {
        }

        ///<SecurityNote>
        /// Critical - calls the SUC'd IBCS.PostReadyStateChange().
        /// TreatAsSafe - Only READYSTATE_COMPLETE is posted, once, at the end of the activation sequence,
        ///     when the browser expects it.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        protected override void OnContentRendered(EventArgs e)
        {
            base.OnContentRendered(e);

            // Posting READYSTATE_COMPLETE triggers the WebOC's DocumentComplete event.
            // Media Center, in particular, uses this to make the WebOC it hosts visible.
            if (!_loadingCompletePosted)
            {
                Browser.PostReadyStateChange(READYSTATE_COMPLETE);
                _loadingCompletePosted = true;
            }
        }

        protected override void OnKeyDown(KeyEventArgs e)
        {
            // In browser apps, Ctrl+Tab switches tabs. F6 simulates it here.
            if (e.Key == Key.F6 && (e.KeyboardDevice.Modifiers & ~ModifierKeys.Shift) == 0)
            {
                if (KeyboardNavigation.Navigate(
                        e.KeyboardDevice.FocusedElement as DependencyObject ?? this,
                        Key.Tab, e.KeyboardDevice.Modifiers | ModifierKeys.Control))
                {
                    e.Handled = true;
                }
            }

            if (!e.Handled)
            {
                base.OnKeyDown(e);
            }
        }

        #endregion Protected methods

        //----------------------------------------------
        //
        // Internal Methods
        //
        //----------------------------------------------
        #region Internal Methods

        /// <summary>
        ///     Creates the RBW object and sets the Style property on it
        ///     to the correct value
        /// </summary>
        /// <SecurityNote>
        ///     Critical: Calls RBW class constructor
        /// </SecurityNote>
        [SecurityCritical]
        internal static RootBrowserWindow CreateAndInitialize()
        {
            RootBrowserWindow rbw = new RootBrowserWindow();
            rbw.InitializeRBWStyle();
            return rbw;
        }

        /// <SecurityNote>
        /// Critical: This code elevates to all window permission
        /// </SecurityNote>
        [SecurityCritical]
        internal override void CreateAllStyle()
        {
            Invariant.Assert(App != null, "RootBrowserWindow must be created in an Application");

            IHostService ihs = (IHostService)App.GetService(typeof(IHostService));

            Invariant.Assert(ihs!=null, "IHostService in RootBrowserWindow cannot be null");
            Invariant.Assert(ihs.HostWindowHandle != IntPtr.Zero, "IHostService.HostWindowHandle in RootBrowserWindow cannot be null");

            //This sets the _ownerHandle correctly and will be used to create the _sourceWindow
            //with the correct parent
            UIPermission uip = new UIPermission(UIPermissionWindow.AllWindows);
            uip.Assert();//Blessed Assert to set owner handle and to set styles
            try
            {
                this.OwnerHandle = ihs.HostWindowHandle;
                this.Win32Style = NativeMethods.WS_CHILD | NativeMethods.WS_CLIPCHILDREN | NativeMethods.WS_CLIPSIBLINGS;
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }

        }

        ///<SecurityNote>
        /// Critical: Exposes a window handle (ParentWindow). Base class implementation is also Critical.
        ///</SecurityNote>
        [SecurityCritical]
        internal override HwndSourceParameters CreateHwndSourceParameters()
        {
            HwndSourceParameters parameters = base.CreateHwndSourceParameters();
            parameters.TreatAsInputRoot = true;
            parameters.TreatAncestorsAsNonClientArea = true;
            return parameters;
        }

        /// <summary>
        ///     Override for SourceWindow creation.
        ///     Virtual only so that we may assert.
        /// </summary>
        /// <SecurityNote>
        ///     Critical - Calls critical base-class function.
        ///                Calls critical functions GetAncestor and GetForegroundWindow.
        /// </SecurityNote>
        [SecurityCritical]
        internal override void CreateSourceWindowDuringShow()
        {
            Browser.OnBeforeShowNavigationWindow();

            base.CreateSourceWindowDuringShow();
            Invariant.Assert(IsSourceWindowNull == false, "Failed to create HwndSourceWindow for browser hosting");

            // _sourceWindowCreationCompleted specifies that HwndSource creation has completed.  This is used
            // to minimize the SetWindowPos calls from ResizeMove when Height/Width is set prior to calling
            // show on RBW (this also occurs when Height/Width is set in the style of RBW)
            _sourceWindowCreationCompleted = true;

            if (_rectSet)
            {
                _rectSet = false;
                ResizeMove(_xDeviceUnits, _yDeviceUnits, _widthDeviceUnits, _heightDeviceUnits);
            }
            // The above window move (resize) operation causes message dispatching, which allows reentrancy
            // from the browser, which can initiate premature shutdown.
            if (IsSourceWindowNull)
                return;

            SetUpInputHooks();

            //
            // While the RBW is created and shown, the Top Browser window should have already been created and shown,
            // Browser doesn't notify this RBW of the activation status again unless user activates/deactivates the main
            // window. It is time to transfer the Top Browser Window's activation status to this RBW so that user's
            // code can get correct status through property IsActivate.
            //
            IntPtr topWindow = UnsafeNativeMethods.GetAncestor(new HandleRef(this, CriticalHandle), 2/*GA_ROOT*/);
            Debug.Assert(topWindow != IntPtr.Zero);
            IntPtr activeWindow = UnsafeNativeMethods.GetForegroundWindow();
            HandleActivate(activeWindow == topWindow);
        }

        // No need to clear App.MainWindow for RBW case.  It throws an exception if attempted
        internal override void TryClearingMainWindow()
        {
        }

        internal override void CorrectStyleForBorderlessWindowCase()
        {
        }

        internal override void GetRequestedDimensions(ref double requestedLeft, ref double requestedTop, ref double requestedWidth, ref double requestedHeight)
        {
            requestedTop = 0;
            requestedLeft = 0;
            requestedWidth = this.Width;
            requestedHeight = this.Height;
        }

        ///<SecurityNote>
        ///     Critical - It also calls critical method (SetRootVisual)
        ///</SecurityNote>
        [SecurityCritical]
        internal override void SetupInitialState(double requestedTop, double requestedLeft, double requestedWidth, double requestedHeight)
        {
            // If RBW Height/Width was set before calling show in RBW, we need
            // to update the browser with that size now
            SetBrowserSize();
            SetRootVisual();
        }

        internal override int nCmdForShow()
        {
            return NativeMethods.SW_SHOW;
        }

        internal override bool HandleWmNcHitTestMsg(IntPtr lParam, ref IntPtr refInt)
        {
            return false;
        }

        internal override WindowMinMax GetWindowMinMax()
        {
            return new WindowMinMax(0, double.PositiveInfinity);
        }

        // RBW overrides WmMoveChangedHelper default behavior where it calls
        // either SetValue/CoerceValue on Top/Left DPs since that will
        // throw an exception for RBW.  Furthermore, in RBW, we don't want
        // to fire LocationChanged event.
        internal override void WmMoveChangedHelper()
        {
        }

        /// <summary>
        ///     Resizes and moves the RBW (which is a WS_CHILD window).  This is called by
        ///     AppProxyInternal when the host callsbacks into it with the new size/location.
        ///     We need this internal since Height/Width/Top/Left on RBW govern the host'ss
        ///     properties.
        /// </summary>
        /// <remarks>
        ///     The location of WS_CHILD window is relative to it parent window thus when the
        ///     browser moves it does not call this method since the relative position of this window
        ///     wrt the browser hasn't changed.
        /// </remarks>
        /// <param name="xDeviceUnits">New left of the RBW</param>
        /// <param name="yDeviceUnits">New top of the RBW</param>
        /// <param name="widthDeviceUnits">New width of the RBW</param>
        /// <param name="heightDeviceUnits">New height of the RBW</param>
        ///<SecurityNote>
        ///     Critical as this method handles critical data.
        ///     TreatAsSafe - as the RBW is always contained within the browser's window.
        ///                          you can move the internal window all you want - but given that you're really
        ///                          contained within the BrowserWindow - the worse you could do is make some of your content not visible.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        internal void ResizeMove(int xDeviceUnits, int yDeviceUnits, int widthDeviceUnits, int heightDeviceUnits)
        {
            // _sourceWindowCreationCompleted specifies that HwndSource creation has completed.  This is used
            // to minimize the SetWindowPos calls from ResizeMove when Height/Width is set prior to calling
            // show on RBW (this also occurs when Height/Width is set in the style of RBW).  Thus, we want to
            // resize the underlying avalon hwnd only after its creation is completed
            if (_sourceWindowCreationCompleted == false)
            {
                _xDeviceUnits = xDeviceUnits;
                _yDeviceUnits = yDeviceUnits;
                _widthDeviceUnits = widthDeviceUnits;
                _heightDeviceUnits = heightDeviceUnits;

                _rectSet = true;

                return;
            }

            Invariant.Assert(IsSourceWindowNull == false, "sourceWindow cannot be null if _sourceWindowCreationCompleted is true");

            HandleRef handleRef;
            handleRef = new HandleRef( this, CriticalHandle ) ;

            UnsafeNativeMethods.SetWindowPos( handleRef ,
                           NativeMethods.NullHandleRef,
                           xDeviceUnits,
                           yDeviceUnits,
                           widthDeviceUnits,
                           heightDeviceUnits,
                           NativeMethods.SWP_NOZORDER
                           | NativeMethods.SWP_NOACTIVATE
                           | NativeMethods.SWP_SHOWWINDOW);
        }

        /// <summary>
        ///     This is called when the Title dependency property changes in the Window.
        /// </summary>
        ///<SecurityNote>
        /// Critical - calls SUC'd IHostBrowser.SetTitle
        /// TreatAsSafe - setting the text on the browser's window is considered safe.
        ///                 - spoofing is not possible as the browser prepends it's own string to the string
        ///                      e.g. Microsoft Internet Explorer
        ///                 - it can be done in partial trust in HTML via the TITLE tag.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        internal override void UpdateTitle(string titleStr)
        {
            IBrowserCallbackServices ibcs = Browser;
            if (ibcs != null) // null on shutdown
            {
                string title = PruneTitleString(titleStr);

                // It's not the end of the world if this fails.
                // VS's browser in particular returns RPC_E_CALL_REJECTED.
                // Not sure of other exceptions that might be thrown here,
                // so keeping this scoped to what's been reported.
                const int RPC_E_CALL_REJECTED = unchecked((int)0x80010001);
                try
                {
                    // SHOULD NOT CALL BASE; BASE IMPLEMENTS TEXT PROPERTY ON WINDOW
                    BrowserInteropHelper.HostBrowser.SetTitle(title);
                }
                catch (COMException e)
                {
                    if (e.ErrorCode != RPC_E_CALL_REJECTED)
                    {
                        throw;
                    }
                }
            }
        }

        /// <summary>
        ///     This is called by NavigationService to set the status bar content
        ///     for the browser
        /// </summary>
        /// <remarks>
        ///     We propagate object.ToString() to the browser's status bar.
        /// </remarks>
        ///<SecurityNote>
        ///     Critical - calls SetStatusText which is SUC'ed.
        ///
        ///     No longer considered TreatAsSafe in order to protect against hyperlink spoofing.
        ///     Browsers implement access restriction to the status bar from script nowadays.
        ///</SecurityNote>
        [SecurityCritical]
        internal void SetStatusBarText(string statusString)
        {
            if (BrowserInteropHelper.HostBrowser != null) // could be null if shutting down
            {
                BrowserInteropHelper.HostBrowser.SetStatusText(statusString);
            }
        }

        /// <summary>
        ///     Called to update Height of the browser.  Currently, this method is called from
        ///     two places:
        ///
        ///     1) OnHeightInvalidated from window.cs
        ///     2) SetBrowserSize in RBW
        /// </summary>
        ///<SecurityNote>
        ///     Critical - Can be used to change the size of the browser
        ///     TreatAsSafe - clamps values so that window cannot be sized greater than desktop bounds.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        internal override void UpdateHeight(double newHeightLogicalUnits)
        {
            Point sizeDeviceUnits = LogicalToDeviceUnits(new Point(0, newHeightLogicalUnits));
            uint heightDeviceUnits = (uint)Math.Round(sizeDeviceUnits.Y);

            if (BrowserInteropHelper.HostBrowser != null)
            {
                //
                // Note: right now IE is clipping browser height to desktop size.
                // However it should be clipped to available desktop size. See Windows OS Bug #1045038
                // The code below is to fix this for now.
                // Even if IE's code is changed - likely we keep this as defense in-depth.
                //

                uint maxHeightDeviceUnits = GetMaxWindowHeight();
                heightDeviceUnits = heightDeviceUnits > maxHeightDeviceUnits ? maxHeightDeviceUnits : heightDeviceUnits;
                heightDeviceUnits = heightDeviceUnits < MIN_BROWSER_HEIGHT_DEVICE_UNITS ? MIN_BROWSER_HEIGHT_DEVICE_UNITS : heightDeviceUnits;
                BrowserInteropHelper.HostBrowser.SetHeight(heightDeviceUnits);
            }
        }

        ///<SecurityNote>
        ///     Critical - Can be used to change the size of the browser
        ///     TreatAsSafe - clamps values so that window cannot be sized greater than desktop bounds.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        internal override void UpdateWidth(double newWidthLogicalUnits)
        {
            Point sizeDeviceUnits = LogicalToDeviceUnits(new Point(newWidthLogicalUnits, 0));
            uint widthDeviceUnits  = (uint)Math.Round(sizeDeviceUnits.X);

            if (BrowserInteropHelper.HostBrowser != null)
            {
                //
                // Note: right now IE is clipping browser width to desktop size.
                // However it should be clipped to available desktop size. See Windows OS Bug #1045038
                // The code below is to fix this for now.
                // Even if IE's code is changed - likely we keep this as defense in-depth.
                //
                uint maxWidthDeviceUnits = GetMaxWindowWidth();
                widthDeviceUnits = widthDeviceUnits > maxWidthDeviceUnits ? maxWidthDeviceUnits : widthDeviceUnits;

                widthDeviceUnits = widthDeviceUnits < MIN_BROWSER_WIDTH_DEVICE_UNITS ? MIN_BROWSER_WIDTH_DEVICE_UNITS : widthDeviceUnits;
                BrowserInteropHelper.HostBrowser.SetWidth(widthDeviceUnits);
            }
        }

        /// <summary>
        /// When being reloaded from history in the browser, we need to
        /// set up the journal again
        /// </summary>
        /// <param name="journal"></param>
        internal void SetJournalForBrowserInterop(Journal journal)
        {
            Invariant.Assert(journal != null, "Failed to get Journal for browser integration");
            base.JournalNavigationScope.Journal = journal;
        }

        void IJournalNavigationScopeHost.OnJournalAvailable()
        {
            base.Journal.BackForwardStateChange += new EventHandler(HandleBackForwardStateChange);
        }

        // For downlevel platforms, we don't have integration with the journal, so we have to
        // use our own Journal.
        ///<SecurityNote>
        ///     Critical - calls IBCS.GoBack
        ///</SecurityNote>
        [SecurityCritical]
        bool IJournalNavigationScopeHost.GoBackOverride()
        {
            if (HasTravelLogIntegration)
            {
                if (BrowserInteropHelper.HostBrowser != null)
                {
                    try
                    {
                        BrowserInteropHelper.HostBrowser.GoBack();
                    }
#pragma warning disable 6502 // PRESharp - Catch statements should not have empty bodies
                    catch (OperationCanceledException)
                    {
                        // Catch the OperationCanceledException when the navigation is canceled.
                        // See comments in applicationproxyinternal._LoadHistoryStreamDelegate.
                    }
#pragma warning restore 6502
                }
                return true;
            }
            return false; // Proceed with internal GoBack.
        }

        // For downlevel platforms, we don't have integration with the journal, so we have to
        // use our own Journal.
        ///<SecurityNote>
        ///     Critical - calls IBCS.GoForward
        ///</SecurityNote>
        [SecurityCritical]
        bool IJournalNavigationScopeHost.GoForwardOverride()
        {
            if (HasTravelLogIntegration)
            {
                if (BrowserInteropHelper.HostBrowser != null)
                {
                    try
                    {
                        BrowserInteropHelper.HostBrowser.GoForward();
                    }
#pragma warning disable 6502 // PRESharp - Catch statements should not have empty bodies
                    catch (OperationCanceledException)
                    {
                        // Catch the OperationCanceledException when the navigation is canceled.
                        // See comments in applicationproxyinternal._LoadHistoryStreamDelegate.
                    }
#pragma warning restore 6502
                }
                return true;
            }
            return false; // Proceed with internal GoForward.
        }

        internal override void VerifyApiSupported()
        {
            throw new InvalidOperationException(SR.Get(SRID.NotSupportedInBrowser));
        }

        internal override void ClearResizeGripControl(Control oldCtrl)
        {
            // don't do anything here since we do not support
            // ResizeGrip for RBW
        }

        internal override void SetResizeGripControl(Control ctrl)
        {
            // don't do anything here since we do not support
            // ResizeGrip for RBW
        }

        // This is called in weboc's static constructor.
        internal void AddLayoutUpdatedHandler()
        {
            LayoutUpdated += new EventHandler(OnLayoutUpdated);
        }

        internal void TabInto(bool forward)
        {
            TraversalRequest tr = new TraversalRequest(
                forward ? FocusNavigationDirection.First : FocusNavigationDirection.Last);
            MoveFocus(tr);
        }

        #endregion Internal Methods

        //----------------------------------------------
        //
        // Private Methods
        //
        //----------------------------------------------
        #region Private methods
        /// <summary>
        ///     Sets the correct style property on the RBW object based on the
        ///     browser version
        /// </summary>
        private void InitializeRBWStyle()
        {
            // If we are on a downlevel platform, then we don't integrate with the browser's
            // travellog, so we have to use our own Journal and supply our own navigation chrome.
            if (!HasTravelLogIntegration)
            {
                SetResourceReference(StyleProperty, SystemParameters.NavigationChromeDownLevelStyleKey);

                // if the Template property is not defined in a custom style, the property system gets
                // the Template property value for the NavigationWindow from the theme file.  Since,
                // we want to get the Template property value from the browser styles, we need to
                // set the DefaultStyleKeyProperty here.
                SetValue(DefaultStyleKeyProperty, SystemParameters.NavigationChromeDownLevelStyleKey);
            }
            else
            {
                SetResourceReference(StyleProperty, SystemParameters.NavigationChromeStyleKey);

                // if the Template property is not defined in a custom style, the property system gets
                // the Template property value for the NavigationWindow from the theme file.  Since,
                // we want to get the Template property value from the browser styles, we need to
                // set the DefaultStyleKeyProperty here.
                SetValue(DefaultStyleKeyProperty, SystemParameters.NavigationChromeStyleKey);
            }
        }

        /// <SecurityNote>
        ///     Critical - Elevates to get access to the HwndSource and installs hooks.
        ///     TreatAsSafe - The HwndSoure is not exposed. The message hooks installed are internal ones, and they are for the RBW specifically.
        /// </SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        private void SetUpInputHooks()
        {
            IKeyboardInputSink sink;
            new UIPermission(PermissionState.Unrestricted).Assert(); //BlessedAssert
            try
            {
                _inputPostFilter = new HwndWrapperHook(BrowserInteropHelper.PostFilterInput);
                HwndSource hwndSource = base.HwndSourceWindow;
                hwndSource.HwndWrapper.AddHookLast(_inputPostFilter);

                sink = (IKeyboardInputSink)hwndSource;
            }
            finally
            {
                UIPermission.RevertAll();
            }
            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); //BlessedAssert
            try
            {
                Debug.Assert(sink.KeyboardInputSite == null);
                sink.KeyboardInputSite = new KeyInputSite(new SecurityCriticalData<IKeyboardInputSink>(sink));
            }
            finally
            {
                SecurityPermission.RevertAll();
            }
        }

        /// <summary>
        ///     Updates browser size if Height/Width is not set to default value (NaN).  This
        ///     means that Height/Width was set prior to calling Show on RBW and we need to
        ///     propagate that to the browser.  This method is called from SetupInitialize which
        ///     is called from CreateSourceWindowImpl
        /// </summary>
        private void SetBrowserSize()
        {
            Point requestedSizeDeviceUnits = LogicalToDeviceUnits(new Point(this.Width, this.Height));

            // if Width was specified
            if (!DoubleUtil.IsNaN(this.Width))
            {
                // at this stage, ActualWidth/Height is not set since
                // layout has not happened (it happens when we set the
                // RootVisual of the HwndSource)
                UpdateWidth(requestedSizeDeviceUnits.X);
            }

            // if Height was specified
            if (!DoubleUtil.IsNaN(this.Height))
            {
                // at this stage, ActualWidth/Height is not set since
                // layout has not happened (it happens when we set the
                // RootVisual of the HwndSource)
                UpdateHeight(requestedSizeDeviceUnits.Y);
            }
        }

        private string PruneTitleString(string rawString)
        {
            StringBuilder sb = new StringBuilder();
            bool inMiddleOfWord = false;

            for (int i=0; i < rawString.Length; i++)
            {
                if (Char.IsWhiteSpace(rawString[i]) == false)
                {
                    sb.Append(rawString[i]);
                    inMiddleOfWord = true;
                }
                else
                {
                    if (inMiddleOfWord == true)
                    {
                        sb.Append(' ');
                        inMiddleOfWord = false;
                    }
                }
            }

            // remove the last space if it exists
            return sb.ToString().TrimEnd(' ');
        }

        private void OnLayoutUpdated(object obj, EventArgs args)
        {
            try
            {
                VerifyWebOCOverlap(NavigationService);
            }
            finally
            {
                _webBrowserList.Clear();
            }
        }

        private void VerifyWebOCOverlap(NavigationService navigationService)
        {
            for (int i = 0; i < navigationService.ChildNavigationServices.Count; i++)
            {
                NavigationService childNavService = (NavigationService)(navigationService.ChildNavigationServices[i]);
                WebBrowser webBrowser = childNavService.WebBrowser;
                if (webBrowser != null)
                {
                    for (int j = 0; j < _webBrowserList.Count; j++)
                    {
                        // Note: We are using WebBrowser.BoundRect, which is relative to parent window.
                        // Since WebBrowsers are all siblings child windows right now, e.g., we don't allow WebOC inside
                        // Popup window, this is a better performed way. If we change that, we should make sure the rects
                        // to compare are relative to desktop.
                        Rect rect = Rect.Intersect(webBrowser.BoundRect, _webBrowserList[j].BoundRect);
                        // Only when the intersect rect's Width and Height are both bigger than 0, we consider them overlapping.
                        // Even when 2 edges are next to each other, it is considered as intersect by the Rect class.
                        if ((rect.Width > 0) && (rect.Height > 0))
                        {
                            throw new InvalidOperationException(SR.Get(SRID.WebBrowserOverlap));
                        }
                    }
                    _webBrowserList.Add(webBrowser);
                }
                else
                {
                    VerifyWebOCOverlap(childNavService);
                }
            }
        }

        /// <summary>
        /// We are not using the CanGoBack/CanGoForward property change since that is fired only
        /// if the value changes eg. if we had 3 entries in the backstack, then a back navigation
        /// won't fire this since the value is still 'true' and has not changed.
        /// What we need is the UpdateView() notification or the BackForwardState change
        /// notification which is fired from UpdateView() of the Journal.
        /// Trying to hook the event will create the journal even if there was no navigation
        /// so just using an virtual override to do the work.
        /// </summary>
        ///<SecurityNote>
        ///     Critical - as this method calls into Browser call back method for back and forward.
        ///                This is a pinoke call.
        ///     TreatAsSafe - as this is a safe operation.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        private void HandleBackForwardStateChange(object sender, EventArgs args)
        {
            //Nothing to do for downlevel platform
            if (!HasTravelLogIntegration)
                return;

            IBrowserCallbackServices ibcs = Browser;
            if (ibcs != null)
            {
                ibcs.UpdateBackForwardState();
            }
        }

        ///<summary>
        /// Given a proposed width - and curWidth - return the MaxWidth the window can be opened to.
        /// Used to prevent sizing of window > desktop bounds in browser.
        ///</summary>
        ///<SecurityNote>
        /// Critical - calls back to browser to get the current left.
        /// TreatAsSafe - this value isn't returned or stored.
        ///               value returned is the current maximum width allowed considered safe.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe ]
        private uint GetMaxWindowWidth()
        {
            NativeMethods.RECT desktopArea = WorkAreaBoundsForNearestMonitor;
            int browserLeft = BrowserInteropHelper.HostBrowser.GetLeft();
            uint curBrowserWidth = BrowserInteropHelper.HostBrowser.GetWidth();

            uint availableWidth = (uint)(desktopArea.right - browserLeft);
            uint maxWidth = availableWidth > curBrowserWidth ? availableWidth : curBrowserWidth;
            return maxWidth;
        }

        ///<summary>
        /// Given a proposed height - and curHeight - return the MaxHeight the window can be opened to.
        /// Used to prevent sizing of window > desktop bounds in browser.
        ///</summary>
        ///<SecurityNote>
        /// Critical - calls back to browser to get the current top.
        /// TreatAsSafe - this value isn't returned or stored.
        ///               value returned is the current maximum height allowed considered safe.
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe ]
        private uint GetMaxWindowHeight()
        {
            NativeMethods.RECT desktopArea = WorkAreaBoundsForNearestMonitor;
            int browserTop = BrowserInteropHelper.HostBrowser.GetTop();
            uint curBrowserHeight = BrowserInteropHelper.HostBrowser.GetHeight();

            uint availableHeight = (uint)(desktopArea.bottom - browserTop);
            uint maxHeight = availableHeight > curBrowserHeight ? availableHeight : curBrowserHeight;
            return maxHeight;
        }

        ///<summary>
        ///For browser hosting cases, we get the rects through OLE activation before we create the
        ///RootBrowserWindow. Even if SourceWindow or Handle are null, we can return the cached rects
        ///</summary>
        private Size GetSizeInLogicalUnits()
        {
            Size size;

            // Adding check for IsCompositionTargetInvalid as part of the fix for WOSB 1453012
            if (IsSourceWindowNull || IsCompositionTargetInvalid)
            {
                // return _widthDeviceUnits & _heightDeviceUnits if hwndsource is not yet available.
                // We will resize when hwnd becomes available, because the DeviceToLogicalUnits calculation
                // depends on hwnd being available. If it's not high dpi, the second resize will be optimized
                // by layout system.
                size = new Size(_widthDeviceUnits, _heightDeviceUnits);
            }
            else
            {
                // It's better to get WindowSize instead of doing WindowSize.Width & WindowSize.Height
                // because WindowSize queries HwndSource.
                size = WindowSize;
                Point ptLogicalUnits = DeviceToLogicalUnits(new Point(size.Width, size.Height));
                size = new Size(ptLogicalUnits.X, ptLogicalUnits.Y);
            }

            return size;
        }

        /// <SecurityNote>
        ///     Critical - Sets the status bar text. Can be used to do URL spoofing.
        /// </SecurityNote>
        [SecurityCritical]
        private void OnRequestSetStatusBar_Hyperlink(object sender, RoutedEventArgs e)
        {
            RequestSetStatusBarEventArgs statusEvent = e as RequestSetStatusBarEventArgs;

            if ( statusEvent != null )
            {
                SetStatusBarText(statusEvent.Text);
            }
        }

        ///<summary>
        /// Prints the content of the App's MainWindow.  The logic is that if the content is not visual but IInputElement
        /// we will try to let it handle the command first. If it does not handle the print command we will get the corresponding
        /// visual in the visual tree and use that to print.
        ///</summary>
        private static void OnCommandPrint(object sender, ExecutedRoutedEventArgs e)
        {
#if !DONOTREFPRINTINGASMMETA
            RootBrowserWindow rbw = sender as RootBrowserWindow;
            Invariant.Assert(rbw != null);

            if (! rbw._isPrintingFromRBW)
            {
                Visual vis = rbw.Content as Visual;

                if (vis == null)
                {
                    // If the content is not Visual but IInputElement, try to let it handle the command first.
                    // This is for the document scenario. Printing a document is different from printing a visual.
                    // Printing a visual is to print how it is rendered on screen. Printing a doc prints the full
                    // doc inculding the part that is not visible. There might be other functionalities that are
                    // specific for document. FlowDocument's viewer knows how to print the doc.
                    IInputElement target = rbw.Content as IInputElement;

                    if (target != null)
                    {
                        // CanExecute will bubble up. If nobody between the content and rbw can handle it,
                        // It would call back on RBW again. Use _isPrintingFromRBW to prevent the loop.
                        rbw._isPrintingFromRBW = true;
                        try
                        {
                            if (ApplicationCommands.Print.CanExecute(null, target))
                            {
                                ApplicationCommands.Print.Execute(null, target);
                                return;
                            }
                        }
                        finally
                        {
                            rbw._isPrintingFromRBW = false;
                        }
                    }
                }

                // Let the user choose a printer and set print options.
                PrintDialog printDlg = new PrintDialog();

                // If the user pressed the OK button on the print dialog, we proceed
                if (printDlg.ShowDialog() == true)
                {
                    string printJobDescription = GetPrintJobDescription(App.MainWindow);

                    // If the root is not visual and does not know how to print itself, we find the
                    // corresponding visual and use that to print.
                    if (vis == null)
                    {
                        INavigatorImpl navigator = rbw as INavigatorImpl;
                        Invariant.Assert(navigator != null);

                        vis = navigator.FindRootViewer();
                        Invariant.Assert(vis != null);
                    }

                    // Area we can print to for the chosen printer
                    Rect imageableRect = GetImageableRect(printDlg);

                    // We print Visuals aligned with the top/left corner of the printable area.
                    // We do not attempt to print very large Visuals across multiple pages.
                    // Any portion that doesn't fit on a single page will get cropped by the
                    // print system.

                    // Used to draw our visual into another visual for printing purposes
                    VisualBrush visualBrush = new VisualBrush(vis);
                    visualBrush.Stretch = Stretch.None;

                    // Visual we will print - containing a rectangle the size of our
                    // original Visual but offset into the printable area
                    DrawingVisual drawingVisual = new DrawingVisual();
                    DrawingContext context = drawingVisual.RenderOpen();
                    context.DrawRectangle(visualBrush,
                                          null,
                                          new Rect(imageableRect.X,
                                                   imageableRect.Y,
                                                   vis.VisualDescendantBounds.Width,
                                                   vis.VisualDescendantBounds.Height));
                    context.Close();

                    printDlg.PrintVisual(drawingVisual, printJobDescription);
                }
            }
#endif // DONOTREFPRINTINGASMMETA
        }

        private static void OnQueryEnabledCommandPrint(object sender, CanExecuteRoutedEventArgs  e)
        {
            RootBrowserWindow rbw = sender as RootBrowserWindow;
            Invariant.Assert(rbw != null);

            if ((!e.Handled) && (!rbw._isPrintingFromRBW))
            {
                // While we could print null it doesn't really make sense to do so
                e.CanExecute = rbw.Content != null;
            }
        }

#if !DONOTREFPRINTINGASMMETA
        ///<SecurityNote>
        /// Critical - calls out to PrintDialog to get the PrintQueue and its PrintCapabilities
        /// TreatAsSafe - these values aren't returned or stored
        ///</SecurityNote>
        [SecurityCritical, SecurityTreatAsSafe]
        private static Rect GetImageableRect(PrintDialog dialog)
        {
            Rect imageableRect = Rect.Empty;

            Invariant.Assert(dialog != null, "Dialog should not be null.");

            System.Printing.PrintQueue queue = null;
            System.Printing.PrintCapabilities capabilities = null;
            System.Printing.PageImageableArea imageableArea = null;

            // This gets the PringDocumentImageableArea.OriginWidth/OriginHeight
            // of the PrintQueue the user chose in the dialog.
            CodeAccessPermission printp = SystemDrawingHelper.NewDefaultPrintingPermission();
            printp.Assert();//Blessed Assert to get PrintQueue and call GetPrintCapabilities
            try
            {
                queue = dialog.PrintQueue;
                if (queue != null)
                {
                    capabilities = queue.GetPrintCapabilities();
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }

            if (capabilities != null)
            {
                imageableArea = capabilities.PageImageableArea;
                if (imageableArea != null)
                {
                    imageableRect = new Rect(imageableArea.OriginWidth,
                                             imageableArea.OriginHeight,
                                             imageableArea.ExtentWidth,
                                             imageableArea.ExtentHeight);
                }
            }

            // If for any reason we couldn't get the actual printer's values
            // we fallback to a constant and the values available from the
            // PrintDialog.
            if (imageableRect == Rect.Empty)
            {
                imageableRect = new Rect(NON_PRINTABLE_MARGIN,
                    NON_PRINTABLE_MARGIN,
                    dialog.PrintableAreaWidth,
                    dialog.PrintableAreaHeight);
            }

            return imageableRect;
        }
#endif

        /// <summary>
        ///    Generate the title of the print job for a given Window.
        /// </summary>
        private static string GetPrintJobDescription(Window window)
        {
            Invariant.Assert(window != null, "Window should not be null.");

            string description = null;
            string pageTitle = null;

            // Get the window title
            string windowTitle = window.Title;
            if (windowTitle != null)
            {
                windowTitle = windowTitle.Trim();
            }

            // Get the page title, if available
            Page page = window.Content as Page;
            if (page != null)
            {
                pageTitle = page.Title;
                if (pageTitle != null)
                {
                    pageTitle = pageTitle.Trim();
                }
            }

            // If window and page title are available, use them together,
            // otherwise use which ever is available
            if (!String.IsNullOrEmpty(windowTitle))
            {
                if (!String.IsNullOrEmpty(pageTitle))
                {
                    description = SR.Get(SRID.PrintJobDescription, windowTitle, pageTitle);
                }
                else
                {
                    description = windowTitle;
                }
            }

            // No window title so use the page title on its own
            if (description == null && !String.IsNullOrEmpty(pageTitle))
            {
                description = pageTitle;
            }

            // If neither window or page titles are available, try and use
            // the source URI for the content
            if (description == null && BrowserInteropHelper.Source != null)
            {
                Uri source = BrowserInteropHelper.Source;
                if (source.IsFile)
                {
                    description = source.LocalPath;
                }
                else
                {
                    description = source.ToString();
                }
            }

            // If no other option, use a localized constant
            if (description == null)
            {
                description = SR.Get(SRID.UntitledPrintJobDescription);
            }

            return description;
        }

        #endregion Private methods

        //----------------------------------------------
        //
        // Private Properties
        //
        //----------------------------------------------
        #region Private properties
        private static Application App
        {
            get { return Application.Current; }
        }

        private static IBrowserCallbackServices Browser
        {
            get
            {
                // There will be no IBrowserCallbackServices available in some situations, e.g., during shutdown
                IBrowserCallbackServices ibcs = (App == null ? null : App.BrowserCallbackServices);
                return ibcs;
            }
        }

        ///<SecurityNote>
        /// Critical - calls the SUC'd IBCS.IsDownlevelPlatform.
        /// TreatAsSafe - this information is okay to give out.
        ///</SecurityNote>
        private bool IsDownlevelPlatform
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            {
                if (!_isDownlevelPlatformValid)
                {
                    IBrowserCallbackServices ibcs = Browser;
                    _isDownlevelPlatform = (ibcs != null) ? ibcs.IsDownlevelPlatform() : false;

                    _isDownlevelPlatformValid = true;
                }

                return _isDownlevelPlatform;
            }
        }

        internal bool HasTravelLogIntegration
        {
            get
            {
                return !IsDownlevelPlatform && BrowserInteropHelper.IsAvalonTopLevel;
            }
        }

        #endregion Private properties

        //----------------------------------------------
        //
        // Private Classes
        //
        //----------------------------------------------
        #region Private Classes

        /// <summary>
        /// This class is used to print objects which are not directly supported by XpsDocumentWriter.
        /// It's sole purpose is to make a non-abstract version of Visual.
        /// </summary>
        private class PrintVisual : ContainerVisual { }

        private class KeyInputSite : IKeyboardInputSite
        {
            internal KeyInputSite(SecurityCriticalData<IKeyboardInputSink> sink)
            {
                _sink = sink;
            }

            /// <SecurityNote>
            /// Critical: sets critical data.
            /// Safe: setting to null is okay.
            /// </SecurityNote>
            [SecurityCritical, SecurityTreatAsSafe]
            void IKeyboardInputSite.Unregister()
            {
                _sink = new SecurityCriticalData<IKeyboardInputSink>(null);
            }

            /// <SecurityNote>
            /// Critical: IKeyboardInputSink could be used to spoof input.
            /// </SecurityNote>
            IKeyboardInputSink IKeyboardInputSite.Sink
            {
                [SecurityCritical]
                get { return _sink.Value; }
            }

            /// <SecurityNote>
            /// Critical: calls the SUC'd IBCS.TabOut().
            /// Safe: tabbing out of the application is safe.
            /// </SecurityNote>
            [SecurityCritical, SecurityTreatAsSafe]
            bool IKeyboardInputSite.OnNoMoreTabStops(TraversalRequest request)
            {
                return Browser.TabOut(request.FocusNavigationDirection == FocusNavigationDirection.Next);
                // i. Tabbing-in is handled by ApplicationProxyInternal.
            }

            /// <SecurityNote>
            /// Critical: The encapsulated interface could be used to spoof input.
            /// </SecurityNote>
            SecurityCriticalData<IKeyboardInputSink> _sink;
        };

        #endregion Private Classes

        //----------------------------------------------
        //
        // Private Members
        //
        //----------------------------------------------
        #region private members

        //Cache the values until the HwndSourceWindow is created
        private int  _xDeviceUnits, _yDeviceUnits, _widthDeviceUnits, _heightDeviceUnits;
        private bool _rectSet;

        private bool _isPrintingFromRBW;
        private bool _isDownlevelPlatformValid;
        private bool _isDownlevelPlatform;
        private bool _sourceWindowCreationCompleted;

        private List<WebBrowser> _webBrowserList = new List<WebBrowser>();

        /// <summary>
        /// The event delegate has to be stored because HwndWrapper keeps only a weak reference to it.
        /// </summary>
        /// <SecurityNote>
        /// Critical: could be used to spoof input
        /// </SecurityNote>
        [SecurityCritical]
        private HwndWrapperHook _inputPostFilter;

        private bool _loadingCompletePosted;
        const int READYSTATE_COMPLETE = 4;

        // Fallback constant for the size of non-printable margin.  This is used if
        // we cant retrieve the actual size from the PrintQueue.
        private const int NON_PRINTABLE_MARGIN = 15;

        //
        // Setting these as the min-browser width & height.
        // Note that we can't use User's min window-width & height - these are specifically about browser window.
        //
        private const int MIN_BROWSER_WIDTH_DEVICE_UNITS = 200;

        private const int MIN_BROWSER_HEIGHT_DEVICE_UNITS = 200;
        #endregion private members
    }
}


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jayktec.dialoga.dialogacore.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author jayktec
 */
@Entity
@Table(name = "wow_tabla")
@NamedQueries({
    @NamedQuery(name = "WowTabla.findAll", query = "SELECT w FROM WowTabla w")
    , @NamedQuery(name = "WowTabla.findByIdTabla", query = "SELECT w FROM WowTabla w WHERE w.idTabla = :idTabla")
    , @NamedQuery(name = "WowTabla.findByTabNemonico", query = "SELECT w FROM WowTabla w WHERE w.tabNemonico = :tabNemonico")
    , @NamedQuery(name = "WowTabla.findByTabNombre", query = "SELECT w FROM WowTabla w WHERE w.tabNombre = :tabNombre")
    , @NamedQuery(name = "WowTabla.findByTabDescripcion", query = "SELECT w FROM WowTabla w WHERE w.tabDescripcion = :tabDescripcion")})
public class WowTabla implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_tabla")
    private Integer idTabla;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "tab_nemonico")
    private String tabNemonico;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "tab_nombre")
    private String tabNombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 120)
    @Column(name = "tab_descripcion")
    private String tabDescripcion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "catTabla")
    private Collection<WowCatalogo> wowCatalogoCollection;

    public WowTabla() {
    }

    public WowTabla(Integer idTabla) {
        this.idTabla = idTabla;
    }

    public WowTabla(Integer idTabla, String tabNemonico, String tabNombre, String tabDescripcion) {
        this.idTabla = idTabla;
        this.tabNemonico = tabNemonico;
        this.tabNombre = tabNombre;
        this.tabDescripcion = tabDescripcion;
    }

    public Integer getIdTabla() {
        return idTabla;
    }

    public void setIdTabla(Integer idTabla) {
        this.idTabla = idTabla;
    }

    public String getTabNemonico() {
        return tabNemonico;
    }

    public void setTabNemonico(String tabNemonico) {
        this.tabNemonico = tabNemonico;
    }

    public String getTabNombre() {
        return tabNombre;
    }

    public void setTabNombre(String tabNombre) {
        this.tabNombre = tabNombre;
    }

    public String getTabDescripcion() {
        return tabDescripcion;
    }

    public void setTabDescripcion(String tabDescripcion) {
        this.tabDescripcion = tabDescripcion;
    }

    public Collection<WowCatalogo> getWowCatalogoCollection() {
        return wowCatalogoCollection;
    }

    public void setWowCatalogoCollection(Collection<WowCatalogo> wowCatalogoCollection) {
        this.wowCatalogoCollection = wowCatalogoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTabla != null ? idTabla.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof WowTabla)) {
            return false;
        }
        WowTabla other = (WowTabla) object;
        if ((this.idTabla == null && other.idTabla != null) || (this.idTabla != null && !this.idTabla.equals(other.idTabla))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jayktec.dialoga.dialogacore.entity.WowTabla[ idTabla=" + idTabla + " ]";
    }

}


text:
<select name="ano_<?echo $numero;?>" size="1">
<option value='' selected >AÑO</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
</select>

<select name="mes_<?echo $numero;?>" size="1">
<option value='' selected >MES</option>
<option value="01">Enero</option>
<option value="02">Febrero</option>
<option value="03">Marzo</option>
<option value="04">Abril</option>
<option value="05">Mayo</option>
<option value="06">Junio</option>
<option value="07">Julio</option>
<option value="08">Agosto</option>
<option value="09">Septiembre</option>
<option value="10">Octubre</option>
<option value="11">Noviembre</option>
<option value="12">Diciembre</option>
</select>

<select name="dia_<?echo $numero;?>" size="1">
<option value='' selected >DÍA</option>
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>

<?php
$control_version = '0aa0b6b3207f0b3839381db1962574a2';

?>


text:
package authoring_environment.room;

public class InvalidConfigureException extends Exception {
	private String myBadInput;

	public InvalidConfigureException(String badInput) {
		super(badInput);
		myBadInput = badInput;
	}

	public String getBadInput() {
		return myBadInput;
	}
}


text:
using System;
using System.Collections.Generic;

namespace SemanticReleaseNotesParser.Logging
{
    internal static class ConsoleLogAction
    {
        private static readonly Dictionary<LogLevel, ConsoleColor> Colors = new Dictionary<LogLevel, ConsoleColor>
             {
                 { LogLevel.Error, ConsoleColor.DarkRed },
                 { LogLevel.Info, ConsoleColor.White },
                 { LogLevel.Debug, ConsoleColor.Gray }
             };

        internal static void Write(string message, LogLevel traceLevel)
        {
            ConsoleColor consoleColor;

            if (Colors.TryGetValue(traceLevel, out consoleColor))
            {
                var originalForground = Console.ForegroundColor;
                try
                {
                    Console.ForegroundColor = consoleColor;
                    Console.WriteLine(message);
                }
                finally
                {
                    Console.ForegroundColor = originalForground;
                }
            }
            else
            {
                Console.WriteLine(message);
            }

        }
    }
}


text:
Translated to PHP from [ooflorent/graphql-parser](https://github.com/ooflorent/graphql-parser)

[![Build Status](https://travis-ci.org/pdziok/graphql-php-parser.svg?branch=master)](https://travis-ci.org/pdziok/graphql-php-parser)

## Installation

The suggested installation method is via [composer](https://getcomposer.org/):

```sh
composer require "paweldziok/graphql-php-parser"
```

## Usage

TODO

## Contributing

* Fork the project.
* Make your bug fix or feature addition.
* Add tests for it.
* Send a pull request.


text:
package com.jarkkovallius.ohjelmointi2.harjoitus2;

import java.util.Scanner;
import com.jarkkovallius.ohjelmointi2.harjoitus2.MobilePhoneSubscription.PhoneCallPackage;
import com.jarkkovallius.ohjelmointi2.harjoitus2.MobilePhoneSubscription.TextMessagePackage;;

/*
Tehtävä	1
Kirjoita	Java-ohjelma,	jolla	kännykkäliittymän	myyjä	tallentaa	liittymän	tiedot	yksinkertaisiin
muuttujiin	ja	tulostaa	ne	lopuksi	näkyville.	Ohjelma	kysyy	seuraavat	asiat:

a)	puheluiden	laskutus	minuuttien	määrän	mukaan	(5	snt/min)	vai	puhepakettina?
b)	jos	puhepaketti,	niin	onko	koko	100	(5	€),	200	(10 €)	vai	500	(15 €)	minuuttia?

c)	onko	tekstaripaketti	vai	laskutetaanko	tekstarit	erikseen	(10	snt/kpl)?
d)	jos	on	tekstaripaketti,	niin	onko	50	(1 €),	100	(2 €)	vai	200	(3 €)	tekstaria?

e)	kuuluuko	nettiliittymä	(kyllä	tai	ei)
f)	jos	kuuluu	nettiliittymä,	niin	onko	laskutus	tiedon	määrän	mukaan	(2€ /	Mt)	vai
kuukausimaksu	(10 €)?

Lopuksi	ohjelma	tulostaa	liittymän	tiedot	ja	kuukausimaksut	näkyville.

Ohjelma	toimii	merkkipohjaisesti,	eikä	siinä	tarvitse	olla	graafista	käyttöliittymää,	halutessasi
voit	toki	sellaisen	tehdä.

Tiedot	tallennetaan	muuttujiin	ja	niitä	ei	tallenneta	tiedostoon
myöhempää	käyttöä	varten. Mieti	miten	ohjelmassa	voisi	käyttää	totuusarvomuuttujia?
*/

public class Tehtava1 {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int input ;
		boolean inputError ;

		MobilePhoneSubscription subscription = new MobilePhoneSubscription();

		// puhelun minuuttihinta
		subscription.phoneCallPricePerMinute = 0.05f ;

		// puhepaketit
		subscription.availablePhoneCallPackages = new PhoneCallPackage[]
				{
					subscription.new PhoneCallPackage(100, 5),
					subscription.new PhoneCallPackage(200, 10),
					subscription.new PhoneCallPackage(500, 15)
				} ;

		// tekstarin hinta
		subscription.textMessagePrice = 0.10f ;

		// tekstaripaketit
		subscription.availableTextMessagePackages = new TextMessagePackage[]
				{
					subscription.new TextMessagePackage(50, 1),
					subscription.new TextMessagePackage(100, 2),
					subscription.new TextMessagePackage(200, 3)
				} ;

		// datan kk-hinta
		subscription.mobileDataPriceMonthly = 10f ;

		// data / megatavu
		subscription.mobileDataPricePerMegabyte = 2f ;

		/*
		 * Puhelun laskutuksen valinta
		 */

		System.out.println("Puheluiden laskutus");
		System.out.println("1 = minuuttiveloitus");
		System.out.println("2 = puhepaketti");

		do {
			inputError = false ;
			input = scanner.nextInt() ;

			switch (input) {
				case 1:
					subscription.selectedPhoneCallBillingType = MobilePhoneSubscription.PHONE_CALL_BILLING_TYPE_PER_MINUTE ;
					break ;
				case 2:
					subscription.selectedPhoneCallBillingType = MobilePhoneSubscription.PHONE_CALL_BILLING_TYPE_PACKAGE ;
					break;
				default:
					inputError = true ;
					System.out.println("Virheellinen syöte");
			}

		} while (inputError) ;

		/*
		 * Puhepaketin valinta
		 */

		if (subscription.selectedPhoneCallBillingType == MobilePhoneSubscription.PHONE_CALL_BILLING_TYPE_PACKAGE) {

			System.out.println("Puhepaketin koko");
			System.out.println("1 = " + subscription.availablePhoneCallPackages[0].minutes + " minuuttia");
			System.out.println("2 = " + subscription.availablePhoneCallPackages[1].minutes + " minuuttia");
			System.out.println("3 = " + subscription.availablePhoneCallPackages[2].minutes + " minuuttia");

			do {
				inputError = false ;
				input = scanner.nextInt() ;

				switch (input) {
					case 1:
					case 2:
					case 3:
						subscription.selectedPhoneCallPackage = subscription.availablePhoneCallPackages[input-1] ;
						break;
					default:
						inputError = true ;
						System.out.println("Virheellinen syöte");
				}

			} while (inputError) ;

		}

		/*
		 * Tekstarin laskutuksen valinta
		 */

		System.out.println("Tekstiviestien laskutus");
		System.out.println("1 = kappaleveloitus");
		System.out.println("2 = tekstiviestipaketti");

		do {
			inputError = false ;
			input = scanner.nextInt() ;

			switch (input) {
				case 1:
					subscription.selectedTextMessageBillingType = MobilePhoneSubscription.TEXT_MESSAGE_BILLING_TYPE_PER_MESSAGE ;
					break ;
				case 2:
					subscription.selectedTextMessageBillingType = MobilePhoneSubscription.TEXT_MESSAGE_BILLING_TYPE_PACKAGE ;
					break;
				default:
					inputError = true ;
					System.out.println("Virheellinen syöte");
			}

		} while (inputError) ;

		/*
		 * Tekstaripaketin valinta
		 */

		if (subscription.selectedTextMessageBillingType == MobilePhoneSubscription.TEXT_MESSAGE_BILLING_TYPE_PACKAGE) {

			System.out.println("Tekstiviestipaketin koko");
			System.out.println("1 = " + subscription.availableTextMessagePackages[0].messages + " kappaletta");
			System.out.println("2 = " + subscription.availableTextMessagePackages[1].messages + " kappaletta");
			System.out.println("3 = " + subscription.availableTextMessagePackages[2].messages + " kappaletta");

			do {
				inputError = false ;
				input = scanner.nextInt() ;

				switch (input) {
					case 1:
					case 2:
					case 3:
						subscription.selectedTextMessagePackage = subscription.availableTextMessagePackages[input-1] ;
						break;
					default:
						inputError = true ;
						System.out.println("Virheellinen syöte");
				}

			} while (inputError) ;

		}

		/*
		 * Datapaketin valinta
		 */

		System.out.println("Mobiilidatapaketti");
		System.out.println("1 = kyllä");
		System.out.println("2 = ei");

		do {
			inputError = false ;
			input = scanner.nextInt() ;

			switch (input) {
				case 1:
					subscription.mobileDataEnabled = true ;
					break ;
				case 2:
					subscription.mobileDataEnabled = false ;
					break;
				default:
					inputError = true ;
					System.out.println("Virheellinen syöte");
			}

		} while (inputError) ;

		/*
		 * Datapaketin tyypin valinta
		 */

		if (subscription.mobileDataEnabled) {

			System.out.println("Mobiilidatapaketin tyyppi");
			System.out.println("1 = laskutus käytön mukaan (" + subscription.mobileDataPricePerMegabyte + " euroa/Mt)");
			System.out.println("2 = kk-maksu (" + subscription.mobileDataPriceMonthly +" euroa/kk)");

			do {
				inputError = false ;
				input = scanner.nextInt() ;

				switch (input) {
					case 1:
						subscription.selectedMobileDataBillingType = MobilePhoneSubscription.MOBILE_DATA_BILLING_TYPE_PER_MEGABYTE ;
						break;
					case 2:
						subscription.selectedMobileDataBillingType = MobilePhoneSubscription.MOBILE_DATA_BILLING_TYPE_MONTHLY ;
						break;
					default:
						inputError = true ;
						System.out.println("Virheellinen syöte");
				}

			} while (inputError) ;

		}

		System.out.println("Liitymän tiedot");
		System.out.println("---------------");

		System.out.println("Puhelut");
		if (subscription.selectedPhoneCallBillingType == MobilePhoneSubscription.PHONE_CALL_BILLING_TYPE_PER_MINUTE) {
			System.out.println("- minuuttiveloitus: " + subscription.phoneCallPricePerMinute + " euroa/minuutti");
		} else {
			System.out.println("- puhepaketti: "
					+ subscription.selectedPhoneCallPackage.minutes + " minuuttia ("
					+ subscription.selectedPhoneCallPackage.price + "e)");
		}

		System.out.println("Tekstiviestit");
		if (subscription.selectedTextMessageBillingType == MobilePhoneSubscription.TEXT_MESSAGE_BILLING_TYPE_PER_MESSAGE) {
			System.out.println("- viestit " + subscription.textMessagePrice + " euroa/kappale");
		} else {
			System.out.println("- viestipaketti: "
					+ subscription.selectedTextMessagePackage.messages + " viestiä ("
					+ subscription.selectedTextMessagePackage.price + "e)");

		}

		if (subscription.mobileDataEnabled) {
			System.out.println("Mobiilidata");
			if (subscription.selectedMobileDataBillingType == MobilePhoneSubscription.MOBILE_DATA_BILLING_TYPE_PER_MEGABYTE) {
				System.out.println("- data " + subscription.mobileDataPricePerMegabyte + " euroa/Mt");
			} else {
				System.out.println("- data " + subscription.mobileDataPriceMonthly + " euroa/kk");
			}
		}

		scanner.close();
	}
}


text:
package com.github.kevinjava.pattern.build.builder;

public class DialogBuilder {
	String title;
	String contentView;
	String buttons;
	public DialogBuilder setTitle(){
		title = "has dialog title";
		return this;
	}

	public DialogBuilder setContentView(){
		contentView = "has Content View";
		return this;
	}

	public DialogBuilder setButtons(){
		buttons = "has click Buttons";
		return this;
	}

	public void print(){
		System.out.println(title);
		System.out.println(contentView);
		System.out.println(buttons);
	}
}


text:
package io.sentry.samples.spring.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;

@SpringBootApplication
@EnableScheduling
public class SentryDemoApplication {
  public static void main(String[] args) {
    SpringApplication.run(SentryDemoApplication.class, args);
  }

  @Bean
  RestTemplate restTemplate(RestTemplateBuilder builder) {
    return builder.build();
  }

  @Bean
  WebClient webClient(WebClient.Builder builder) {
    return builder.build();
  }
}