protected override IUavcanType TryResolveTypeCore(string ns, string typeName) { var definitionPath = TryLocateCompoundTypeDefiniton(ns, typeName); if (definitionPath == null) { return(null); } var meta = ParseMeta(definitionPath); Stream stream = null; try { stream = File.Open(definitionPath, FileMode.Open, FileAccess.Read, FileShare.Read); using (var reader = new StreamReader(stream)) { stream = null; return(DsdlParser.Parse(reader, meta)); } } finally { if (stream != null) { stream.Dispose(); } } }
public IUavcanType TryResolveType(string ns, string typeName) { var fullName = typeName.IndexOf('.') == -1 ? ns + "." + typeName : typeName; if (_fullNameToType.TryGetValue(fullName, out var type)) { return(type); } lock (_fullNameToType) { if (_fullNameToType.TryGetValue(fullName, out type)) { return(type); } type = TryResolveTypeCore(ns, typeName); if (type != null && !string.Equals(fullName, type.Meta.FullName, StringComparison.Ordinal)) { fullName = type.Meta.FullName; if (_fullNameToType.TryGetValue(fullName, out type)) { return(type); } } _fullNameToType[fullName] = type; if (type != null) { DsdlParser.ResolveNestedTypes(type, this); } } return(type); }