codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  C# beginner  yibman at 13:19 on Sunday, May 07, 2006
 

hi i am a beginner in C# programming. Can anybody tell me what happens in the codelines of these 2 classes :

using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Text;
using Wilson.ORMapper;

namespace WindowsApplication3.Data
{
public class DataObject
{
private int id = 0;
public int ID
{
get { return this.id; }
}

private LogEntryCollection logEntries;
public LogEntryCollection LogEntries
{
get
{
if (logEntries == null)
{
logEntries = new LogEntryCollection(this);

OPathQuery<LogEntry> opath = new OPathQuery<LogEntry>("ReferringID = " + this.ID + " AND Type = '" + this.GetType().ToString() + "'");
Collection<LogEntry> os = DataManager.Current.Engine.GetCollection<LogEntry>(opath);
foreach (LogEntry le in os) logEntries.Add(le);
}

return logEntries;
}
}

public void Delete()
{
if (this.id > 0) DataManager.Current.Engine.MarkForDeletion(this);
this.Persist();
}

public void Persist()
{
DataManager.Current.Engine.PersistChanges(this, Wilson.ORMapper.PersistDepth.ObjectGraph);
if (logEntries != null) logEntries.Persist();
}

public DataObject() { }
}
}



using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;

namespace WindowsApplication3.Data
{
public class ObjectCollection<T> : Collection<T>
{
public ObjectCollection<T> Search(string search)
{
ObjectCollection<T> completedSearch = new ObjectCollection<T>();

foreach (T o in this)
{
Type t = o.GetType();
PropertyInfo[] pInfos = t.GetProperties();

foreach (PropertyInfo pInfo in pInfos)
{
object oval = pInfo.GetValue(o, null);
string val;

if (oval == null) val = "";
else val = oval.ToString();

if (val.ToLower().Contains(search.ToLower()) && !completedSearch.Contains(o))
completedSearch.Add(o);
}
}

return completedSearch;
}

public ObjectCollection() { }
}
}










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  onChange issue
•  Remote program execution using cgi-perl
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007