当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Guid.parse方法代码示例

本文整理汇总了TypeScript中cubitt-common.Guid.parse方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Guid.parse方法的具体用法?TypeScript Guid.parse怎么用?TypeScript Guid.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cubitt-common.Guid的用法示例。


在下文中一共展示了Guid.parse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: parseInt

router.get("/projects/:projectid/:version").handler(function (routingContext: RoutingContext): any {
	let response: HttpServerResponse = routingContext.response();
	response.putHeader("content-type", "application/json");
	let projectId: Common.Guid = Common.Guid.parse(routingContext.request().getParam("projectid"));
	if (projectId === null) {
		response.setStatusCode(404).end();
		return;
	}

	let version: number | string;
	if (routingContext.request().getParam("version") === "latest"){
		version = "latest";
	} else {
		version = parseInt(routingContext.request().getParam("version"));
	}

	eb.send("projects.query." + projectId, version, function(res, res_err) {
		if (res_err) {
			console.log("Query message delivery failure! : " + res_err);
			response.setStatusCode(500).end();
		} else {
			response.setStatusCode(200).end(res.body());
		}
	});
});
开发者ID:uu-cubitt,项目名称:project-manager,代码行数:25,代码来源:cubitt-project-manager.ts

示例2: function

router.post("/projects/:projectid").handler(function (routingContext: RoutingContext): any {
	let transaction: any = routingContext.getBodyAsJson();
	let response: HttpServerResponse = routingContext.response();
	response.putHeader("content-type", "application/json");
	let projectId: Common.Guid = Common.Guid.parse(routingContext.request().getParam("projectid"));
	if (projectId === null) {
		response.setStatusCode(404).end();
		return;
	}
	// Check if we have such an Actor with that ID
	// Check if we already have such an project actor
	sd.getClusterWideMap("actors", function (res, res_err) {
		if (res_err !== null) {
			console.log("Failed to obtain actor map: " + res_err);
			response.setStatusCode(500).end();
			return;
		}
		let actors = res;

		actors.get(projectId.toString(), function (res, res_err) {
			if (res_err !== null) {
				console.log("Could not get data from cluster wide map " + res_err);
				response.setStatusCode(500).end();
				return;
			}
			if (res === null) {
				console.log("No actor with id " + projectId + " is known");
				response.setStatusCode(404).end();
				return;
			}
			// Validate postbody
			if (transaction.commands === undefined || transaction.commands === null) {
				response.setStatusCode(400).end(JSON.stringify({ status: 400, data: null, error: "Missing required commands" }));
				return;
			}
			if ((transaction.commands instanceof Array) === false || transaction.commands.length === 0) {
				response.setStatusCode(400).end(JSON.stringify({ status: 400, data: null, error: "commands should be a non-empty Array" }));
				return;
			}
			eb.send("projects.commands." + projectId.toString(), JSON.stringify(routingContext.getBodyAsJson()), function (reply: Message, reply_err: any): any {
				if (reply_err === null) {
					// Write to the response and end it
					let body: any = JSON.parse(reply.body());
					response.setStatusCode(body.status).end(reply.body());
				} else {
					response.setStatusCode(500).end();
				}
			});
		});
	});
});
开发者ID:uu-cubitt,项目名称:project-manager,代码行数:51,代码来源:cubitt-project-manager.ts

示例3: deserialize

  public deserialize(jsonObject : Object) : Draw2D {
      var draw2d = new Draw2D();
      var models = jsonObject['models'];

      for (var modelKey in models) {
          var model = models[modelKey];
          var id = Common.Guid.parse(model["id"]);
          var properties = this.propertiesFromJSON(model["properties"]);
          draw2d.addModel(id,properties["type"],properties);
      }

      var nodes = jsonObject['nodes'];
      for (var nodeKey in nodes) {
          var node = nodes[nodeKey];
          var id = Common.Guid.parse(node["id"]);
          var properties = this.propertiesFromJSON(node["properties"]);
          var modelId = Common.Guid.parse(node["neighbours"]["models"]["parent"][0]);
          draw2d.addNode(id,properties["type"],modelId,properties)
      }

      var connectors = jsonObject['connectors'];
      for (var connectorKey in connectors) {
          var connector = connectors[connectorKey];
          var id = Common.Guid.parse(connector["id"]);
          var properties = this.propertiesFromJSON(connector["properties"]);
          var nodeId = Common.Guid.parse(connector["neighbours"]["nodes"]["parent"]["0"]);
          draw2d.addConnector(id,properties['type'], properties, nodeId);
      }

      var edges = jsonObject['edges'];
      for (var edgeKey in edges) {
          var edge = edges[edgeKey];
          var id = Common.Guid.parse(edge["id"]);
          var properties = this.propertiesFromJSON(edge["properties"]);
          var modelId = Common.Guid.parse(edge["neighbours"]["models"]["parent"][0]);
          var startConnector = Common.Guid.parse(edge["neighbours"]["connectors"]["parent"][0]);
          var endConnector = Common.Guid.parse(edge["neighbours"]["connectors"]["parent"][1]);
          draw2d.addEdge(id,properties["type"],modelId,startConnector, endConnector, properties);
      }
      return draw2d;
  }
开发者ID:sacapita,项目名称:csa,代码行数:41,代码来源:Draw2D.ts

示例4: require

import http = require('http');
import request = require('request');
import path = require('path');
import {Graph as D2DGraph} from "./Graph";
import {CommandGenerator} from "./CommandGenerator";
import {Draw2D} from "./Draw2D";
import {D2DAbstractElement} from "./D2DAbstractElement"
import {D2DModelElement} from "./D2DModelElement"

let app = express();
let router = express.Router();
let host = "http://185.3.208.201";
let appPort = 12345;
let backendPort = 8080;
let graph = null;
let sessionId: Common.Guid = Common.Guid.parse("cd46e14a-97ca-40e3-81be-ae1c18e7e114");
let cg = null; // CommandGenerator
let d2dGraph;

router.use(bodyParser.json());
router.use(bodyParser.urlencoded({ extended: true }));
routes();
router.use(express.static(__dirname + '/client'));
app.use('/', router);
app.listen(appPort, function () {
  console.log('Running at '+ host +':' + appPort);
});

function routes(){
  router.get( '/', function( req, res ) {
    console.log("sessionId for this session: " + sessionId.toString());
开发者ID:sacapita,项目名称:csa,代码行数:31,代码来源:app.ts

示例5: serialize

  /**
   * Convert a JSON Draw2D graph object to a Graph
   */
    public serialize(jsGraph: string): Graph {
        let graph = new Graph();
        let json = JSON.parse(jsGraph);

        for(let m in json){
            let model = json[m];
            let modelId = (model.id ? Common.Guid.parse(model.id) : Common.Guid.newGuid());

            this.addModel(modelId, model.type, {});
            let ports : string[] = []; // ports from Draw2D aka connectors for this object

            for(let key in model.elements) {
                let elem = model.elements[key];
                let elemId = elem.id;
                let elemProperties: Object[] = [];
                let connectorsToAdd: {id: Common.Guid, type: string; elemId: Common.Guid, props: Object[]}[] = [];

                switch(elem.type){
                    case "csa.Edge":
                        var startNodeId: Common.Guid = null;
                        var startConnectorId: Common.Guid = null;
                        var endNodeId: Common.Guid = null;
                        var endConnectorId: Common.Guid = null;
                        for(let prop in elem) {
                            let value = elem[prop];
                            if(prop == "source" && elem.hasOwnProperty("source")){
                                startNodeId = Common.Guid.parse(elem.source.node);
                                startConnectorId = Common.Guid.parse(ports[elem.source.port]);
                            }else if(prop == "target" && elem.hasOwnProperty("target")){
                                endNodeId = Common.Guid.parse(elem.target.node);
                                endConnectorId = Common.Guid.parse(elem.target.port.substring(6, elem.target.port.length));
                            }else{
                                elemProperties[prop] = value;
                            }
                        }
                        this.addEdge(elemId, elem.type, modelId, startNodeId, startConnectorId, endNodeId, endConnectorId, elemProperties);
                        break;
                    default:
                        for(let prop in elem) {
                            let value = elem[prop];
                            if(prop == "ports" && elem.hasOwnProperty(prop)){
                                for(let port in value){
                                    // Add connector for each port
                                    let portObject = value[port];
                                    let portProperties: Object[] = [];
                                    for(let portProps in portObject){
                                        portProperties[portProps] = portObject[portProps];
                                    }
                                    let connector = {id: portObject.id, type: portObject.type, elemId: elemId, props: portProperties};
                                    connectorsToAdd.push(connector);
                                    ports[portProperties["name"]] = portObject.id;
                                }
                            }else{
                                elemProperties[prop] = value;
                            }
                        }
                        this.addNode(elemId, elem.type, modelId, elemProperties);
                        let self = this;
                        connectorsToAdd.forEach(function(currentValue, index, arr){ self.addConnector(currentValue.id, currentValue.type, currentValue.elemId, currentValue.props); });
                        break;
                }
            }
        }
        return this;
    }
开发者ID:sacapita,项目名称:csa,代码行数:68,代码来源:Graph.ts


注:本文中的cubitt-common.Guid.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。