code_junkie

What will you be able to do with the dynamic binding in C# 4.0?

Nov 12th, 2011
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. filter.PredicateExpression.Add(QuoteFields.FieldName == someValue)
  2.  
  3. filter.PredicateExpression.AddEquals("FieldName", someValue)
  4.  
  5. //C# 3.0 version
  6. compositeType = plugin.CompositeType;
  7. MethodInfo method = compositeType.GetMethod("Compose");
  8. var commands = (List<Command>)method.Invoke(compositeInstance,null);
  9.  
  10. //C# 4.0 version
  11. dynamic compositeInstance = plugin.CompositeInstance
  12. var commands = (List<Command>)compositeInstance.Compose();
  13.  
  14. dynamic xml = DynamicXmlParser.Parse("<Customer><Name>Thomas</Name></Customer/>");
  15. Assert.AreEqual("Thomas", xml.Customer.Name);
  16.  
  17. public dynamic GetResult(dynamic a, dynamic b)
  18. {
  19. return MyLibrary.Process(a, b);
  20. }
  21.  
  22. public dynamic Add(dynamic a, dynamic b)
  23. {
  24. return a + b;
  25. }
Add Comment
Please, Sign In to add comment