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


TypeScript Guid.newGuid方法代码示例

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


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

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

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