示例#1
0
        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;
        }
示例#2
0
        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;
        }
示例#3
0
        private void AddControlScripts(string typename, string ns, Assembly assembly)
        {
            var fullname = ns + "." + typename;
            var rtype = assembly.GetType(fullname);
            var ctype = new NativeTypeRef(this, rtype);

            AddDependencyObjectScripts(ctype);

            ctype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.Control.js");

            if (typename == "ComboBox")
            {
                ctype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts.ItemsControl.js");
            }

            ctype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts." + typename + ".js");
        }
示例#4
0
        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");

        }
示例#5
0
 private void AddControlScripts(Type type)
 {
     var ctype = new NativeTypeRef(this, type, true);
     ctype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts." + type.Name + ".js");
 }
示例#6
0
 private NativeTypeRef AddClassScripts(Type type)
 {
     var ctype = new NativeTypeRef(this, type, true);
     ctype.AddScriptReference(typeof(StockObjectRoot).Assembly, "Scripts." + type.Name + ".js");
     return ctype;
 }
示例#7
0
        /// <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;
        }