<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coding Quirks</title>
	<atom:link href="http://codingquirks.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codingquirks.com</link>
	<description>Just another Coding weblog</description>
	<lastBuildDate>Fri, 18 Mar 2011 16:42:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple XML Serializer/De-Serializer</title>
		<link>http://codingquirks.com/2011/03/simple-xml-serializerde-serializer/</link>
		<comments>http://codingquirks.com/2011/03/simple-xml-serializerde-serializer/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 15:48:20 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=242</guid>
		<description><![CDATA[using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Xml.Serialization; namespace XmlSerializerHelper { static class SerializerHelpers { public static void Save(string fileName, object objectToSerialze) { XmlSerializer x = new XmlSerializer(objectToSerialze.GetType()); using (XmlWriter writer = XmlWriter.Create(fileName)) { x.Serialize(writer, objectToSerialze); } } public static T LoadFromFile&#60;T&#62;(string fileName) where T : class { try { XmlSerializer [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush:csharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace XmlSerializerHelper
{
    static class SerializerHelpers
    {
        public static void Save(string fileName, object objectToSerialze)
        {
            XmlSerializer x = new XmlSerializer(objectToSerialze.GetType());
            using (XmlWriter writer = XmlWriter.Create(fileName))
            {
                x.Serialize(writer, objectToSerialze);
            }
        }

        public static T LoadFromFile&lt;T&gt;(string fileName) where T : class
        {
            try
            {
                XmlSerializer x = new XmlSerializer(typeof(T));
                using (XmlReader reader = XmlReader.Create(fileName))
                {
                    return x.Deserialize(reader) as T;
                }
            }
            catch
            {
                return null;
            }

        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2011/03/simple-xml-serializerde-serializer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XNA User Group &amp; Boise Code Camp</title>
		<link>http://codingquirks.com/2011/02/xna-user-group/</link>
		<comments>http://codingquirks.com/2011/02/xna-user-group/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 22:29:31 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Boise Group]]></category>
		<category><![CDATA[XNA User Group]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=235</guid>
		<description><![CDATA[Boise Code Camp happened yesterday and we had an excellent turn out. I decided to give a session on XNA game development which turned out to have more people than I expected. I was also shocked to see so many hands go up when I asked how many people used XNA already, then see almost all [...]]]></description>
			<content:encoded><![CDATA[<p>Boise Code Camp happened yesterday and we had an excellent turn out.</p>
<p>I decided to give a session on XNA game development which turned out to have more people than I expected. I was also shocked to see so many hands go up when I asked how many people used XNA already, then see almost all those hands drop when I asked if anyone launched any games.</p>
<p>What is it that causes people to stop making their game? There must be some reason games are not being completed. My personal opinion&#8230; and thats all it is&#8230; is that many give up on development when they get stuck on something, bored of working alone, or see their dream of a game becoming a never ending processes of jumping through hoops.</p>
<p>This being said I think its time for us to start an XNA user group in the Boise, Idaho area. A few of us talked after the session and are putting out feelers to see who may be interested. I would like to have at least 15-20 dedicated folks that wouldn&#8217;t mind meeting once ever month or 2. I do not want to lead this alone and feel 2-3 leaders would be best. I am going to send out an email to BSDG (Boise Development Group) and see if we get a positive response.</p>
<p>If you are interested in joining an XNA user group please contact me directly or reply to this post.</p>
<p>Also&#8230; the demo game from code camp is available for download</p>
<p><a href="http://codingquirks.com/wp-content/uploads/2011/02/River-Rush-Code-Camp.zip">River Rush (Code Camp)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2011/02/xna-user-group/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Trials and Tribulations Working with XNA</title>
		<link>http://codingquirks.com/2011/02/trials-and-tribulations-working-with-xna/</link>
		<comments>http://codingquirks.com/2011/02/trials-and-tribulations-working-with-xna/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 01:28:01 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=230</guid>
		<description><![CDATA[Wow, getting a game started on your own can be a pain in the ass. The XNA forums are full of information but scattered here and there and everywhere. Building a game is more than writing lines of code. Working with XNA you must deal with Importing objects, positioning them, lighting/shading them, and once you [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, getting a game started on your own can be a pain in the ass. The XNA forums are full of information but scattered here and there and everywhere. Building a game is more than writing lines of code. Working with XNA you must deal with Importing objects, positioning them, lighting/shading them, and once you have that figured out you may be able to write some code.</p>
<p>For those of us who fly solo, It&#8217;s very time consuming and extremely painful to research, build a little, research more&#8230; erase what we have done, start again, build a little, research, build, erase, build, research, research, erase, erase all, Start over&#8230; you catch my drift.</p>
<p>Well I am in the start over phase, I had a game going (XNA Tanks) about a year ago that I finally have time to come back to. A year later&#8230; I am a much better programmer and a new version of XNA is out so I think its time to do this game correct.</p>
<p>What am I going to do other than build a game? I am going to post all the questions I have and every road block I run into. Then as I solve these riddles I will post how, and why when relevant, that way when the next developer going mano-a-mano with XNA doesn&#8217;t get blown away within the first couple days.</p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2011/02/trials-and-tribulations-working-with-xna/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Render BoundingSphere in XNA 4.0</title>
		<link>http://codingquirks.com/2011/01/render-boundingsphere-in-xna-4-0/</link>
		<comments>http://codingquirks.com/2011/01/render-boundingsphere-in-xna-4-0/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 04:34:59 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=226</guid>
		<description><![CDATA[There have been some changes in XNA 4.0 that prevent drawing primitives with XNA 3.1 code. The following is a bounding sphere render class /// &#60;summary&#62; /// Provides a set of methods for rendering BoundingSpheres. /// &#60;/summary&#62; public static class BoundingSphereRenderer { static VertexBuffer vertBuffer; static VertexDeclaration vertDecl; static BasicEffect effect; static int sphereResolution; /// [...]]]></description>
			<content:encoded><![CDATA[<p>There have been some changes in XNA 4.0 that prevent drawing primitives with XNA 3.1 code.<br />
The following is a bounding sphere render class</p>
<pre class="brush:csharp"> /// &lt;summary&gt;
    /// Provides a set of methods for rendering BoundingSpheres.
    /// &lt;/summary&gt;
    public static class BoundingSphereRenderer
    {
        static VertexBuffer vertBuffer;
        static VertexDeclaration vertDecl;
        static BasicEffect effect;
        static int sphereResolution;

        /// &lt;summary&gt;
        /// Initializes the graphics objects for rendering the spheres. If this method isn't
        /// run manually, it will be called the first time you render a sphere.
        /// &lt;/summary&gt;
        /// &lt;param name="graphicsDevice"&gt;The graphics device to use when rendering.&lt;/param&gt;
        /// &lt;param name="sphereResolution"&gt;The number of line segments
        ///     to use for each of the three circles.&lt;/param&gt;
        public static void InitializeGraphics(GraphicsDevice graphicsDevice, int sphereResolution)
        {
            BoundingSphereRenderer.sphereResolution = sphereResolution;

            //vertDecl = new VertexDeclaration(
            effect = new BasicEffect(graphicsDevice);
            effect.LightingEnabled = false;
            effect.VertexColorEnabled = false;

            VertexPositionColor[] verts = new VertexPositionColor[(sphereResolution + 1) * 3];

            int index = 0;

            float step = MathHelper.TwoPi / (float)sphereResolution;

            //create the loop on the XY plane first
            for (float a = 0f; a &lt;= MathHelper.TwoPi; a += step)
            {
                verts[index++] = new VertexPositionColor(
                    new Vector3((float)Math.Cos(a), (float)Math.Sin(a), 0f),
                    Color.White);
            }

            //next on the XZ plane
            for (float a = 0f; a &lt;= MathHelper.TwoPi; a += step)
            {
                verts[index++] = new VertexPositionColor(
                    new Vector3((float)Math.Cos(a), 0f, (float)Math.Sin(a)),
                    Color.White);
            }

            //finally on the YZ plane
            for (float a = 0f; a &lt;= MathHelper.TwoPi; a += step)
            {
                verts[index++] = new VertexPositionColor(
                    new Vector3(0f, (float)Math.Cos(a), (float)Math.Sin(a)),
                    Color.White);
            }

            vertBuffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), verts.Length, BufferUsage.None);
            vertBuffer.SetData(verts);
        }

        /// &lt;summary&gt;
        /// Renders a bounding sphere using different colors for each axis.
        /// &lt;/summary&gt;
        /// &lt;param name="sphere"&gt;The sphere to render.&lt;/param&gt;
        /// &lt;param name="graphicsDevice"&gt;The graphics device to use when rendering.&lt;/param&gt;
        /// &lt;param name="view"&gt;The current view matrix.&lt;/param&gt;
        /// &lt;param name="projection"&gt;The current projection matrix.&lt;/param&gt;
        /// &lt;param name="xyColor"&gt;The color for the XY circle.&lt;/param&gt;
        /// &lt;param name="xzColor"&gt;The color for the XZ circle.&lt;/param&gt;
        /// &lt;param name="yzColor"&gt;The color for the YZ circle.&lt;/param&gt;
        public static void Render(
            BoundingSphere sphere,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color xyColor,
            Color xzColor,
            Color yzColor)
        {
            if (vertBuffer == null)
                InitializeGraphics(graphicsDevice, 30);

            graphicsDevice.SetVertexBuffer(vertBuffer);

            effect.World =
                Matrix.CreateScale(sphere.Radius) *
                Matrix.CreateTranslation(sphere.Center);
            effect.View = view;
            effect.Projection = projection;
            effect.DiffuseColor = xyColor.ToVector3();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                //render each circle individually
                graphicsDevice.DrawPrimitives(
                      PrimitiveType.LineStrip,
                      0,
                      sphereResolution);
                pass.Apply();
                effect.DiffuseColor = xzColor.ToVector3();
                graphicsDevice.DrawPrimitives(
                      PrimitiveType.LineStrip,
                      sphereResolution + 1,
                      sphereResolution);
                pass.Apply();
                effect.DiffuseColor = yzColor.ToVector3();
                graphicsDevice.DrawPrimitives(
                      PrimitiveType.LineStrip,
                      (sphereResolution + 1) * 2,
                      sphereResolution);
                pass.Apply();

            }

        }

        public static void Render(BoundingSphere[] spheres,
           GraphicsDevice graphicsDevice,
           Matrix view,
           Matrix projection,
           Color xyColor,
            Color xzColor,
            Color yzColor)
        {
            foreach (BoundingSphere sphere in spheres)
            {
                Render(sphere, graphicsDevice, view, projection, xyColor, xzColor, yzColor);
            }
        }

        public static void Render(BoundingSphere[] spheres,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color color)
        {
            foreach (BoundingSphere sphere in spheres)
            {
                Render(sphere, graphicsDevice, view, projection, color);
            }
        }

        /// &lt;summary&gt;
        /// Renders a bounding sphere using a single color for all three axis.
        /// &lt;/summary&gt;
        /// &lt;param name="sphere"&gt;The sphere to render.&lt;/param&gt;
        /// &lt;param name="graphicsDevice"&gt;The graphics device to use when rendering.&lt;/param&gt;
        /// &lt;param name="view"&gt;The current view matrix.&lt;/param&gt;
        /// &lt;param name="projection"&gt;The current projection matrix.&lt;/param&gt;
        /// &lt;param name="color"&gt;The color to use for rendering the circles.&lt;/param&gt;
        public static void Render(
            BoundingSphere sphere,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color color)
        {
            if (vertBuffer == null)
                InitializeGraphics(graphicsDevice, 30);

            graphicsDevice.SetVertexBuffer(vertBuffer);

            effect.World =
                  Matrix.CreateScale(sphere.Radius) *
                  Matrix.CreateTranslation(sphere.Center);
            effect.View = view;
            effect.Projection = projection;
            effect.DiffuseColor = color.ToVector3();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                //render each circle individually
                graphicsDevice.DrawPrimitives(
                      PrimitiveType.LineStrip,
                      0,
                      sphereResolution);
                graphicsDevice.DrawPrimitives(
                      PrimitiveType.LineStrip,
                      sphereResolution + 1,
                      sphereResolution);
                graphicsDevice.DrawPrimitives(
                      PrimitiveType.LineStrip,
                      (sphereResolution + 1) * 2,
                      sphereResolution);

            }

        }
    }</pre>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2011/01/render-boundingsphere-in-xna-4-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Active Directory Property Names</title>
		<link>http://codingquirks.com/2010/09/active-directory-property-names/</link>
		<comments>http://codingquirks.com/2010/09/active-directory-property-names/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 21:58:35 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[AD property names]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=218</guid>
		<description><![CDATA[lastlogoff homemdb badpwdcount legacyexchangedn givenname logonhours title cn whencreated displayname lastlogon dscorepropagationdata samaccounttype msexchhomeservername countrycode objectguid logoncount msexchmailboxguid authorigbl usnchanged objectsid codepage samaccountname lastlogontimestamp whenchanged msexchmailboxsecuritydescriptor homedirectory mdbusedefaults pwdlastset mailnickname homedrive badpasswordtime instancetype adspath msexchalobjectversion primarygroupid objectcategory sn objectclass proxyaddresses useraccountcontrol description distinguishedname usncreated textencodedoraddress memberof homemta msexchuseraccountcontrol mail showinaddressbook telephonenumber accountexpires department scriptpath msexchpoliciesincluded [...]]]></description>
			<content:encoded><![CDATA[<p>lastlogoff<br />
homemdb<br />
badpwdcount<br />
legacyexchangedn<br />
givenname<br />
logonhours<br />
title<br />
cn<br />
whencreated<br />
displayname<br />
lastlogon<br />
dscorepropagationdata<br />
samaccounttype<br />
msexchhomeservername<br />
countrycode<br />
objectguid<br />
logoncount<br />
msexchmailboxguid<br />
authorigbl<br />
usnchanged<br />
objectsid<br />
codepage<br />
samaccountname<br />
lastlogontimestamp<br />
whenchanged<br />
msexchmailboxsecuritydescriptor<br />
homedirectory<br />
mdbusedefaults<br />
pwdlastset<br />
mailnickname<br />
homedrive<br />
badpasswordtime<br />
instancetype<br />
adspath<br />
msexchalobjectversion<br />
primarygroupid<br />
objectcategory<br />
sn<br />
objectclass<br />
proxyaddresses<br />
useraccountcontrol<br />
description<br />
distinguishedname<br />
usncreated<br />
textencodedoraddress<br />
memberof<br />
homemta<br />
msexchuseraccountcontrol<br />
mail<br />
showinaddressbook<br />
telephonenumber<br />
accountexpires<br />
department<br />
scriptpath<br />
msexchpoliciesincluded<br />
userprincipalname<br />
name<br />
company</p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2010/09/active-directory-property-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Release] AutoLoL</title>
		<link>http://codingquirks.com/2010/07/release-autolol/</link>
		<comments>http://codingquirks.com/2010/07/release-autolol/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 23:53:21 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=211</guid>
		<description><![CDATA[Thanks to SaphuA (my Dutch buddy) Mastery Clicker v2.0 is ready to go&#8230; However it has happened to change its name to AutoLoL in the process. AutoLoL can be found at http://autolol.codeplex.com/ Feel free to download and enjoy the greatness of AutoLoL A new page regarding all the features will be up shortly&#8230;. for now [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to SaphuA (my Dutch buddy) Mastery Clicker v2.0 is ready to go&#8230; However it has happened to change its name to AutoLoL in the process. </p>
<p>AutoLoL can be found at <a href="http://autolol.codeplex.com/">http://autolol.codeplex.com/</a><br />
Feel free to download and enjoy the greatness of AutoLoL</p>
<p>A new page regarding all the features will be up shortly&#8230;. for now look at Mastery Clicker Page</p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2010/07/release-autolol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Epic Battle</title>
		<link>http://codingquirks.com/2010/07/epic-battle/</link>
		<comments>http://codingquirks.com/2010/07/epic-battle/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 06:42:07 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=196</guid>
		<description><![CDATA[I can&#8217;t believe I&#8217;m uploading this to my site but I just got done with an Epic battle in League of Legends. So epic that I had to take a screenshot of the results. This match was so well balanced and came down to the last minute, too bad recording games doesn&#8217;t work yet!]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t believe I&#8217;m uploading this to my site but I just got done with an Epic battle in League of Legends. So epic that I had to take a screenshot of the results. This match was so well balanced and came down to the last minute, too bad recording games doesn&#8217;t work yet!</p>
<p><a href="http://codingquirks.com/wp-content/uploads/2010/07/LoLMatch.png"><img src="http://codingquirks.com/wp-content/uploads/2010/07/LoLMatch-300x188.png" alt="" title="LoLMatch" width="300" height="188" class="aligncenter size-medium wp-image-198" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2010/07/epic-battle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Near Disaster &#8212; Thanks Arvixe</title>
		<link>http://codingquirks.com/2010/07/near-disaster-thanks-arvixe/</link>
		<comments>http://codingquirks.com/2010/07/near-disaster-thanks-arvixe/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 14:59:27 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[arvix]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=177</guid>
		<description><![CDATA[So, I was messing with my FTP accounts and every time I delete an account there is a little checkbox&#8230; Remove accounts home directory&#8230; well thats bad if the home directory of the account is public_html and did I mention the box is checked by default&#8230; Well anyways, as you can see its all back [...]]]></description>
			<content:encoded><![CDATA[<p>So, I was messing with my FTP accounts and every time I delete an account there is a little checkbox&#8230; Remove accounts home directory&#8230; well thats bad if the home directory of the account is public_html and did I mention the box is checked by default&#8230; Well anyways, as you can see its all back up. Thanks Arvixe for keeping a backup! Their tech support was quick and I didn&#8217;t even have to call them (I used their online chat). My host has been great so anyone looking for a great host should check out http://www.arvixe.com</p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2010/07/near-disaster-thanks-arvixe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Return JSON from Web Services, Capture with jQuery</title>
		<link>http://codingquirks.com/2010/07/return-json-from-web-service-capture-with-jquery/</link>
		<comments>http://codingquirks.com/2010/07/return-json-from-web-service-capture-with-jquery/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 19:35:03 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[WebServices]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=178</guid>
		<description><![CDATA[Many times now I have banged my head against the keyboard because I can&#8217;t get JSON to return correctly from my web service&#8230; Or is it the other way around? Is my service setup correctly but my Ajax call breaking things&#8230; Hopefully this can help people that were in my situation. I have seen many [...]]]></description>
			<content:encoded><![CDATA[<p>Many times now I have banged my head against the keyboard because I can&#8217;t get JSON to return correctly from my web service&#8230; Or is it the other way around? Is my service setup correctly but my Ajax call breaking things&#8230; Hopefully this can help people that were in my situation.</p>
<p>I have seen many people using a JSON serializer in their code. This is not normally necessary since WebServices should have the cabapility to serialize your object directly. Now lets get started&#8230; Your Web Service should look something like this.</p>
<pre class="brush: c#">
[WebService(Namespace = &quot;http://tempuri.org/&quot;)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService] //Make sure this is uncommented
public class MyWebService: System.Web.Services.WebService
{
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)] //This line is optional!
        public string MyJSONString()
        {
            return &quot;MyJSONString!&quot;;
        }

        [WebMethod]
        public List&lt;KeyValuePair&lt;int, string&gt;&gt; MyJSONList(string sample)
        {
            return new List&lt;KeyValuePair&lt;int,string&gt;&gt;(){
                new KeyValuePair&lt;int,string&gt;(0,&quot;MyValue1&quot;),
                new KeyValuePair&lt;int,string&gt;(1,&quot;MyValue2&quot;),
                new KeyValuePair&lt;int,string&gt;(2,&quot;MyValue3&quot;),
                new KeyValuePair&lt;int,string&gt;(3,&quot;MyValue4&quot;),
                new KeyValuePair&lt;int,string&gt;(4,&quot;MyValue5&quot;),
            };

        }
}
</pre>
<p>Once you have that ready to go, and it looks like this you should be able to make an AJax call to return it as JSON. This is were a lot of people get caught up. You can&#8217;t use Jquery&#8217;s built in getJSON for reasons unknown to me webservices can only return JSON with a POST not a GET so here is a sample call that works for me. First the string, then the more advanced list.</p>
<pre class="brush: javascript">
 $.ajax({
    type: &quot;POST&quot;,
    url: &quot;http://localhost/WebServices/MyWebService.asmx/MyJSONString&quot;,
    data: &quot;{}&quot;, //This is the KEY, Send in an empty object as the data
    contentType: &quot;application/json; charset=utf-8&quot;, //this must be added in order to request json
    dataType: &quot;json&quot;, //as well as this.
    success: function (data) {
        alert(data.d); //Should = &quot;MyJSONString!&quot;
    }
 });
</pre>
<p>Now the List, sometimes things get tricky here because as you can see the method requires a string as a parameter. This string needs to be sent in the Data&#8230; but remember we have to have a json object in the Data field. so we must send our parameters as a certain way&#8230; &#8216;{sample:value}&#8217; just like that, if there are more you just add a comma &#8216;{sample:value, arg2:value}&#8217;.</p>
<pre class="brush: javascript">
 $.ajax({
    type: &quot;POST&quot;,
    url: &quot;http://localhost/WebServices/MyWebService.asmx/MyJSONList&quot;,
    data: &#039;{sample:&quot;&#039; + myVar +&#039;&quot;}&#039;, //This is the KEY if you require arguments
    contentType: &quot;application/json; charset=utf-8&quot;, //this must be added in order to request json
    dataType: &quot;json&quot;, //as well as this.
    success: function (data) {
        alert(data.d); //Should = &quot;[object],[object],etc&quot;
    }
 });
</pre>
<p>using FireBug you can see the results of the query<br />
<a href="http://codingquirks.com/wp-content/uploads/2010/07/AjaxCalls.png"><img src="http://codingquirks.com/wp-content/uploads/2010/07/AjaxCalls-300x272.png" alt="" title="AjaxCalls" width="300" height="272" class="alignnone size-medium wp-image-183" /></a></p>
<p>As you can see web services adds a d to the json object&#8230; not sure why, but it does. Therefore you might not be able to implement this directly into a plugin that isn&#8217;t expecting the d you will have to modify it and then pass it back into the plugin.<br />
But if you are having issues let me know&#8230; I&#8217;m more than happy to help.</p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2010/07/return-json-from-web-service-capture-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mastery Clicker &amp; League of Legends Season One</title>
		<link>http://codingquirks.com/2010/07/mastery-clicker-league-of-legends-season-one/</link>
		<comments>http://codingquirks.com/2010/07/mastery-clicker-league-of-legends-season-one/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 01:39:31 +0000</pubDate>
		<dc:creator>Matt Overall</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://codingquirks.com/?p=175</guid>
		<description><![CDATA[I thought Season One would give us the option to save our masteries&#8230; Apparently I was wrong. I am currently in Hawaii so I won&#8217;t be able to release a patch for mastery clicker until I get home from vacation. In fact Mastery Clicker 2.0 or should I say AutoLOL should be released in the [...]]]></description>
			<content:encoded><![CDATA[<p>I thought Season One would give us the option to save our masteries&#8230; Apparently I was wrong. I am currently in Hawaii so I won&#8217;t be able to release a patch for mastery clicker until I get home from vacation. In fact Mastery Clicker 2.0 or should I say AutoLOL should be released in the short future adding a lot more features then just clicking masteries. </p>
]]></content:encoded>
			<wfw:commentRss>http://codingquirks.com/2010/07/mastery-clicker-league-of-legends-season-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

