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


C# SourceLocation类代码示例

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


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


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