private static List<Document> GetOperationDocs(ServiceModelType serviceModel, string fileName) { List<Document> operationDocs = new List<Document>(); foreach (var operation in serviceModel.Service.SelectMany(ser => ser.Operation)) { string id = fileName + "_" + operation.name; //.Replace("-", "").Replace(".", ""); //id = Guid.NewGuid().ToString(); string serviceNameSpace = operation.semanticTypeName; Document doc = new Document(); doc.Add(new Field("ID", id, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(getField("DocType", "SERVICEMODEL")); doc.Add(new Field("FileName", fileName, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("SemanticTypeName", serviceNameSpace, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("OperationName", operation.name, Field.Store.YES, Field.Index.NOT_ANALYZED)); string hashValue = GetCombinedSemanticHashValue(operation); doc.Add(new Field("SemanticCombinedString", hashValue, Field.Store.YES, Field.Index.NOT_ANALYZED)); string semanticThumbprintSHA256 = CalculateHexThumbprintSha256(hashValue); doc.Add(new Field("SemanticThumbprint", semanticThumbprintSHA256, Field.Store.YES, Field.Index.NOT_ANALYZED)); addOperationRequiringInputs(operation, doc); addOperationProvidingOutput(operation, doc); if (operation.UsesOperation != null) { var fields = operation.UsesOperation.Select(usesOperation => new Field("UsesOperation", usesOperation.semanticTypeName, Field.Store.YES, Field.Index.NOT_ANALYZED)) .ToArray(); Array.ForEach(fields, doc.Add); } if (operation.RequiresContext != null) { var fields = operation.RequiresContext.Select(reqCtx => new Field("RequiresContext", reqCtx.semanticTypeName, Field.Store.YES, Field.Index.NOT_ANALYZED)) .ToArray(); Array.ForEach(fields, doc.Add); } operationDocs.Add(doc); } return operationDocs; }
private static ServiceNode[] GetServiceNodes(ServiceModelType serviceModel, string name) { List<ServiceNode> serviceNodes = new List<ServiceNode>(); foreach (var operation in serviceModel.Service.SelectMany(ser => ser.Operation)) { var semanticCombination = GetCombinedSemanticHashValue(operation); var hashValue = CalculateHexThumbprintSha256(semanticCombination); ServiceNode serviceNode = new ServiceNode { ID = name + "_" + operation.name, SemanticName = operation.semanticTypeName, SemanticThumbprint = hashValue }; var semanticUsages = getTechSemanticStrArray(operation.Parameter); serviceNode.ConsumeFields.AddRange(semanticUsages); if (operation.ReturnValue != null) { var semanticProducing = getTechSemanticStrArray(operation.ReturnValue); serviceNode.ProducesFields.AddRange(semanticProducing); } if (operation.UsesOperation != null) { serviceNode.ConsumesServices.AddRange(operation.UsesOperation.Select(use => use.semanticTypeName)); } if (operation.RequiresContext != null) { var contextUsages = getTechSemanticStrArray(operation.RequiresContext); serviceNode.ConsumeFields.AddRange(contextUsages); } serviceNodes.Add(serviceNode); } return serviceNodes.ToArray(); }
private static List<Document> GetDataModelDocs(ServiceModelType serviceModel, string fileName) { List<Document> dataModelDocs = new List<Document>(); foreach (var dataModel in serviceModel.DataContract ?? new DataContractType[0]) { string id = fileName + "_" + dataModel.name; Document doc = new Document(); doc.Add(getField("ID", id)); doc.Add(getField("DocType", "DATAMODEL")); string hashValue = GetCombinedSemanticHashValue(dataModel); doc.Add(getField("SemanticCombinedString", hashValue)); string semanticThumbprintSHA256 = CalculateHexThumbprintSha256(hashValue); doc.Add(new Field("SemanticThumbprint", semanticThumbprintSHA256, Field.Store.YES, Field.Index.NOT_ANALYZED)); addDataModelProvider(dataModel, doc); dataModelDocs.Add(doc); } return dataModelDocs; }