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

C# SourceLocation类代码示例

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

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



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

示例1: Selector

        public Selector(string selector,SourceLocation sourceLocation)  {
            AfterTheParameter = null;

            // parse up to the first square bracket.
            if (string.IsNullOrEmpty(selector)) {
                Name = string.Empty;
                Parameter = null;
            } else {
                selector = selector.TrimStart('.');
                var p = selector.IndexOf('[');
                var c = selector.IndexOf(']', p + 1);
                if (p == -1) {
                    Name = selector;
                    Parameter = null;
                } else {
                    Name = p == 0 ? "*" : selector.Substring(0, p);
                    p++;
                    Parameter = selector.Substring(p, c - p).Trim();
                    if(c < selector.Length) {
                        AfterTheParameter = selector.Substring(c + 1);
                    }
                    
                }
            }
            SourceLocation = sourceLocation;
            
            _hashCode = AfterTheParameter == null ? this.CreateHashCode(Name, Parameter) : this.CreateHashCode(Name,Parameter,AfterTheParameter);
        }
开发者ID:roomaroo,项目名称:coapp.powershell,代码行数:28,代码来源:Selector.cs


示例2: CheckStatics

		public void CheckStatics()
		{
			SourceLocation min = new SourceLocation(0, 0);
			SourceLocation max = new SourceLocation(SourceLocation.MaxColumn, SourceLocation.MaxLine);
			Assert.AreEqual(min, SourceLocation.MinValue);
			Assert.AreEqual(max, SourceLocation.MaxValue);
		}
开发者ID:chenzuo,项目名称:nquery,代码行数:7,代码来源:SourceLocationTests.cs


示例3: BinaryOperationNode

 public BinaryOperationNode(SourceLocation location, BinaryOperation operation, AstNode left, AstNode right)
 {
     this.SourceLocation = location;
     BinaryOperation = operation;
     Children.Add(left);
     Children.Add(right);
 }
开发者ID:GruntTheDivine,项目名称:Hassium,代码行数:7,代码来源:BinaryOperationNode.cs


示例4: Resolve

        /// <summary>
        /// Loads an <see cref="Assembly"/> using the given <paramref name="name"/> and resolves
        /// all valid <see cref="ITagHelper"/> <see cref="Type"/>s.
        /// </summary>
        /// <param name="name">The name of an <see cref="Assembly"/> to search.</param>
        /// <param name="documentLocation">The <see cref="SourceLocation"/> of the associated
        /// <see cref="Parser.SyntaxTree.SyntaxTreeNode"/> responsible for the current <see cref="Resolve"/> call.
        /// </param>
        /// <param name="errorSink">The <see cref="ErrorSink"/> used to record errors found when resolving
        /// <see cref="ITagHelper"/> <see cref="Type"/>s.</param>
        /// <returns>An <see cref="IEnumerable{Type}"/> of valid <see cref="ITagHelper"/> <see cref="Type"/>s.
        /// </returns>
        public IEnumerable<Type> Resolve(string name, 
                                         SourceLocation documentLocation, 
                                         [NotNull] ErrorSink errorSink)
        {
            if (string.IsNullOrEmpty(name))
            {
                errorSink.OnError(documentLocation,
                                  Resources.TagHelperTypeResolver_TagHelperAssemblyNameCannotBeEmptyOrNull);

                return Type.EmptyTypes;
            }

            var assemblyName = new AssemblyName(name);

            IEnumerable<TypeInfo> libraryTypes;
            try
            {
                libraryTypes = GetExportedTypes(assemblyName);
            }
            catch (Exception ex)
            {
                errorSink.OnError(
                    documentLocation,
                    Resources.FormatTagHelperTypeResolver_CannotResolveTagHelperAssembly(
                        assemblyName.Name,
                        ex.Message));

                return Type.EmptyTypes;
            }

            var validTagHelpers = libraryTypes.Where(IsTagHelper);

            // Convert from TypeInfo[] to Type[]
            return validTagHelpers.Select(type => type.AsType());
        }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:47,代码来源:TagHelperTypeResolver.cs


示例5: Resolve_CalculatesAssemblyLocationInLookupText

        public void Resolve_CalculatesAssemblyLocationInLookupText(string lookupText, int assemblyLocation)
        {
            // Arrange
            var errorSink = new ErrorSink();
            var tagHelperDescriptorResolver = new InspectableTagHelperDescriptorResolver();
            var directiveType = TagHelperDirectiveType.AddTagHelper;
            var resolutionContext = new TagHelperDescriptorResolutionContext(
                new[]
                {
                    new TagHelperDirectiveDescriptor
                    {
                        DirectiveText = lookupText,
                        Location = SourceLocation.Zero,
                        DirectiveType = directiveType
                    }
                },
                errorSink);
            var expectedSourceLocation = new SourceLocation(assemblyLocation, 0, assemblyLocation);

            // Act
            tagHelperDescriptorResolver.Resolve(resolutionContext);

            // Assert
            Assert.Empty(errorSink.Errors);
            Assert.Equal(expectedSourceLocation, tagHelperDescriptorResolver.DocumentLocation);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:26,代码来源:TagHelperDescriptorResolverTest.cs


示例6: MethodParameterInfoContext

		public MethodParameterInfoContext(SourceLocation sourceLocation, int parameterIndex, Scope scope, Type expressionType, Identifier methodName)
			: base(sourceLocation, parameterIndex)
		{
			_scope = scope;
			_expressionType = expressionType;
			_methodName = methodName;
		}
开发者ID:chenzuo,项目名称:nquery,代码行数:7,代码来源:MethodParameterInfoContext.cs


示例7: highlightSourceAtLocation

        /// <summary>
        /// Render a helpful description of the location of the error in the GraphQL
        /// Source document.
        /// </summary>
        private static string highlightSourceAtLocation(Source source, SourceLocation location)
        {
            var line = location.Line;
            var prevLineNum = (line - 1).ToString();
            var lineNum = line.ToString();
            var nextLineNum = (line + 1).ToString();
            var padLen = nextLineNum.Length;
            var lines = _lineSplitter.Split(source.Body);
            var errorMessage = new StringBuilder();

            if (line >= 2)
            {
                errorMessage.AppendLine(prevLineNum.PadLeft(padLen, ' ') + ": " + lines[line - 2]);
            }
            else
            {
                errorMessage.AppendLine();
            }

            errorMessage.AppendLine(lineNum.PadLeft(padLen, ' ') + ": " + lines[line - 1]);
            errorMessage.AppendLine(new String(' ', padLen + location.Column) + "^");
            if (line < lines.Length)
            {
                errorMessage.AppendLine(nextLineNum.PadLeft(padLen, ' ') + ": " + lines[line]);
            }
            else
            {
                errorMessage.AppendLine();
            }

            return errorMessage.ToString();
        }
开发者ID:zhech2,项目名称:graphql-dotnet,代码行数:36,代码来源:SyntaxError.cs


示例8: TableContext

		public TableContext(SourceLocation sourceLocation, Identifier remainingPart, Scope scope, TableBinding tableBinding, string correlationName)
			: base(sourceLocation, remainingPart)
		{
			_scope = scope;
			_tableBinding = tableBinding;
			_correlationName = correlationName;
		}
开发者ID:chenzuo,项目名称:nquery,代码行数:7,代码来源:TableContext.cs


示例9: TryCatchFinally

 public static TryStatement TryCatchFinally(SourceSpan span, SourceLocation header, Statement body, CatchBlock[] handlers, Statement @finally)
 {
     return new TryStatement(
         span, header,
          body, CollectionUtils.ToReadOnlyCollection(handlers), @finally
     );
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:TryStatementBuilder.cs


示例10: Switch

        public static SwitchStatement Switch(SourceSpan span, SourceLocation header, Expression value, params SwitchCase[] cases)
        {
            Contract.RequiresNotNull(value, "value");
            Contract.Requires(value.Type == typeof(int), "value", "Value must be int");
            Contract.RequiresNotEmpty(cases, "cases");
            Contract.RequiresNotNullItems(cases, "cases");

            bool @default = false;
            int max = Int32.MinValue;
            int min = Int32.MaxValue;
            foreach (SwitchCase sc in cases) {
                if (sc.IsDefault) {
                    Contract.Requires(@default == false, "cases", "Only one default clause allowed");
                    @default = true;
                } else {
                    int val = sc.Value;
                    if (val > max) max = val;
                    if (val < min) min = val;
                }
            }

            Contract.Requires(UniqueCaseValues(cases, min, max), "cases", "Case values must be unique");

            return new SwitchStatement(span, header, value, CollectionUtils.ToReadOnlyCollection(cases));
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:25,代码来源:SwitchStatement.cs


示例11: UseStatement

		public UseStatement (SourceLocation location, string module, bool relative = false)
			: base (location)
		{
			Module = module;
			Relative = relative;
			Imports = new List<string> ();
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:UseStatement.cs


示例12: SwitchCase

 internal SwitchCase(SourceLocation header, bool @default, int value, Statement body)
     : base(AstNodeType.SwitchCase) {
     _header = header;
     _default = @default;
     _value = value;
     _body = body;
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:SwitchCase.cs


示例13: CaseExpression

		public CaseExpression (SourceLocation location, AstNode pattern, AstNode condition, AstNode value)
			: base (location)
		{
			Children.Add (pattern);
			Children.Add (condition);
			Children.Add (value);
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:CaseExpression.cs


示例14: IfNode

 public IfNode(SourceLocation location, AstNode predicate, AstNode body, AstNode elseBody)
 {
     this.SourceLocation = location;
     Children.Add(predicate);
     Children.Add(body);
     Children.Add(elseBody);
 }
开发者ID:GruntTheDivine,项目名称:Hassium,代码行数:7,代码来源:IfNode.cs


示例15: ForeachStatement

		public ForeachStatement (SourceLocation location, string item, AstNode iterator, AstNode body)
			: base (location)
		{
			this.Item = item;
			this.Add (iterator);
			this.Add (body);
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:ForeachStatement.cs


示例16: CodeBlockInfo

 public CodeBlockInfo(string name, SourceLocation start, bool isTopLevel, Span transitionSpan, Span initialSpan) {
     Name = name;
     Start = start;
     IsTopLevel = isTopLevel;
     TransitionSpan = transitionSpan;
     InitialSpan = initialSpan;
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:7,代码来源:CodeBlockInfo.cs


示例17: WriterConstructedWithoutContentLengthAndSourceFile_AddsLinePragmas_OnDispose

        public void WriterConstructedWithoutContentLengthAndSourceFile_AddsLinePragmas_OnDispose()
        {
            // Arrange
            var location = new SourceLocation(10, 1, 20);
            var expected = string.Join(Environment.NewLine,
                                       @"#line 2 ""myfile""",
                                       "Hello world",
                                       "",
                                       "#line default",
                                       "#line hidden",
                                       "");
            var expectedMappings = new LineMapping(
                                new MappingLocation(location, 30),
                                new MappingLocation(new SourceLocation(18, 1, 0), 11));
            var writer = new CSharpCodeWriter();

            // Act
            using (var mappingWriter = new CSharpLineMappingWriter(writer, location, "myfile"))
            {
                writer.Write("Hello world");
            }

            // Assert
            Assert.Equal(expected, writer.GenerateCode());
            Assert.Empty(writer.LineMappingManager.Mappings);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:26,代码来源:CSharpLineMappingWriterTest.cs


示例18: BinaryExpression

		public BinaryExpression (SourceLocation location, BinaryOperation op, AstNode left, AstNode right)
			: base (location)
		{
			Operation = op;
			Add (left);
			Add (right);
		}
开发者ID:GruntTheDivine,项目名称:Iodine,代码行数:7,代码来源:BinaryExpression.cs


示例19: FunctionCallNode

 public FunctionCallNode(SourceLocation location, AstNode target, ArgumentListNode parameters, List<BinaryOperationNode> initialAttributes)
 {
     this.SourceLocation = location;
     Children.Add(target);
     Children.Add(parameters);
     InitialAttributes = initialAttributes;
 }
开发者ID:GruntTheDivine,项目名称:Hassium,代码行数:7,代码来源:FunctionCallNode.cs


示例20: EnforcedAssignmentNode

 public EnforcedAssignmentNode(SourceLocation location, string type, string variable, AstNode value)
 {
     this.SourceLocation = location;
     Type = type;
     Variable = variable;
     Children.Add(value);
 }
开发者ID:GruntTheDivine,项目名称:Hassium,代码行数:7,代码来源:EnforcedAssignmentNode.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SourceMetadataDictionary类代码示例发布时间:2022-05-24
下一篇:
C# SourceLevels类代码示例发布时间: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