示例#1
0
        /// <summary>
        ///     This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="textSpan">This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.</param>
        /// <returns>This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.</returns>
        public static XmlDesignerBaseTextSpan ConvertFromVSTextSpan(VSTextSpan textSpan)
        {
            var ret = new XmlDesignerBaseTextSpan();

            ret.iStartIndex = textSpan.iStartIndex;
            ret.iStartLine  = textSpan.iStartLine;
            ret.iEndIndex   = textSpan.iEndIndex;
            ret.iEndLine    = textSpan.iEndLine;

            return(ret);
        }
        public void GetTextSpanForXObject_calls_XmlModel_GetTextSpan_if_xobject_not_null()
        {
            var textSpan = new TextSpan { iStartLine = 42, iStartIndex = 43, iEndLine = 44, iEndIndex = 45 };

            var xmlModelMock = new Mock<XmlModel>();
            xmlModelMock
                .Setup(m => m.GetTextSpan(It.IsAny<XObject>()))
                .Returns(textSpan);

            var modelProviderMock = new Mock<XmlModelProvider> { CallBase = true };
            modelProviderMock
                .Setup(m => m.GetXmlModel(It.IsAny<Uri>()))
                .Returns(xmlModelMock.Object);

            Assert.Equal(
                textSpan,
                modelProviderMock.Object.GetTextSpanForXObject(new XText("2.71828"), new Uri("http://tempuri")));
        }
示例#3
0
        /// <summary>
        ///     This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="textSpan">This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.</param>
        /// <returns>This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.</returns>
        public static XmlDesignerBaseTextSpan ConvertFromVSTextSpan(VSTextSpan textSpan)
        {
            var ret = new XmlDesignerBaseTextSpan();
            ret.iStartIndex = textSpan.iStartIndex;
            ret.iStartLine = textSpan.iStartLine;
            ret.iEndIndex = textSpan.iEndIndex;
            ret.iEndLine = textSpan.iEndLine;

            return ret;
        }
示例#4
0
 /// <summary>
 ///     -1: (lin,col) is before TextSpan /
 ///     0: (lin,col) is within TextSpan /
 ///     1: (lin,col) is after TextSpan /
 /// </summary>
 private static int HitTest(TextSpan ts, int line, int col)
 {
     if (ts.iStartLine < line)
     {
         if (ts.iEndLine > line)
         {
             return 0;
         }
         else
         {
             if (ts.iEndLine == line)
             {
                 if (ts.iEndIndex > col)
                 {
                     return 0;
                 }
                 else
                 {
                     // ts.iEndIndex <= col
                     return 1;
                 }
             }
             else
             {
                 // ts.iEndLine < line
                 return 1;
             }
         }
     }
     else if (ts.iStartLine == line)
     {
         if (ts.iEndLine == line)
         {
             if (ts.iStartIndex <= col)
             {
                 if (ts.iEndIndex > col)
                 {
                     return 0;
                 }
                 else
                 {
                     // ts.iEndIndex <= col
                     return 1;
                 }
             }
             else
             {
                 // ts.iStartIndex > col
                 return -1;
             }
         }
         else
         {
             Debug.Assert(ts.iEndLine > line);
             if (ts.iStartIndex <= col)
             {
                 return 0;
             }
             else
             {
                 // ts.iStartIndex > col
                 return -1;
             }
         }
     }
     else
     {
         // ts.iStartLine > line
         return -1;
     }
 }