• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript cubitt-common.Guid类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Guid类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: it

		it("should correctly process a single command in a transaction", (done) => {
			try {
				subject.BeginTransaction();
				//Valid command
				let com: Commands.Command = new Commands.AddModelCommand(
					Common.Guid.newGuid(),
					Common.Guid.newGuid(),
					Common.Guid.newGuid(),
					Common.Guid.newGuid(),
					"TEST_MODEL",
					{}
				);
				subject.ApplyCommand(com);
				subject.CommitTransaction();
			} catch(e) {
				subject.Rollback();
			}
			done();
		});
开发者ID:uu-cubitt,项目名称:graph-cqrs,代码行数:19,代码来源:01_EmptyGraphTests.ts


示例3: 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


示例4: 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


示例5: 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


示例6: 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类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript cubitt-graph-cqrs.CQRSGraph类代码示例发布时间:2022-05-25
下一篇:
TypeScript csx.ColorHelper类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap