当前位置: 首页>>代码示例>>C#>>正文


C# Globals.AddNamespace方法代码示例

本文整理汇总了C#中Globals.AddNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# Globals.AddNamespace方法的具体用法?C# Globals.AddNamespace怎么用?C# Globals.AddNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Globals的用法示例。


在下文中一共展示了Globals.AddNamespace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseNamespace

        protected void ParseNamespace(StringReader rdr, Globals globals, DepthScanner scanner, ref int currentLine, bool asNamespace)
        {
            string l = "";
            int depth = scanner.GetBraceDepth(currentLine);
            bool hitDeeper = false;
            while ((l = rdr.ReadLine()) != null)
            {
                string defName = "";
                int lineNumber = 0;
                ExtractLineInfo(ref l, out defName, out lineNumber);

                ++currentLine;
                if (l.Trim().StartsWith("//"))
                    continue;
                if (l.Trim().StartsWith("#"))
                    continue;
                int curDepth = scanner.GetBraceDepth(currentLine-1);
                if (!asNamespace)
                {
                    if (curDepth < depth) // Left our namespace depth
                        return;
                    else if (curDepth > depth) // Outside of the desired scanning depth (namespace level)
                        continue;
                }
                else
                {
                    if (curDepth > depth)
                        hitDeeper = true;
                    if (curDepth == depth && hitDeeper)
                        return;
                    else if (curDepth > depth + 1) //We do not go deeper than the namespace
                        continue;
                }

                string line = l.Trim();
                if (line.Length == 0)
                    continue;
                string[] tokens = line.Split(BREAKCHARS);

                // Class / Interface/ Template type
                if (ResemblesClass(line))
                {
                    int abstractIdx = Array.IndexOf(tokens, "abstract");
                    int sharedIdx = Array.IndexOf(tokens, "shared");
                    int templateIdx = Array.IndexOf(tokens, "template");
                    int mixinIdx = Array.IndexOf(tokens, "mixin");
                    int finalIdx = Array.IndexOf(tokens, "final");

                    int classTermIdx = Math.Max(abstractIdx, Math.Max(sharedIdx, Math.Max(templateIdx, Math.Max(mixinIdx, finalIdx)))) + 1;

                    bool isInterface = tokens[classTermIdx].Equals("interface");
                    if (templateIdx != -1)
                    {
                        //Resolve template type?
                    }

                    string className = tokens[classTermIdx + 1];
                    TypeInfo ti = new TypeInfo { Name = className,
                        IsTemplate = templateIdx != -1, IsShared = sharedIdx != -1,
                        IsAbstract = abstractIdx != -1, IsMixin = mixinIdx != -1,
                        IsInterface = isInterface,
                        SourceLine = lineNumber, SourceFile = defName };

                    // Get any baseclasses, baseclass must appear first
                    for (int i = classTermIdx + 2; i < tokens.Length; ++i)
                    {
                        string baseName = tokens[i];
                        if (globals.ContainsTypeInfo(baseName.Replace(",","")))
                            ti.BaseTypes.Add(globals.GetTypeInfo(baseName.Replace(",","")));
                    }
                    ParseClass(rdr, globals, scanner, ti, ref currentLine);
                    globals.AddTypeInfo(className, ti);
                }
                else if (tokens[0].ToLower().Equals("namespace")) // Namespace
                {
                    string nsName = tokens[1];
                    Globals namespaceGlobals = null;
                    if (globals.ContainsNamespace(nsName)) // Check if the namespace has been encountered before
                        namespaceGlobals = globals.GetNamespace(nsName);
                    else
                        namespaceGlobals = new Globals(false);
                    namespaceGlobals.Parent = globals;
                    ParseNamespace(rdr, namespaceGlobals, scanner, ref currentLine, true);
                    namespaceGlobals.Name = nsName;
                    globals.AddNamespace(nsName, namespaceGlobals);
                }
                else if (tokens[0].ToLower().Equals("enum")) // Enumeration
                {
                    ParseEnum(line, rdr, globals, ref currentLine);
                }
                else
                {
                    if (ResemblesFunction(line)) // Global/namespace function
                    {
                        try
                        {
                            FunctionInfo fi = _parseFunction(rdr, line, globals, lineNumber, defName);
                            if (fi != null)
                                globals.AddFunction(fi);
                        }
//.........这里部分代码省略.........
开发者ID:nonconforme,项目名称:UrhoAngelscriptIDE,代码行数:101,代码来源:AngelscriptParser.cs


注:本文中的Globals.AddNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。