MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / ToReadOnlyKeyValueCollection

Method ToReadOnlyKeyValueCollection

src/NodeRTLib/Converter.cs:330–357  ·  view source on GitHub ↗
(string collectionName, Type keyType, Type valueType)

Source from the content-addressed store, hash-verified

328 }
329
330 public static string[] ToReadOnlyKeyValueCollection(string collectionName, Type keyType, Type valueType)
331 {
332 string keyRtType = TX.ToWinRT(keyType);
333 string[] keyTypeToJs = ToJS(keyType, TX.MainModel.Types.ContainsKey(keyType));
334 string keyCheckType = TypeCheck(keyType, TX.MainModel.Types.ContainsKey(keyType));
335 string[] jsToKeyElementType = ToWinRT(keyType, TX.MainModel.Types.ContainsKey(keyType));
336
337 string valueRtType = TX.ToWinRT(valueType);
338 string[] valueTypeToJs = ToJS(valueType, TX.MainModel.Types.ContainsKey(valueType));
339
340 // note that double curl braces here are used because String.Format will
341 string creatorFunction = "NodeRT::Collections::" + collectionName + "Wrapper<" + keyRtType + "," + valueRtType + ">::Create" + collectionName + "Wrapper({0}, \r\n" +
342" [](" + keyRtType + " val) -> Local<Value> {{\r\n" +
343" return " + ReplaceBracketsWithDoubleBrackets(String.Format(keyTypeToJs[1], "val")) + ";\r\n" +
344" }},\r\n" +
345" [](Local<Value> value) -> bool {{\r\n" +
346" return " + ReplaceBracketsWithDoubleBrackets(String.Format(keyCheckType, "value")) + ";\r\n" +
347" }},\r\n" +
348" [](Local<Value> value) -> " + keyRtType + " {{\r\n" +
349" return " + ReplaceBracketsWithDoubleBrackets(String.Format(jsToKeyElementType[1], "value")) + ";\r\n" +
350" }},\r\n" +
351" [](" + valueRtType + " val) -> Local<Value> {{\r\n" +
352" return " + ReplaceBracketsWithDoubleBrackets(String.Format(valueTypeToJs[1], "val")) + ";\r\n" +
353" }}\r\n" +
354" )";
355
356 return new[] { "NodeRT::Collections::Create" + collectionName + "<" + keyRtType + "," + valueRtType + ">", creatorFunction };
357 }
358
359 public static string[] ToKeyValueCollection(string collectionName, Type keyType, Type valueType)
360 {

Callers

nothing calls this directly

Calls 1

ToWinRTMethod · 0.45

Tested by

no test coverage detected