translating the C# from the linked web page into code to stick in your snippet, it is

1
2
3
      // Create a new Contact
      let myNewContact = outlookClass.CreateItem (OlItemType.olContactItem ) :?> ContactItem
      myNewContact.FullName <- "Onorio Catenacci"
By on 6/21/2010 12:29 PM ()

translating the C# from the linked web page into code to stick in your snippet, it is

1
2
3
// Create a new Contact
let myNewContact = outlookClass.CreateItem (OlItemType.olContactItem ) :?> ContactItem
      myNewContact.FullName <- "Onorio Catenacci"

Hi Brian,

Thanks for that; I think I can cobble together the rest of it from that.

I am curious though--how would you handle creating an object expression for the Microsoft.Office.Interop.Outlook.Application interface? I hope I don't have a situation where I have to overload 72 methods but I am curious if there's a way to handle this sort of thing other than overloading 72 methods.

Also would there be a way to construct myNewContact with the FullName member specified in the constructor?

By on 6/21/2010 7:01 PM ()

If you want to create an object that implements an interface with 72 methods, then you have to implement all the methods. I am unclear what other alternative you're imagining.

There's no way to specify FullName in the constructor, since there is no constructor. You're just calling the CreateItem method and it returns you an object of that type. The shorthand syntax of 'new Foo(Prop1=val1, Prop2=val2)' only works for constructors.

By on 6/21/2010 10:44 PM ()

If you want to create an object that implements an interface with 72 methods, then you have to implement all the methods.  I am unclear what other alternative you're imagining.

I was thinking of something where I would override a few of the methods and point the rest of them at the base class behavior. But possibly this isn't the best class on which to discuss the general idiom to handle this sort of scenario.

By on 6/22/2010 5:33 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper