Exemplo n.º 1
0
        /// <summary>
        /// Coordinateses the specified geography.
        /// </summary>
        /// <param name="geography">The geography.</param>
        /// <returns></returns>
        public static List<MapCoordinate> Coordinates( this System.Data.Entity.Spatial.DbGeography geography )
        {
            var coordinates = new List<MapCoordinate>();

            var match = Regex.Match( geography.AsText(), @"(?<=POLYGON \(\()[^\)]*(?=\)\))" );
            if ( match.Success )
            {
                string[] longSpaceLat = match.ToString().Split( ',' );

                for ( int i = 0; i < longSpaceLat.Length; i++ )
                {
                    string[] longLat = longSpaceLat[i].Trim().Split( ' ' );
                    if ( longLat.Length == 2 )
                    {
                        double? lat = longLat[1].AsDoubleOrNull();
                        double? lon = longLat[0].AsDoubleOrNull();
                        if ( lat.HasValue && lon.HasValue )
                        {
                            coordinates.Add( new MapCoordinate( lat, lon ) );
                        }
                    }
                }
            }

            return coordinates;
        }
    public static Response AsNonCachedText(this IResponseFormatter responseFormatter, string responseText) {
      if (responseFormatter == null) throw new ArgumentNullException("responseFormatter");

      return responseFormatter.AsText(responseText)
        .WithHeader("Cache-Control", "no-cache, no-store, must-revalidate")
        .WithHeader("Pragma", "no-cache")
        .WithHeader("Expires", "0");
    }
Exemplo n.º 3
0
        public static System.Data.Entity.Spatial.DbGeometry MakeValid(
            this System.Data.Entity.Spatial.DbGeometry geometry)
        {
            var coordinateSystemId = 0;

            return
                System.Data.Entity.Spatial.DbGeometry.FromText(
                    SqlGeometry.STGeomFromText(new SqlChars(geometry.AsText()), coordinateSystemId)
                        .MakeValid()
                        .STAsText()
                        .ToSqlString()
                        .ToString(), coordinateSystemId);
        }
Exemplo n.º 4
0
 public static Task<string> AsTextAsync(this IEnumerable<Utoken> utokens, Unparser unparser)
 {
     return unparser.Lock.LockAsync()
         .ContinueWith(task => { using (task.Result) return TaskEx.Run(() => utokens.AsText(unparser)); })
         .Unwrap();
 }
Exemplo n.º 5
0
 public static string AsText(this IEnumerable<Utoken> utokens, Unparser unparser)
 {
     return utokens.AsText(unparser.Formatter);
 }
Exemplo n.º 6
0
 public static async Task<string> AsTextAsync(this IEnumerable<Utoken> utokens, Unparser unparser)
 {
     using (await unparser.Lock.LockAsync())
         return await Task.Run(() => utokens.AsText(unparser));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gets the <see cref="Document"/> from the corresponding <see cref="Workspace.CurrentSolution"/> that is associated with the <see cref="ITextSnapshot"/>'s buffer
 /// in its current project context, updated to contain the same text as the snapshot if necessary. There may be multiple <see cref="Document"/>s
 /// associated with the buffer if it is linked into multiple projects or is part of a Shared Project. In this case, the <see cref="Workspace"/>
 /// is responsible for keeping track of which of these <see cref="Document"/>s is in the current project context.
 /// </summary>
 public static Document GetOpenDocumentInCurrentContextWithChanges(this ITextSnapshot text)
 {
     return text.AsText().GetOpenDocumentInCurrentContextWithChanges();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Gets the <see cref="Document"/>s from the corresponding <see cref="Workspace.CurrentSolution"/> that are associated with the <see cref="ITextSnapshot"/>'s buffer,
 /// updated to contain the same text as the snapshot if necessary. There may be multiple <see cref="Document"/>s associated with the buffer
 /// if the file is linked into multiple projects or is part of a Shared Project.
 /// </summary>
 public static IEnumerable<Document> GetRelatedDocumentsWithChanges(this ITextSnapshot text)
 {
     return text.AsText().GetRelatedDocumentsWithChanges();
 }
Exemplo n.º 9
0
 /// <summary>
 /// get Document corresponding to the snapshot
 /// </summary>
 public static bool TryGetDocument(this ITextSnapshot snapshot, out Document document)
 {
     document = snapshot.AsText().GetRelatedDocumentsWithChanges().FirstOrDefault();
     return document != null;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Class나 Property의 Naming 방식인 Pascal Naming 또는 Camelcase Naming 방식의 문자열을 ORACLE Naming 방식의 문자열로 변환합니다.
        /// </summary>
        /// <param name="s">변환할 문자열</param>
        /// <param name="delimiter">단어 사이의 구분자 (기본값은 '_')</param>
        /// <returns>변환된 문자열</returns>
        /// <example>
        /// <code>
        ///		"CompanyName".ToOracleNaming().Should().Be("COMPANY_NAME");
        ///		"UserId".ToOracleNaming().Should().Be("USER_ID");
        ///     "ExAttr1".ToOracleNaming().Should().Be("EX_ATTR1");
        ///		"IX_CompanyName.ToOracleNaming().Should().Be("IX_COMPANY_NAME");
        ///		"IX_User_CompanyId".ToOracleNaming().Should().Be("IX_USER_COMPANY_ID");
        /// </code>
        /// </example>
        public static string ToOracleNaming(this string s, string delimiter = "_") {
            if(s.IsWhiteSpace())
                return s.AsText();

            delimiter = delimiter ?? "_";
            var builder = new StringBuilder();

            var prevCharIsCapital = false;

            foreach(var c in s) {
                var isCapital = (c >= 'A' && c <= 'Z') || (c.ToString() == delimiter);

                if(isCapital) {
                    if(prevCharIsCapital == false)
                        builder.Append(delimiter);
                }

                builder.Append(c);
                prevCharIsCapital = isCapital;
            }

            return
                builder
                    .Replace(delimiter + delimiter, delimiter)
                    .ToString()
                    .TrimStart('_')
                    .ToUpper(CultureInfo.InvariantCulture);
        }
Exemplo n.º 11
0
		/// <summary>
		/// Gets the document or null
		/// </summary>
		/// <param name="snapshot">Snapshot</param>
		/// <returns></returns>
		public static Document GetOpenDocumentInCurrentContextWithChanges(this ITextSnapshot snapshot) =>
			snapshot.AsText().GetOpenDocumentInCurrentContextWithChanges();
Exemplo n.º 12
0
 public static DbGeography GetCentre(this DbGeography spatial)
 {
     if (spatial == null)
         return null;
     return DbGeography.FromText(SqlGeography.Parse(spatial.AsText()).MakeValid().EnvelopeCenter().ToString());
 }
Exemplo n.º 13
0
 public static Response AsSvg(this IResponseFormatter formatter, Svg svg)
 {
     return formatter.AsText(svg.ToString(), "image/svg+xml");
 }
Exemplo n.º 14
0
 /// <summary>
 /// XML 문법에 맞는 문자열로 인코딩한다.
 /// </summary>
 /// <param name="value">원본 문자열</param>
 /// <param name="defaultValue">원본이 null이거나 빈 문자열이면, 대체할 값</param>
 /// <returns>Xml 형식으로 인코딩된 문자열</returns>
 public static string XmlEncode(this object value, string defaultValue = "") {
     return XmlEncode(value.AsText(defaultValue));
 }
Exemplo n.º 15
0
 /// <summary>
 /// HTML Element의 Attribute 값을 안전한 값으로 인코딩한다.
 /// </summary>
 /// <param name="value">Attribute에 지정될 값</param>
 /// <param name="defaultValue">지정될 값이 null이거나 빈 문자열일때 대체할 문자열</param>
 /// <returns>HTML Element의 Attribute 값에 지정할 안전한 문자열</returns>
 public static string HtmlAttributeEncode(this object value, string defaultValue = "") {
     return HtmlAttributeEncode(value.AsText(defaultValue));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Visual Basic Script 문을 동적으로 생성시, script 코드 내용을 vb script 문법에 맞게끔 인코딩한다.
 /// </summary>
 /// <param name="value">대상 문자열</param>
 /// <param name="defaultValue">대상 문자열이 null이거나 빈 문자열인 경우, 대체할 기본값</param>
 /// <returns>Visual Basic Script 로 인코딩한 문자열</returns>
 public static string VBScriptEncode(this object value, string defaultValue = "") {
     return VBScriptEncode(value.AsText(defaultValue));
 }