<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Santhosh Reddy's  Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/nagavo/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/nagavo/feed.xml</link>
    <description>&amp;quot;My world of Programming  &amp;quot;</description>
    <lastBuildDate>Wed, 17 Apr 2019 04:10:40 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Design pattern : Observer pattern</title>
      <link>https://docs.microsoft.com/archive/blogs/nagavo/design-pattern-observer-pattern</link>
      <pubDate>Thu, 22 Dec 2011 09:47:00 GMT</pubDate>
      <dc:creator><![CDATA[Smartysanthosh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/nagavo/2011/12/22/design-pattern-observer-pattern/</guid>
      <description><![CDATA[DefinitionA way of notifying dependent classes of changes.The Observer pattern defines a one to many...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"><b>Definition</b><br /><br /><span style="font-size: medium;">A way of notifying dependent classes of changes.</span><br /><br /><span style="font-size: medium;">The Observer pattern defines a one to many relationships between objects so that when one changes its state, all the others are notified accordingly. </span><br /><br /><span style="font-size: medium;">Encapsulate the core components in a Subject abstraction, and the variable components in an Observer hierarchy.</span><br /><br /><span style="font-size: medium;"><b>Design<br /></b></span><br /><span style="font-size: medium;">The Observer pattern is composed of two classes. The Subject/Target is a class whose objects change their state at an independent rate. Observers may indicate that they wish to be informed of these changes so the Subject/Target will send them notifications.</span><br /><br /><br /><br /><b>Code</b><br /><br /></span>//Notifier</p>
<p>&nbsp;&nbsp;&nbsp; public delegate void ChangedEventHandler(object sender);</p>
<p>&nbsp;&nbsp;&nbsp; //Subject</p>
<p>&nbsp;&nbsp;&nbsp; public class Temperature</p>
<p>&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public event ChangedEventHandler Changed;</p>
<p>private int _temperaturevalue;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Public TemperatureValue</p>
<p>{</p>
<p>get {return _temperaturevalue;}</p>
<p>set(object value)</p>
<p>{&nbsp;&nbsp;&nbsp; if( changed!=null) { changed( this) }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _temperaturevalue=value;</p>
<p>}</p>
<p>}</p>
<p>}&nbsp;&nbsp;&nbsp; public class ObserverOne<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public ObserverOne(Temperature temperature)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Temperature.Changed += new ChangedEventHandler(A);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void A(object sender, ChangedEventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("Temperature modified ");</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; public class ObserverTwo<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public ObserverTwo(Temperature temperature )<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Temperature .Changed += new ChangedEventHandler(A);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void A(object sender, ChangedEventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("Temperature modified ");</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />//Client<br />static void Main(string[] args)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Temperature temperature = new Temperature ();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ObserverOne observer1 = new ObserverOne(temperature );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ObserverTwo observer2 = new ObserverTwo(temperature );</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Temperature .TemperatureValue=100;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<span style="font-family: Verdana; font-size: x-small;" face="Verdana" size="2"><br /></span></p>
<p><span style="font-family: Verdana; font-size: medium;" face="Verdana" size="2"><span style="font-family: Verdana;" face="Verdana" size="2"></span></span>&nbsp;</p>
<p><span style="font-family: Verdana; font-size: medium;" face="Verdana" size="2"><span style="font-family: Verdana;" face="Verdana" size="2">Result : As soon as the TemperatureValue property is changed it will notify the changes to the both observerone and observertwo . </span></span></p>
<p></p>]]></content:encoded>
    </item>
    <item>
      <title>HTML 5 : How to track your location using the GeoLocation API .</title>
      <link>https://docs.microsoft.com/archive/blogs/nagavo/html-5-how-to-track-your-location-using-the-geolocation-api</link>
      <pubDate>Tue, 29 Nov 2011 07:58:00 GMT</pubDate>
      <dc:creator><![CDATA[Smartysanthosh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/nagavo/2011/11/29/html-5-how-to-track-your-location-using-the-geolocation-api/</guid>
      <description><![CDATA[I have recently going through some of the interesting things which can be done using HTML 5 , the...]]></description>
      <content:encoded><![CDATA[<p>I have recently going through some of the interesting things which can be done using HTML 5 , the next generation of web . One of the API which got my attention is GEOLOCATION .</p>
<p>&nbsp;</p>
<p>here using this API we can get to know the current user latitude and longitude and using MAP's we can exactly show you the user's current location . Please go through the details over internet and i am sure you will definetly try this out .</p>
<p>&nbsp;</p>
<p>let's not waste time , i will show you a simple demo of how to make use of this API in tracking the exact location .</p>
<p>&nbsp;</p>
<p>let's create a simple .aspx page with the following layout</p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="text-decoration: underline;"><strong><span style="color: blue; text-decoration: underline;">Geolocation.aspx : </span></strong></span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: maroon;">body</span><span style="color: blue;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">div</span><span style="color: blue;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">div</span>&nbsp;<span style="color: red;">id</span>&nbsp;<span style="color: blue;">=</span><span style="color: blue;">"message"</span>&nbsp;<span style="color: blue;">&gt;&lt;/</span><span style="color: maroon;">div</span><span style="color: blue;">&gt;</span>
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">div</span>&nbsp;<span style="color: red;">id</span><span style="color: blue;">=</span><span style="color: blue;">"position"</span><span style="color: blue;">&gt;&lt;/</span><span style="color: maroon;">div</span><span style="color: blue;">&gt;</span>
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">div</span>&nbsp;<span style="color: red;">id</span><span style="color: blue;">=</span><span style="color: blue;">"map"</span>&nbsp;<span style="color: red;">style</span><span style="color: blue;">=</span><span style="color: blue;">"</span><span style="color: red;">border</span><span style="color: blue;">:</span><span style="color: blue;">1px</span><span style="color: blue;">&nbsp;</span><span style="color: blue;">solid</span><span style="color: blue;">&nbsp;</span><span style="color: blue;">blue</span><span style="color: blue;">;&nbsp;</span><span style="color: red;">height</span><span style="color: blue;">:</span><span style="color: blue;">400px</span><span style="color: blue;">;</span><span style="color: red;">width</span><span style="color: blue;">:</span><span style="color: blue;">400px</span><span style="color: blue;">"</span><span style="color: blue;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;/</span><span style="color: maroon;">div</span><span style="color: blue;">&gt;</span>
<span style="color: blue;">&lt;/</span><span style="color: maroon;">body</span><span style="color: blue;">&gt;</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">i just created a div tag for showing the map .i hope every one knows about JQUERY [ its a &nbsp;fast, concise, library that</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"> simplifies how to traverse HTML documents,</span><span style="color: blue;"> handle events, perform animations , </span><span style="color: blue;">if you are not familiar with it , i would advice you to go through it ,</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"> and i am sure you gonna love the power of JQUERY ] </span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;">i have made use of JQUERY in my code and i have written a small javascript for using the HTML5 built in GeoLocation API .</span> </pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="text-decoration: underline;"><strong><span style="color: blue; text-decoration: underline;">javascript code : </span></strong></span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="text-decoration: underline;"><strong><span style="color: blue; text-decoration: underline;"></span></strong></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: maroon;">head</span>&nbsp;<span style="color: red;">runat</span><span style="color: blue;">=</span><span style="color: blue;">"server"</span><span style="color: blue;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>Geolocation<span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">script</span>&nbsp;<span style="color: red;">src</span><span style="color: blue;">=</span><span style="color: blue;">"../../Scripts/jquery-1.4.1.js"</span>&nbsp;<span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/javascript"</span><span style="color: blue;">&gt;&lt;/</span><span style="color: maroon;">script</span><span style="color: blue;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">script</span>&nbsp;<span style="color: red;">src</span><span style="color: blue;">=</span><span style="color: blue;"><a href="https://maps.googleapis.com/maps/api/js?sensor=false">https://maps.googleapis.com/maps/api/js?sensor=false</a></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/javascript"</span><span style="color: blue;">&gt;</span><span style="color: blue;">&lt;/</span><span style="color: maroon;">script</span><span style="color: blue;">&gt;</span>&nbsp;
 
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: maroon;">script</span>&nbsp;<span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/javascript"</span><span style="color: blue;">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(document).ready(<span style="color: blue;">function</span>&nbsp;()&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;message&nbsp;=&nbsp;$(<span style="color: maroon;">"#message"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;position&nbsp;=&nbsp;$(<span style="color: maroon;">"#position"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">if</span>&nbsp;(window.navigator.geolocation)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message.html(<span style="color: maroon;">"locating"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;geolocation&nbsp;=&nbsp;window.navigator.geolocation;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;options&nbsp;=&nbsp;{&nbsp;enableHighAccuracy:&nbsp;<span style="color: blue;">true</span>}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background-color: #ffff00;">&nbsp;&nbsp;geolocation.getCurrentPosition(onComplete,&nbsp;onFail,&nbsp;options); </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">else</span>&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message.html(<span style="color: maroon;">"No&nbsp;support"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">function</span>&nbsp;onComplete(geoPosition)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color: maroon;">"#position"</span>).append(<span style="color: maroon;">"&lt;p&gt;&nbsp;Latitude"</span>&nbsp;+&nbsp;geoPosition.coords.latitude&nbsp;+&nbsp;<span style="color: maroon;">"&lt;/p&gt;"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(<span style="color: maroon;">"#position"</span>).append(<span style="color: maroon;">"&lt;p&gt;&nbsp;Longitude"</span>&nbsp;+&nbsp;geoPosition.coords.longitude&nbsp;+&nbsp;<span style="color: maroon;">"&lt;/p&gt;"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initializemap(geoPosition.coords.latitude,&nbsp;geoPosition.coords.longitude);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">function</span>&nbsp;onFail()&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(<span style="color: maroon;">"Failed&nbsp;"</span>);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">function</span>&nbsp;Initializemap(latitude,&nbsp;longitude)&nbsp;{
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;Latlng&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;google.maps.LatLng(latitude,&nbsp;longitude);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;options&nbsp;=&nbsp;{zoom:&nbsp;18,&nbsp;center:&nbsp;Latlng,&nbsp;mapTypeId:&nbsp;google.maps.MapTypeId.ROADMAP&nbsp;};
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;map&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;google.maps.Map(document.getElementById(<span style="color: maroon;">"map"</span>),options);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;/</span><span style="color: maroon;">script</span><span style="color: blue;">&gt;</span>
<span style="color: blue;">&lt;/</span><span style="color: maroon;">head</span><span style="color: blue;">&gt;</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="text-decoration: underline;"><strong><span style="color: blue; text-decoration: underline;"></span></strong></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;">i have used document ready() function which will be called as soon as the page get's loaded . </pre>
<pre style="background: white; color: black; font-family: Consolas;">&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="text-decoration: underline;"><strong><span style="color: blue; text-decoration: underline;">Note:</span></strong></span><span style="color: #000000;"> The highlighted portion in the above codei.e..<span style="background-color: #ffff00;">geolocation.getCurrentPosition(onComplete, onFail, options);</span> is the main part which uses the getCurrentPosition()</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;"> method of the geolocation API which </span><span style="color: #000000;">provides us with the Latidude and Longitude coordinates . Here we have provided 2 methods , to inform that if everything is</span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;"> successful it will call the onComplete() method or incase of any errors in the code </span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;">it will call onFail() method . </span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;"></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;">i have created another Function Initializemap which takes the inputs as the 2 coords latitude and longitude and provides us with the map showing us exact current user location . </span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;"></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #0000ff; text-decoration: underline;"><strong><span style="text-decoration: underline;">output:</span></strong></span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #0000ff; text-decoration: underline;"><strong><span style="text-decoration: underline;"></span></strong></span>&nbsp;</pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #000000;">it gives us the location like the picture below [ my work location ] </span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #0000ff; text-decoration: underline;"><strong><span style="text-decoration: underline;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/00/3264.Microsoft.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-00/3264.Microsoft.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/00/3264.Microsoft.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-00/3264.Microsoft.png" width="594" height="292" /></a></span></strong></span><span style="color: #0000ff; text-decoration: underline;"><strong><span style="text-decoration: underline;"></span></strong></span></pre>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: #0000ff; text-decoration: underline;"><strong><span style="text-decoration: underline;"></span></strong></span></pre>]]></content:encoded>
    </item>
    <item>
      <title>How to randomly shuffle the items inside a dictionary .</title>
      <link>https://docs.microsoft.com/archive/blogs/nagavo/how-to-randomly-shuffle-the-items-inside-a-dictionary</link>
      <pubDate>Tue, 29 Nov 2011 07:27:00 GMT</pubDate>
      <dc:creator><![CDATA[Smartysanthosh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/nagavo/2011/11/29/how-to-randomly-shuffle-the-items-inside-a-dictionary/</guid>
      <description><![CDATA[i have come across a&nbsp;this kind of situation in one of my projects where i need to randomly...]]></description>
      <content:encoded><![CDATA[<p>i have come across a&nbsp;this kind of situation in one of my projects where i need to randomly shuffle the dicitionary . we are going to take a quick look at an easy and simple way to randomize a dictionary, which is most likely something that you may be using in a complex application.</p>
<p>&nbsp;&nbsp;</p>
<p>so let's get started . Before that we need to create a simple dictionary and assign some elements into that</p>
<p><span style="text-decoration: underline;"><strong>code :</strong></span></p>
<p><span style="color: #008080;">Dictionary</span><span style="color: #000000;">&lt;</span><span style="color: #008080;">String</span>, <span style="color: #0600ff;">int</span><span style="color: #000000;">&gt;</span> myDictionary<span style="color: #296d26;">=</span> <span style="color: #0600ff;">new</span> <span style="color: #008080;">Dictionary</span><span style="color: #000000;">&lt;</span><span style="color: #0600ff;">string</span>, <span style="color: #0600ff;">int</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">;</span><br /><br /><span style="color: #0600ff;">for</span> <span style="color: #000000;">(</span><span style="color: #0600ff;">int</span> i <span style="color: #296d26;">=</span> <span style="color: #000000;">0</span><span style="color: #000000;">;</span> i <span style="color: #000000;">&lt;</span> 50<span style="color: #000000;">;</span> i<span style="color: #296d26;">++</span><span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />&nbsp; myDictionary<span style="color: #296d26;"></span>.<span style="color: #000000;">Add</span><span style="color: #000000;">(</span><span style="color: #ff0000;">"number"</span> <span style="color: #296d26;">+</span> i.<span style="color: #000000;">ToString</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>, i<span style="color: #000000;">)</span><span style="color: #000000;">;</span><br /><span style="color: #000000;">}</span></p>
<p>Elements inside dictionary :</p>
<p><span style="color: #008000; font-style: italic;">// "number 0" -&gt; 0</span><br /><span style="color: #008000; font-style: italic;">// "number 1" -&gt; 1</span><br /><span style="color: #008000; font-style: italic;">// "number 2" -&gt; 2</span><br /><em><span style="color: #008000;" color="#008000">and so on .</span></em></p>
<p>so now we have created a simple dictionary and inserted some integers into it .</p>
<p>&nbsp;</p>
<p>Now let's look at how we can shuffle this dicitonary&nbsp;and provide a random output of number.[being our main task ].</p>
<p>Yeah, you guessed it right , it requires rather complex algorithm to accomplish this task , but we have LINQ which comes to rescue at this point of time . let's look into it and see how we can achieve this using LINQ. &nbsp;</p>
<p>Most collections in .Net implement the IEnumerable interface,this interface allows us to use the <code>OrderBy</code> extension method provided by the System.Linq namespace. As you may have guessed, this takes a collection and orders it. To make things even easier, this function allows some pretty fancy Lamda functions, so we can actually order our Dictionary with just one line of code.</p>
<p>However, we want to shuffle our Dictionary. To do this, we have to order it by a random value. To do this we basically pass in a function that chooses a random number for the index. When we combine the ordering and random index together, our code looks something like so:</p>
<p><em><span style="color: #008000;" color="#008000"><span style="color: #0600ff;"></span><span style="color: #000000;"></span><span style="color: #000000; text-decoration: underline;"><strong>code :</strong></span><br /><br /><span style="color: #008080;">Random</span> rand <span style="color: #296d26;">=</span> <span style="color: #0600ff;">new</span> <span style="color: #008080;">Random</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">;</span><br /><span style="color: #296d26;">myDictionary<span style="color: #296d26;"></span>=</span> myDictionary<span style="color: #296d26;"></span>.<span style="color: #000000;">OrderBy</span><span style="color: #000000;">(</span>x <span style="color: #296d26;">=</span><span style="color: #000000;">&gt;</span> rand.<span style="color: #000000;">Next</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br />&nbsp; .<span style="color: #000000;">ToDictionary</span><span style="color: #000000;">(</span>item <span style="color: #296d26;">=</span><span style="color: #000000;">&gt;</span> item.<span style="color: #000000;">Key</span>, item <span style="color: #296d26;">=</span><span style="color: #000000;">&gt;</span> item.<span style="color: #000000;">Value</span><span style="color: #000000;">)</span><span style="color: #000000;">;</span></span></em></p>
<p><em><span style="color: #008000;" color="#008000"><span style="color: #000000;"></span></span></em>&nbsp;</p>
<p><em><span style="color: #008000;" color="#008000"><span style="color: #000000;">now when you print</span></span></em><span style="color: #008000;" color="#008000"><span style="color: #000000;"> the dictionary</span></span><em><span style="color: #008000;" color="#008000"><span style="color: #000000;"> you will get </span></span></em><span style="color: #008000;" color="#008000"><span style="color: #000000;">randomly</span></span><em><span style="color: #008000;" color="#008000"><span style="color: #000000;"> shuffled items . </span></span></em></p>
<p><em><span style="color: #008000;" color="#008000"><span style="color: #000000;"><span style="color: #008080;">output : </span></span></span></em></p>
<p><em><span style="color: #008000;" color="#008000"><span style="color: #000000;"><span style="color: #008080;"><span style="color: #008000; font-style: italic;">// "number 10" -&gt; 10</span><br /><span style="color: #008000; font-style: italic;">// "number 17" -&gt; 17</span><br /><span style="color: #008000; font-style: italic;">// "number 25" -&gt; 25</span><br /><em><span style="color: #008000;" color="#008000">and so on .</span></em></span></span></span></em></p>
<p><span style="color: #008000; background-color: #ffffff;" color="#008000"></span>&nbsp;</p>
<p><span style="color: #3366ff; background-color: #ffffff;" color="#008000">I hope this might be helpful to some one some day ...............</span></p>
<p></p>]]></content:encoded>
    </item>
    <item>
      <title>String.Intern() method  implements FlyWeight pattern for better Performance and reduces MemoryFootprint.</title>
      <link>https://docs.microsoft.com/archive/blogs/nagavo/string-intern-method-implements-flyweight-pattern-for-better-performance-and-reduces-memoryfootprint</link>
      <pubDate>Sat, 12 Nov 2011 10:42:00 GMT</pubDate>
      <dc:creator><![CDATA[Smartysanthosh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/nagavo/2011/11/12/string-intern-method-implements-flyweight-pattern-for-better-performance-and-reduces-memoryfootprint/</guid>
      <description><![CDATA[As we all know String is a reference type in Dotnet and what we dont know is how it will effectively...]]></description>
      <content:encoded><![CDATA[<p>As we all know String is a reference type in Dotnet and what we dont know is how it will effectively manages Memory by using Flyweight Pattern for &nbsp;String.Intern() method .</p>
<p></p>
<p>What is exactly <strong>Flyweight pattern</strong> do ?&nbsp;</p>
<p>&nbsp;1) &nbsp;Reduce Storage Costs for Large number of objects&nbsp;</p>
<p>&nbsp; 2) share objects to be used in Multiple contexts simultaneously , but still maintains object oriented granularity and flexibility .&nbsp;</p>
<p>Suppose there is a requirement to implement "BRICK" class for building an Apartment, there might involve many Bricks During Construction . Here generally, user end up Creating milions of Brick Objects for building single room and this has to be repeated in building entire Apartment . &nbsp;[ though different sizes of bricks may be used ] .&nbsp;</p>
<p>Here complexity increases in creating more number of similar objects , flyweight pattern comes to rescue at this position .&nbsp;</p>
<p>Using FlyWeight pattern, group of shared objects are replaced by few shared objects once Extrinsic State[ like <strong>brick dimensions</strong> ] &nbsp;is removed . Dividing the states and seperating them into intrinsic and extrinsic state is important in flyweight pattern . this will improve performance and reduces complexity and memory footprint.</p>
<p></p>
<p>To give you more details , let us consider a small example on this &nbsp;&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>Case 1 :&nbsp;</strong></span></p>
<p>consider 2 strings&nbsp;</p>
<p>String s1= "Santhosh" ;</p>
<p>String s2= s1 ; // as we know strings are reference type so both s1 and s2 will be pointing to the same address location&nbsp;</p>
<p>Console.WriteLine( ReferenceEquals(s1,s2)); // returns True .</p>
<p></p>
<p><span style="text-decoration: underline;"><strong>Case 2 :&nbsp;</strong></span></p>
<p>consider</p>
<p>String s1= "Santhosh" ;</p>
<p>String s2= "Santhosh" ;&nbsp;</p>
<p>Console.WriteLine( ReferenceEquals(s1,s2)); // returns True, reason being dotnet runtime maintains an INTERN pool, contains &nbsp;single reference to each unique string in the program .</p>
<p></p>
<p><span style="text-decoration: underline;"><strong>Case 3 :&nbsp;</strong></span></p>
<p>consider</p>
<p>String s1= "Santhosh" ;</p>
<p>String s2= Console.ReadLine()&nbsp;</p>
<p>Console.WriteLine( ReferenceEquals(s1,s2)); // returns False.</p>
<p></p>
<p>&nbsp;Here .net runtime by default doesnt replace runtime input with shared reference . In order to check use&nbsp;</p>
<p>string s2= String.Intern(Console.ReadLine() );&nbsp;</p>
<p>now the output will be true . &nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>My First Post in MSDN .Wish me good luck .</title>
      <link>https://docs.microsoft.com/archive/blogs/nagavo/my-first-post-in-msdn-wish-me-good-luck</link>
      <pubDate>Sat, 12 Nov 2011 09:45:45 GMT</pubDate>
      <dc:creator><![CDATA[Smartysanthosh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/nagavo/2011/11/12/my-first-post-in-msdn-wish-me-good-luck/</guid>
      <description><![CDATA[Hi everyone ,&nbsp;
I have recently joined Microsoft India , its been a fun filled and learning...]]></description>
      <content:encoded><![CDATA[<p>Hi everyone ,&nbsp;</p>
<p>I have recently joined Microsoft India , its been a fun filled and learning career so far @ Microsoft . i still remember my induction day where we had lot many activites and events which cannot be forgetted in a life time . The people here are very co-ordial and easily approachable for any kind of help . Eventhough people are very busy in their day to day work , but still they continue to share information and help the community by actively participating in forums and groups .&nbsp;</p>
<p>it is really a good intiative to have blogs where we get to know about latest happenings in the product team as well as sharing information . i do believe " information is Wealth" and it needs to be shared with everyone for effective progress .&nbsp;</p>
<p>This turns out to be a good place for me to invest my free time in understanding the latest happenings as well as helping people on various issues . Please wish me all the best and i hope i will be an active member in this community .&nbsp;</p>
<p></p>
<p>Thanks every one .</p>]]></content:encoded>
    </item>
  </channel>
</rss>