Cool bits about Office Communicator

image

Our regular morning project scrum was cancelled for today, as I went back to my desk, I noticed that my Office Communicator has updated my status to "In a meeting". 

I checked my team members, theirs were updated too.

It knows this because Outlook told it about my calendar!

Another thing I liked was how you can add Active Directory groups (or possibly any outlook groups) directly as contact lists.  Which saves you the problem of adding new people (and possibly removing/maintaining your list).

That's very cool integration.  Well done MS.

C# Generic TryParse Extension method

public static T? TryParse<T>(this object obj) where T : struct
{
if (obj == null) return null;

T? result = null;
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
if (converter != null)
{
try
{
// result = (T)converter.ConvertFrom(obj);
string str = obj.ToString();
result = (T)converter.ConvertFromString(str);
}
catch (Exception)
{
}
}
return result;
}
To use this baby:
decimal? d = obj.TryParse<decimal>();
int? i = obj.TryParse<int>();
DateTime? dt = obj.TryParse<DateTime>();
object = null.TryParse<string>();
here's some more craziness...
 
public static T? TryParse<T>(this object obj, Func<Exception, T?> repairFunc) where T : struct
// repairFunc to handle what happens during an exception.





Source code merge program

A good source code merge program is different from a basic text merge program.  A source code merge program needs to understand that it is computer code it's merging.

This affects how the merge program's behaviour when it comes to:

  • Code blocks
  • comment blocks
  • Refactoring
  • File headers
  • Indentation
  • Matching brackets }

jliu

Total disconnection in a large company

HR is an interesting business, here's how I see it (fails to) work:

Client: Your consultant X is fantastic, he's a legend.
Team Lead: He's an asset to the company.

Performance Review: Fantastic but there's room to grow.

Salary Review: Here's your below market average salary raise.

 

I'm at a stage in my life where choices are hard, and I think it will only get harder as I go.  I have a bit of money saved up.  The industry is nearing its peak.  I think it is time to take the dive and run my own business.

I vote with my feet.

Good bye!  Thanks for all the fish.

The funkiness that is LINQ.Contains

Ok, I'm running into brick walls.

I'm trying to do this:

from p in Products
join i in new[] {1,2,3}
on p.Id equals i
select p

I get


NotSupportedException 
Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator.

I try again with this:

from p in Products
where ( new[] {1,2,3}).Contains (p.Id )
select p

Woot got some data back in LinqPad.


Tried this in actual code...

IList<int> ids = new List<int>(new[] {1, 2, 3});
IQueryable<Product> product =
from p in Products
where ids.Contains(p.Id)
select p;



I get


Method 'Boolean Contains(Int32)' has no supported translation to SQL.


But it just worked in LinqPad...

Try again:

IEnumerable<int> ids = new int[] {1, 2, 3};
IQueryable<Product> product =
from p in Products
where ids.Contains(p.Id)
select p;

Bingo.


So summary:

In LINQ, IEnumerable.Contains is only implemented for the IEnumerable interface and not the IList interface.  Seems obvious now in hindsight.