text:
using namespace llvm;
using namespace llvm::pdb;

DIAEnumInjectedSources::DIAEnumInjectedSources(
    const DIASession &PDBSession,
    CComPtr<IDiaEnumInjectedSources> DiaEnumerator)
    : Session(PDBSession), Enumerator(DiaEnumerator) {}

uint32_t DIAEnumInjectedSources::getChildCount() const {
  LONG Count = 0;
  return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
}

std::unique_ptr<IPDBInjectedSource>
DIAEnumInjectedSources::getChildAtIndex(uint32_t Index) const {
  CComPtr<IDiaInjectedSource> Item;
  if (S_OK != Enumerator->Item(Index, &Item))
    return nullptr;

  return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item));
}

std::unique_ptr<IPDBInjectedSource> DIAEnumInjectedSources::getNext() {
  CComPtr<IDiaInjectedSource> Item;
  ULONG NumFetched = 0;
  if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
    return nullptr;

  return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item));
}

void DIAEnumInjectedSources::reset() { Enumerator->Reset(); }

DIAEnumInjectedSources *DIAEnumInjectedSources::clone() const {
  CComPtr<IDiaEnumInjectedSources> EnumeratorClone;
  if (S_OK != Enumerator->Clone(&EnumeratorClone))
    return nullptr;
  return new DIAEnumInjectedSources(Session, EnumeratorClone);
}


text:
using System;
using System.ComponentModel;
using System.Linq.Expressions;

namespace MyTimers.Model.View
{
    public class NotifyPropertyChanged
        : INotifyPropertyChanged
    {
        #region -- INotifyPropertyChanged Members --

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged<TSource, TKey>(TSource source, Expression<Func<TSource, TKey>> propertySelector)
        {
            var changedHandler = PropertyChanged;

            if (changedHandler != null)
            {
                changedHandler(source,
                    new PropertyChangedEventArgs(((MemberExpression)(propertySelector.Body)).Member.Name));
            }
        }

        protected void OnPropertiesChanged<TSource>(TSource source)
        {
            var changedHandler = PropertyChanged;

            if (changedHandler != null)
            {
                changedHandler(source, AllPropertiesChangedEventArgs);
            }
        }
        private static readonly PropertyChangedEventArgs AllPropertiesChangedEventArgs = new PropertyChangedEventArgs(String.Empty);

        public void RemoveAllHandlers()
        {
            var changedHandler = PropertyChanged;

            if (changedHandler != null)
            {
                foreach (var handler in changedHandler.GetInvocationList())
                {
                    changedHandler -= (PropertyChangedEventHandler)handler;
                }
            }
        }

        #endregion
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.apache.camel</groupId>
    <artifactId>components</artifactId>
    <version>2.16-SNAPSHOT</version>
  </parent>

  <artifactId>camel-cxf-transport</artifactId>
  <packaging>bundle</packaging>
  <name>Camel :: CXF :: Transport</name>
  <description>Camel Transport for CXF </description>

   <properties>
    <camel.osgi.import>
      !org.apache.camel.component.cxf.*,
      !META-INF.cxf.camel,
      javax.activation*;version="[0.0,2)",
      javax.annotation*;version="[0.0,2)",
      javax.jws*;version="[0.0,3)",
      javax.ws.rs*;version="[0.0,2)",
      javax.xml.stream*;version="[0.0,2)",
      javax.xml.ws*;version="[0.0,3.0)",
      javax.servlet*;resolution="optional";version="[0,4)",
      org.apache.camel.*;${camel.osgi.import.camel.version},
      org.springframework*;version="${spring-version-range}";resolution:=optional,
      ${camel.osgi.import.defaults},
      ${camel.osgi.import.additional},
      org.osgi.framework;resolution:=optional,
      org.apache.aries.blueprint*;resolution:=optional,
      org.osgi.service.blueprint*;resolution:=optional,
      *
    </camel.osgi.import>

    <camel.osgi.export>
      org.apache.camel.component.cxf.*;${camel.osgi.version};-split-package:=merge-first,
      '=META-INF.cxf.camel'
    </camel.osgi.export>
    <camel.osgi.failok>true</camel.osgi.failok>

  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-bindings-soap</artifactId>
      <version>${cxf-version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
    </dependency>

    <!-- OSGi, Blueprint -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-blueprint</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.compendium</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.aries.blueprint</groupId>
      <artifactId>org.apache.aries.blueprint.core</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- for testing -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-jetty8</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-testutils</artifactId>
      <version>${cxf-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
      <version>${cxf-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>${httpclient4-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
      <version>${cxf-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymockclassextension</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkCount>1</forkCount>
	  <reuseForks>false</reuseForks>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-test-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot>
              <defaultOptions>
                  <frontEnd>jaxws21</frontEnd>
              </defaultOptions>
              <wsdlOptions>
                <wsdlOption>
                  <wsdl>${basedir}/src/test/resources/person.wsdl</wsdl>
                </wsdlOption>
              </wsdlOptions>
            </configuration>
            <goals>
              <goal>wsdl2java</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>


text:
pushd $SRC_DIR/src
./autogen.sh
./configure --prefix=$PREFIX --with-bamtools=$PREFIX  && make && make install


text:
<?php

    if (!class_exists('DOPBSPViewsBackEndRules')){
        class DOPBSPViewsBackEndRules extends DOPBSPViewsBackEnd{
            /*
             * Constructor
             */
            function __construct(){
            }

            /*
             * Returns rules template.
             *
             * @param args (array): function arguments
             *
             * @return rules HTML page
             */
            function template($args = array()){
                global $DOPBSP;

                $this->getTranslation();
?>

        <?php $this->displayHeader($DOPBSP->text('TITLE'), $DOPBSP->text('RULES_TITLE')); ?>
        <input type="hidden" name="DOPBSP-rule-ID" id="DOPBSP-rule-ID" value="" />

                <colgroup>
                    <col id="DOPBSP-col-column1" class="dopbsp-column1" />
                    <col id="DOPBSP-col-column-separator1" class="dopbsp-separator" />
                    <col id="DOPBSP-col-column2" class="dopbsp-column2" />
                </colgroup>

<?php
                if (isset($_GET['page'])
                        && $DOPBSP->classes->backend_settings_users->permission(wp_get_current_user()->ID, 'use-booking-system')){
?>
                                <?php echo $DOPBSP->text('RULES_ADD_RULE_SUBMIT'); ?>
                                <a href="<?php echo DOPBSP_CONFIG_HELP_DOCUMENTATION_URL; ?>" target="_blank" class="dopbsp-button dopbsp-help"><?php echo $DOPBSP->text('RULES_HELP').'

'.$DOPBSP->text('RULES_ADD_RULE_HELP').'

'.$DOPBSP->text('HELP_VIEW_DOCUMENTATION'); ?>
<?php
                }
                else{
?>
				<a href="<?php echo DOPBSP_CONFIG_HELP_DOCUMENTATION_URL; ?>" target="_blank" class="dopbsp-button dopbsp-help"><?php echo $DOPBSP->text('RULES_HELP').'

'.$DOPBSP->text('HELP_VIEW_DOCUMENTATION'); ?>
<?php
                }
?>

<?php
            }
        }
    }


text:
<!doctype html>

    <title>Shopping List Check Off</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles/bootstrap.min.css">

        YSF NG-PLAYGROUND

Shopping List Check Off

      <form class="form-inline">

         Item Name:
         <input type="text" ng-model="buyController.itemName" class="form-control">

         Quantity:
         <input type="text" class="form-control" ng-model="buyController.itemQuantity">

       <button type="submit" class="btn btn-default" ng-click="buyController.addNewItem()">Add </button>
     </form>

To Buy: {{ buyController.items.length}} item(s)

Buy {{item.quantity}} {{item.name}}
         <button ng-click="buyController.addToBoughtList($index)" class="btn btn-default"> Bought</button>

Everything is bought!

Already Bought: {{ boughtController.items.length}} item(s)

Bought {{ item.quantity }} {{item.name}}

Nothing bought yet.

         Checkout my other projects in my Github


text:
import * as nls from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { URI as uri } from 'vs/base/common/uri';
import { first, distinct } from 'vs/base/common/arrays';
import * as errors from 'vs/base/common/errors';
import severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
import * as aria from 'vs/base/browser/ui/aria/aria';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IMarkerService } from 'vs/platform/markers/common/markers';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { FileChangesEvent, FileChangeType, IFileService } from 'vs/platform/files/common/files';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { DebugModel, ExceptionBreakpoint, FunctionBreakpoint, Breakpoint, Expression } from 'vs/workbench/parts/debug/common/debugModel';
import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel';
import * as debugactions from 'vs/workbench/parts/debug/browser/debugActions';
import { ConfigurationManager } from 'vs/workbench/parts/debug/electron-browser/debugConfigurationManager';
import Constants from 'vs/workbench/parts/markers/electron-browser/constants';
import { ITaskService, ITaskSummary } from 'vs/workbench/parts/tasks/common/taskService';
import { TaskError } from 'vs/workbench/parts/tasks/common/taskSystem';
import { VIEWLET_ID as EXPLORER_VIEWLET_ID } from 'vs/workbench/parts/files/common/files';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { EXTENSION_LOG_BROADCAST_CHANNEL, EXTENSION_ATTACH_BROADCAST_CHANNEL, EXTENSION_TERMINATE_BROADCAST_CHANNEL, EXTENSION_RELOAD_BROADCAST_CHANNEL, EXTENSION_CLOSE_EXTHOST_BROADCAST_CHANNEL } from 'vs/platform/extensions/common/extensionHost';
import { IBroadcastService } from 'vs/platform/broadcast/electron-browser/broadcastService';
import { IRemoteConsoleLog, parse, getFirstFrame } from 'vs/base/node/console';
import { TaskEvent, TaskEventKind, TaskIdentifier } from 'vs/workbench/parts/tasks/common/tasks';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IAction, Action } from 'vs/base/common/actions';
import { deepClone, equals } from 'vs/base/common/objects';
import { DebugSession } from 'vs/workbench/parts/debug/electron-browser/debugSession';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { IDebugService, State, IDebugSession, CONTEXT_DEBUG_TYPE, CONTEXT_DEBUG_STATE, CONTEXT_IN_DEBUG_MODE, IThread, IDebugConfiguration, VIEWLET_ID, REPL_ID, IConfig, ILaunch, IViewModel, IConfigurationManager, IDebugModel, IEnablement, IBreakpoint, IBreakpointData, ICompound, IGlobalConfig, IStackFrame, AdapterEndEvent } from 'vs/workbench/parts/debug/common/debug';
import { isExtensionHostDebugging } from 'vs/workbench/parts/debug/common/debugUtils';
import { RunOnceScheduler } from 'vs/base/common/async';
import { isErrorWithActions, createErrorWithActions } from 'vs/base/common/errorsWithActions';

const DEBUG_BREAKPOINTS_KEY = 'debug.breakpoint';
const DEBUG_BREAKPOINTS_ACTIVATED_KEY = 'debug.breakpointactivated';
const DEBUG_FUNCTION_BREAKPOINTS_KEY = 'debug.functionbreakpoint';
const DEBUG_EXCEPTION_BREAKPOINTS_KEY = 'debug.exceptionbreakpoint';
const DEBUG_WATCH_EXPRESSIONS_KEY = 'debug.watchexpressions';

function once(kind: TaskEventKind, event: Event<TaskEvent>): Event<TaskEvent> {
	return (listener, thisArgs = null, disposables?) => {
		const result = event(e => {
			if (e.kind === kind) {
				result.dispose();
				return listener.call(thisArgs, e);
			}
		}, null, disposables);
		return result;
	};
}

const enum TaskRunResult {
	Failure,
	Success
}

export class DebugService implements IDebugService {
	_serviceBrand: any;

	private readonly _onDidChangeState: Emitter<State>;
	private readonly _onDidNewSession: Emitter<IDebugSession>;
	private readonly _onWillNewSession: Emitter<IDebugSession>;
	private readonly _onDidEndSession: Emitter<IDebugSession>;
	private model: DebugModel;
	private viewModel: ViewModel;
	private configurationManager: ConfigurationManager;
	private toDispose: IDisposable[];
	private debugType: IContextKey<string>;
	private debugState: IContextKey<string>;
	private inDebugMode: IContextKey<boolean>;
	private breakpointsToSendOnResourceSaved: Set<string>;
	private initializing = false;
	private previousState: State;

	constructor(
		@IStorageService private storageService: IStorageService,
		@IEditorService private editorService: IEditorService,
		@ITextFileService private textFileService: ITextFileService,
		@IViewletService private viewletService: IViewletService,
		@IPanelService private panelService: IPanelService,
		@INotificationService private notificationService: INotificationService,
		@IDialogService private dialogService: IDialogService,
		@IPartService private partService: IPartService,
		@IBroadcastService private broadcastService: IBroadcastService,
		@ITelemetryService private telemetryService: ITelemetryService,
		@IWorkspaceContextService private contextService: IWorkspaceContextService,
		@IContextKeyService contextKeyService: IContextKeyService,
		@ILifecycleService private lifecycleService: ILifecycleService,
		@IInstantiationService private instantiationService: IInstantiationService,
		@IExtensionService private extensionService: IExtensionService,
		@IMarkerService private markerService: IMarkerService,
		@ITaskService private taskService: ITaskService,
		@IFileService private fileService: IFileService,
		@IConfigurationService private configurationService: IConfigurationService,
	) {
		this.toDispose = [];

		this.breakpointsToSendOnResourceSaved = new Set<string>();

		this._onDidChangeState = new Emitter<State>();
		this._onDidNewSession = new Emitter<IDebugSession>();
		this._onWillNewSession = new Emitter<IDebugSession>();
		this._onDidEndSession = new Emitter<IDebugSession>();

		this.configurationManager = this.instantiationService.createInstance(ConfigurationManager);
		this.toDispose.push(this.configurationManager);

		this.debugType = CONTEXT_DEBUG_TYPE.bindTo(contextKeyService);
		this.debugState = CONTEXT_DEBUG_STATE.bindTo(contextKeyService);
		this.inDebugMode = CONTEXT_IN_DEBUG_MODE.bindTo(contextKeyService);

		this.model = new DebugModel(this.loadBreakpoints(), this.storageService.getBoolean(DEBUG_BREAKPOINTS_ACTIVATED_KEY, StorageScope.WORKSPACE, true), this.loadFunctionBreakpoints(),
			this.loadExceptionBreakpoints(), this.loadWatchExpressions(), this.textFileService);
		this.toDispose.push(this.model);

		this.viewModel = new ViewModel(contextKeyService);

		this.toDispose.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
		this.toDispose.push(this.storageService.onWillSaveState(this.saveState, this));
		this.lifecycleService.onShutdown(this.dispose, this);

		this.toDispose.push(this.broadcastService.onBroadcast(broadcast => {
			const session = this.model.getSessions(true).filter(s => s.getId() === broadcast.payload.debugId).pop();
			if (session) {
				switch (broadcast.channel) {

					case EXTENSION_ATTACH_BROADCAST_CHANNEL:
						// EH was started in debug mode -> attach to it
						session.configuration.request = 'attach';
						session.configuration.port = broadcast.payload.port;
						this.launchOrAttachToSession(session);
						break;

					case EXTENSION_TERMINATE_BROADCAST_CHANNEL:
						// EH was terminated
						session.disconnect();
						break;

					case EXTENSION_LOG_BROADCAST_CHANNEL:
						// extension logged output -> show it in REPL
						const extensionOutput = <IRemoteConsoleLog>broadcast.payload.logEntry;
						const sev = extensionOutput.severity === 'warn' ? severity.Warning : extensionOutput.severity === 'error' ? severity.Error : severity.Info;
						const { args, stack } = parse(extensionOutput);
						let frame = undefined;
						if (stack) {
							frame = getFirstFrame(stack);
						}
						session.logToRepl(sev, args, frame);
						break;
				}
			}
		}, this));

		this.toDispose.push(this.viewModel.onDidFocusStackFrame(() => {
			this.onStateChange();
		}));
		this.toDispose.push(this.viewModel.onDidFocusSession(session => {
			const id = session ? session.getId() : undefined;
			this.model.setBreakpointsSessionId(id);
			this.onStateChange();
		}));
	}

	getModel(): IDebugModel {
		return this.model;
	}

	getViewModel(): IViewModel {
		return this.viewModel;
	}

	getConfigurationManager(): IConfigurationManager {
		return this.configurationManager;
	}

	sourceIsNotAvailable(uri: uri): void {
		this.model.sourceIsNotAvailable(uri);
	}

	dispose(): void {
		this.toDispose = dispose(this.toDispose);
	}

	//---- state management

	get state(): State {
		const focusedSession = this.viewModel.focusedSession;
		if (focusedSession) {
			return focusedSession.state;
		}

		return this.initializing ? State.Initializing : State.Inactive;
	}

	private startInitializingState() {
		if (!this.initializing) {
			this.initializing = true;
			this.onStateChange();
		}
	}

	private endInitializingState() {
		if (this.initializing) {
			this.initializing = false;
			this.onStateChange();
		}
	}

	private onStateChange(): void {
		const state = this.state;
		if (this.previousState !== state) {
			const stateLabel = State[state];
			if (stateLabel) {
				this.debugState.set(stateLabel.toLowerCase());
				this.inDebugMode.set(state !== State.Inactive);
			}
			this.previousState = state;
			this._onDidChangeState.fire(state);
		}
	}

	get onDidChangeState(): Event<State> {
		return this._onDidChangeState.event;
	}

	get onDidNewSession(): Event<IDebugSession> {
		return this._onDidNewSession.event;
	}

	get onWillNewSession(): Event<IDebugSession> {
		return this._onWillNewSession.event;
	}

	get onDidEndSession(): Event<IDebugSession> {
		return this._onDidEndSession.event;
	}

	//---- life cycle management

	/**
	 * main entry point
	 * properly manages compounds, checks for errors and handles the initializing state.
	 */
	startDebugging(launch: ILaunch, configOrName?: IConfig | string, noDebug = false, unresolvedConfig?: IConfig, ): TPromise<boolean> {

		this.startInitializingState();
		// make sure to save all files and that the configuration is up to date
		return this.extensionService.activateByEvent('onDebug').then(() =>
			this.textFileService.saveAll().then(() => this.configurationService.reloadConfiguration(launch ? launch.workspace : undefined).then(() =>
				this.extensionService.whenInstalledExtensionsRegistered().then(() => {

					let config: IConfig, compound: ICompound;
					if (!configOrName) {
						configOrName = this.configurationManager.selectedConfiguration.name;
					}
					if (typeof configOrName === 'string' && launch) {
						config = launch.getConfiguration(configOrName);
						compound = launch.getCompound(configOrName);

						const sessions = this.model.getSessions();
						const alreadyRunningMessage = nls.localize('configurationAlreadyRunning', "There is already a debug configuration \"{0}\" running.", configOrName);
						if (sessions.some(s => s.configuration.name === configOrName && (!launch || !launch.workspace || !s.root || s.root.uri.toString() === launch.workspace.uri.toString()))) {
							return Promise.reject(new Error(alreadyRunningMessage));
						}
						if (compound && compound.configurations && sessions.some(p => compound.configurations.indexOf(p.configuration.name) !== -1)) {
							return Promise.reject(new Error(alreadyRunningMessage));
						}
					} else if (typeof configOrName !== 'string') {
						config = configOrName;
					}

					if (compound) {
						// we are starting a compound debug, first do some error checking and than start each configuration in the compound
						if (!compound.configurations) {
							return Promise.reject(new Error(nls.localize({ key: 'compoundMustHaveConfigurations', comment: ['compound indicates a "compounds" configuration item', '"configurations" is an attribute and should not be localized'] },
								"Compound must have \"configurations\" attribute set in order to start multiple configurations.")));
						}

						return Promise.all(compound.configurations.map(configData => {
							const name = typeof configData === 'string' ? configData : configData.name;
							if (name === compound.name) {
								return Promise.resolve(false);
							}

							let launchForName: ILaunch;
							if (typeof configData === 'string') {
								const launchesContainingName = this.configurationManager.getLaunches().filter(l => !!l.getConfiguration(name));
								if (launchesContainingName.length === 1) {
									launchForName = launchesContainingName[0];
								} else if (launchesContainingName.length > 1 && launchesContainingName.indexOf(launch) >= 0) {
									// If there are multiple launches containing the configuration give priority to the configuration in the current launch
									launchForName = launch;
								} else {
									return Promise.reject(new Error(launchesContainingName.length === 0 ? nls.localize('noConfigurationNameInWorkspace', "Could not find launch configuration '{0}' in the workspace.", name)
										: nls.localize('multipleConfigurationNamesInWorkspace', "There are multiple launch configurations '{0}' in the workspace. Use folder name to qualify the configuration.", name)));
								}
							} else if (configData.folder) {
								const launchesMatchingConfigData = this.configurationManager.getLaunches().filter(l => l.workspace && l.workspace.name === configData.folder && !!l.getConfiguration(configData.name));
								if (launchesMatchingConfigData.length === 1) {
									launchForName = launchesMatchingConfigData[0];
								} else {
									return Promise.reject(new Error(nls.localize('noFolderWithName', "Can not find folder with name '{0}' for configuration '{1}' in compound '{2}'.", configData.folder, configData.name, compound.name)));
								}
							}

							return this.createSession(launchForName, launchForName.getConfiguration(name), unresolvedConfig, noDebug);
						})).then(values => values.every(success => !!success)); // Compound launch is a success only if each configuration launched successfully
					}

					if (configOrName && !config) {
						const message = !!launch ? nls.localize('configMissing', "Configuration '{0}' is missing in 'launch.json'.", typeof configOrName === 'string' ? configOrName : JSON.stringify(configOrName)) :
							nls.localize('launchJsonDoesNotExist', "'launch.json' does not exist.");
						return Promise.reject(new Error(message));
					}

					return this.createSession(launch, config, unresolvedConfig, noDebug);
				})
			))).then(success => {
				// make sure to get out of initializing state, and propagate the result
				this.endInitializingState();
				return success;
			}, err => {
				this.endInitializingState();
				return Promise.reject(err);
			});
	}

	/**
	 * gets the debugger for the type, resolves configurations by providers, substitutes variables and runs prelaunch tasks
	 */
	private createSession(launch: ILaunch, config: IConfig, unresolvedConfig: IConfig, noDebug: boolean): TPromise<boolean> {
		// We keep the debug type in a separate variable 'type' so that a no-folder config has no attributes.
		// Storing the type in the config would break extensions that assume that the no-folder case is indicated by an empty config.
		let type: string;
		if (config) {
			type = config.type;
		} else {
			// a no-folder workspace has no launch.config
			config = Object.create(null);
		}
		unresolvedConfig = unresolvedConfig || deepClone(config);

		if (noDebug) {
			config.noDebug = true;
		}

		const debuggerThenable: Thenable<void> = type ? Promise.resolve(null) : this.configurationManager.guessDebugger().then(dbgr => { type = dbgr && dbgr.type; });
		return debuggerThenable.then(() =>
			this.configurationManager.resolveConfigurationByProviders(launch && launch.workspace ? launch.workspace.uri : undefined, type, config).then(config => {
				// a falsy config indicates an aborted launch
				if (config && config.type) {
					return this.substituteVariables(launch, config).then(resolvedConfig => {

						if (!resolvedConfig) {
							// User canceled resolving of interactive variables, silently return
							return false;
						}

						if (!this.configurationManager.getDebugger(resolvedConfig.type) || (config.request !== 'attach' && config.request !== 'launch')) {
							let message: string;
							if (config.request !== 'attach' && config.request !== 'launch') {
								message = config.request ? nls.localize('debugRequestNotSupported', "Attribute '{0}' has an unsupported value '{1}' in the chosen debug configuration.", 'request', config.request)
									: nls.localize('debugRequesMissing', "Attribute '{0}' is missing from the chosen debug configuration.", 'request');

							} else {
								message = resolvedConfig.type ? nls.localize('debugTypeNotSupported', "Configured debug type '{0}' is not supported.", resolvedConfig.type) :
									nls.localize('debugTypeMissing', "Missing property 'type' for the chosen launch configuration.");
							}

							return this.showError(message).then(() => false);
						}

						const workspace = launch ? launch.workspace : undefined;
						return this.runTaskAndCheckErrors(workspace, resolvedConfig.preLaunchTask).then(result => {
							if (result === TaskRunResult.Success) {
								return this.doCreateSession(workspace, { resolved: resolvedConfig, unresolved: unresolvedConfig });
							}
							return false;
						});
					}, err => {
						if (err && err.message) {
							return this.showError(err.message).then(() => false);
						}
						if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
							return this.showError(nls.localize('noFolderWorkspaceDebugError', "The active file can not be debugged. Make sure it is saved on disk and that you have a debug extension installed for that file type."))
								.then(() => false);
						}

						return launch && launch.openConfigFile(false, true).then(() => false);
					});
				}

				if (launch && type && config === null) {	// show launch.json only for "config" being "null".
					return launch.openConfigFile(false, true, type).then(() => false);
				}

				return false;
			})
		);
	}

	/**
	 * instantiates the new session, initializes the session, registers session listeners and reports telemetry
	 */
	private doCreateSession(root: IWorkspaceFolder, configuration: { resolved: IConfig, unresolved: IConfig }): TPromise<boolean> {

		const session = this.instantiationService.createInstance(DebugSession, configuration, root, this.model);

		// register listeners as the very first thing!
		this.registerSessionListeners(session);

		// since the Session is now properly registered under its ID and hooked, we can announce it
		// this event doesn't go to extensions
		this._onWillNewSession.fire(session);

		return this.launchOrAttachToSession(session).then(() => {

			// since the initialized response has arrived announce the new Session (including extensions)
			this._onDidNewSession.fire(session);

			const internalConsoleOptions = session.configuration.internalConsoleOptions || this.configurationService.getValue<IDebugConfiguration>('debug').internalConsoleOptions;
			if (internalConsoleOptions === 'openOnSessionStart' || (this.viewModel.firstSessionStart && internalConsoleOptions === 'openOnFirstSessionStart')) {
				this.panelService.openPanel(REPL_ID, false);
			}

			const openDebug = this.configurationService.getValue<IDebugConfiguration>('debug').openDebug;
			// Open debug viewlet based on the visibility of the side bar and openDebug setting. Do not open for 'run without debug'
			if (!configuration.resolved.noDebug && (openDebug === 'openOnSessionStart' || (openDebug === 'openOnFirstSessionStart' && this.viewModel.firstSessionStart))) {
				this.viewletService.openViewlet(VIEWLET_ID);
			}
			this.viewModel.firstSessionStart = false;

			this.debugType.set(session.configuration.type);
			if (this.model.getSessions().length > 1) {
				this.viewModel.setMultiSessionView(true);
			}

			return this.telemetryDebugSessionStart(root, session.configuration.type);
		}).then(() => true, (error: Error | string) => {

			if (errors.isPromiseCanceledError(error)) {
				// don't show 'canceled' error messages to the user #7906
				return Promise.resolve(undefined);
			}

			// Show the repl if some error got logged there #5870
			if (session && session.getReplElements().length > 0) {
				this.panelService.openPanel(REPL_ID, false);
			}

			if (session.configuration && session.configuration.request === 'attach' && session.configuration.__autoAttach) {
				// ignore attach timeouts in auto attach mode
				return Promise.resolve(undefined);
			}

			const errorMessage = error instanceof Error ? error.message : error;
			this.telemetryDebugMisconfiguration(session.configuration ? session.configuration.type : undefined, errorMessage);
			return this.showError(errorMessage, isErrorWithActions(error) ? error.actions : []).then(() => false);
		});
	}

	private launchOrAttachToSession(session: IDebugSession, focus = true): TPromise<void> {
		const dbgr = this.configurationManager.getDebugger(session.configuration.type);
		return session.initialize(dbgr).then(() => {
			return session.launchOrAttach(session.configuration).then(() => {
				if (focus) {
					this.focusStackFrame(undefined, undefined, session);
				}
			});
		}).then(undefined, err => {
			session.shutdown();
			return Promise.reject(err);
		});
	}

	private registerSessionListeners(session: IDebugSession): void {
		const sessionRunningScheduler = new RunOnceScheduler(() => {
			// Do not immediatly focus another session or thread if a session is running
			// Stepping in a session should preserve that session focused even if some continued events happen
			if (session.state === State.Running && this.viewModel.focusedSession === session) {
				this.focusStackFrame(undefined);
			}
		}, 200);
		this.toDispose.push(session.onDidChangeState(() => {
			if (session.state === State.Running && this.viewModel.focusedSession === session) {
				sessionRunningScheduler.schedule();
			}
		}));

		this.toDispose.push(session.onDidEndAdapter(adapterExitEvent => {

			if (adapterExitEvent.error) {
				this.notificationService.error(nls.localize('debugAdapterCrash', "Debug adapter process has terminated unexpectedly ({0})", adapterExitEvent.error.message || adapterExitEvent.error.toString()));
			}

			// 'Run without debugging' mode VSCode must terminate the extension host. More details: #3905
			if (isExtensionHostDebugging(session.configuration) && session.state === State.Running && session.configuration.noDebug) {
				this.broadcastService.broadcast({
					channel: EXTENSION_CLOSE_EXTHOST_BROADCAST_CHANNEL,
					payload: [session.root.uri.toString()]
				});
			}

			this.telemetryDebugSessionStop(session, adapterExitEvent);

			if (session.configuration.postDebugTask) {
				this.runTask(session.root, session.configuration.postDebugTask).then(undefined, err =>
					this.notificationService.error(err)
				);
			}
			session.shutdown();
			this._onDidEndSession.fire(session);

			const focusedSession = this.viewModel.focusedSession;
			if (focusedSession && focusedSession.getId() === session.getId()) {
				this.focusStackFrame(undefined);
			}

			if (this.model.getSessions().length === 0) {
				this.debugType.reset();
				this.viewModel.setMultiSessionView(false);

				if (this.partService.isVisible(Parts.SIDEBAR_PART) && this.configurationService.getValue<IDebugConfiguration>('debug').openExplorerOnEnd) {
					this.viewletService.openViewlet(EXPLORER_VIEWLET_ID);
				}
			}

		}));
	}

	restartSession(session: IDebugSession, restartData?: any): TPromise<any> {
		return this.textFileService.saveAll().then(() => {
			const isAutoRestart = !!restartData;
			const runTasks: () => Thenable<TaskRunResult> = () => {
				if (isAutoRestart) {
					// Do not run preLaunch and postDebug tasks for automatic restarts
					return Promise.resolve(TaskRunResult.Success);
				}

				return this.runTask(session.root, session.configuration.postDebugTask)
					.then(() => this.runTaskAndCheckErrors(session.root, session.configuration.preLaunchTask));
			};

			if (session.capabilities.supportsRestartRequest) {
				return runTasks().then(taskResult => taskResult === TaskRunResult.Success ? session.restart() : undefined);
			}

			if (isExtensionHostDebugging(session.configuration) && session.root) {
				return runTasks().then(taskResult => taskResult === TaskRunResult.Success ? this.broadcastService.broadcast({
					channel: EXTENSION_RELOAD_BROADCAST_CHANNEL,
					payload: [session.root.uri.toString()]
				}) : undefined);
			}

			const shouldFocus = this.viewModel.focusedSession && session.getId() === this.viewModel.focusedSession.getId();
			// If the restart is automatic  -> disconnect, otherwise -> terminate #55064
			return (isAutoRestart ? session.disconnect(true) : session.terminate(true)).then(() => {

				return new Promise<void>((c, e) => {
					setTimeout(() => {
						runTasks().then(taskResult => {
							if (taskResult !== TaskRunResult.Success) {
								return;
							}

							// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
							let needsToSubstitute = false;
							let unresolved: IConfig;
							const launch = session.root ? this.configurationManager.getLaunch(session.root.uri) : undefined;
							if (launch) {
								unresolved = launch.getConfiguration(session.configuration.name);
								if (unresolved && !equals(unresolved, session.unresolvedConfiguration)) {
									// Take the type from the session since the debug extension might overwrite it #21316
									unresolved.type = session.configuration.type;
									unresolved.noDebug = session.configuration.noDebug;
									needsToSubstitute = true;
								}
							}

							let substitutionThenable: Thenable<IConfig> = Promise.resolve(session.configuration);
							if (needsToSubstitute) {
								substitutionThenable = this.configurationManager.resolveConfigurationByProviders(launch.workspace ? launch.workspace.uri : undefined, unresolved.type, unresolved)
									.then(resolved => this.substituteVariables(launch, resolved));
							}
							substitutionThenable.then(resolved => {
								session.setConfiguration({ resolved, unresolved });
								session.configuration.__restart = restartData;

								this.launchOrAttachToSession(session, shouldFocus).then(() => {
									this._onDidNewSession.fire(session);
									c(null);
								}, err => e(err));
							});
						});
					}, 300);
				});
			});
		});
	}

	stopSession(session: IDebugSession): TPromise<any> {

		if (session) {
			return session.terminate();
		}

		const sessions = this.model.getSessions();
		return Promise.all(sessions.map(s => s.terminate()));
	}

	private substituteVariables(launch: ILaunch | undefined, config: IConfig): TPromise<IConfig> {
		const dbg = this.configurationManager.getDebugger(config.type);
		if (dbg) {
			let folder: IWorkspaceFolder | undefined = undefined;
			if (launch && launch.workspace) {
				folder = launch.workspace;
			} else {
				const folders = this.contextService.getWorkspace().folders;
				if (folders.length === 1) {
					folder = folders[0];
				}
			}
			return dbg.substituteVariables(folder, config).then(config => {
				return config;
			}, (err: Error) => {
				this.showError(err.message);
				return undefined;	// bail out
			});
		}
		return Promise.resolve(config);
	}

	private showError(message: string, actions: IAction[] = []): TPromise<void> {
		const configureAction = this.instantiationService.createInstance(debugactions.ConfigureAction, debugactions.ConfigureAction.ID, debugactions.ConfigureAction.LABEL);
		actions.push(configureAction);
		return this.dialogService.show(severity.Error, message, actions.map(a => a.label).concat(nls.localize('cancel', "Cancel")), { cancelId: actions.length }).then(choice => {
			if (choice < actions.length) {
				return actions[choice].run();
			}

			return void 0;
		});
	}

	//---- task management

	private runTaskAndCheckErrors(root: IWorkspaceFolder, taskId: string | TaskIdentifier): TPromise<TaskRunResult> {

		const debugAnywayAction = new Action('debug.debugAnyway', nls.localize('debugAnyway', "Debug Anyway"), undefined, true, () => Promise.resolve(TaskRunResult.Success));
		return this.runTask(root, taskId).then((taskSummary: ITaskSummary) => {
			const errorCount = taskId ? this.markerService.getStatistics().errors : 0;
			const successExitCode = taskSummary && taskSummary.exitCode === 0;
			const failureExitCode = taskSummary && taskSummary.exitCode !== undefined && taskSummary.exitCode !== 0;
			if (successExitCode || (errorCount === 0 && !failureExitCode)) {
				return <any>TaskRunResult.Success;
			}

			const taskLabel = typeof taskId === 'string' ? taskId : taskId.name;
			const message = errorCount > 1
				? nls.localize('preLaunchTaskErrors', "Build errors have been detected during preLaunchTask '{0}'.", taskLabel)
				: errorCount === 1
					? nls.localize('preLaunchTaskError', "Build error has been detected during preLaunchTask '{0}'.", taskLabel)
					: nls.localize('preLaunchTaskExitCode', "The preLaunchTask '{0}' terminated with exit code {1}.", taskLabel, taskSummary.exitCode);

			const showErrorsAction = new Action('debug.showErrors', nls.localize('showErrors', "Show Errors"), undefined, true, () => {
				return this.panelService.openPanel(Constants.MARKERS_PANEL_ID).then(() => TaskRunResult.Failure);
			});

			return this.showError(message, [debugAnywayAction, showErrorsAction]);
		}, (err: TaskError) => {
			return this.showError(err.message, [debugAnywayAction, this.taskService.configureAction()]);
		});
	}

	private runTask(root: IWorkspaceFolder, taskId: string | TaskIdentifier): TPromise<ITaskSummary> {
		if (!taskId) {
			return Promise.resolve(null);
		}
		if (!root) {
			return Promise.reject(new Error(nls.localize('invalidTaskReference', "Task '{0}' can not be referenced from a launch configuration that is in a different workspace folder.", typeof taskId === 'string' ? taskId : taskId.type)));
		}
		// run a task before starting a debug session
		return this.taskService.getTask(root, taskId).then(task => {
			if (!task) {
				const errorMessage = typeof taskId === 'string'
					? nls.localize('DebugTaskNotFoundWithTaskId', "Could not find the task '{0}'.", taskId)
					: nls.localize('DebugTaskNotFound', "Could not find the specified task.");
				return Promise.reject(createErrorWithActions(errorMessage));
			}

			// If a task is missing the problem matcher the promise will never complete, so we need to have a workaround #35340
			let taskStarted = false;
			const promise = this.taskService.getActiveTasks().then(tasks => {
				if (tasks.filter(t => t._id === task._id).length) {
					// task is already running - nothing to do.
					return Promise.resolve(null);
				}
				once(TaskEventKind.Active, this.taskService.onDidStateChange)((taskEvent) => {
					// Task is active, so everything seems to be fine, no need to prompt after 10 seconds
					// Use case being a slow running task should not be prompted even though it takes more than 10 seconds
					taskStarted = true;
				});
				const taskPromise = this.taskService.run(task);
				if (task.isBackground) {
					return new Promise((c, e) => once(TaskEventKind.Inactive, this.taskService.onDidStateChange)(() => {
						taskStarted = true;
						c(null);
					}));
				}

				return taskPromise;
			});

			return new Promise((c, e) => {
				promise.then(result => {
					taskStarted = true;
					c(result);
				}, error => e(error));

				setTimeout(() => {
					if (!taskStarted) {
						const errorMessage = typeof taskId === 'string'
							? nls.localize('taskNotTrackedWithTaskId', "The specified task cannot be tracked.")
							: nls.localize('taskNotTracked', "The task '{0}' cannot be tracked.", JSON.stringify(taskId));
						e({ severity: severity.Error, message: errorMessage });
					}
				}, 10000);
			});
		});
	}

	//---- focus management

	focusStackFrame(stackFrame: IStackFrame, thread?: IThread, session?: IDebugSession, explicit?: boolean): void {
		if (!session) {
			if (stackFrame || thread) {
				session = stackFrame ? stackFrame.thread.session : thread.session;
			} else {
				const sessions = this.model.getSessions();
				const stoppedSession = sessions.filter(s => s.state === State.Stopped).shift();
				session = stoppedSession || (sessions.length ? sessions[0] : undefined);
			}
		}

		if (!thread) {
			if (stackFrame) {
				thread = stackFrame.thread;
			} else {
				const threads = session ? session.getAllThreads() : undefined;
				const stoppedThread = threads && threads.filter(t => t.stopped).shift();
				thread = stoppedThread || (threads && threads.length ? threads[0] : undefined);
			}
		}

		if (!stackFrame) {
			if (thread) {
				const callStack = thread.getCallStack();
				stackFrame = first(callStack, sf => sf.source && sf.source.available, undefined);
			}
		}

		if (stackFrame) {
			stackFrame.openInEditor(this.editorService, true).then(undefined, errors.onUnexpectedError);
			aria.alert(nls.localize('debuggingPaused', "Debugging paused, reason {0}, {1} {2}", thread.stoppedDetails.reason, stackFrame.source ? stackFrame.source.name : '', stackFrame.range.startLineNumber));
		}

		this.viewModel.setFocus(stackFrame, thread, session, explicit);
	}

	//---- watches

	addWatchExpression(name: string): void {
		const we = this.model.addWatchExpression(name);
		this.viewModel.setSelectedExpression(we);
	}

	renameWatchExpression(id: string, newName: string): void {
		return this.model.renameWatchExpression(id, newName);
	}

	moveWatchExpression(id: string, position: number): void {
		this.model.moveWatchExpression(id, position);
	}

	removeWatchExpressions(id?: string): void {
		this.model.removeWatchExpressions(id);
	}

	//---- breakpoints

	enableOrDisableBreakpoints(enable: boolean, breakpoint?: IEnablement): TPromise<void> {
		if (breakpoint) {
			this.model.setEnablement(breakpoint, enable);
			if (breakpoint instanceof Breakpoint) {
				return this.sendBreakpoints(breakpoint.uri);
			} else if (breakpoint instanceof FunctionBreakpoint) {
				return this.sendFunctionBreakpoints();
			}

			return this.sendExceptionBreakpoints();
		}

		this.model.enableOrDisableAllBreakpoints(enable);
		return this.sendAllBreakpoints();
	}

	addBreakpoints(uri: uri, rawBreakpoints: IBreakpointData[]): TPromise<IBreakpoint[]> {
		const breakpoints = this.model.addBreakpoints(uri, rawBreakpoints);
		breakpoints.forEach(bp => aria.status(nls.localize('breakpointAdded', "Added breakpoint, line {0}, file {1}", bp.lineNumber, uri.fsPath)));

		return this.sendBreakpoints(uri).then(() => breakpoints);
	}

	updateBreakpoints(uri: uri, data: { [id: string]: DebugProtocol.Breakpoint }, sendOnResourceSaved: boolean): void {
		this.model.updateBreakpoints(data);
		if (sendOnResourceSaved) {
			this.breakpointsToSendOnResourceSaved.add(uri.toString());
		} else {
			this.sendBreakpoints(uri);
		}
	}

	removeBreakpoints(id?: string): TPromise<any> {
		const toRemove = this.model.getBreakpoints().filter(bp => !id || bp.getId() === id);
		toRemove.forEach(bp => aria.status(nls.localize('breakpointRemoved', "Removed breakpoint, line {0}, file {1}", bp.lineNumber, bp.uri.fsPath)));
		const urisToClear = distinct(toRemove, bp => bp.uri.toString()).map(bp => bp.uri);

		this.model.removeBreakpoints(toRemove);

		return Promise.all(urisToClear.map(uri => this.sendBreakpoints(uri)));
	}

	setBreakpointsActivated(activated: boolean): TPromise<void> {
		this.model.setBreakpointsActivated(activated);
		return this.sendAllBreakpoints();
	}

	addFunctionBreakpoint(name?: string, id?: string): void {
		const newFunctionBreakpoint = this.model.addFunctionBreakpoint(name || '', id);
		this.viewModel.setSelectedFunctionBreakpoint(newFunctionBreakpoint);
	}

	renameFunctionBreakpoint(id: string, newFunctionName: string): TPromise<void> {
		this.model.renameFunctionBreakpoint(id, newFunctionName);
		return this.sendFunctionBreakpoints();
	}

	removeFunctionBreakpoints(id?: string): TPromise<void> {
		this.model.removeFunctionBreakpoints(id);
		return this.sendFunctionBreakpoints();
	}

	sendAllBreakpoints(session?: IDebugSession): TPromise<any> {
		return Promise.all(distinct(this.model.getBreakpoints(), bp => bp.uri.toString()).map(bp => this.sendBreakpoints(bp.uri, false, session)))
			.then(() => this.sendFunctionBreakpoints(session))
			// send exception breakpoints at the end since some debug adapters rely on the order
			.then(() => this.sendExceptionBreakpoints(session));
	}

	private sendBreakpoints(modelUri: uri, sourceModified = false, session?: IDebugSession): TPromise<void> {

		const breakpointsToSend = this.model.getBreakpoints({ uri: modelUri, enabledOnly: true });

		return this.sendToOneOrAllSessions(session, s =>
			s.sendBreakpoints(modelUri, breakpointsToSend, sourceModified)
		);
	}

	private sendFunctionBreakpoints(session?: IDebugSession): TPromise<void> {

		const breakpointsToSend = this.model.getFunctionBreakpoints().filter(fbp => fbp.enabled && this.model.areBreakpointsActivated());

		return this.sendToOneOrAllSessions(session, s => {
			return s.capabilities.supportsFunctionBreakpoints ? s.sendFunctionBreakpoints(breakpointsToSend) : Promise.resolve(undefined);
		});
	}

	private sendExceptionBreakpoints(session?: IDebugSession): TPromise<void> {

		const enabledExceptionBps = this.model.getExceptionBreakpoints().filter(exb => exb.enabled);

		return this.sendToOneOrAllSessions(session, s => {
			return s.sendExceptionBreakpoints(enabledExceptionBps);
		});
	}

	private sendToOneOrAllSessions(session: IDebugSession, send: (session: IDebugSession) => TPromise<void>): TPromise<void> {
		if (session) {
			return send(session);
		}
		return Promise.all(this.model.getSessions().map(s => send(s))).then(() => void 0);
	}

	private onFileChanges(fileChangesEvent: FileChangesEvent): void {
		const toRemove = this.model.getBreakpoints().filter(bp =>
			fileChangesEvent.contains(bp.uri, FileChangeType.DELETED));
		if (toRemove.length) {
			this.model.removeBreakpoints(toRemove);
		}

		fileChangesEvent.getUpdated().forEach(event => {

			if (this.breakpointsToSendOnResourceSaved.delete(event.resource.toString())) {
				this.sendBreakpoints(event.resource, true);
			}
		});
	}

	private loadBreakpoints(): Breakpoint[] {
		let result: Breakpoint[];
		try {
			result = JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((breakpoint: any) => {
				return new Breakpoint(uri.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition, breakpoint.logMessage, breakpoint.adapterData, this.textFileService);
			});
		} catch (e) { }

		return result || [];
	}

	private loadFunctionBreakpoints(): FunctionBreakpoint[] {
		let result: FunctionBreakpoint[];
		try {
			result = JSON.parse(this.storageService.get(DEBUG_FUNCTION_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((fb: any) => {
				return new FunctionBreakpoint(fb.name, fb.enabled, fb.hitCondition, fb.condition, fb.logMessage);
			});
		} catch (e) { }

		return result || [];
	}

	private loadExceptionBreakpoints(): ExceptionBreakpoint[] {
		let result: ExceptionBreakpoint[];
		try {
			result = JSON.parse(this.storageService.get(DEBUG_EXCEPTION_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((exBreakpoint: any) => {
				return new ExceptionBreakpoint(exBreakpoint.filter, exBreakpoint.label, exBreakpoint.enabled);
			});
		} catch (e) { }

		return result || [];
	}

	private loadWatchExpressions(): Expression[] {
		let result: Expression[];
		try {
			result = JSON.parse(this.storageService.get(DEBUG_WATCH_EXPRESSIONS_KEY, StorageScope.WORKSPACE, '[]')).map((watchStoredData: { name: string, id: string }) => {
				return new Expression(watchStoredData.name, watchStoredData.id);
			});
		} catch (e) { }

		return result || [];
	}

	private saveState(): void {
		const breakpoints = this.model.getBreakpoints();
		if (breakpoints.length) {
			this.storageService.store(DEBUG_BREAKPOINTS_KEY, JSON.stringify(breakpoints), StorageScope.WORKSPACE);
		} else {
			this.storageService.remove(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE);
		}

		if (!this.model.areBreakpointsActivated()) {
			this.storageService.store(DEBUG_BREAKPOINTS_ACTIVATED_KEY, 'false', StorageScope.WORKSPACE);
		} else {
			this.storageService.remove(DEBUG_BREAKPOINTS_ACTIVATED_KEY, StorageScope.WORKSPACE);
		}

		const functionBreakpoints = this.model.getFunctionBreakpoints();
		if (functionBreakpoints.length) {
			this.storageService.store(DEBUG_FUNCTION_BREAKPOINTS_KEY, JSON.stringify(functionBreakpoints), StorageScope.WORKSPACE);
		} else {
			this.storageService.remove(DEBUG_FUNCTION_BREAKPOINTS_KEY, StorageScope.WORKSPACE);
		}

		const exceptionBreakpoints = this.model.getExceptionBreakpoints();
		if (exceptionBreakpoints.length) {
			this.storageService.store(DEBUG_EXCEPTION_BREAKPOINTS_KEY, JSON.stringify(exceptionBreakpoints), StorageScope.WORKSPACE);
		} else {
			this.storageService.remove(DEBUG_EXCEPTION_BREAKPOINTS_KEY, StorageScope.WORKSPACE);
		}

		const watchExpressions = this.model.getWatchExpressions();
		if (watchExpressions.length) {
			this.storageService.store(DEBUG_WATCH_EXPRESSIONS_KEY, JSON.stringify(watchExpressions.map(we => ({ name: we.name, id: we.getId() }))), StorageScope.WORKSPACE);
		} else {
			this.storageService.remove(DEBUG_WATCH_EXPRESSIONS_KEY, StorageScope.WORKSPACE);
		}
	}

	//---- telemetry

	private telemetryDebugSessionStart(root: IWorkspaceFolder, type: string): TPromise<any> {
		const extension = this.configurationManager.getDebugger(type).extensionDescription;
		/* __GDPR__
			"debugSessionStart" : {
				"type": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
				"breakpointCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"exceptionBreakpoints": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
				"watchExpressionsCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"extensionName": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" },
				"isBuiltin": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true},
				"launchJsonExists": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
			}
		*/
		return this.telemetryService.publicLog('debugSessionStart', {
			type: type,
			breakpointCount: this.model.getBreakpoints().length,
			exceptionBreakpoints: this.model.getExceptionBreakpoints(),
			watchExpressionsCount: this.model.getWatchExpressions().length,
			extensionName: extension.id,
			isBuiltin: extension.isBuiltin,
			launchJsonExists: root && !!this.configurationService.getValue<IGlobalConfig>('launch', { resource: root.uri })
		});
	}

	private telemetryDebugSessionStop(session: IDebugSession, adapterExitEvent: AdapterEndEvent): TPromise<any> {

		const breakpoints = this.model.getBreakpoints();

		/* __GDPR__
			"debugSessionStop" : {
				"type" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
				"success": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"sessionLengthInSeconds": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"breakpointCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
				"watchExpressionsCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
			}
		*/
		return this.telemetryService.publicLog('debugSessionStop', {
			type: session && session.configuration.type,
			success: adapterExitEvent.emittedStopped || breakpoints.length === 0,
			sessionLengthInSeconds: adapterExitEvent.sessionLengthInSeconds,
			breakpointCount: breakpoints.length,
			watchExpressionsCount: this.model.getWatchExpressions().length
		});
	}

	private telemetryDebugMisconfiguration(debugType: string, message: string): TPromise<any> {
		/* __GDPR__
			"debugMisconfiguration" : {
				"type" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
				"error": { "classification": "CallstackOrException", "purpose": "FeatureInsight" }
			}
		*/
		return this.telemetryService.publicLog('debugMisconfiguration', {
			type: debugType,
			error: message
		});
	}
}


text:
module GUI.Widget.TextWidget
(
  TextWidget,

  makeTextWidget,
  makeTextWidgetSplit,

  -- tmp:
  outputTextWidget,

) where

import MyPrelude
import GUI.Widget
import GUI.Widget.Output

data TextWidget a =
  TextWidget
  {
      -- textCentered :: !Bool,
      textShape :: !GUIShape,
      textLines :: ![String]
  }

instance Widget TextWidget where
  widgetShape = \gd gs w -> textShape w
  widgetBegin = \gd gs w -> return w
  widgetEatInput = \gd gs w wi -> w
  widgetIterate = textIterate

textIterate :: GUIData -> GUIState -> TextWidget a -> a -> IO (TextWidget a, a)
textIterate gd gs text a = do
  outputTextWidget gd gs text
  return (text, a)

outputTextWidget :: GUIData -> GUIState -> TextWidget a -> IO ()
outputTextWidget gd gs text = do
{-
  -- draw background
  gs' <- useFillTexMid gd gs
  useNoStencil gd gs'
  draw4ShapeNoTex gd gs' $ textShape text
-}
  beginNoDepth gd gs

  -- draw texts, stacked downwards
  drawTexts gd gs $ (flip zip) (textLines text)
                  $ map (\y -> (GUIPos 0.0 y))
                  $ let dy = guidataFontSize gd
                    in  iterate (+ dy) 0.0

  endNoDepth gd gs

--------------------------------------------------------------------------------
--  make

-- fixme: hth = 2.0 * unit (or gamedataHth)
-- | make TextWidget from lines.
makeTextWidget :: GUIData -> [String] -> TextWidget a
makeTextWidget gd lines =
  let size = guidataFontSize gd
      charWth = fontdataCharWth (guidataFontData gd) size
      charHth = fontdataCharHth (guidataFontData gd) size
      wth = charWth * fI (foldl max 0 (map length lines))
      hth = charHth * fI (length lines)

  in  TextWidget
      {
          textShape = GUIShape wth hth,
          textLines = lines
      }

-- | make TextWidget from lines, which are "readably" splitted from 'str'
--   at character width or newline.
makeTextWidgetSplit :: GUIData -> UInt -> String -> TextWidget a
makeTextWidgetSplit gd width str =
  makeTextWidget gd $ splitReadable width str

splitReadable :: UInt -> String -> [String]
splitReadable wth str =
  concatMap (splitLine wth) $ lines str

splitLine :: UInt -> String -> [String]
splitLine linewth str =
  helper linewth "" $ myWords str
  where
    helper wth line [] =
      case line of
          []    -> []
          _     -> [line]
    helper wth line (word:words) =
      let wordLen = fI $ length word
      in  if wordLen <= wth
          -- add word to current line
          then helper (wth - wordLen) (line ++ word) words
            -- add word to next line
            else case line of
                []    -> helper' wth word words
                line  -> line : helper' linewth word words

    helper' wth word words =
      case helper'' wth word of
          (0, ws, ws')  -> ws : helper' linewth ws' words
          (wth', ws, _) -> helper wth' ws words

    helper'' wth word =
      if wth == 0
        then (wth, [], word)
        else case word of
            []      -> (wth, [], word)
            (w:ws)  -> let (wth', ws', ws'') = helper'' (wth - 1) ws
                       in  (wth', w:ws', ws'')

    myWords as =
        case as of
            []       -> []
            (a:as')  -> if myIsSpace a
                        then [a] : myWords as'
                        else let (as', as'') = break myIsSpace as
                             in  as' : myWords as''

    myIsSpace ' ' = True
    myIsSpace _   = False


text:
<!DOCTYPE html>

        <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<meta name="description" content="From the whiteboard to the keyboard">
<title>
Programmatically Installing and Using Your Management Certificate With the New .Publishsettings File - Wade Wegner
</title>

        <meta property="og:title" content="Programmatically Installing and Using Your Management Certificate with the New .publishsettings File - Wade Wegner" />
<meta property="og:type" content="website" />
<meta property="og:description" content="From the whiteboard to the keyboard"/>
<meta property="og:url" content="https://www.wadewegner.com/2011/11/programmatically-installing-and-using-your-management-certificate-with-the-new-.publishsettings-file/"/>
<meta property="og:site_name" content="Wade Wegner"/>

<meta property="og:image" content="https://www.wadewegner.com/home/favicon.ico"/>

<link rel="shortcut icon" href="/home/favicon.ico">

<link rel="stylesheet" href="/css/main.min.7234953717df3eaff5f4783a8c545c65897f4ac5d802aa4deabcf2538ec29449.css" integrity="sha256-cjSVNxffPq/19Hg6jFRcZYl/SsXYAqpN6rzyU47ClEk=" crossorigin="anonymous" media="screen">

    <link rel="stylesheet" href="/css/screen.css" integrity="" crossorigin="anonymous" media="screen">

Blog

                Home

                All Posts

                About

        Programmatically Installing and Using Your Management Certificate with the New .publishsettings File

        Nov 16, 2011 |
        3 minutes read

Earlier this week we released the Windows Azure SDK 1.6, which includes a lot of great updates to the emulators, tools for Visual Studio, and libraries. One of my favorite additions is a new way to get a management certificate installed into Windows Azure and onto your machine. You can now browse to https://windows.azure.com/download/publishprofile.aspx and login with your Live ID; this process will do two things:

Generate a management certificate that is installed into Windows Azures on your behalf.

Prompts you to download a .publishsettings file which includes an encoded version of your certificate and all of your subscription IDs.

The new tools for Visual Studio let you easily important this file and immediately start working with your subscriptions from within Visual Studio. It's a much simpler experience than in the past. In fact, on this weeks episode of the Cloud Cover Show (not yet published) Steve and I cover how to use this file from within your own code. While Steve beat me to it and published a great blog post showing some of the things you can do, I thought I'd take this a slightly different way and show you a couple different things:

How to install the certificate into your personal certificate store (which is exactly what Visual Studio is doing).

How to use the certificate from your person certificate store to make calls to the Service Management API.

The code is very similar. Take a look:

var publishSettingsFile = @"C:\temp\CORP DPE Account-11-16-2011-credentials.publishsettings";
XDocument xdoc = XDocument.Load(publishSettingsFile);

var managementCertbase64string = xdoc.Descendants("PublishProfile").Single().Attribute("ManagementCertificate").Value;
var importedCert = new X509Certificate2(Convert.FromBase64String(managementCertbase64string));

Now that we've imported the certificate, we can extract some information. I'll grab the certificate thumbprint, which uniquely identifies the certificate—we'll use it later in the post.

thumbprint = importedCert.Thumbprint;

Additionally, I can grab my subscription ID from the .publishsettings file – this we will also use later.

string subscriptionId = xdoc.Descendants("Subscription").First().Attribute("Id").Value;

Now, we can take our X509Certificate2 and install it directly into our certificate store.

X509Store store = new X509Store(StoreName.My); store.Open(OpenFlags.ReadWrite); store.Add(importedCert); store.Close();

After running this code, you can see that the certificate has been installed into my personal certificate store.

If you select the certificate you'll see that it's the same certificate with the same thumbprint.

Since the certificate is now loaded into the certificate store I can delete the .publishsettings file – I no longer need it. (It's also a credential that I don't want to let anyone else get their hands on.)

Now I have the following resources available to me:

My X509 certificate loaded in my personal certificate store.

The thumbprint for the certificate (which we'll use to identify the right certificate).

My Windows Azure subscription ID.

With this information we can do the exact same thing Steve shows in his post except without the .publishsettings file.

X509Store store = new X509Store(StoreName.My);
store.Open(OpenFlags.ReadWrite);

X509Certificate2 managementCert = store.Certificates.Find(X509FindType.FindByThumbprint, thumbrprint, false)[0];

var req = (HttpWebRequest)WebRequest.Create(string.Format("https://management.core.windows.net/{0}/services/hostedservices", subscriptionId));
req.Headers["x-ms-version"] = "2011-10-01";
req.ClientCertificates.Add(managementCert);

XNamespace xmlns = "http://schemas.microsoft.com/windowsazure";

Console.WriteLine(string.Join("\n", XDocument.Load(req.GetResponse().GetResponseStream()).Descendants(xmlns + "ServiceName").Select(n => n.Value).ToArray()));

Essentially, we can grab the certificate out of the certificate store using the thumbprint and then make the exact same call to the service management API.

The console output below shows that I'm able to get a list of all my hosted services:

It's as simple as that!

I'm not sure that this post applies to everyone—in fact, most of you may find it boring or cryptic—but for those of you that are building content or tools you'll probably find this a really simple way to automate a lot of the pieces. I know that my team plans to use these techniques in a lot of places to simply the experience of getting started with Windows Azure.

I hope this helps!

Please enable JavaScript to view the comments powered by Disqus.
comments powered by Disqus

            Introduction theme for Hugo. Made with  and  by open source contributors.


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace Ragnarok.Update
{
    /// <summary>
    /// アプリの最新バージョン情報をネット上から取得します。
    /// </summary>
    internal static class AppCastItemUtil
    {
        private const string TopItemNode = "/rss/channel/item";
        private const string TitleNode = "title";
        private const string UpdatePackLinkNode = "sparkle:updatePackLink";
        private const string ReleaseNotesLinkNode = "sparkle:releaseNotesLink";
        private const string EnclosureNode = "enclosure";
        private const string UrlAttribute = "url";
        private const string VersionAttribute = "sparkle:version";
        private const string MD5Signature = "sparkle:md5Signature";

        /// <summary>
        /// バージョン情報をXMLノードから作成します。
        /// </summary>
        private static AppCastItem CreateAppCastItemFromNode(XmlDocument doc, XmlNode e)
        {
            var ns = new XmlNamespaceManager(doc.NameTable);
            ns.AddNamespace("sparkle", "http://www.andymatuschak.org/xml-namespaces/sparkle");

            var titleNode = e.SelectSingleNode(TitleNode);
            if (titleNode == null)
            {
                throw new RagnarokUpdateException(
                    "バージョン情報にtitleタグがありません。");
            }

            var updatePackNode = e.SelectSingleNode(UpdatePackLinkNode, ns);
            if (updatePackNode == null)
            {
                throw new RagnarokUpdateException(
                    "バージョン情報にupdatePackLinkタグがありません。");
            }

            var releaseNoteNode = e.SelectSingleNode(ReleaseNotesLinkNode, ns);
            if (releaseNoteNode == null)
            {
                throw new RagnarokUpdateException(
                    "バージョン情報にreleaseNoteLinkタグがありません。");
            }

            var enclosureNode = e.SelectSingleNode(EnclosureNode);
            if (enclosureNode == null)
            {
                throw new RagnarokUpdateException(
                    "バージョン情報にenclosureタグがありません。");
            }

            var urlAttr = enclosureNode.Attributes[UrlAttribute];
            if (urlAttr == null)
            {
                throw new RagnarokUpdateException(
                    "バージョン情報にアプリのurlがありません。");
            }

            var versionAttr = enclosureNode.Attributes[VersionAttribute];
            if (versionAttr == null)
            {
                throw new RagnarokUpdateException(
                    "バージョン情報にアプリのバージョンがありません。");
            }

            // md5は無くても良しとする。
            var md5Attr = enclosureNode.Attributes[MD5Signature];

            return new AppCastItem
            {
                AppName = titleNode.InnerText,
                UpdatePackLink = updatePackNode.InnerText.Trim(),
                ReleaseNotesLink = releaseNoteNode.InnerText.Trim(),
                DownloadLink = urlAttr.Value,
                Version = versionAttr.Value,
                MD5Signature = (md5Attr != null ? md5Attr.Value : null),
            };
        }

        /// <summary>
        /// アプリの最新バージョン情報を取得します。
        /// </summary>
        /// <remarks>
        /// このメソッドは例外を投げる可能性があります。
        /// </remarks>
        public static AppCastItem GetLatestVersion(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return null;
            }

            /*using (var textReader = new StringReader(text))
            using (var reader = XmlReader.Create(textReader))*/
            {
                var doc = new XmlDocument
                {
                    PreserveWhitespace = false,
                };
                doc.LoadXml(text);

                var itemNodes = doc.SelectNodes(TopItemNode);
                AppCastItem latestVersion = null;

                // rss中の全itemタグを検索します。
                foreach (var itemNode in itemNodes.OfType<XmlNode>())
                {
                    var currentItem = CreateAppCastItemFromNode(doc, itemNode);

                    if (latestVersion == null)
                    {
                        latestVersion = currentItem;
                    }
                    else if (currentItem.CompareTo(latestVersion) > 0)
                    {
                        latestVersion = currentItem;
                    }
                }

                // go ahead
                return latestVersion;
            }
        }
    }
}


text:
'use strict';

module TourabuEx.resizeWidget {

    var GAME_WIDTH = 960,
        GAME_HEIGHT = 580,
        WINDOW_FRAME_WIDTH = window.outerWidth - window.innerWidth,
        WINDOW_FRAME_HEIGHT = window.outerHeight - window.innerHeight;

    function widgetProcess() {
        $(document).ready(function () {
            var width = GAME_WIDTH,
                height = GAME_HEIGHT;
            $('#dmm-ntgnavi-renew').hide();
            $(".dmm-ntgnavi").hide()
            $(document.body).css({ 'overflow': 'hidden' });
            $('#game_frame').attr('width', '100%').css({ width: '100%' });

            resizeAndScroll(width, height);

            onresized(onResizedHandler);
        });
    }

    function resizeAndScroll(width, height) {
        resize(width, height);
        scroll();
    }

    function scroll() {
        var gameFrame = document.getElementById('game_frame'),
            top = gameFrame.offsetTop,
            left = gameFrame.offsetLeft;

        window.scrollTo(left, top);
    }

    /**
    高さと幅のうち、変化量の大きい方を基準にして縦横比を維持しつつリサイズ
    */
    function onResizedHandler(oldWidth: number, oldHeight: number) {
        var currentWidth = window.outerWidth - WINDOW_FRAME_WIDTH,
            currentHeight = window.outerHeight - WINDOW_FRAME_HEIGHT,
            diffWidth = Math.abs(oldWidth - currentWidth),
            diffHeight = Math.abs(oldHeight - currentHeight),
            newWidth,
            newHeight;

        if (diffWidth > diffHeight) {
            newWidth = currentWidth;
            newHeight = Math.ceil(GAME_HEIGHT * (newWidth / GAME_WIDTH));
        } else {
            newHeight = currentHeight;
            newWidth = Math.ceil(GAME_WIDTH * (newHeight / GAME_HEIGHT));
        }

        chrome.runtime.sendMessage({
            type: 'widget/resized',
            body: {
                width: window.innerWidth,
                height: window.innerHeight
            }
        }, function () { });

        return resizeAndScroll(newWidth, newHeight);
    }

    /**
    内側のwidthとheightを基準にしてウィンドウをリサイズする
    */
    function resize(width, height) {
        var outerWidth = WINDOW_FRAME_WIDTH + width,
            outerHeight = WINDOW_FRAME_HEIGHT + height;
        window.resizeTo(outerWidth, outerHeight);
    }

    /**
    リサイズが完了したらファイアーする何か
    生のタイマーイベントは1pxごとに発火して
    */
    function onresized(fn: (width: number, height: number) => void): void {
        var tid, width = null, height = null;
        $(window).resize(function () {
            if (tid) { window.clearTimeout(tid); }
            if (!width) {
                width = window.innerWidth;
                height = window.innerHeight;
            }

            tid = window.setTimeout(function () {
                fn(width, height);
                width = null;
                height = null;
            }, 300);
        });
    }

    chrome.runtime.onMessage.addListener(function (mes, sender, res) {
        if (mes === 'mode/widget') {
            console.log('widget-mode');
            widgetProcess();
            return;
        }
    });
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Convay: Dokumentacja katalogu ConsoleConvay</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="navtree.css" rel="stylesheet" type="text/css"/>

<link href="search/search.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

Convay

Dokumentacja katalogu ConsoleConvay

Katalogi

katalog  	obj

katalog  	Properties

Pliki

plik  	Program.cs [kod źródłowy]

ConsoleConvay

Wygenerowano przez

     1.8.12