public IType ConvertCSharpTypeToPromptoType(Context context, Type type, IType returnType) { IType result; typeToPromptoMap.TryGetValue(type, out result); if (result != null) { return(result); } result = GetITypeFromCollectionType(context, type); if (result != null) { return(result); } NativeCategoryDeclaration decl = context.getNativeBinding(type); if (decl != null) { return(decl.GetIType(context)); } else if (returnType == AnyType.Instance) { return(returnType); } else { return(null); } }
public void registerNativeBinding(Type type, NativeCategoryDeclaration declaration) { if (this == globals) { nativeBindings[type] = declaration; } else { globals.registerNativeBinding(type, declaration); } }
public NativeInstance(NativeCategoryDeclaration declaration, Object instance) : base(new CategoryType(declaration.GetName())) { this.declaration = declaration; this.instance = instance; if (declaration.Storable) { List <string> categories = new List <string>(); categories.Add(declaration.GetName()); storable = DataStore.Instance.NewStorable(categories, null); } }
public void TestAttributeList() { MethodInfo method = typeof(TestCSharpClassType).GetMethod("getAllAttributes"); Assert.IsNotNull(method); Type type = method.ReturnType; Assert.IsNotNull(type); Context context = Context.newGlobalsContext(); String name = "Attribute"; NativeCategoryDeclaration declaration = new NativeCategoryDeclaration(name, null, null, null, null); context.registerNativeBinding(typeof(AttributeDeclaration), declaration); IType listType = new ListType(new CategoryType(name)); IType returnType = new CSharpClassType(type).ConvertCSharpTypeToPromptoType(context, listType); Assert.AreEqual(listType, returnType); }
private static IValue ConvertCategory(Context context, Object value, Type type, IType returnType) { if (type == null) { return(null); } NativeCategoryDeclaration decl = context.getNativeBinding(type); if (decl != null) { return(new NativeInstance(decl, value)); } else if (returnType == AnyType.Instance) { return(new NativeInstance(AnyNativeCategoryDeclaration.Instance, value)); } else { return(null); } }
private IValue GetCategory(Context context) { NativeCategoryDeclaration decl = context.getRegisteredDeclaration <NativeCategoryDeclaration>("Category"); return(new NativeInstance(decl, declaration)); }