private void ClassNameReadCallback(ClassName arg) { if (!DataTypes.ContainsKey(arg.InternalId)) { DataTypes.Add(arg.InternalId, arg.Name); } }
public void RegisterMembers(DataTable table, ColumnCreator creator, string schema = "TABLE_SCHEMA", string name = "TABLE_NAME") { var query = SupportSchema ? from a in table.AsEnumerable() group a by a.Field <string>(schema) + "." + a.Field <string>(name) into g select new { g.Key, Columns = g } : from a in table.AsEnumerable() group a by a.Field <string>(name) into g select new { g.Key, Columns = g }; foreach (var item in query) { if (Objects.TryGetValue(item.Key, out ObjectElement obj)) { foreach (var data in item.Columns) { var typename = Convert.ToString(data[Names.DataType]); if (DataTypes.ContainsKey(typename)) { var clrtype = DataTypes[typename]; var column = creator.CreateColumn(data, clrtype); obj.Columns.Add(column.Name, column); } } } } }
public static DataType ByName(string dataTypeName) { if (DataTypes.ContainsKey(dataTypeName)) { return(DataTypes[dataTypeName]); } Exceptions.LogException( new UnknownDataTypeException(string.Format("DataType \"{0}\" is not installed.", dataTypeName))); return(DataTypes[DataTypeNames.UDT_DataType_String]); }
/*public IODataPathHandler GetODataPathHandler() { * return new TypeNameODataPathHandler(TypeNameResolver); * }*/ public IsRepository GetRepositoryForType(Type type) { if (DataTypes.ContainsKey(type)) { var repositoryType = DataTypes[type]; if (ContextResolver != null) { return((IsRepository)ContextResolver.Get(repositoryType, repositoryType.Name)); } return(repositoryType.New <IsRepository>()); } return(null); }
/// <summary> /// Implements Validate method from <see cref="IValidatableObject" /> interface /// </summary> /// <param name="validationContext">Context the validation runs in</param> /// <returns>List of validation results if any</returns> IEnumerable <ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) { var validationResults = new List <ValidationResult>(); foreach (var nodeTypeKeyValue in NodeTypes) { nodeTypeKeyValue.Value.SetDerivedFromToRoot(nodeTypeKeyValue.Key); foreach (var requirementKeyValue in nodeTypeKeyValue.Value.Requirements.SelectMany(r => r).ToArray()) { if (!string.IsNullOrEmpty(requirementKeyValue.Value.Node) && !NodeTypes.ContainsKey(requirementKeyValue.Value.Node)) { validationResults.Add(CreateRequirementValidationResult(requirementKeyValue, nodeTypeKeyValue)); } } foreach (var capabilityKeyValue in nodeTypeKeyValue.Value.Capabilities) { if (!CapabilityTypes.ContainsKey(capabilityKeyValue.Value.Type)) { validationResults.Add(CreateCapabilityTypeValidationResult(nodeTypeKeyValue.Key, capabilityKeyValue.Value.Type, capabilityKeyValue.Key)); } } foreach (var complexDataTypeKeyValue in DataTypes) { foreach (var basicDatatypeKeyValue in complexDataTypeKeyValue.Value.Properties) { var basicType = basicDatatypeKeyValue.Value.Type; if (!DataTypes.ContainsKey(basicType)) { validationResults.Add(new ValidationResult( string.Format("Data type '{0}' specified as part of data type '{1}' not found.", basicType, complexDataTypeKeyValue.Key))); } } } var circularDependencyValidationResults = nodeTypeKeyValue.Value.ValidateCircularDependency().ToList(); if (circularDependencyValidationResults.Any()) { return(validationResults.Concat(circularDependencyValidationResults)); } } var importCircularValidationResults = ValidateImportsCircularDependency(); if (importCircularValidationResults.Any()) { return(validationResults.Concat(importCircularValidationResults)); } if (!validationResults.Any()) { var requirementsGraph = new ToscaNodeTypeRequirementsGraph(this); if (requirementsGraph.ContainsCyclicLoop()) { validationResults.Add(new ValidationResult("Circular dependency detected by requirements on node type")); } } return(validationResults); }