• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SourceCode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GenerateReader

 public override SourceCode GenerateReader(CodeContext context)
 {
     var code = new SourceCode();
     code.Append("this->skip(static_cast<msg_size_t>(sizeof(msg_type_t)));");
     code.Append("(*this) >> {0};", GetVarAccessor(context));
     return code;
 }
开发者ID:ktj007,项目名称:mmo,代码行数:7,代码来源:RefField.cs


示例2: Compile

        public TargetCodeResult Compile(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition)
        {
            String line = aCurrentCodeLine;
            if (aSourceCode.ContainKeyword(aCurrentCodeLine, "override"))
                line = aSourceCode.RemoveKeyword(line, "override");

            if (aSourceCode.ContainKeyword(aCurrentCodeLine, "virtual"))
                line = aSourceCode.RemoveKeyword(line,"virtual");

            if (aSourceCode.ContainKeyword(aCurrentCodeLine, "internal"))
                line = aSourceCode.ReplaceKeyword(line, "internal", "protected");

            if (aSourceCode.ContainKeyword(aCurrentCodeLine, "internal protected"))
                line = aSourceCode.ReplaceKeyword(line, "internal protected", "protected");

            StringBuilder newLine = new StringBuilder();

            newLine.Append(line);

            // TODO: We need to b able to indicate exception per method not just for all methods
            //if (aSourceCode.Arguments.ContainProgramArgument("throwexceptions"))
            //newLine.Append(" throws Exception");

            return new TargetCodeResult(newLine.ToString());
        }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:25,代码来源:MethodDefinitionComp.cs


示例3: GenerateField

 public override SourceCode GenerateField(CodeContext context)
 {
     var code = new SourceCode();
     code.Append("typedef std::vector<{0}> {1};", CanonicalTarget, TypeName);
     code.Append("{0} {1};", TypeName, VarName);
     return code;
 }
开发者ID:ktj007,项目名称:mmo,代码行数:7,代码来源:RefListField.cs


示例4: Compile

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

            String superClassName = GetSupperClassName(aCurrentCodeLine);
            if (superClassName != null)
            {

                String classDef = GetClassDefinition(aCurrentCodeLine);

                StringBuilder newLine = new StringBuilder();
                if (classDef.StartsWith("class"))
                    newLine.Append("public ");

                newLine.Append(classDef);

                if (superClassName.IndexOf(",") > -1)
                    newLine.Append(" extends ").Append(GetExtendClass(superClassName)).Append(GetInterfaces(superClassName));
                else
                {
                    if (!superClassName.StartsWith("I"))
                        newLine.Append(" extends ").Append(superClassName);
                    else
                        newLine.Append(" implements ").Append(superClassName);
                }
                result = new TargetCodeResult(newLine.ToString());
            }

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


示例5: GetType

 private ComparisonOperatorToken.OperatorType GetType(ref SourceCode code)
 {
     ComparisonOperatorToken.OperatorType t = ComparisonOperatorToken.OperatorType.Equals;
     if (code.Matches("=="))
     {
         t = ComparisonOperatorToken.OperatorType.Equals;
         code += 2;
     }
     if (code.Matches("!="))
     {
         t = ComparisonOperatorToken.OperatorType.NotEquals;
         code += 2;
     }
     if (code.Matches("<="))
     {
         t = ComparisonOperatorToken.OperatorType.LessThanOrEqual;
         code += 2;
     }
     if (code.Matches("<"))
     {
         t = ComparisonOperatorToken.OperatorType.LessThan;
         code++;
     }
     if (code.Matches(">="))
     {
         t = ComparisonOperatorToken.OperatorType.GreaterThanOrEqual;
         code += 2;
     }
     if (code.Matches(">"))
     {
         t = ComparisonOperatorToken.OperatorType.GreaterThan;
         code++;
     }
     return t;
 }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:35,代码来源:ComparisonOperatorBuilder.cs


示例6: GetUsingNamespace

 private static String GetUsingNamespace(SourceCode aSourceCode, string aCurrentCodeLine)
 {
     String usingNamespace = aCurrentCodeLine;
     usingNamespace = aSourceCode.ReplaceKeyword(usingNamespace, "using", "").Trim();
     usingNamespace = usingNamespace.Replace(";", "").Trim();
     return usingNamespace;
 }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:7,代码来源:UsingCompDirective.cs


示例7: LateBuild

 public override Token LateBuild(ScriptEngine engine, ref SourceCode sourceCode, ref Script script)
 {
     bool plus = _typeStack.Pop();
     var tokens = new List<Token>(engine.CurrentTokens);
     engine.CurrentTokens.Clear();
     return new PlusPlusMinusMinusToken(tokens, plus, true);
 }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:7,代码来源:PlusPlusMinusMinusBuilder.cs


示例8: 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


示例9: InitializeWizard

        private void InitializeWizard(SourceCode.Framework.WizardInitializeArgs e)
        {
            PowerShellEvent eventObj = null;

            switch (base.Status)
            {
                case WizardStatus.New:
                case WizardStatus.NewDelayed:
                    eventObj = new PowerShellEvent();
                    eventObj.WizardDefinition = base.Definition;
                    SourceCode.Workflow.Wizards.WizardHelper.GetEventActivity(e.Parent).Events.Insert(e.InsertIndex, eventObj);
                    if (base.Status == WizardStatus.NewDelayed)
                    {
                        return;
                    }
                    break;
                case WizardStatus.Executed:
                case WizardStatus.Delayed:
                    if (e.Parent is PowerShellEvent)
                    {
                        eventObj = (PowerShellEvent)e.Parent;
                    }
                    break;
            }

            base.Pages.Add(new Pages.Start());
            base.Pages.Add(new Pages.InputVariables(eventObj));
            base.Pages.Add(new Pages.PowerShellScript(eventObj));
            base.Pages.Add(new Pages.OutputVariables(eventObj));
            base.Pages.Add(new Pages.Finish());
        }
开发者ID:cyclops1982,项目名称:SourceCode.Wizard.PowerShell,代码行数:31,代码来源:PowerShellWizard.cs


示例10: IdentifyMainMethod

 public static bool IdentifyMainMethod(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition)
 {
     bool result = false;
     if (aSourceCode.ContainKeyword(aCurrentCodeLine, "static") && aCurrentCodeLine.IndexOf("Main") > -1  && (aCurrentCodeLine.EndsWith("{") || aSourceCode.GetNextLine(aLinePosition).StartsWith("{")))
         result = true;
     return result;
 }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:7,代码来源:MainMethodComp.cs


示例11: GetConditionalPreprocessorBodyExpression

        /// <summary>
        /// Extracts the body of the given preprocessor directive symbol, parses it, and returns the parsed expression.
        /// </summary>
        /// <param name="parser">
        /// The C# parser.
        /// </param>
        /// <param name="sourceCode">
        /// The source code containing the preprocessor directive symbol.
        /// </param>
        /// <param name="preprocessorSymbol">
        /// The preprocessor directive symbol.
        /// </param>
        /// <param name="startIndex">
        /// The index of the start of the expression body within the text string.
        /// </param>
        /// <returns>
        /// Returns the expression.
        /// </returns>
        internal static Expression GetConditionalPreprocessorBodyExpression(CsParser parser, SourceCode sourceCode, Symbol preprocessorSymbol, int startIndex)
        {
            Param.AssertNotNull(parser, "parser");
            Param.AssertNotNull(sourceCode, "sourceCode");
            Param.AssertNotNull(preprocessorSymbol, "preprocessorSymbol");
            Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");
            Debug.Assert(preprocessorSymbol.SymbolType == SymbolType.PreprocessorDirective, "The symbol is not a preprocessor directive.");

            string text = preprocessorSymbol.Text.Substring(startIndex, preprocessorSymbol.Text.Length - startIndex).Trim();
            if (text.Length > 0)
            {
                using (StringReader reader = new StringReader(text))
                {
                    // Extract the symbols within this text.
                    CodeLexer lexer = new CodeLexer(parser, sourceCode, new CodeReader(reader));
                    List<Symbol> symbolList = lexer.GetSymbols(sourceCode, null);
                    SymbolManager directiveSymbols = new SymbolManager(symbolList);

                    CodeParser preprocessorBodyParser = new CodeParser(parser, directiveSymbols);

                    // Parse these symbols to create the body expression.
                    return preprocessorBodyParser.GetNextConditionalPreprocessorExpression(sourceCode);
                }
            }

            // The directive has no body.
            return null;
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:46,代码来源:CodeParser.Preprocessor.cs


示例12: Build

        public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
        {
            // while (condition) { /* Code */ }
            sourceCode += 4; // The +1 comes from below.

            while ((++sourceCode).SpecialChar)
            {
            }

            if (sourceCode.CurrentCode != '(')
            {
                sourceCode.Throw("Error parsing a 'while' statement, was epexting a '(' after 'while'.");
            }

            List<List<Token>> exitCondition = engine.BuildTokensAdvanced(ref sourceCode, ref script, new[] {')'});

            if (!sourceCode.SeekToNext('{'))
            {
                sourceCode.Throw(String.Format("Unexpected char: '{0}'", sourceCode.CurrentCode));
            }

            List<List<List<Token>>> code = engine.BuildLongTokens(ref sourceCode, ref script, new[] {'}'});

            return new WhileLoopToken(exitCondition, code);
        }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:25,代码来源:WhileBlockBuilder.cs


示例13: Build

        public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
        {
            while ((++sourceCode).SpecialChar)
            {
            }
            if (sourceCode.Peek() != '{')
            {
                sourceCode.Throw(String.Format("Error parsing a 'do' statement, expected a '{' but got '{0}' instead.",
                                               sourceCode.Peek()));
            }
            List<List<List<Token>>> code = engine.BuildLongTokens(ref sourceCode, ref script, new[] {'}'});

            if (!sourceCode.SeekToNext("while"))
            {
                sourceCode.Throw("Error parsing a 'do' statement, was expecting a 'while' after the { } block.");
            }

            if (!sourceCode.SeekToNext('('))
            {
                sourceCode.Throw("Error parsing a 'do' statement, was expecting a '(' after 'while'.");
            }

            List<List<Token>> exitCondition = engine.BuildTokensAdvanced(ref sourceCode, ref script, new[] {')'});

            return new DoWhileToken(code, exitCondition);
        }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:26,代码来源:DoWhileBlockBuilder.cs


示例14: Compile

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

            int propertyNameLocationInCode = 0;

            String propertyName = GetPropertyName(aCurrentCodeLine, out propertyNameLocationInCode);
            String propertyType = GetPropertyType(aCurrentCodeLine, propertyNameLocationInCode);

            String memberVariableName = "_" + propertyName.ToLower();
            String parameterName = "a" + propertyName;

            StringBuilder newLine = new StringBuilder();
            newLine.Append("\n");
            newLine.Append("private ").Append(propertyType).Append(" ").Append(memberVariableName).Append(";\n\n");
            newLine.Append("public").Append(" ").Append(propertyType).Append(" ").Append("get").Append(propertyName).Append("()\n");
            newLine.Append("{\n");
            newLine.Append("return this.").Append(memberVariableName).Append(";\n");
            newLine.Append("}");
            newLine.Append("\n\n");
            newLine.Append("public void ").Append("set").Append(propertyName).Append("(").Append(propertyType).Append(" ").Append(parameterName).Append(")").Append("\n");
            newLine.Append("{\n");
            newLine.Append("this.").Append(memberVariableName).Append(" = ").Append(parameterName).Append(";\n");
            newLine.Append("}\n");

            result = new TargetCodeResult(newLine.ToString());

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


示例15: ConditionMatch

 public override bool ConditionMatch(Token lastToken, SourceCode sourceCode)
 {
     if (sourceCode.CurrentCode == '-' && char.IsNumber(sourceCode.Peek(true)))
     {
         return true;
     }
     return char.IsNumber(sourceCode.Script, sourceCode.Offset);
 }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:8,代码来源:NumberBuilder.cs


示例16: Build

        public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
        {
            sourceCode++;

            engine.AddPostBuildOperation(new NotToken.NotPass(), 1000);

            return new NotToken();
        }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:8,代码来源:NotBuilder.cs


示例17: IsProgramNamespace

        private bool IsProgramNamespace(SourceCode aSourceCode, string aUsingNamespace)
        {
            var found = (from code in aSourceCode.GetLines()
                         where code.StartsWith("namespace") && aSourceCode.ContainKeyword(code, aUsingNamespace)
                         select code).FirstOrDefault();

            return found != null;
        }
开发者ID:Mayur23491,项目名称:csharpblackberry,代码行数:8,代码来源:UsingCompDirective.cs


示例18: Identify

        public bool Identify(SourceCode aSourceCode, string aCurrentCodeLine, int aLinePosition)
        {
            bool result = false;
            if (aCurrentCodeLine.StartsWith("using") && aCurrentCodeLine.IndexOf("{") == -1 && !aSourceCode.GetNextLine(aLinePosition).StartsWith("{"))
                result = true;

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


示例19: ConditionMatch

 public override bool ConditionMatch(Token lastToken, SourceCode sourceCode)
 {
     if (lastToken == null)
     {
         return sourceCode.CurrentCode == '[';
     }
     return false;
 }
开发者ID:iammitch,项目名称:Slimterpreter,代码行数:8,代码来源:ArrayBuilder.cs


示例20: Execute

 internal override void Execute(InterpreterState state, SourceCode code, BaseInterpreterStack stack)
 {
     dynamic result = PropertyNameAndExpression(stack);
     if (result.PropertyName == Constants.KeyWords.Pop)
         Environment(state).Push(result.Expression);
     else
         Environment(state)[result.PropertyName] = result.Expression;
 }
开发者ID:afgbeveridge,项目名称:EsotericInterpreters,代码行数:8,代码来源:Commands.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SourceCodeKind类代码示例发布时间:2022-05-24
下一篇:
C# Source类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap