मैं सीखने और अभ्यास IoC में अभ्यास करने और वस्तुओं के बजाय इंटरफेस के खिलाफ प्रोग्राम करने की कोशिश कर रहा हूं। यह मेरे लिए काफी कठिन है। मेरे पास अब तक का कोड है। क्या मैंने कोई गलतियां की हैं? उन्हें इंगित करें कि मुझे समझने में मदद मिलेगी कि यह वास्तव में अभ्यास में कब फिट बैठता है।क्या यह कोड डीकॉप्लेड है और क्या मैं इसे सही कर रहा हूं?
धन्यवाद!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SharpDIC.Api.Interfaces
{
interface IDownloader
{
void DownloadInformation();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpDIC.Api.Interfaces;
namespace SharpDIC.Api.Models
{
public class Member
{
/********************************************************************************
* Some of these attributes aren't even used. The API doesn't provide them yet, *
* so I'll have to scrape the information from the HTML itself. Still thinking *
* about how to tackle this. *
* *
* Author: Sergio Tapia *
* Website: http://www.alphaot.com
* Date: 16/12/2010
* ******************************************************************************/
#region "Attributes"
public string ID { get; set; }
public string Name { get; set; }
public string Rating { get; set; }
public string Photo { get; set; }
public string LastActive { get; set; }
public string Location { get; set; }
public string Birthday { get; set; }
public string Age { get; set; }
public string Gender { get; set; }
public string Email { get; set; }
public string Title { get; set; }
public string Reputation { get; set; }
public string DreamKudos { get; set; }
public string Group { get; set; }
public string Posts { get; set; }
public string PostsPerDay { get; set; }
public string MostActiveIn { get; set; }
public string JoinDate { get; set; }
public string ProfileViews { get; set; }
public string FavoriteOs { get; set; }
public string FavoriteBrowser { get; set; }
public string FavoriteProcessor { get; set; }
public string FavoriteConsole { get; set; }
public List<Visitor> Visitors { get; set; }
public List<Friend> Friends { get; set; }
public List<Comment> Comments { get; set; }
public string ProgrammingLanguages { get; set; }
public string Aim { get; set; }
public string Msn { get; set; }
public string Website { get; set; }
public string Icq { get; set; }
public string Yahoo { get; set; }
public string Jabber { get; set; }
public string Skype { get; set; }
public string LinkedIn { get; set; }
public string Facebook { get; set; }
public string Twitter { get; set; }
public string XFire { get; set; }
#endregion
}
public class Comment
{
public string ID { get; set; }
public string Text { get; set; }
public string Date { get; set; }
public string Owner { get; set; }
}
public class Friend
{
public string ID { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public string Photo { get; set; }
}
public class Visitor
{
public string ID { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public string Photo { get; set; }
public string TimeOfLastVisit { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using SharpDIC.Api.Interfaces;
using SharpDIC.Api.Models;
namespace SharpDIC.Api
{
public class Wrapper : IDownloader
{
public void DownloadInformation()
{
}
public Member SearchForMember(int memberID)
{
XDocument response = GetXmlResponse(memberID);
//Member then is responsible to parse and fill his contents.
Member member = new Member(response);
}
}
}
आप इस कोड में क्या बदलेंगे? क्या मैं इसे ठीक से कर रहा हूं?
संपादित करें: ध्यान दें कि DownloadInformation() विधि वास्तव में कुछ भी नहीं कर रही है। मेरा इरादा था कि एक इंटरफ़ेस में वह तरीका हो, जिस तरह से मैं या तो xml (अब के लिए) से जानकारी प्राप्त कर सकता हूं लेकिन भविष्य में जेएसओएन या जो भी प्रदाता ऑफर कर सकता है, पर स्विच करने में सक्षम हो सकता है।
मुझे कोई आईओसी अपने कोड में देखते हैं। – VVS
धन्यवाद, आपकी टिप्पणी मुझे बहुत मदद करता है।/s –