public override ITypeItem TranslateRType(Type type, TranslateOptions options) { ITypeItem result; if (type.IsGenericParameter) { throw new Exception("generic parameters are not supported."); } if (!Types.TryGetItem(type.GetRName(), out result)) { if (options.IsAdd()) { result = new NativeTypeRef(this, type); result.SetExternal(); } else { if (type.IsGenericType) { var ge = new GenericInterfaceEnumerator(type); foreach (var itf in ge.Interfaces) { if (Types.TryGetItem(itf.GetRName(), out result)) { break; } } if (null == result) { throw new UnresolvedTypeException("no mapping for generic type [" + type.GetRName() + "]"); } } } } if (null == result && options == TranslateOptions.MustExist) { throw new UnresolvedTypeException("runtime type '" + type.GetRName() + "' could not be resolved."); } return result; }
protected virtual ITypeItem AddRuntimeType(Type type) { ITypeItem result; if (type.IsGenericType) { // pass generic types to Module level result = Parent.TranslateRType(type, true); } else if (type.IsEnum) { result = new Enumeration(GetTypeDeclarationContext(), type); } else { // convert this type (JL3A77746Z)? if (IsGeneratedRType(type)) { result = new Class(GetTypeDeclarationContext(), type); } else { // explicitly external class result = new NativeTypeRef(GetTypeDeclarationContext(), type); result.SetExternal(); } } return result; }
private void AddDependencyObjectScripts(NativeTypeRef ntype) { ntype.SetExternal(); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.Delegate.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.ControlFactory.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.Binding.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.InputBinding.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.DependencyObject.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.Control.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.TemplateFactory.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.DataTypes.js"); // TODO: does not belong here! ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.TypeSystem.js"); // TODO: neither do these. ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.UserControl.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.PathControl.js"); ntype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.Converters.js"); }
/// <summary> /// All types inserted on this level are considered native types. /// </summary> /// <param name="type"></param> /// <returns></returns> private ITypeItem AddRType(Type type) { ITypeItem result; if (!Types.TryGetItem(type.GetRName(), out result)) { result = new NativeTypeRef(this, type); result.SetExternal(); } return result; }