private static void initializePlatformServices()
 {
     if (!ServiceFinder.IsRegistered <IPlatformBridge>())
     {
         ServiceFinder.RegisterInstance <IPlatformBridge>(new IOSPlatformBridge());
     }
 }
Exemplo n.º 2
0
        public static ServiceFinder AddTasksInfrastructure(this IServiceCollection services, IConfiguration configuration)
        {
            var assemblies = AssemblyLoadContext.Default.Assemblies.Where(a => a.FullName.Contains("Leftware"));
            var names      = assemblies.Select(a => a.FullName).ToList();

            foreach (var assembly in assemblies)
            {
                LoadReferencedAssembly(assembly);
            }

            var logger = CreateLogger(services, configuration);

            var dynamicLoader = new DynamicAssemblyLoader(configuration);

            dynamicLoader.Execute();

            var taskTypeLocator = new TaskTypeLocator(dynamicLoader, logger);

            services.AddSingleton(taskTypeLocator);

            var defaultProvider = new DefaultInjectionProvider(services);

            services.AddSingleton <IInjectionProvider>(defaultProvider);

            var finder = new ServiceFinder(defaultProvider, configuration, logger);

            finder.Find();

            var taskInjector = new TaskInjector(taskTypeLocator);

            taskInjector.Inject(defaultProvider);

            return(finder);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ServiceFinder <IGatewayService> finder = new ServiceFinder <IGatewayService>();

            finder.ServiceDiscovied += GateWayServiceProxy.Default.ServiceDiscoveryHandle;
            finder.Start();

            var binding = new CustomBinding();

            binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8));
            binding.Elements.Add(new HttpTransportBindingElement());
            var stateServerWebService = ChannelFactory <IStateServerWebService> .CreateChannel(binding, new EndpointAddress("http://localhost:7778/Gateway/webService"));

            stateServerWebService.NotifyManagerStarted("nettcp// mangaer", "my iExchange");

            using (ServiceHost host = new ServiceHost(typeof(CommandCollectService)))
            {
                host.Description.Behaviors.Add(new ServiceDiscoveryBehavior());
                host.AddServiceEndpoint(new UdpDiscoveryEndpoint());
                host.Open();

                //Thread.Sleep(1000 * 60);
                //GateWayServiceProxy.Default.Place(CreateTransactionData());
                Console.WriteLine("started ");
                Console.Read();
            }
        }
 private static void initializePlatformServices(Context appContext)
 {
     if (!ServiceFinder.IsRegistered <IPlatformBridge>())
     {
         ServiceFinder.RegisterInstance <IPlatformBridge>(new AndroidPlatformBridge(appContext));
     }
 }
        private string GetDeviceId()
        {
            IDeviceService deviceService = ServiceFinder.Resolve <IDeviceService>();
            string         deviceId      = deviceService.GetDeviceId();

            return(deviceId);
        }
 public void SetUp()
 {
     server   = FluentMockServer.Start();
     localUrl = server.Urls[0];
     ServiceFinder.RegisterInstance <IPlatformBridge>(new DummyPlatformBridge());
     server.Given(Request.Create().WithPath(GET_TEST_PATH).UsingGet()).RespondWith(Response.Create().WithStatusCode(200).WithHeader("Content-Type", "application/json").WithBody(GET_TEST_BODY));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:AeroGear.Mobile.Auth.AuthService"/> class.
 /// </summary>
 /// <param name="mobileCore">Mobile core.</param>
 /// <param name="serviceConfig">Service configuration.</param>
 public AuthService(MobileCore mobileCore = null, ServiceConfiguration serviceConfig = null) : base(mobileCore, serviceConfig)
 {
     Core.Logger.Info("AuthService construct start");
     Core.Logger.Info("AuthService construct storage");
     CredentialManager = new CredentialManager(ServiceFinder.Resolve <IPlatformBridge>().GetUserPreferences("AeroGear.Mobile.Auth.Credentials"));
     Core.Logger.Info("AuthService construct credential manager");
 }
Exemplo n.º 8
0
        public void DeleteTestFailWithUsers()
        {
            string Code = string.Empty;

            using (var TokenService = ServiceFinder.GetTokenService())
            {
                Code = TokenService.CreateToken(TokenType.WebAuth, 1);
            }

            var GroupService = ServiceFinder.GetGroupService(Code, TokenType.WebAuth);

            var CreatedId = GroupService.Create("DeleteTestGroup");

            using (var CdDb = new CDSEntities())
            {
                var User = CdDb.Users.SingleOrDefault(x => x.Id == 1);
                User.IdGroup = CreatedId;
                CdDb.SaveChanges();

                try
                {
                    GroupService.Delete(CreatedId);
                }
                catch (Exception)
                {
                    User.IdGroup = null;
                    CdDb.SaveChanges();
                    CdDb.Groups.Remove(CdDb.Groups.SingleOrDefault(x => x.Id == CreatedId));
                    CdDb.SaveChanges();
                    throw;
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Check if a session token exists
        /// </summary>
        /// <returns></returns>
        public bool Exists()
        {
            var data  = ServiceFinder.Resolve <IDataService>();
            var saved = data.GetData(SessionTokenKey);

            return(null != saved);
        }
Exemplo n.º 10
0
        public Authenticator() : base(null, null)
        {
            UserRepository = new UserRepository();
            RoleRepository = new RoleRepository();

            RoleRepository.Add(new Role()
            {
                Name = "login", Active = true
            });
            RoleRepository.Add(new Role()
            {
                Name = "admin", Active = true
            });
            User user = new User()
            {
                Active = true, Login = "******", Password = "******"
            };

            user.Roles.Add(RoleRepository.FirstOrDefault(p => p.Name == "admin"));
            UserRepository.Add(user);

            ServiceFinder.GetInstance <IEventAggregator>().GetEvent <AuthenticationNeeded>().Subscribe((auser) =>
            {
                lock (authLock)
                {
                    IAuthenticator <IUser, IRole> authenticator = ServiceFinder.GetInstance <IAuthenticator <IUser, IRole> >();
                    if ((authenticator != null) && (authenticator.CurrentUser == null))
                    {
                        authenticator.Authenticate(null, null);
                    }
                }
            });
        }
Exemplo n.º 11
0
        public WinService()
        {
            InitializeComponent();
            this.ServiceName = ConfigurationManager.AppSettings["ServiceName"];

            ServiceContext.Initialize(ServiceFinder.GetServices(ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location)));
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Return the saved session token value
        /// </summary>
        /// <returns></returns>
        public string GetToken()
        {
            var data  = ServiceFinder.Resolve <IDataService>();
            var saved = data.GetData(SessionTokenKey);

            return(saved);
        }
Exemplo n.º 13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // add a hook for service finder...this should be the last call
            ServiceFinder.Configure(services);
        }
Exemplo n.º 14
0
        public static T GetService <T>(RequestContext Request) where T : class
        {
            string Token       = string.Empty;
            var    SessionAuth = Request.HttpContext.Session[GlobalParams.UserSessionKey];
            var    TokenType   = SVC.DTO.TokenType.WebAuth;

            if (SessionAuth != null)
            {
                var AuthObject = (AuthResponse)SessionAuth;
                Token = AuthObject.Token;
            }

            if (typeof(T) == typeof(IAuthService))
            {
                return((T)ServiceFinder.GetAuthService());
            }
            else if (typeof(T) == typeof(IContentService))
            {
                return((T)ServiceFinder.GetContentService(Token, TokenType, Request.HttpContext.Server.MapPath("~/Uploads/")));
            }
            else if (typeof(T) == typeof(IUserService))
            {
                return((T)ServiceFinder.GetUserService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGroupService))
            {
                return((T)ServiceFinder.GetGroupService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGenreService))
            {
                return((T)ServiceFinder.GetGenreService(Token, TokenType));
            }

            return(null);
        }
Exemplo n.º 15
0
        public void CreteTest()
        {
            string Code = string.Empty;

            using (var TokenService = ServiceFinder.GetTokenService())
            {
                Code = TokenService.CreateToken(TokenType.WebAuth, 1);
            }

            var GroupService = ServiceFinder.GetGroupService(Code, TokenType.WebAuth);

            using (var CdDb = new CDSEntities())
            {
                var LastGroupId = CdDb.Groups.Max(x => x.Id);

                try
                {
                    GroupService.Create("default");
                    Assert.Fail("Exception should by raised");
                }
                catch { }

                var CreatedID = GroupService.Create("TEST" + LastGroupId);
                Assert.IsTrue(CreatedID != 0);
                Assert.IsTrue(LastGroupId < CreatedID);
            }
        }
Exemplo n.º 16
0
        public async Task ShouldOAuthRequest()
        {
            await FHClient.Init();

            //given
            ServiceFinder.RegisterType <IOAuthClientHandlerService, MockOAuthClient>();

            var json        = JObject.Parse(@"{
                ""hosts"": {""host"": ""HOST""}
             }");
            var config      = new FHConfig(new MockDeviceService());
            var props       = new CloudProps(json, config);
            var authRequest = new FHAuthRequest(props);

            authRequest.SetAuthUser("gmail", "user", "password");

            var mockHttpCLient =
                new MockHttpClient {
                Content = "{\"status\": \"ok\", \"url\": \"http://oauthurl.url\"}"
            };

            FHHttpClientFactory.Get = () => mockHttpCLient;

            //when
            var response = await authRequest.ExecAsync();

            //then
            Assert.IsNotNull(response);
            var responseParams = response.GetResponseAsDictionary();

            Assert.IsNotNull(responseParams);
            Assert.AreEqual("token", responseParams["sessionToken"]);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gnerate SHA1 hash.
        /// </summary>
        /// <param name="pObject"></param>
        /// <returns></returns>
        public static string GenerateSHA1Hash(object pObject)
        {
            JArray       sorted = SortObj(pObject);
            string       strVal = sorted.ToString(Formatting.None);
            IHashService hasher = ServiceFinder.Resolve <IHashService> ();

            return(hasher.GenerateSha1Hash(strVal));
        }
Exemplo n.º 18
0
 static ServiceHelper()
 {
     ServiceContext.Initialize(ServiceFinder.GetServices(ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location)),
                               (host, args) =>
     {
         Console.WriteLine("服务{0}启动", host.Description.Name);
     });
 }
Exemplo n.º 19
0
        /// <summary>
        /// Get default storage path.
        /// </summary>
        /// <param name="dataId"></param>
        /// <returns></returns>
        public static string GetDefaultDataDir(string dataId)
        {
            IIOService ioService   = ServiceFinder.Resolve <IIOService> ();
            string     dirName     = "com_feedhenry_sync";
            string     dataDirPath = Path.Combine(ioService.GetDataPersistDir(), dataId, dirName);

            return(dataDirPath);
        }
Exemplo n.º 20
0
        public void AuthUserTest()
        {
            var AuthService = ServiceFinder.GetAuthService();

            Assert.IsFalse(AuthService.AuthUser(MockEmail, "", SVC.DTO.TokenType.WebAuth).IsSuccess);
            Assert.IsFalse(AuthService.AuthUser(MockEmail, "h" + MockPassword, TokenType.WebAuth).IsSuccess);
            Assert.IsTrue(AuthService.AuthUser(MockEmail, MockPassword, TokenType.WebAuth).IsSuccess);
        }
        private void InitMenu()
        {
            MenuBuilder builder = new MenuBuilder(ServiceFinder.GetInstance <ICommandContainer>().Commands);

            foreach (MenuItem item in builder.Menu)
            {
                Items.Add(item);
            }
        }
 public MainMenu()
 {
     InitializeComponent();
     InitMenu();
     ServiceFinder.GetInstance <ICommandContainer>().Commands.CollectionChanged += (o, e) => {
         Items.Clear();
         InitMenu();
     };
 }
Exemplo n.º 23
0
        private void OnExit(object sender, ExitEventArgs e)
        {
            ILogger logger = ServiceFinder.GetInstance <ILogger>();

            if (logger != null)
            {
                logger.InfoFormat("Application exited with code {0}", e.ApplicationExitCode);
            }
        }
Exemplo n.º 24
0
        public ScrollViewer(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            ServiceFinder serviceFinder = new ServiceFinder(game);

            spriteBatch = serviceFinder.FindService <SpriteBatch>();

            renderer = new BasicScrollViewerRenderer(game, this);
        }
 public T WithDeviceCheck(params IDeviceCheckType[] checkTypes)
 {
     foreach (var checkType in NonNull(checkTypes, "checkTypes"))
     {
         IDeviceCheck check = ServiceFinder.Resolve <IDeviceCheckFactory>().create(checkType);
         CheckList.Add(check);
     }
     return((T)this);
 }
        public AppMetrics()
        {
            ApplicationRuntimeInfo appInfo = ServiceFinder.Resolve <IPlatformBridge>().ApplicationRuntimeInfo;

            this.appId      = appInfo.Identifier;
            this.appVersion = appInfo.Version;
            this.sdkVersion = typeof(MobileCore).GetTypeInfo().Assembly.GetName().Version.ToString();
            this.framework  = appInfo.Framework;
        }
Exemplo n.º 27
0
        public FarmZilla(ConfigurationConstants configuration)
        {
            _configuration = configuration;

            _dependencyFinder = new DependencyFinder();
            _fileCacheFarmer  = new FileCacheFarmer();
            _serviceFinder    = new ServiceFinder();
            _summarizer       = new Summarizer(configuration.SummaryOutputPath);
        }
Exemplo n.º 28
0
        public InMemoryDataStoreTest()
        {
            FHClient.Init();
            _ioService = ServiceFinder.Resolve <IIOService>();
            var dataDir        = _ioService.GetDataPersistDir();
            var dataPersistDir = Path.Combine(dataDir, "syncTestDir");

            _dataPersistFile = Path.Combine(dataPersistDir, ".test_data_file");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:AeroGear.Mobile.Security.DeviceChecks"/> class.
        /// Private so that it can't be instantiated externally: useful to emulate an enum.
        /// </summary>
        /// <param name="checkType">The class type of the check represented by this instance.</param>
        private DeviceChecks(Type checkType, string friendlyName = null)
        {
            if (!ServiceFinder.IsRegistered <IDeviceCheckFactory>())
            {
                ServiceFinder.RegisterInstance <IDeviceCheckFactory>(IOSDeviceCheckFactory.INSTANCE);
            }

            this.CheckType = checkType;
            typesByName[friendlyName ?? checkType.Name] = this;
        }
Exemplo n.º 30
0
        public void GetAuthResponseTest()
        {
            var TokenService = ServiceFinder.GetTokenService();
            var AuthService  = ServiceFinder.GetAuthService();
            var CodeToken    = TokenService.CreateToken(TokenType.WebAuth, 1);
            var Auth         = AuthService.GetAuthResponse(CodeToken, TokenType.WebAuth);

            Assert.IsTrue(Auth.Token.Length == 32);
            Assert.IsFalse(string.IsNullOrEmpty(Auth.Name));
            Assert.IsFalse(string.IsNullOrEmpty(Auth.Email));
        }
Exemplo n.º 31
0
 public Polo()
 {
     Services = new List<RegisterService>();
     Finder = new ServiceFinder();
 }