/// <reference path="Default.aspx" />
function SerializeData()
{
    var person = new MicrosoftAJAXDemo.Person();
    person.FirstName = "Adam";
    person.LastName = "Calderon";
    
    var personJSON = Sys.Serialization.JavaScriptSerializer.serialize(person);
    
    alert(String.format("Zwróć uwagę na sposób dołączania informacji o typach:\n {0}",personJSON));
    
}

function SerializeData2()
{
   var person = new LocalType.Person();
   person.set_firstName("Adam");
   person.set_lastName("Calderon");
   
   var personJSON = Sys.Serialization.JavaScriptSerializer.serialize(person);
   alert(String.format("Zwróć uwagę na sposób dołączania informacji o typach:\n {0}",personJSON));
   
}

function CallServiceJSON()
{
    var personQuery = new MicrosoftAJAXDemo.PersonQuery();
    personQuery.FirstName = "Adam";
    personQuery.LastName = "Calderon";
    
    ajaxbooksamples.com.personservice.GetPersonAdvanced(personQuery,onSuccessJSON,onFailed);
    
}

function onSuccessJSON(result)
{
    alert(String.format("Pierwsze imię to {0}; nazwisko to {1}.",result.FirstName,result.LastName));
}

function onFailed()
{
    alert("Failed");
}

Type.registerNamespace('LocalType');

LocalType.Person=function() {
    LocalType.Person.initializeBase(this);
    this._firstName = null;
    this._lastName = null;
}

LocalType.Person.prototype={
    get_firstName: function(){
        return this._firstName;
    },
    set_firstName: function(value){
        this._firstName = value;
    },
    get_lastName: function(){
        return this._lastName;
    },
    set_lastName: function(value){
        this._lastName = value;
    }
}

LocalType.Person.registerClass('LocalType.Person');
