The Artima Developer Community
Sponsored Link •

C# Answers Forum
C# beginner

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frank Collins

Posts: 1
Nickname: yibman
Registered: May, 2006

C# beginner Posted: May 7, 2006 5:57 AM
Reply to this message Reply
Advertisement
hi i am a beginner in C# programming.Can anybody tell me what happens in the code lines for 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() { }
}
}

Topic: C# arraylist and recursion problems Previous Topic   Next Topic Topic: News:UCanCode Releases Upgraded Visio 2003- Like Flow/Diagramming Source Co

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use