Beispiel #1
0
        public void Initialize(GeneratorInitializationContext context)
        {
            var sp = ServiceInitializer.GetInstances();

            _instances = sp.Item1;
            _resolver  = sp.Item2;
        }
Beispiel #2
0
        /// <summary>
        /// Creates the specified service running all life cycles for it.
        /// </summary>
        /// <param name="type">The service type.</param>
        /// <returns></returns>
        protected override object CreateService(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            object instance;

            try
            {
                instance = Activator.CreateInstance(type);
            }
            catch (Exception ex)
            {
                throw new MonoRailException("Error trying to instantiate service " + type.FullName, ex);
            }

            try
            {
                ServiceInitializer.Initialize(instance, this);
            }
            catch (Exception ex)
            {
                throw new MonoRailException("Error running lifecycle steps for MonoRail service " + type.FullName, ex);
            }

            return(instance);
        }
        private bool StorageAccountExists()
        {
            ClientOutputMessageInspector messageInspector;
            IServiceManagement           serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector);
            AvailabilityResponse         response     = serviceProxy.CheckStorageAccountNameAvailability(this._subscriptionId, this.StorageAccount);

            if (response.Result == false) //If storage account already exists..verify if it is located in same location supplied in input parameter.
            {
                StorageService storageAcctProperties;
                try
                {
                    storageAcctProperties = serviceProxy.GetStorageAccountProperties(this._subscriptionId, this.StorageAccount);
                }
                catch (EndpointNotFoundException)
                {
                    throw new ApplicationFailedException(string.Format(CultureInfo.InvariantCulture, Resources.StorageAccExistsForDiffSubscription, this.StorageAccount));
                }

                if (string.IsNullOrEmpty(Location) == false &&
                    Location.Trim().ToUpperInvariant() != storageAcctProperties.StorageServiceProperties.Location.ToUpperInvariant())
                {
                    WriteWarning(Resources.StorageAccDiffLocationWarning);
                }
            }
            return(!response.Result);
        }
        private void WaitTillCreationComplete()
        {
            bool isDone = false;

            while (isDone == false)
            {
                System.Threading.Thread.Sleep(5000);

                ClientOutputMessageInspector messageInspector;
                IServiceManagement           serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector);
                Operation status = serviceProxy.GetOperationStatus(this._subscriptionId, this._createRequestToken);

                _createStorageAccStatus = status.Status;
                WriteObject("Storage account creation status: " + _createStorageAccStatus);

                if (status.Status == OperationStatus.Succeeded)
                {
                    break;
                }
                if (status.Status != OperationStatus.InProgress)
                {
                    if (IsStorageAccountLimitExceeded() == true)
                    {
                        throw new ApplicationFailedException(Resources.StorageAccLimitReached);
                    }
                    else
                    {
                        throw new ApplicationFailedException(string.Format(CultureInfo.InvariantCulture, Resources.StorageAccCreationFailed, _createStorageAccStatus));
                    }
                }
            }
        }
Beispiel #5
0
        private List <IPEndPoint> GetServiceEndpoints()
        {
            ClientOutputMessageInspector messageInspector;
            IServiceManagement           serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector);

            WriteObject(String.Format(CultureInfo.InvariantCulture, Resources.FetchingEndpoints, ServiceName));
            HostedService hostedService = serviceProxy.GetHostedServiceProperties(this._subscriptionId, this.ServiceName);

            List <IPEndPoint> endPointsToTest = new List <IPEndPoint>();

            if (hostedService.Deployments != null && hostedService.Deployments.Length != 0)
            {
                foreach (Deployment eachDeployment in hostedService.Deployments)
                {
                    if (eachDeployment.RoleList != null && eachDeployment.RoleList.Length != 0)
                    {
                        foreach (Role eachRole in eachDeployment.RoleList)
                        {
                            if (eachRole.ConfigurationSets != null && eachRole.ConfigurationSets.Length != 0)
                            {
                                foreach (ConfigurationSet eachConfigSet in eachRole.ConfigurationSets)
                                {
                                    NetworkConfigurationSet networkConfigset = eachConfigSet as NetworkConfigurationSet;
                                    if (networkConfigset != null && networkConfigset.InputEndpoints != null && networkConfigset.InputEndpoints.Length != 0)
                                    {
                                        endPointsToTest.AddRange(networkConfigset.InputEndpoints.Select(eachEndpoint => new IPEndPoint(IPAddress.Parse(eachEndpoint.Vip), eachEndpoint.Port)));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(endPointsToTest);
        }
        private string GetStorageAccKey()
        {
            ClientOutputMessageInspector messageInspector;
            IServiceManagement           serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector);
            StorageService response = serviceProxy.GetStorageAccountKeys(this._subscriptionId, this.StorageAccount);

            return(response.StorageServiceKeys.Primary);
        }
Beispiel #7
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //初始化实体
            ServiceInitializer.RegisterEntities();
            DatabaseMigrator <EfDbContext, EfConfiguration> .MigrateDatabase();

            RegisterService();
        }
        private bool IsStorageAccountLimitExceeded()
        {
            WriteObject(Resources.VerifyStorageAccCount);

            ClientOutputMessageInspector messageInspector;
            IServiceManagement           serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector);

            ServiceProxy.Subscription subscriptionDetails = serviceProxy.GetSubscription(this._subscriptionId);

            if (subscriptionDetails.MaxStorageAccounts == subscriptionDetails.CurrentStorageAccounts)
            {
                return(true);
            }
            return(false);
        }
Beispiel #9
0
    private void SetupVariables()
    {
        serviceConverter   = new ServiceConverter();
        serviceInitializer = ScriptableObject.CreateInstance <ServiceInitializer>();
        serviceInitializer.Init(serviceConverter, topVerticesPoints, PPoints, sliders);

        simulation = gameObject.AddComponent <PickAndPlaceSimulation>();

        thetas = new double[TOTAL_NO_JOINTS] {
            0.0, 0.0, 0.0
        };
        Ei = new double[TOTAL_NO_JOINTS];
        Fi = new double[TOTAL_NO_JOINTS];
        Gi = new double[TOTAL_NO_JOINTS];
        L  = DeltaRobotIKUtils.L;
        l  = DeltaRobotIKUtils.l;
    }
        public static void Main()
        {
            //using (var dbContext = new EmployeesDbContext())
            //{
            //    dbContext.Database.EnsureDeleted();
            //    dbContext.Database.EnsureCreated();
            //}
            MapperInitializer.InitializeMapper();

            var serviceProvider    = ServiceInitializer.ConfigureServices();
            var commandInterpreter = new CommandInterpreter(serviceProvider);

            var reader = new ConsoleReader();
            var writer = new ConsoleWriter();
            var engine = new Engine(reader, writer, commandInterpreter);

            engine.Run();
        }
Beispiel #11
0
        public static ApplicationContext ApplicationContextFactory()
        {
            var config             = new ConfigurationBuilder().BuildConfiguration(Directory.GetCurrentDirectory(), "appsettings.json").Build();
            var serviceCollection  = new ServiceCollection();
            var applicationContext = new ApplicationContext();

            serviceCollection.AddSingleton <IConfiguration>(config);

            foreach (var migrationType in MigrationTypes)
            {
                serviceCollection.AddSingleton(migrationType);
            }

            ServiceInitializer?.Invoke(config, serviceCollection, applicationContext);
            applicationContext.ServiceProvider = serviceCollection.BuildServiceProvider();

            return(applicationContext);
        }
Beispiel #12
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <AuthOptions>(Configuration.GetSection("Token"));
            services.Configure <UploadPhotoApiOptions>(Configuration.GetSection("UploadPhotoApi"));

            services
            .AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultScheme             = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(jwtBearerOptions =>
            {
                jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidateIssuer           = true,
                    ValidIssuer              = Configuration["Token:Issuer"],
                    ValidateAudience         = true,
                    ValidAudience            = Configuration["Token:Audience"],
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Token:Key"]))
                };
            });

            ServiceInitializer.ConfigureServices(services, Configuration);

            var mapper = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            })
                         .CreateMapper();

            services.AddSingleton(mapper);
            services.AddCors();
            services.AddControllers();

            services.Configure <ApiBehaviorOptions>(options =>
            {
                options.InvalidModelStateResponseFactory = ctx => new ValidationErrorDetailsResult();
            });
        }
Beispiel #13
0
    private void Setup()
    {
        L              = DeltaRobotFKUtils.L;
        l              = DeltaRobotFKUtils.l;
        NO_OF_LEGS     = DeltaRobotFKUtils.NO_OF_LEGS;
        coefficients   = new double[NO_OF_LEGS];
        a              = new double[DeltaRobotFKUtils.FIRST_ROW_NUMBER, DeltaRobotFKUtils.FIRST_COLUMN_NUMBER];
        b              = new double[DeltaRobotFKUtils.SECOND_NUMBER];
        c              = new double[DeltaRobotFKUtils.THIRD_NUMBER];
        thetas         = new double[NO_OF_LEGS];
        centresCircles = new Vector3[NO_OF_LEGS];

        serviceConverter   = new ServiceConverter();
        serviceInitializer = ScriptableObject.CreateInstance <ServiceInitializer>();
        serviceInitializer.Init(serviceConverter, topVerticesPoints, PPoints, sliders);

        legsRotation = ScriptableObject.CreateInstance <LegsRotation>();
        legsRotation.Init(serviceConverter, topLPivots, parallelograms, PPoints, endEffector);
    }
Beispiel #14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <MyDbContext>(options =>
                                                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <MyDbContext>()
            .AddDefaultTokenProviders();

            ServiceInitializer.ConfigureServices(services);
            services.Configure <AuthMessageSenderOptions>(Configuration);

            services.AddMvc();

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
        }
Beispiel #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ServiceInitializer.ConfigureServices(services, Configuration);

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            var mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            //services.AddMvc(options =>
            //{
            //    options.Filters.Add(typeof(GlobalExceptionFilter));
            //});

            services.AddControllersWithViews();
            services.AddMvc();
        }
Beispiel #16
0
        public void ConfigureServices(IServiceCollection services)
        {
            ServiceInitializer.ConfigureServices(services, Configuration);
            services.AddScoped <ErrorHelper>();

            var supportedCultures = new[] { new CultureInfo("ru") };

            services.Configure <RequestLocalizationOptions>(options =>
            {
                options.SupportedCultures   = supportedCultures;
                options.SupportedUICultures = supportedCultures;
            });

            var mapper = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            })
                         .CreateMapper();

            services.AddSingleton(mapper);
            services.AddCors();
            services.AddControllers();
        }
        public static void Run([ServiceBusTrigger("hweb_poc_passage_published_topic2", "hweb_sbus_subscription_passage_processor", Connection = "SASListener")] Message sbusMsg, ILogger log)
        {
            try
            {
                ServiceInitializer.Initialize();

                ParaMessage message = null;

                if (sbusMsg != null && sbusMsg.Body != null)
                {
                    var messageBody = Encoding.UTF8.GetString(sbusMsg.Body);

                    message = JsonConvert.DeserializeObject <ParaMessage>(messageBody, new JsonSerializerSettings {
                        NullValueHandling = NullValueHandling.Ignore
                    });

                    log.LogInformation($"C# ServiceBus topic trigger function processed message: {message.Title}");
                }

                if (message != null)
                {
                    var analyser = GetAnalyser();

                    var result = analyser.Analyse(message.Sample);

                    if (result != null)
                    {
                        log.LogInformation($"Longest Sentence is: {result.LongestSentence} having {result.MaxWordCount} words!");
                    }
                }
            }
            catch (Exception ex)
            {
                log.LogCritical(ex, $"FAILED to process message! : {ex.Message} - {ex.StackTrace}");
            }
        }
Beispiel #18
0
 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     kernel.Bind <IWebApplicationConfig>().To <WebApplicationConfig>();
     ServiceInitializer.RegisterServices(kernel);
 }
 static void Main(string[] args)
 {
     ServiceInitializer.OnGuiOrConsoleStart += new EventHandler <JerichoServiceEventArgs>(JerichoServiceInitializer_OnGuiOrConsoleStart);
     ServiceInitializer.StartCurrentService(new ServiceAProvider(), InitializerMode.Console);
 }
Beispiel #20
0
 protected void Application_Start(object sender, EventArgs e)
 {
     ServiceInitializer.Initialize(null);
 }
Beispiel #21
0
        void Awake()
        {
            //At this point we want to initialize the SDK's
            //FIXME: we may want to reconsider this method - right now the concept
            //is to have the GameApplication object initialize what it can, and then
            //have the GameApplication object initialized through this object when running
            //in full "game" mode, and on its own automatically when running in "scene" mode
            // - that is, a single scene called from the unity editor
            //the downside to this is that we have to re-init all the services again and again
            //when debugging - it may be benefitial to create an "external" singleton to retain
            //this object - one that "lives" through unity editor run sessions (its lifecycle
            //is an editor session, not a game session)
            //note that it's possible to do that later on, but the downside to that is that
            //we will need some method to "reset" it from the editor
            string nextScene = openingScene;

#if UNITY_EDITOR
            SceneController.s_jumpToInitOnTestScenes = false;

            if (GameApplication.RequestingScene != "")
            {
                nextScene = GameApplication.RequestingScene;
            }
            else
            {
                GameApplication.RequestingScene = nextScene;
            }
#endif

            //find the SplashScreen, so we can signal it off later
            SplashScreen       splashScreen       = gameObject.GetComponentInChildren <SplashScreen>();
            GameApplication    gameApplication    = GameApplication.CreateOrGet();
            ServiceInitializer serviceInitializer = new ServiceInitializer();
            if (splashScreen == null)
            {
                GameApplication.InitDone += () => {
                    GameApplication.Instance.SceneManager.SwitchScene(nextScene);
                };

                //iff we finish the pre-init phase, we can start the kernel
                serviceInitializer.Run(GetComponentsInChildren(typeof(IApplicationPreInit)).Cast <IApplicationPreInit>(), result => {
                    if (result)
                    {
                        StartCoroutine(gameApplication.Init(false));
                    }
                    else
                    {
                        CoreLogger.LogError("Init", "failed to start the application");
                        Application.Quit();
                    }
                });
            }
            else
            {
                serviceInitializer.Run(GetComponentsInChildren(typeof(IApplicationPreInit)).Cast <IApplicationPreInit>(), result => {
                    //iff we finish the pre-init phase, we can ask the splash screen to start the kernel
                    if (result)
                    {
                        splashScreen.Enqueue(() => gameApplication.Init(false), "Build Game Application");

                        splashScreen.Done += () => {
                            CoreLogger.LogDebug("GameApplication.Instance == " + GameApplication.Instance);
                            CoreLogger.LogDebug("GameApplication.Instance.SceneManager ==" + GameApplication.Instance.SceneManager);

                            GameApplication.Instance.SceneManager.SwitchScene(nextScene);
                        };
                    }
                    else
                    {
                        CoreLogger.LogError("Init", "failed to start the application");
                        Application.Quit();
                    }
                });
            }


#if UNITY_EDITOR
#else
            Debugger.Assert(GameApplication.Instance == null, "GameApplication initialization called twice!");
#endif
        }