コード例 #1
0
ファイル: Backendless.cs プロジェクト: Mohamie/.NET-SDK
        public static void InitApp(String applicationId, String apiKey)
        {
            if (String.IsNullOrEmpty(applicationId))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_APPLICATION_ID);
            }

            if (String.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_SECRET_KEY);
            }

            Log.addLogger(Log.DEFAULTLOGGER, new ConsoleLogger());
            Log.startLogging(BACKENDLESSLOG);
#if WITHRT
            Quobject.EngineIoClientDotNet.Modules.LogManager.Enabled = !DeviceCheck.IsMobile;
#endif
            AppId  = applicationId;
            APIKey = apiKey;

            Persistence   = new PersistenceService();
            Data          = Persistence;
            Geo           = new GeoService();
            Messaging     = new MessagingService();
            Files         = new FileService();
            UserService   = new UserService();
            Events        = Events.GetInstance();
            Cache         = Cache.GetInstance();
            Counters      = CounterService.GetInstance();
            Logging       = new LoggingService();
            CustomService = new CustomService();

      #if WITHRT
            RT = new RTServiceImpl();
      #endif

            MessageWriter.DefaultWriter = new UnderflowWriter();
            MessageWriter.AddAdditionalTypeWriter(typeof(BackendlessUser), new BackendlessUserWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Geometry), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Point), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(LineString), new BackendlessGeometryWriter());
            MessageWriter.AddAdditionalTypeWriter(typeof(Polygon), new BackendlessGeometryWriter());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(BackendlessUser).FullName, new BackendlessUserFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(GeometryDTO).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Geometry).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Point).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(LineString).FullName, new BackendlessGeometryFactory());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(Polygon).FullName, new BackendlessGeometryFactory());

            HeadersManager.CleanHeaders();
            LoginStorage loginStorage = new LoginStorage();

            if (loginStorage.HasData)
            {
                HeadersManager.GetInstance().AddHeader(HeadersEnum.USER_TOKEN_KEY, loginStorage.UserToken);
            }
        }
コード例 #2
0
ファイル: Backendless.cs プロジェクト: ramilbgd/.NET-SDK
        public static void InitApp(string applicationId, string apiKey)
        {
            if (string.IsNullOrEmpty(applicationId))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_APPLICATION_ID);
            }

            if (string.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_SECRET_KEY);
            }

            AppId  = applicationId;
            APIKey = apiKey;

            Persistence   = new PersistenceService();
            Data          = Persistence;
            Geo           = new GeoService();
            Messaging     = new MessagingService();
            Files         = new FileService();
            UserService   = new UserService();
            Events        = Events.GetInstance();
            Cache         = Cache.GetInstance();
            Counters      = CounterService.GetInstance();
            Logging       = new LoggingService();
            CustomService = new CustomService();

            MessageWriter.DefaultWriter = new UnderflowWriter();
            MessageWriter.AddAdditionalTypeWriter(typeof(BackendlessUser), new BackendlessUserWriter());
            ORBConfig.GetInstance().getObjectFactories().AddArgumentObjectFactory(typeof(BackendlessUser).FullName, new BackendlessUserFactory());

            HeadersManager.CleanHeaders();
            LoginStorage loginStorage = new LoginStorage();

            if (loginStorage.HasData)
            {
                HeadersManager.GetInstance().AddHeader(HeadersEnum.USER_TOKEN_KEY, loginStorage.UserToken);
            }
        }