C# nybegynder
Hej jeg er en nybegynder i C# programmering. Er der nogen der kan fortælle mig hvad der sker i kodelinjerne i nedenstående klasser. Tak.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() { }
}
}
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() { }
}
}
Og denne metode :
public Kontaktperson()
{
DataManager.Current.Engine.StartTracking(this, Wilson.ORMapper.InitialState.Inserted);
}