Skip to content

Instantly share code, notes, and snippets.

View mgroves's full-sized avatar

Matthew D. Groves mgroves

View GitHub Profile
void Main()
{
using(var db = Db4oClientServer.OpenClient("localhost",8732,"debug-user","debug-password"))
{
var objects = (from MyEntity e in db
where e.Address == "337 Main St."
select e);
objects.Dump();
}
}
@mgroves
mgroves / db4oExample.linq
Created November 4, 2010 18:14
LINQPad example file for using db4o client/server
<Query Kind="Program">
<Reference>C:\zproj\project\libs\Db4objects.Db4o.dll</Reference>
<Reference>C:\zproj\project\libs\Db4objects.Db4o.CS.dll</Reference>
<Reference>C:\zproj\project\libs\Db4objects.Db4o.Linq.dll</Reference>
<Reference>C:\zproj\project\arcadefinder.Entities\bin\Debug\project.Entities.dll</Reference>
<Namespace>project.Entities</Namespace>
<Namespace>Db4objects.Db4o</Namespace>
<Namespace>Db4objects.Db4o.Linq</Namespace>
<Namespace>Db4objects.Db4o.CS</Namespace>
</Query>
void tr_LongClick(object sender, Android.Views.View.LongClickEventArgs e)
{
longClickOptions = new IList<char>[] {"Edit".ToCharArray(), "Delete".ToCharArray()};
var dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.SetTitle("Options");
dialogBuilder.SetItems(longClickOptions, tr_LongClick_Options);
dialogBuilder.Create().Show();
}
private void tr_LongClick_Options(object sender, DialogClickEventArgs e)
private void addPortfolioButton_Click(object sender, EventArgs e)
{
var intent = new Intent();
intent.SetClassName(this, AddPortfolioActivity.ClassName);
StartActivityForResult(intent, 0);
}
private void saveButton_Click(object sender, EventArgs e)
{
var portfolioName = FindViewById<EditText>(Resource.id.portfolioName);
_repo.SavePortfolio(new Portfolio() {Name = portfolioName.Text.ToString()});
Toast.MakeText(this, "You saved: " + portfolioName.Text, ToastLength.Short).Show();
var intent = new Intent();
SetResult(Result.Ok, intent);
private void listView_ItemClick(object sender, ItemEventArgs e)
{
var intent = new Intent();
intent.SetClassName(this, PortfolioActivity.ClassName);
intent.PutExtra(PortfolioActivity.Extra_PortfolioID, _portfolios[e.Position].ID ?? -1);
StartActivityForResult(intent, 0);
}
private void RefreshData()
{
var t = new Thread(() =>
{
var tickers = _svc.GetDetailedItems(_portfolioId, GetStockItems());
RunOnUiThread(() =>
{
if (tickers.Any())
{
[TestFixture]
public class DynamicTest
{
[Test]
public void DynamicTestMethod()
{
dynamic result = GetRating();
Assert.AreEqual(result.Count, 10);
Assert.AreEqual(result.Sum, 50);
}
using Android.Util;
using PostSharp.Aspects;
namespace MonoStockPortfolio
{
public class LogMeAttribute : OnMethodBoundaryAspect
{
public override void OnExit(MethodExecutionArgs args)
{
Log.W("PostSharp", "Hello from the OnMethodBoundaryAspect for the '" + args.Method.Name + "' method!");
public class WhateverActivity : Activity
{
// ... other methods omitted
[LogMe]
private void RefreshList()
{
// do stuff to refresh the list
}
}