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


C# SourceCode.GetFileName方法代码示例

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


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

示例1: Compile

        public TargetCodeResult Compile(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition)
        {
            TargetCodeResult result = new TargetCodeResult(aCurrentCodeLine);
            String usingNamespace = GetUsingNamespace(aSourceCode, aCurrentCodeLine);

            bool correctLine = IsUsingCorrect(usingNamespace);

            if (!correctLine && (IsSystemNamespace(usingNamespace) || IsProgramNamespace(aSourceCode, usingNamespace)))
                return new TargetCodeResult("");

            if (correctLine)
            {
                // TODO: For now we import all the Java classes in that package, we don't worry much about that since the Java compiler will take care of this for us
                // Suggest that we do change this in the future if required
                StringBuilder newLine = new StringBuilder();
                newLine.Append("import ").Append(usingNamespace).Append(".*;");
                result = new TargetCodeResult(newLine.ToString());
            }
            else
            {
                StringBuilder newLine = new StringBuilder();
                newLine.Append("//");
                newLine.Append(aCurrentCodeLine);
                newLine.Append("  // Not supported yet");
                result = new TargetCodeResult(newLine.ToString());
                result.LogError(aSourceCode.GetFileName() + ": Using directive not supported yet on line: " + aLinePosition);
            }
            return result;
        }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:29,代码来源:UsingCompDirective.cs

示例2: DoValidation

        public String DoValidation(SourceCode aSourceCode)
        {
            String result = null;

            int totalClasses = CountClassName(aSourceCode);
            int totalInterfaces = CountInterfaces(aSourceCode);

            if (totalClasses == 0 && totalInterfaces == 0)
                result = aSourceCode.GetFileName() + ": A C# file must at least contain a class or an interface. ";

            if (totalClasses == 1 && totalInterfaces != 0)
                result = aSourceCode.GetFileName() + ": A C# file can only have one class or interface just like Java. ";
            else if (totalInterfaces == 1 && totalClasses != 0)
                result = aSourceCode.GetFileName() + ": A C# file can only have one class or interface just like Java. ";

            return result;
        }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:17,代码来源:OnlySingleClassAndInterfacePerFile.cs

示例3: Identify

        public bool Identify(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition)
        {
            // TODO: We need to also cater for C# properties later on

            bool result = false;
            if (aSourceCode.CountTokens(aCurrentCodeLine, '(') == 1 &&
                aSourceCode.CountTokens(aCurrentCodeLine, ')') == 1 &&
                aCurrentCodeLine.IndexOf(aSourceCode.GetFileName()) == -1 &&
                !aSourceCode.ContainKeyword(aCurrentCodeLine, "class") &&
                aCurrentCodeLine.Split(' ').Length > 2 &&
                !MainMethodComp.IdentifyMainMethod(aSourceCode, aCurrentCodeLine, aLinePosition) &&
                (aCurrentCodeLine.EndsWith("{") || aSourceCode.GetNextLine(aLinePosition).StartsWith("{")))
                result = true;

            return result;
        }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:16,代码来源:MethodDefinitionComp.cs

示例4: DoValidation

        public string DoValidation(SourceCode aSourceCode)
        {
            String result = null;

            bool foundIndexers = false;
            int pos = 1;
            foreach (String line in aSourceCode.GetLines())
            {
                if (line.IndexOf("this[") > -1 && (line.EndsWith("{") || aSourceCode.GetNextLine(pos).StartsWith("{")))
                    foundIndexers = true;
                pos++;
            }

            if (foundIndexers)
                result = aSourceCode.GetFileName() + ": Java unfortunatly doesn't support C# indexers. ";

            return result;
        }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:18,代码来源:NoCSharpIndexers.cs


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