I have a .net control with a method using the following signatures
1) Insert(TEntry)(AtomFeed, TEntry) 2) Insert(TEntry)(Uri, TEntry) 3) Insert(Uri, Stream, String, String)
I need to use option (2), but the OEA only suggests option 3, and won't compile if I don't use option 3.
How do I use option 2 ? I have some feeling that it's something to do with <> or [] or some other chicken-bone incantation
Hi,
Thank you for your email. I'm currently out of the office travelling for business. I will return on November 15. During my absence I will have no or very limited access to my email. For urgent matters, call me on my mobile and leave a message on my voice mail or call our office.
Best regards,
Wouter.
--
Wouter Dupré
Senior Solution Consultant
Progress Software NV
Stocletlaan 202 B| B-2570 Duffel | Belgium
Direct Line +32 (0) 15 30 77 00 | Mobile +32 (0) 478 50 00 49
wdupre@progress.com
If option 2 requires overloading a method in a generic type, that won't work in the ABL.
Mike is correct that option 2 is a generic method - the first set of parenthesis is used to identify the .NET type to use. This is not currently supported in ABL. Can you give me some more details on the .NET class with this method?
Thanks
-Shelley
Awwww, these are the google .net sdk classes
Specifically, the calendar service dll
Julian
Awwww
Just wrap it in a custom C# assembly and you're all set...
I don't want to have to reproduce all methods, properties etc. Could I
create a class that inherits everything, but create a new method to get
round this issue?
On 5 Nov 2010 20:42, "Mike Fechner"
Tell me more about what you're up to. Why do you need inheritance to use an API?
Using .NET generic types is a piece of cake with 10.2B. It's just the inheritance that's not possible; and I hope Shelley is looking for the use case to justify ABL generics.
Well, I'm trying to use the google sdk .net library in OpenEdge
I've gotten most of the calendar stuff working for reading calendars,
events etc but I hit this brick wall when trying to create a new
calendar.
How can I write a c# assembly that only has a new "insert" method,
wouldn't I have to reproduce or inherit in the c# the original .net
class from google in order to get all the existing methods, properties
and events in order to expose them to the ABL client ?
Julian
What is your TEntry?
I beg your pardon ?
I have no idea what you mean.
Julian
This is the example code from Google
CalendarEntry calendar = new CalendarEntry();
calendar.Title.Text = "Little League Schedule";
calendar.Summary.Text = "This calendar contains the practice schedule and game times.";
calendar.TimeZone = "America/Los_Angeles";
calendar.Hidden = false;
calendar.Color = "#2952A3";
calendar.Location = new Where("", "", "Oakland");
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarEntry createdCalendar = (CalendarEntry) service.Insert(postUri, calendar);
Ok, that has nothing to do with generic types at all. The type name in parenthesis in C# is a CAST instruction.
CalendarEntry createdCalendar = (CalendarEntry) service.Insert(postUri, calendar);
DEFINE VARIABLE createdCalendar AS CalendarEntry NO-UNDO .
createdCalendar = CAST (service.Insert(postUri, calendar), CalendarEntry) .
That is exactly what I had:
CalendarEntry2 =
CAST(CalendarService1:Insert(uri1,CalendarEntry1),CalendarEntry).
but the compiler complained about "- Mismatched number of parameters
supplied to 'Insert'. Expecting 4 but 2 were
specified. (2680)"
Julian
How do the different versions of the Insert method look like in the OpenEdge Architect class browser?
This is the only entry in the class browser
METHOD PUBLIC FINAL Google.GData.Client.AtomEntry Insert (uriTarget AS
CLASS System.Uri, input AS CLASS System.IO.Stream, contentType AS
character, slugHeader AS character)
Member of Google.GData.Client.Service
Julian
METHOD PUBLIC FINAL Google.GData.Client.AtomEntry Insert (uriTarget AS
CLASS System.Uri, input AS CLASS System.IO.Stream, contentType AS
character, slugHeader AS character)
Well, my guess is that the sample is either for a different version of the API or a different class. Does CalendarEntry inherit from System.IO.Stream?
CLASS CalendarEntry :
Member of Google.GData.Calendar
Inherits Google.GData.Client.AbstractEntry
Implements Google.GData.Client.IExtensionContainer,
Google.GData.Client.IVersionAware, Google.GData.Client.ISupportsEtag
Summary:
ABL Syntax:
USING
USING Google.GData.Calendar.CalendarEntry.
DEFINE VARIABLE class1 AS CLASS CalendarEntry.
class1 = NEW CalendarEntry().
DEFINE
DEFINE VARIABLE class1 AS CLASS Google.GData.Calendar.CalendarEntry.
class1 = NEW Google.GData.Calendar.CalendarEntry().
Viewing the same .net assembly in c# express 2010, I get this in the
object browser
Google.GData.Client.IService.Insert(Google.GData.Client.AtomFeed,
Google.GData.Client.AtomEntry)
Google.GData.Client.IService.Insert(System.Uri, System.IO.Stream,
string, string)
Julian
Do you have a working version of the C# code available? You got me downloading that SDK and I tried using it in VS2010. I basically just copied the sample code from http://code.google.com/intl/de-DE/apis/calendar/data/2.0/developers_guide_dotnet.html#CreatingCalendars to a C# class (I had to define a CalendarService object first) and get the same error.
I also get additional errors from the calendar.Title property which is not known.
As long as the sample code does not compile in C#, I suggest you try to find a google/.NET expert first... Did you try here: http://www.google.com/support/forum/p/apps-apis/label?lid=5b1004a84758c3f8&hl=en
Yes, I do.
Using 2010 c# express, I added a button to a form and added this code to the trigger. The code was pasted from http://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html#CreatingCalendars , and the 2 service lines added
private void button1_Click(object sender, EventArgs e)
{
CalendarEntry calendar = new CalendarEntry();
calendar.Title.Text = "Little League Schedule";
calendar.Summary.Text = "This calendar contains the practice schedule and game times.";
calendar.TimeZone = "America/Los_Angeles";
calendar.Hidden = false;
calendar.Color = "#2952A3";
calendar.Location = new Where("", "", "Oakland");
/* the following 2 lines are the only thing I've changed or added */
CalendarService service = new CalendarService("CalendarSampleApp");service.setUserCredentials("MyEmail@doo.com","MyPassword");
/* end of my changes to the code */
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarEntry createdCalendar = (CalendarEntry)service.Insert(postUri, calendar);
}
This code added a new calendar to my google account. Note that the Insert method only has 2 parameters. Both the c# project and the openedge project are using the same dll (C:\Program Files (x86)\Google\Google Data API SDK\Redist\Google.GData.Calendar.dll), although I have copied all of the google dlls to my aoe project directory, and added them to the used assemblies list
ok, I've created a c# class with the following:
"Works For Me (TM)"
using System;
using System.Collections.Generic;
using System.Text;
using Google.GData.Calendar;
using Google.GData.Client;
using Google.GData.Extensions;
namespace com.dotr.GoogleABL
{
public class Calendar
{
public CalendarEntry Insert(Service p_Service, CalendarEntry p_Calendar)
{
CalendarEntry CalendarEntry1;
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarEntry1 = (CalendarEntry)p_Service.Insert(postUri, p_Calendar);
return CalendarEntry1;
}
}
}
I can now call this from the ABL with the following:
[snip]
CalendarProxy1 = NEW com.dotr.GoogleABL.Calendar().
DEF VAR CalendarEntry1 AS CLASS CalendarEntry NO-UNDO.
DEF VAR CalendarEntry2 AS CLASS CalendarEntry NO-UNDO.
CalendarEntry1 = NEW CalendarEntry().
ASSIGN CalendarEntry1:HIDDEN = NO
CalendarEntry1:Title:Text = "SomeName"
CalendarEntry1:Summary:Text = "SomeSummary".
CalendarEntry2 = CalendarProxy1:Insert(INPUT CalendarService1,INPUT CalendarEntry1) .
RETURN.
FINALLY:
DELETE OBJECT CalendarEntry1 NO-ERROR.
DELETE OBJECT CalendarEntry2 NO-ERROR.
END FINALLY.
"Works For Me (TM)"
He, he.
I guess you did build your Assembly using .NET 4.0 as the target framework platform (default for VS2010). I did use .NET 3.0 as that's the framework version supported by OpenEdge. Looks like Google is using .NET 4.0 language features. At least the Google.GData.Calendar, Version 1.6.0.0 Assembly has dependencies to a System.Web 4.0.0.0 Assembly.
Can you use your custom Assembly in OpenEdge without issues?
Hmmm - no, the project properties page states that the target
framework is ".Net Framework 3.5"
The plot thickens ...
Julian
Will try 3.5 tomorrow
3.5 would be also supported by OpenEdge. Are you using the Google Data classes in your PUG Challenge presentation next week?
Are you using the Google Data classes in your PUG Challenge presentation next week?
Maybe that depends on whether he can get it working!
I will be showing how we are going to be using them in the next release ...
Julian
Har Har
On 8 November 2010 23:00, Thomas Mercer-Hursh
I'll take that as your proposal for our 2011 conference