AskiaPortal Common API Documentation |
This documentation help you quick start using the AskiaPortal Common API and provide the full API reference.
This topic contains the following sections:
AskiaPortal Common API (AskiaPortalCmn.dll) is a .Net library providing an access to the AskiaPortal database and managing AskiaPortal cross-modules interactions.
It's intended to be used by all of the server-side AskiaPortal modules.
AskiaPortal Common API provide the following non-exhaustive list of features:
Most of the objects in the AskiaPortalCmn API are only available through their interfaces.
As many as possible, it avoid to expose classes and constructors.
For several reasons we feel it's good pattern to be future-proof and to do seamless improvements.
To instantiate an object, AskiaPortalCmn API uses static object factories such as ContextFactory, ModuleFactory, UserFactory, GroupFactory, UserProfileFactory, SurveyFactory, ShareFactory, EmailFactory, LanguageFactory, TranslatorFactory, InterpreterFactory, ...
IUser user = UserFactory.FindByGuid(context, guid);
AskiaPortalCmn API tries as much as possible to not throw exceptions.
try{} catch {} blocks degrade performances and are necessary when an API intensively throw exceptions.
Instead of throwing, AskiaPortalCmn API will, most of the time, returns a result in form of IReturnValue or IReturnValueT.
IReturnValue result = object.Method(); if (!result.Success) { // Use the result.Exception, // result.Exception.Code, // result.Exception.TranslatedMessage, // result.Exception.Message // or // throw result.Exception; }
IReturnValue<string> result = object.Method(); if (!result.Success) { // Use the result.Exception, // result.Exception.Code, // result.Exception.TranslatedMessage, // result.Exception.Message // or // throw result.Exception; } // Use the value returned by the method string value = result.Value;