/// <summary> /// Convert to model design /// </summary> /// <param name="types"></param> /// <returns></returns> public static ModelDesign ToModelDesign(this ITypeDictionary types) { var namespaceUri = types.TargetNamespace; if (namespaceUri == "http://opcfoundation.org/UA/Core/") { namespaceUri = Namespaces.OpcUa; } // Convert to node declartions var nodes = new List <NodeDesign>(); foreach (var dataType in types.Items) { var id = new XmlQualifiedName(dataType.Name, namespaceUri); var design = new DataTypeDesign { SymbolicId = id, SymbolicName = id, BaseType = Constants.BaseDataType, NoArraysAllowed = !dataType.AllowArrays, NoClassGeneration = dataType.NotInAddressSpace, NotInAddressSpace = dataType.NotInAddressSpace, IsAbstract = false, Description = dataType.Documentation.ToLocalizedText(), Category = dataType.Category, ReleaseStatus = (Design.Schema.ReleaseStatus)(int) dataType.ReleaseStatus, Purpose = (Design.Schema.DataTypePurpose)(int) dataType.Purpose }; switch (dataType) { case TypeDeclaration simpleType: design.SetDataType(simpleType); nodes.Add(design); break; case ComplexType complexType: design.SetDataType(complexType); nodes.Add(design); break; case ServiceType serviceType: // Not supported break; case EnumeratedType enumeratedType: design.SetDataType(enumeratedType); nodes.Add(design); break; } } return(new ModelDesign { Items = nodes.ToArray(), TargetNamespace = Namespaces.OpcUa, TargetVersion = types.TargetVersion, TargetPublicationDate = types.TargetPublicationDate, TargetPublicationDateSpecified = true, }); }
private static void AddToDictionary(ITypeDictionary dictionary, MSSQLTypeDesc desc, params string[] aliases) { List <string> names = null; if (!string.IsNullOrEmpty(desc.Name)) { names = new List <string>(aliases.Length + 1) { desc.Name }; names.AddRange(aliases); } dictionary.AddDesc(desc, names); }
private void Test(ITypeDictionary dictionary) { dictionary.Add(new Value(0)); dictionary.Add(new Value1(1)); dictionary.Add(new Value2(2)); dictionary.Add(new Value3(3)); Assert.AreEqual(4, dictionary.Count); try { dictionary.Add(new Value(1)); Assert.Fail("应该为重复加入!"); } catch (ArgumentException) { } try { dictionary.Add <Value>(new Value1(0)); Assert.Fail("应该为重复加入!"); } catch (ArgumentException) { } Assert.IsTrue(dictionary.Remove <Value>()); Assert.IsTrue(IsFind(dictionary.Values, 1, 2, 3)); Assert.IsTrue(dictionary.Contains <Value1>()); Assert.IsFalse(dictionary.Contains <Value>()); try { dictionary.Get <Value>(); Assert.Fail("应该提示未找到!"); } catch (KeyNotFoundException) { } }
private static void AddType(this ITypeDictionary dictionary, short typeIndex, NativeTypes baseType, string searchName, TypeOptions config, TypeUsageInfo info, params string[] aliases) { AddToDictionary(dictionary, new MSSQLTypeDesc(typeIndex, baseType, searchName, config, info), aliases); }
private static void AddType(this ITypeDictionary dictionary, short typeIndex, string searchName, TypeOptions config, TypeUsageInfo info, params string[] aliases) { AddType(dictionary, typeIndex, (NativeTypes)typeIndex, searchName, config, info, aliases); }
private static void AddType <T>(this ITypeDictionary dictionary, short typeIndex, NativeTypes baseType, string searchName, TypeOptions config, params string[] aliases) { var info = typeof(T).ToUsageInfo(); AddType(dictionary, typeIndex, baseType, searchName, config, info, aliases); }
private static void AddType <T>(this ITypeDictionary dictionary, short typeIndex, TypeOptions config, params string[] aliases) { AddType <T>(dictionary, typeIndex, null, config, aliases); }
protected Tester(ITypeDictionary <Object> map) => _map = map;