示例#1
0
        public T FindType <T>(string name, bool raiseException)
        {
            if (name.EndsWith(" std::string"))
            {
                name = "std::string";
            }

            if (name == "std::string")
            {
                return((T)(object)new DefString());
            }

            if (name == "DisplayString")
            {
                return((T)(object)new DefUtfString());
            }

            if (name.StartsWith(Globals.NativeNamespace + "::"))
            {
                name = name.Substring(name.IndexOf("::") + 2);
            }

            T type = FindTypeInList <T>(name, Types, false);

            if (type == null)
            {
                if (ParentNameSpace == null)
                {
                    if (raiseException)
                    {
                        throw new Exception("Could not find type");
                    }
                    else
                    {
                        return((T)(object)new DefInternal(name));
                    }
                }
                else
                {
                    return(ParentNameSpace.FindType <T>(name, raiseException));
                }
            }

            if (type is DefType)
            {
                // Short circuit out to handle OGRE 1.6 memory allocator types
                if (((DefType)(object)type).IsIgnored)
                {
                    return((T)(object)type);
                }
            }

            return((T)(object)DefType.CreateExplicitType((DefType)(object)type));
        }
示例#2
0
        public T FindType <T>(string name, bool raiseException)
        {
            if (name.EndsWith(" std::string"))
            {
                name = "std::string";
            }

            if (name == "std::string")
            {
                return((T)(object)new DefString());
            }

            if (name.StartsWith(Globals.NativeNamespace + "::"))
            {
                name = name.Substring(name.IndexOf("::") + 2);
            }

            T type = FindTypeInList <T>(name, Types, false);

            if (type == null)
            {
                if (ParentNameSpace == null)
                {
                    if (raiseException)
                    {
                        throw new Exception("Could not find type");
                    }
                    else
                    {
                        return((T)(object)new DefInternal(name));
                    }
                }
                else
                {
                    return(ParentNameSpace.FindType <T>(name, raiseException));
                }
            }

            return((T)(object)DefType.CreateExplicitType((DefType)(object)type));
        }