Popular Posts
Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement... Simple Web snapshot import java.util.Date; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.graphics.GC; import org.e... Tired of Hibernate? Try JDBI in your code JDBI Quick sample ICategoryDAO.java : create a data access interface (implement is not required) package com.prhythm.erotic.task.data....
Stats
Capture response output stream using HttpModule
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;

namespace TestWebApplication
{
    public class ResponseSniffModule : IHttpModule
    {
        public void Dispose()
        {

        }

        public void Init(HttpApplication context)
        {
            context.PreRequestHandlerExecute += context_PreRequestHandlerExecute;
            context.PreSendRequestContent += context_PreSendRequestContent;
        }

        void context_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            var application = sender as HttpApplication;
            var context = application.Context;
            var response = context.Response;

            // Add a filter to capture response stream
            response.Filter = new ResponseSniffer(response.Filter);
        }

        void context_PreSendRequestContent(object sender, EventArgs e)
        {
            var application = sender as HttpApplication;
            var context = application.Context;
            var response = context.Response;

            var filter = response.Filter as ResponseSniffer;

            if (filter != null)
            {
                var reader = new StreamReader(new MemoryStream(filter.RecordStream.GetBuffer()));
                var source = reader.ReadToEnd();
            }
        }
    }

    public class ResponseSniffer : Stream
    {
        private readonly Stream ResponseStream;

        public MemoryStream RecordStream { get; set; }

        #region Implements of Stream
        public override bool CanRead
        {
            get { return ResponseStream.CanRead; }
        }

        public override bool CanSeek
        {
            get { return ResponseStream.CanSeek; }
        }

        public override bool CanWrite
        {
            get { return ResponseStream.CanWrite; }
        }

        public override void Flush()
        {
            ResponseStream.Flush();
        }

        public override long Length
        {
            get { return ResponseStream.Length; }
        }

        public override long Position
        {
            get
            {
                return ResponseStream.Position;
            }
            set
            {
                ResponseStream.Position = value;
            }
        }

        public override int Read(byte[] buffer, int offset, int count)
        {
            return ResponseStream.Read(buffer, offset, count);
        }

        public override long Seek(long offset, SeekOrigin origin)
        {
            return Seek(offset, origin);
        }

        public override void SetLength(long value)
        {
            ResponseStream.SetLength(value);
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            RecordStream.Write(buffer, offset, count);
            ResponseStream.Write(buffer, offset, count);
        }
        #endregion

        public ResponseSniffer(Stream stream)
        {
            RecordStream = new MemoryStream();
            ResponseStream = stream;
        }
    }
}
Multiple line of text limit
With Sharepoint Designer, edit the page of list view. Add xsl template as below to override original template. Source template could be found at http://[servername]/_layouts/xsl/fldtypes.xsl.
<xsl:template name="FieldRef_Note_body" ddwrt:dvt_mode="body" match="FieldRef" mode="Note_body">
  <xsl:param name="thisNode" select="."/>
  <div dir="{@Direction}" class="ms-rtestate-field">
    <xsl:value-of select="concat(substring($thisNode/@*[name()=current()/@Name],0,50), '  ...')" disable-output-escaping="yes"/>
  </div>
</xsl:template>
explicit, implicit and operator
public class Name
{
    /// <summary>
    /// The implicit keyword is used to declare an implicit user-defined type conversion operator.
    /// Use it to enable implicit conversions between a user-defined type and another type, 
    /// if the conversion is guaranteed not to result in a loss of data.
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    public static implicit operator Name(string name)
    {
        return new Name(name);
    }

    /// <summary>
    /// The explicit keyword declares a user-defined type conversion operator that must be 
    /// invoked with a cast
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    public static explicit operator string(Name name)
    {
        return name.Content;
    }

    /// <summary>
    /// Use the operator keyword to overload a built-in operator or to provide a user-defined 
    /// conversion in a class or struct declaration.
    /// </summary>
    /// <param name="n1"></param>
    /// <param name="n2"></param>
    /// <returns></returns>
    public static Name operator +(Name n1, Name n2)
    {
        return n1.Content + n1.Content;
    }

    string Content;

    public Name(string name)
    {
        Content = name;
    }

    public override string ToString()
    {
        return Content;
    }
}

class Program
{
    public static void Main(string[] args)
    {
        Name n1 = new Name("Bruce");
        Console.WriteLine(n1);  // output: Bruce

        Name n2 = "Bruce";      // auto cast
        Console.WriteLine(n2);  // output: Bruce

        string n3 = (string)n1; // manual cast
        Console.WriteLine(n3);  // output: Bruce

        Console.WriteLine(n1 + n2);  // output: BruceBruce
    }
}
reference: explicit, implicit, operator