private void WriteConstants(InjectionService injectionService)
 {
     constantWriter.WriteLine("// <auto-generated />");
     constantWriter.WriteLine("namespace Anvil.Tests.Resources");
     constantWriter.WriteLine("{");
     constantWriter.WriteLine("  internal static class StandardResRef");
     constantWriter.WriteLine("  {");
     WriteBlueprintConstants("Creature", injectionService.Inject(new Palette(CreaturePaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Door", injectionService.Inject(new Palette(DoorPaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Encounter", injectionService.Inject(new Palette(EncounterPaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Item", injectionService.Inject(new Palette(ItemPaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Placeable", injectionService.Inject(new Palette(PlaceablePaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Sound", injectionService.Inject(new Palette(SoundPaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Store", injectionService.Inject(new Palette(StorePaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Trigger", injectionService.Inject(new Palette(TriggerPaletteResRef)).GetBlueprints());
     constantWriter.WriteLine();
     WriteBlueprintConstants("Waypoint", injectionService.Inject(new Palette(WaypointPaletteResRef)).GetBlueprints());
     constantWriter.WriteLine("  }");
     constantWriter.WriteLine("}");
 }
        public StandardResRefGenerator(InjectionService injectionService, PluginStorageService storageService)
        {
            constantWriter = new StreamWriter(Path.Combine(storageService.GetPluginStoragePath(typeof(StandardResRefGenerator).Assembly), "StandardResRef.cs"));
            WriteConstants(injectionService);
            constantWriter.Dispose();

            Log.Info("Generation complete.");
        }
Exemple #3
0
        // writes value to oldData and to memory
        private bool DoWrite(T val)
        {
            this.Write(val, ref this.newData);

            if (!Equals(this.newData, this.oldData))
            {
                Array.Copy(this.newData, this.oldData, (int)this.length);
                InjectionService.WriteProcessMemory(this.process.Handle, this.address, this.oldData, (UIntPtr)this.length, out IntPtr bytesRead);
                return(true);
            }

            return(false);
        }
Exemple #4
0
        // Reads memory into newData array
        private void DoRead()
        {
            if (!InjectionService.ReadProcessMemory(this.process.Handle, this.address, this.newData, (UIntPtr)this.length, IntPtr.Zero))
            {
                int code = Marshal.GetLastWin32Error();

                // code 0 means success. ooh boy Win32 legacy API's.
                if (code == 0)
                {
                    return;
                }

                throw new MemoryException("Failed to read process memory", new Win32Exception(code));
            }
        }
Exemple #5
0
        public override void SetupContainers()
        {
            IInjectionContainer container = new InjectionContainer()
                                            .RegisterExtension <UnityBindingContainerExtension>()
                                            .RegisterExtension <EventCallerContainerExtension>();

            IInjectionService injectionService = new InjectionService(container);

            container
            .Bind <IInjectionService>().To(injectionService)
            .Bind <IEntityGeneratorService>().ToSingleton <EntityGeneratorService>();

            BindControllers(container);

            AddContainer(container);
        }
Exemple #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            lkWebContext.connectionString = ConfigurationHelper.getConnStr();
            // services.AddDbContextPool<lkWebContext>(options => options.UseSqlServer(lkWebContext.connectionString), poolSize: 64);
            services.AddDbContext <lkWebContext>(options => options.UseSqlServer(lkWebContext.connectionString), ServiceLifetime.Transient);
            services.AddSession(config =>
            {
                config.Cookie.Name = "lkWeb.Session";
                config.IdleTimeout = TimeSpan.FromMinutes(15);
            });

            //Add Hangfire
            services.AddHangfire(x => x.UseSqlServerStorage(lkWebContext.connectionString));

            // Add framework services.
            services.AddMvc(option => option.Filters.Add <HttpGlobalExceptionFilter>())
            .AddJsonOptions(
                opt => opt.SerializerSettings.DateFormatString = "yyyy-M-d hh:mm:ss"
                );

            services.AddAuthentication();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            // Add application services. For instance:
            InjectionService.services = services;
            InjectionService.Injection();

            services.ConfigureApplicationCookie(options =>
            {
                // Cookie settings
                options.Cookie.HttpOnly   = true;
                options.Cookie.Expiration = TimeSpan.FromDays(7);
                options.LoginPath         = "/admin/user/login";           // If the LoginPath is not set here, ASP.NET Core will default to /Account/Login
                options.LogoutPath        = "/admin/user/logout";          // If the LogoutPath is not set here, ASP.NET Core will default to /Account/Logout
                options.AccessDeniedPath  = "/admin/control/AccessDenied"; // If the AccessDeniedPath is not set here, ASP.NET Core will default to /Account/AccessDenied
                options.SlidingExpiration = true;
            });

            //automapper
            services.AddSingleton(sp => _mapperConfiguration.CreateMapper());
        }
        protected ApplicationModelSkeletonImmutable(
            ApplicationArchitecture <ApplicationModel <ApplicationSPI> > architecture,
            Type genericCompositePropertyMixin,
            Type genericCompositeEventMixin,
            Type genericFragmentBaseType,
            DictionaryQuery <CompositeModelType, CompositeModelTypeAssemblyScopeSupport> modelTypeAssemblyScopeSupport,
            out DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport,
            out DictionaryProxy <Int32, CompositeModel> models
            )
        {
            ArgumentValidator.ValidateNotNull("Application architecture", architecture);
            ArgumentValidator.ValidateNotNull("Generic composite property mixin", genericCompositePropertyMixin);
            ArgumentValidator.ValidateNotNull("Generic composite event mixin", genericCompositeEventMixin);
            ArgumentValidator.ValidateNotNull("Generic fragment base type", genericFragmentBaseType);

            this._injectionService = new InjectionServiceImpl();
            this._genericCompositePropertyMixin = genericCompositePropertyMixin;
            this._genericCompositeEventMixin    = genericCompositeEventMixin;
            this._genericFragmentBaseType       = genericFragmentBaseType;
            this._collectionsFactory            = architecture.CollectionsFactory;
            this._compositeModelTypeSupport     = this._collectionsFactory.NewDictionaryProxy <CompositeModelType, CompositeModelTypeModelScopeSupport>(modelTypeAssemblyScopeSupport.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.CreateModelScopeSupport())).CQ;
            this._models              = this._collectionsFactory.NewDictionaryProxy <Int32, CompositeModel>();
            this._validationResult    = new Lazy <ApplicationValidationResultIQ>(this.DoValidate, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
            compositeModelTypeSupport = this._compositeModelTypeSupport;
            models             = this._models;
            this._typeModelDic = new Lazy <DictionaryQuery <CompositeModel, CompositeTypeModel> >(() =>
                                                                                                  this._collectionsFactory.NewDictionaryProxy(this.CompositeModels.Values
                                                                                                                                              .Select(cModel => Tuple.Create(cModel, ((CompositeValidationResultImmutable)this._validationResult.Value.CompositeValidationResults[cModel]).TypeModel))
                                                                                                                                              .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2, ReferenceEqualityComparer <CompositeModel> .ReferenceBasedComparer)).CQ
                                                                                                  , System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
            this._affectedAssemblies = new Lazy <SetQuery <Assembly> >(() =>
                                                                       this._collectionsFactory.NewSetProxy(new HashSet <Assembly>(
                                                                                                                this._typeModelDic.Value
                                                                                                                .SelectMany(tModel => tModel.Key.PublicTypes
                                                                                                                            .Concat(tModel.Value.PrivateCompositeTypeInfos.Keys)
                                                                                                                            .Concat(tModel.Value.FragmentTypeInfos.Keys)
                                                                                                                            .Concat(tModel.Value.ConcernInvocationTypeInfos.Keys)
                                                                                                                            .Concat(tModel.Value.SideEffectInvocationTypeInfos.Keys))
                                                                                                                .Select(type => type.GetAssembly())
                                                                                                                )).CQ
                                                                       , System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
        }
Exemple #8
0
        protected virtual void ValidateInjectableModel(CompositeValidationResult result, CompositeModel compositeModel, AbstractInjectableModel model)
        {
            Int32 amount = model.GetAttributesMarkedWith(typeof(InjectionScopeAttribute)).Count;

            if (amount > 1)
            {
                result.InjectionValidationErrors.Add(ValidationErrorFactory.NewInjectionError("Only one injection permitted for field or parameter.", model));
            }
            else
            {
                Attribute attr = model.InjectionScope;
                if (attr != null)
                {
                    InjectionService injectionService = compositeModel.ApplicationModel.InjectionService;
                    if (injectionService.HasFunctionalityFor(attr))
                    {
                        if (!model.IsOptional)
                        {
                            var validationResult = injectionService.InjectionPossible(model);
                            if (validationResult == null || !validationResult.InjectionPossible)
                            {
                                result.InjectionValidationErrors.Add(ValidationErrorFactory.NewInjectionError("Injection was not possible" + (validationResult == null ? "." : (": " + validationResult.AdditionalMessage)), model));
                            }
                        }
                    }
                    else if (!model.IsOptional)
                    {
                        result.InjectionValidationErrors.Add(ValidationErrorFactory.NewInjectionError("Could not find injection functionality for attribute " + attr + ".", model));
                    }
                }
                else if (model is FieldModel)
                {
                    result.InternalValidationErrors.Add(ValidationErrorFactory.NewInternalError("Injection attribute was null", model));
                }
            }
        }