Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationContext"/> class.
        /// </summary>
        /// <param name="options">A reference to the application configuration.</param>
        /// <param name="rsaDecryptor">A reference to the RSA decryptor in use.</param>
        /// <param name="scriptsLoader">A reference to the scripts loader in use.</param>
        /// <param name="itemTypeLoader">A reference to the item type loader in use.</param>
        /// <param name="monsterTypeLoader">A reference to the monster type loader in use.</param>
        /// <param name="telemetryClient">A reference to the telemetry client.</param>
        /// <param name="cancellationTokenSource">A reference to the master cancellation token source.</param>
        /// <param name="dbContextGenerationFunc">A reference to a function to generate the database context.</param>
        public ApplicationContext(
            IOptions <ApplicationContextOptions> options,
            IRsaDecryptor rsaDecryptor,
            IScriptLoader scriptsLoader,
            IItemTypeLoader itemTypeLoader,
            IMonsterTypeLoader monsterTypeLoader,
            TelemetryClient telemetryClient,
            CancellationTokenSource cancellationTokenSource,
            Func <IFibulaDbContext> dbContextGenerationFunc)
        {
            options.ThrowIfNull(nameof(options));
            rsaDecryptor.ThrowIfNull(nameof(rsaDecryptor));
            scriptsLoader.ThrowIfNull(nameof(scriptsLoader));
            itemTypeLoader.ThrowIfNull(nameof(itemTypeLoader));
            monsterTypeLoader.ThrowIfNull(nameof(monsterTypeLoader));
            cancellationTokenSource.ThrowIfNull(nameof(cancellationTokenSource));
            dbContextGenerationFunc.ThrowIfNull(nameof(dbContextGenerationFunc));

            DataAnnotationsValidator.ValidateObjectRecursive(options.Value);

            this.Options                 = options.Value;
            this.RsaDecryptor            = rsaDecryptor;
            this.ScriptLoader            = scriptsLoader;
            this.CancellationTokenSource = cancellationTokenSource;

            this.TelemetryClient = telemetryClient;

            this.itemTypeLoader            = itemTypeLoader;
            this.monsterTypeLoader         = monsterTypeLoader;
            this.contextGenerationFunction = dbContextGenerationFunc;
        }
Пример #2
0
        public IScriptLoader TryGetPkg(string name, int tp)
        {
            List <SimpleDictionary <int, ScriptPkg> > values = this.ScriptDic.Values;

            IScriptLoader loader = null;

            for (int i = 0; i < values.Count; ++i)
            {
                List <ScriptPkg> list = values[i].Values;
                for (int j = 0; j < list.Count; ++j)
                {
                    if (list[j].Name == name)
                    {
                        loader = list[j].Loader;
                        ListPool.TryDespawn(list);
                        break;
                    }
                }
                ListPool.TryDespawn(list);
            }

            ListPool.TryDespawn(values);

            return(loader);
        }
Пример #3
0
 public TypeScriptContext(IScriptLoader scriptLoader, ILogger logger)
 {
     this.scriptLoader = scriptLoader;
     host = new LanguageServiceShimHost(logger);
     host.AddDefaultLibScript(new FileName(scriptLoader.LibScriptFileName), scriptLoader.GetLibScript());
     context.SetParameter("host", host);
     context.Run(scriptLoader.GetTypeScriptServicesScript());
 }
 public TypeScriptContext(IScriptLoader scriptLoader, ILogger logger)
 {
     this.scriptLoader = scriptLoader;
     host = new LanguageServiceShimHost(logger);
     host.AddDefaultLibScript(new FileName(scriptLoader.LibScriptFileName), scriptLoader.GetLibScript());
     context.SetParameter("host", host);
     context.Run(scriptLoader.GetTypeScriptServicesScript());
 }
Пример #5
0
 public BuildScriptLocator(
     IFileExistsService fileExistsService,
     IConsoleLogger consoleLogger,
     IScriptLoader scriptLoader)
 {
     this.fileExistsService = fileExistsService;
     this.consoleLogger     = consoleLogger;
     this.scriptLoader      = scriptLoader;
 }
Пример #6
0
        public Bootstrap(IRepository repository, IScriptLoader scriptLoader, IErrorCache errorCache)
        {
            Repository   = repository;
            ScriptLoader = scriptLoader;
            ErrorCache   = errorCache;

            globalLoader = new GlobalLoader(errorCache);
            cache        = new PackageCache(errorCache);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="ScriptEditor" /> class.
        /// </summary>
        /// <param name="scriptLoader"> The script loader for the script. </param>
        /// <param name="scriptSerializer">The script serializer used to save the script to a file on disk</param>
        public ScriptEditor(IScriptLoader scriptLoader, IScriptSerializer scriptSerializer)
        {
            Check.IfIsNull(scriptLoader).Throw<ArgumentNullException>(() => scriptLoader);
            Check.IfIsNull(scriptSerializer).Throw<ArgumentNullException>(() => scriptSerializer);

            InitializeComponent();

            DataContext = new ScriptEditorViewModel(scriptLoader, scriptSerializer);
        }
        public MigrationConfigurationBuilder AddScriptLoader(IScriptLoader scriptLoader)
        {
            if (scriptLoader is null)
            {
                throw new ArgumentNullException(nameof(scriptLoader));
            }

            _configuration.ScriptLoaders.Add(scriptLoader);
            return(this);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="ScriptEditorViewModel" /> class.
        /// </summary>
        /// <param name="scriptLoader"> The script loader for the script. </param>
        /// <param name="scriptSerializer">The script serializer used to save the script to a file on disk</param>
        public ScriptEditorViewModel(IScriptLoader scriptLoader, IScriptSerializer scriptSerializer)
        {
            Check.IfIsNull(scriptLoader).Throw<ArgumentNullException>(() => scriptLoader);
            Check.IfIsNull(scriptSerializer).Throw<ArgumentNullException>(() => scriptSerializer);

            this.scriptLoader = scriptLoader;
            this.scriptSerializer = scriptSerializer;

            FileChangedEventHandler += OnFileChanged;
        }
Пример #10
0
 public CommandExecutor(
     CommandArguments args,
     IScriptLoader scriptLoader,
     ITaskSession taskSession,
     ILogger <CommandExecutor> log)
 {
     _args         = args;
     _scriptLoader = scriptLoader;
     _taskSession  = taskSession;
     _log          = log;
 }
Пример #11
0
 public CommandExecutor(
     CommandArguments args,
     IScriptLoader scriptLoader,
     IFlubuSession flubuSession,
     ILogger <CommandExecutor> log)
 {
     _args         = args;
     _scriptLoader = scriptLoader;
     _flubuSession = flubuSession;
     _log          = log;
 }
Пример #12
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public UnityScriptingHost(
            IScriptLoader loader,
            IScriptDependencyResolver resolver)
            : base(options => options.AllowClr())
        {
            Loader   = loader;
            Resolver = resolver;

            SetValue("Log", new UnityLogWrapper());
            SetValue("Scene", new UnitySceneManager());

            SetValue("require", new Func <string, JsValue>(Require));
            SetValue("inject", new Func <string, object>(Inject));
        }
Пример #13
0
 public CommandExecutor(
     CommandArguments args,
     IScriptLoader scriptLoader,
     ITaskSession taskSession,
     IFileWrapper file,
     IPathWrapper path,
     ILogger <CommandExecutor> log)
 {
     _args         = args;
     _scriptLoader = scriptLoader;
     _taskSession  = taskSession;
     _file         = file;
     _path         = path;
     _log          = log;
 }
Пример #14
0
        public string ReadFile(string filepath, out string debugpath)
        {
            debugpath = GetScriptDebugPath(filepath);
            IScriptLoader loader = null;

            for (int i = 0; i < loaders.Count; i++)
            {
                if (!loaders[i].FileExists(filepath))
                {
                    continue;
                }
                if (loader == null || loader.version.time < loaders[i].version.time)
                {
                    loader = loaders[i];
                }
            }
            return(loader.ReadFile(filepath));
        }
Пример #15
0
        public Worker(ulong id,
                      Action disposeCallback,
                      IJSRuntime jsRuntime,
                      IMessagingService messagingService,
                      IMessagingProvider messagingProvider,
                      WorkerCreationConfiguration workerCreationConfiguration,
                      IScriptLoader scriptLoader,
                      ILogger logger)
        {
            Id = id;

            _disposeCallback             = disposeCallback;
            _workerCreationConfiguration = workerCreationConfiguration;
            _jsRuntime         = jsRuntime;
            _messagingService  = messagingService;
            _messagingProvider = messagingProvider;

            _scriptLoader = scriptLoader;
            _serializer   = new DefaultSerializer();

            _logger = logger;
        }
Пример #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Player"/> class.
        /// </summary>
        /// <param name="client">The client to associate this player to.</param>
        /// <param name="characterEntity">The player's corresponding character entity lodaded from storage.</param>
        /// <param name="scriptsLoader">A reference to the scripts loader in use.</param>
        public Player(
            IClient client,
            ICharacterEntity characterEntity,
            IScriptLoader scriptsLoader)
            : base(characterEntity)
        {
            scriptsLoader.ThrowIfNull(nameof(scriptsLoader));
            client.ThrowIfNull(nameof(client));
            characterEntity.ThrowIfNull(nameof(characterEntity));

            this.Client          = client;
            this.Client.PlayerId = this.Id;

            this.CharacterId = characterEntity.Id;

            this.Outfit = characterEntity.Outfit;

            this.InitializeSkills(scriptsLoader);

            var expLevel = this.Skills.TryGetValue(SkillType.Experience, out ISkill expSkill) ? expSkill.CurrentLevel : 1;

            this.Stats[CreatureStat.BaseSpeed].Set(220 + (2 * (expLevel - 1)));
            this.Stats[CreatureStat.CarryStrength].Set(150);

            this.Stats.Add(CreatureStat.ManaPoints, new Stat(CreatureStat.ManaPoints, characterEntity.CurrentManapoints == default ? characterEntity.MaxHitpoints : characterEntity.CurrentManapoints, characterEntity.MaxManapoints));
            this.Stats[CreatureStat.ManaPoints].Changed += this.RaiseStatChange;

            this.Stats.Add(CreatureStat.SoulPoints, new Stat(CreatureStat.SoulPoints, 0, 0));
            this.Stats[CreatureStat.SoulPoints].Changed += this.RaiseStatChange;

            this.Inventory = new PlayerInventory(this);

            // Hard-coded stuff.
            this.EmittedLightLevel = (byte)LightLevels.Torch;
            this.EmittedLightColor = (byte)LightColors.Orange;
        }
 public CssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer)
     : this(scriptLoader, domContainer, "findByCssMarker" + ++_cssMarkerIndex)
 {
 }
 public TestableCssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer)
     : base(scriptLoader, domContainer)
 {
 }
 public TestableCssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer, string markerClass)
     : base(scriptLoader, domContainer, markerClass)
 {
 }
 public TypeScriptContextFactory(IScriptLoader scriptLoader, ILogger logger)
 {
     this.scriptLoader = scriptLoader;
     this.logger = logger;
 }
Пример #21
0
 public CssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer)
     : this(scriptLoader, domContainer, "findByCssMarker" + ++_cssMarkerIndex)
 {
 }
Пример #22
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TextureManager"/> class.
		/// </summary>
		/// <param name="nativeInstance">The native instance.</param>
		public TextureManager(IScriptLoader nativeInstance)
			: base(nativeInstance)
		{
		}
Пример #23
0
 public TestableCssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer, string markerClass) : base(scriptLoader, domContainer, markerClass)
 {
 }
Пример #24
0
 /// <summary>
 /// Register a script loader with the manager.
 /// </summary>
 /// <param name="loader">The script loader to register.</param>
 public static void RegisterLoader(this IScriptLoader loader)
 {
     _loaders.Add(loader);
 }
Пример #25
0
 public TestableCssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer) 
     : base(scriptLoader, domContainer)
 {
 }
 public CachingScriptLoader(IScriptLoader underlying)
 {
     _underlying = underlying;
 }
Пример #27
0
 public ScriptIncluder(JavascriptContext context, IScriptLoader loader)
 {
     _context = context;
     _loader = loader;
 }
Пример #28
0
 public CssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer, string markerClass)
     : base(markerClass)
 {
     _scriptLoader = scriptLoader;
     _domContainer = domContainer;
 }
Пример #29
0
 public WebApiScriptProvider(IScriptLoader scriptLoader)
 {
     _scriptLoader = scriptLoader;
 }
 public CssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer, string markerClass)
     : base(markerClass)
 {
     _scriptLoader = scriptLoader;
     _domContainer = domContainer;
 }
 public CssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer)
 {
     _scriptLoader = scriptLoader;
     _domContainer = domContainer;
 }
Пример #32
0
 public ScriptProvider(IScriptLoader scriptLoader)
 {
     _scriptLoader = scriptLoader;
 }
Пример #33
0
 public CssSelectorConstraint(IScriptLoader scriptLoader, DomContainer domContainer)
 {
     _scriptLoader = scriptLoader;
     _domContainer = domContainer;
 }
Пример #34
0
 public ScriptEngine(IScriptLoader scriptLoader)
 {
     _scriptLoader = scriptLoader;
 }
 public TypeScriptContextFactory(IScriptLoader scriptLoader, ILogger logger)
 {
     this.scriptLoader = scriptLoader;
     this.logger       = logger;
 }
Пример #36
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ResourceManager"/> class.
		/// </summary>
		/// <param name="nativeInstance">The native instance.</param>
		public ResourceManager(IScriptLoader nativeInstance)
			: base(nativeInstance)
		{
		}