The Pages of Velio Ivanov

 Artem(BG) is the creative outlet of Velio Ivanov.

On this website you will find information about me, most of my recent personal projects, my custom visual studio project and item templates, code snippets and code for free download.

  • XML Providers 4.0beta under Tiny Providers released

    Posted Thursday 13, January 2011, 20:37 in ASP.NET, Web, Security, Membership

    Today I released XML Providers 4.0beta under Tiny Membership Providers project.

    Custom ASP.NET XML membership providers targeting .NET 4.0
    The implementation ASP.NET XML membership providers targeting .NET 2.0 could be found at ASP.NET XmlProviders
    I start with version 4.0 by purpose.
    The versions bellow 4.0 are kept for future releases of .NET 2.0 implementation of ASP.NET XML membership providers.

    For how to use samples, please, check out the SampleWebSite under downloads.
    Some more samples and screencast will be provided as possible.

  • Extension Methods: HtmlTextWriter part 1 - RenderTag

    Posted Tuesday 17, August 2010, 8:51 in C#, ASP.NET, Extension Methods

    So, for me case is clear guys: “Static helper methods are dead, long live the Extension Methods.”
    Since extension methods were out, I become a big fan of them.
    For example, instead of:

    StringHelper.Encode(“Some secret”);

    it looks much more nice and natural to me:

    ”Some secret”.Encode();

    I have implemented and I’m using tons of extension methods so far and I decided to start a category in my blog where to share some of them with you guys.
    Hope all those methods to be useful to you too, as they are to me.

    First of the series will be a couple of extension methods to HtmlTextWriter.
    You know, as a web and especially web controls developer, I use it much and that’s why I like extending it.

    During my development I found a lot of lines where I just render and open tag and then immediately the closing (end) tag is rendered, like:

    writer.AddAttribute(HtmlTextWriterAttribute.Id, fieldName + "_Error");
    writer.AddAttribute(HtmlTextWriterAttribute.Class, "field-validation-error");
    writer.RenderBeginTag(HtmlTextWriterTag.Span);
    writer.RenderEndTag();

    The other case I often found myself using is: open tag, write some content text and closing the tag, like:

    writer.RenderBeginTag(HtmlTextWriterTag.Span);
    writer.Write("allow editing");
    writer.RenderEndTag();

    I have developed some snippets for Visual Studio, which you could find at my website, in order to speed up typing such a kind of code bocks, but at some point I said to myself: why not merge those lines in a single methods. Of course, in a single extension method smile_teeth.

    Here are the simple extension methods I came with:

    /// <summary>
    /// Renders the tag.
    /// </summary>
    /// <param name="writer">The writer.</param>
    /// <param name="tag">The tag.</param>
    public static void RenderTag(this HtmlTextWriter writer, HtmlTextWriterTag tag) {
        writer.RenderBeginTag(tag);
        writer.RenderEndTag();
    }
     
    /// <summary>
    /// Renders the tag.
    /// </summary>
    /// <param name="writer">The writer.</param>
    /// <param name="tag">The tag.</param>
    public static void RenderTag(this HtmlTextWriter writer, string tag) {
        writer.RenderBeginTag(tag);
        writer.RenderEndTag();
    }
     
    /// <summary>
    /// Renders the tag.
    /// </summary>
    /// <param name="writer">The writer.</param>
    /// <param name="tag">The tag.</param>
    /// <param name="content">The content.</param>
    public static void RenderTag(this HtmlTextWriter writer, HtmlTextWriterTag tag, string content) {
     
        writer.RenderBeginTag(tag);
        writer.Write(content);
        writer.RenderEndTag();
    }
     
    /// <summary>
    /// Renders the tag.
    /// </summary>
    /// <param name="writer">The writer.</param>
    /// <param name="tag">The tag.</param>
    /// <param name="content">The content.</param>
    public static void RenderTag(this HtmlTextWriter writer, string tag, string content) {
     
        writer.RenderBeginTag(tag);
        writer.Write(content);
        writer.RenderEndTag();
    }

    Now using those extension methods the sample lines of code above will become:

    writer.AddAttribute(HtmlTextWriterAttribute.Id, fieldName + "_Error");
    writer.AddAttribute(HtmlTextWriterAttribute.Class, "field-validation-error");
    writer.RenderTag(HtmlTextWriterTag.Span);

    and:

    writer.RenderTag(HtmlTextWriterTag.Span, "allow editing");


    Hope this helps.

    Regards,
    Velio

  • Google Geocoder 1.0

    Posted Sunday 1, August 2010, 16:45 in C#, Google, Geocoding

    Google Geocoding Web Service via HTTP .NET client implemented in request(GeoRequest)-response(GeoResponse) fashion.

    Installation & Usage

    In order to use the GoogleGecoding you have to:

    1. add reference to Artem.GoogleGeocoding
    2. add using statement for Artem.Google.Net namespace.
    Features
    • Support standard and reverse geocoding;
    Samples
    • Geocoding Request
    GeoRequest request = new GeoRequest("plovdiv bulgaria");
    GeoResponse response = request.GetResponse();
    GeoLocation location = response.Results[0].Geometry.Location;
    double latitude = location.Latitude;
    double longitude = location.Longitude;
    // TODO use latitude/longitude values
    • Reverse Geocoding Request
    GeoRequest request = new GeoRequest(42.1438409, 24.7495615);
    GeoResponse response = request.GetResponse();
    string address = response.Results[0].FormattedAddress;
    // TODO use address values
  • VisualStudion 2010 Javascript Outlining 1.2

    Posted Thursday 29, July 2010, 18:11 in VisualStudio, JS

    A support for CSS content type was added in order to use outlining in CSS files, as well.

    Features
    • Outlines CSS codeblock regions for the code placed between { }. The closing brace is places on a new line and there is not another opeing brace on same line.
    • Outlines custom regions defined by:
      • /#region/ - /#endregion/
      • /#>/ - /#</
    Samples
    • code block
    body {
        background-color: #AAA;
        font-family: Verdana;
        font-size: 11px;
    }
    • long custom region definition
    /*#region Test */
    body {
        background-color: #AAA;
        font-family: Verdana;
        font-size: 11px;
    }
    h1, h2, h3, h4 {
        color: #5377A9;
        font-family: Tahoma;
    }
    /*#endregion*/
    • short custom region definition
    /*#> Test */
    body {
        background-color: #AAA;
        font-family: Verdana;
        font-size: 11px;
    }
    h1, h2, h3, h4 {
        color: #5377A9;
        font-family: Tahoma;
    }
    /*#<*/
  • VisualStudion 2010 Javascript Outlining 1.0

    Posted Saturday 5, June 2010, 13:06 in VisualStudio, JS

     As a Web 2 developer I found myself dealing with fast growing JavaScript code files.
    And I really missed the code regions in Visual Studio, which is a nice way to organize the code blocks and focus on reasonable small amount of code.
    There are some macros available out on the web for placing a regions outlining in JavaScript code editor.
    I was not fully satisfied with macros and the fact I have to manually run them (even with a shortcut keys) every time I open the JavaScript file.
    Thus, I have spend some amount of my time and came out with a Visual Studio 2010 Editor Extension for JavaScript Oulining.


    Even, if this first version is simple as functionality it gave me much better JavaScript code experience.
    So, I decided to share it with you guys and hope it helps you too.

    Please, find the visual studio package here


    Enjoy