public PingTest(ILoggerService logger, INetworkServices networkServices, IFileAndFolderServices fileAndFolderServices) : base(logger, networkServices, fileAndFolderServices) { ActionName = "Ping Test"; Description = "Runs a ping test against the device list."; Category = "Other"; }
/// <summary> /// Initializes a new instance of the <see cref="UserController"/> class. /// </summary> /// <param name="loggerService">Logger Service</param> /// <param name="userService">User Service</param> /// <param name="tripService">Trip Service</param> /// <param name="postService">Post Service</param> public UserController( ILoggerService loggerService, IUserService userService, ITripService tripService, IPostService postService) : base(loggerService) { if(userService == null) { throw new ArgumentNullException("User Service, User Controller"); } if (tripService == null) { throw new ArgumentNullException("Trip Service, User Controller"); } if (postService == null) { throw new ArgumentNullException("Post Service, User Controller"); } this.userService = userService; this.tripService = tripService; this.postService = postService; }
public ProjectVersionService(IStore<Project> projectStore, IStore<ProjectVersion> projectVersionStore, IMappingEngine mapper, ILoggerService log) { ProjectStore = projectStore; ProjectVersionStore = projectVersionStore; Mapper = mapper; Log = log; }
public TopicsService(ITopicsDataAccess da, IMessagesDataAccess messagesDa, ISearchService searchIndex, ILoggerService loggerService) { _dataAccess = da; _messagesDataAccess = messagesDa; _searchIndex = searchIndex; _loggerService = loggerService; }
public ToDoItemListService(IUnitOfWork uoW, IToDoItemListRepository rep, IToDoItemService itemService, ILoggerService logger) { _repository = rep; _unitOfWork = uoW; _toDoItemService = itemService; _loggerService = logger; }
public UserPolicyRetrievalCycleSccm(ILoggerService logger, IWmiServices wmiService, ISccmClientServices sccmClientService, INetworkServices networkServices, IFileAndFolderServices fileAndFolderServices) : base(logger, wmiService, sccmClientService, networkServices, fileAndFolderServices) { ActionName = "User Policy Retrieval Cycle"; Description = "Forces SCCM to schedule a User Policy Retrieval check on the client."; Category = "SCCM"; }
public ProjectService(IStore<Project> ps, IStore<Platform> tps, IMappingEngine mapper, ILoggerService log) { TestProjectStore = ps; TestPlatformStore = tps; Mapper = mapper; Log = log; }
protected ContentViewModel(AbstractWorkspace workspace, ICommandManager commandManager, ILoggerService logger) { _workspace = workspace; _commandManager = commandManager; _logger = logger; CloseCommand = new DelegateCommand(CloseDocument); }
public override void FinishedInitialization() { base.FinishedInitialization(); logger = ServiceManager.Get<ILoggerService>(); semProc = ServiceManager.Get<ISemanticProcessor>(); Assert.SilentTry(() => httpOnly = ServiceManager.Get<IAppConfigService>().GetValue("httpOnly").to_b()); }
public MetronomeActionBuilder() { this.ticks = new List<MetronomeTick>(); this.audioService = new AudioServiceMock(MockBehavior.Loose); this.delayService = new DelayServiceMock(MockBehavior.Loose); this.loggerService = new LoggerServiceMock(MockBehavior.Loose); }
public FileCopy(ILoggerService logger, INetworkServices networkServices, IFileAndFolderServices fileAndFolderServices) : base(logger, networkServices, fileAndFolderServices) { ActionName = "File Copy"; Description = "Copy file to all devices in the list."; Category = "Other"; }
public Exercise(ILoggerService loggerService, ISpeechService speechService, string name, int setCount, int repetitionCount, IEnumerable<MatcherWithAction> matchersWithActions) { loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); name.AssertNotNull(nameof(name)); matchersWithActions.AssertNotNull(nameof(matchersWithActions)); if (setCount < 0) { throw new ArgumentException("setCount cannot be less than zero.", "setCount"); } if (repetitionCount < 0) { throw new ArgumentException("repetitionCount cannot be less than zero.", "repetitionCount"); } this.logger = loggerService.GetLogger(this.GetType()); this.speechService = speechService; this.name = name; this.setCount = setCount; this.repetitionCount = repetitionCount; this.matchersWithActions = matchersWithActions.ToImmutableList(); using (var dummyExecutionContext = new ExecutionContext()) { this.duration = this .GetEventsWithActions(dummyExecutionContext) .SelectMany(x => x.Actions) .Select(x => x.Duration) .DefaultIfEmpty() .Aggregate((running, next) => running + next); } }
public static void Main(string[] args) { LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance); //this is optional - DefaultLoggerService will be used if not set Logger = LoggerServiceFactory.GetLogger(typeof(PiExample)); var sparkContext = new SparkContext(new SparkConf()); try { const int slices = 3; var numberOfItems = (int)Math.Min(100000L * slices, int.MaxValue); var values = new List<int>(numberOfItems); for (var i = 0; i <= numberOfItems; i++) { values.Add(i); } var rdd = sparkContext.Parallelize(values, slices); CalculatePiUsingAnonymousMethod(numberOfItems, rdd); CalculatePiUsingSerializedClassApproach(numberOfItems, rdd); Logger.LogInfo("Completed calculating the value of Pi"); } catch (Exception ex) { Logger.LogError("Error calculating Pi"); Logger.LogException(ex); } sparkContext.Stop(); }
/// <summary> /// Initializes a new instance of the <see cref="YoufferPaymentService"/> class. /// </summary> /// <param name="loggerService">The logger service.</param> /// <param name="paymentRepository">The payment repository.</param> /// <param name="payPalDetailsRepository"> The PayPalDetails repository</param> /// <param name="mapperFactory">The mapper factory.</param> public YoufferPaymentService(ILoggerService loggerService, IRepository<LeadOpportunityMapping> paymentRepository, IRepository<PayPalDetails> payPalDetailsRepository, IMapperFactory mapperFactory) { this.LoggerService = loggerService; this.paymentRepository = paymentRepository; this.mapperFactory = mapperFactory; this.payPalDetailsRepository = payPalDetailsRepository; }
public ErrorController(ILoggerService LoggerService) { if (LoggerService == null) { throw new ArgumentNullException("LoggerService"); } this.loggerService = LoggerService; }
public HardwareInventoryCycleSccm(ILoggerService logger, IWmiServices wmiService, ISccmClientServices sccmClientService, INetworkServices networkServices, IFileAndFolderServices fileAndFolderServices) : base(logger, wmiService, sccmClientService, networkServices, fileAndFolderServices) { ActionName = "Hardware Inventory Cycle"; Description = "Forces SCCM to schedule a Hardware Inventory check on the client."; Category = "SCCM"; }
/// <summary> /// Initializes a new instance of the <see cref="YoufferContactService" /> class. /// </summary> /// <param name="loggerService"> The logger service. </param> /// <param name="contactLeadRepository"> The Contact Lead Repository. </param> /// <param name="mapperFactory"> The mapper factory. </param> /// <param name="appUser"> The ApplicationUser repository. </param> public YoufferContactService(ILoggerService loggerService, IRepository<ContactLeadMapping> contactLeadRepository, IMapperFactory mapperFactory, IRepository<ApplicationUser> appUser) { this.LoggerService = loggerService; this.contactLeadRepository = contactLeadRepository; this.mapperFactory = mapperFactory; this.appUser = appUser; }
public AppDeploymentScheduleSccm(ILoggerService logger, IWmiServices wmiService, ISccmClientServices sccmClientService, INetworkServices networkServices, IFileAndFolderServices fileAndFolderServices) : base(logger, wmiService, sccmClientService, networkServices, fileAndFolderServices) { ActionName = "Application Deployment Evaluation Cycle"; Description = "Forces SCCM to schedule an Application Deployment check on the client."; Category = "SCCM"; }
public WebTestCurrentResultViewModel(AbstractWorkspace workspace, ICommandManager commandManager, ILoggerService logger, IMenuService menuService, WebTestResultView view) : base(workspace, commandManager, logger, menuService) { _tooltip = "Web Test Results"; _title = "Web Test Results"; this.View = view; }
/// <summary> /// Initializes a new instance of the <see cref="PushService" /> class. /// </summary> /// <param name="googleGcmApiKey"> The google api key</param> /// <param name="appleCertPwd"> The Api certificate password</param> /// <param name="outputPath">The output path</param> /// <param name="loggerService"> The logger service</param> /// <param name="mapperFactory">the mapper factory</param> /// <param name="notificationLogRepository">The notification log repository</param> public PushService(string googleGcmApiKey, string appleCertPwd, string outputPath, ILoggerService loggerService, IMapperFactory mapperFactory, IRepository<NotificationLog> notificationLogRepository) { this.loggerService = loggerService; this.mapperFactory = mapperFactory; this.notificationLogRepository = notificationLogRepository; this.pushBroker = new PushBroker(); try { this.pushBroker.RegisterGcmService(new GcmPushChannelSettings(googleGcmApiKey)); } catch (Exception ex) { this.loggerService.LogException("Register Android notification service" + ex.Message); } var appleCert = File.ReadAllBytes(outputPath); try { this.pushBroker.RegisterAppleService(new ApplePushChannelSettings(appleCert, appleCertPwd)); } catch (Exception ex) { this.loggerService.LogException("Register iOS notification service" + ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="AccountController"/> class. /// </summary> /// <param name="logger">Logger Service</param> /// <param name="loginService">Login Service</param> /// <param name="userService">User Service</param> /// <param name="passwordService">Password Service</param> public AccountController( ILoggerService logger, ILoginService loginService, IUserService userService, IPasswordService passwordService) : base(logger) { if (loginService == null) { throw new ArgumentNullException("ILoginService, LoginController"); } if (userService == null) { throw new ArgumentNullException("IUserService, LoginController"); } if(passwordService == null) { throw new ArgumentNullException("IPasswordService, LoginController"); } this._loginService = loginService; this._userService = userService; this._passwordService = passwordService; }
public UserController(IUserService userService, ICommunicationService communicationService, ILoggerService loggerService) { this.userService = userService; this.communicationService = communicationService; this.loggerService = loggerService; _repo = new AuthRepository(); }
public static int Main(string[] args) { LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance); //this is optional - DefaultLoggerService will be used if not set Logger = LoggerServiceFactory.GetLogger(typeof(WordCountExample)); if (args.Length != 1) { Console.Error.WriteLine("Usage: WordCount <file>"); return 1; } var sparkContext = new SparkContext(new SparkConf().SetAppName("MobiusWordCount")); try { var lines = sparkContext.TextFile(args[0]); var counts = lines .FlatMap(x => x.Split(' ')) .Map(w => new KeyValuePair<string, int>(w, 1)) .ReduceByKey((x, y) => x + y); foreach (var wordcount in counts.Collect()) { Console.WriteLine("{0}: {1}", wordcount.Key, wordcount.Value); } } catch (Exception ex) { Logger.LogError("Error performing Word Count"); Logger.LogException(ex); } sparkContext.Stop(); return 0; }
public static void Log(string message, TraceEventType severity, string category) { Trace.WriteLine(message); string disable = ConfigurationManager.AppSettings["DisableLogging"]; if (string.IsNullOrWhiteSpace(disable) || disable == "false") { try { if (LoggerService == null) { // if someone hasn't overridden the default LoggerService before first Log, create one LoggerService = new LoggerService(); LoggerService.Log(message, severity, category); } else { LoggerService.Log(message, severity, category); } } catch (Exception ex) { LoggingFailure("EnterpriseLibrary logging error.", ex); } } }
static void Main(string[] args) { LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance); //this is optional - DefaultLoggerService will be used if not set Logger = LoggerServiceFactory.GetLogger(typeof(SparkCLRSamples)); Configuration = CommandlineArgumentProcessor.ProcessArugments(args); PrintLogLocation(); bool status = true; if (Configuration.IsDryrun) { status = SamplesRunner.RunSamples(); } else { SparkContext = CreateSparkContext(); SparkContext.SetCheckpointDir(Path.GetTempPath()); status = SamplesRunner.RunSamples(); PrintLogLocation(); ConsoleWriteLine("Completed running samples. Calling SparkContext.Stop() to tear down ..."); //following comment is necessary due to known issue in Spark. See https://issues.apache.org/jira/browse/SPARK-8333 ConsoleWriteLine("If this program (SparkCLRSamples.exe) does not terminate in 10 seconds, please manually terminate java process launched by this program!!!"); //TODO - add instructions to terminate java process SparkContext.Stop(); } if (Configuration.IsValidationEnabled && !status) { Environment.Exit(1); } }
protected SccmScheduleActionBase(ILoggerService logger, IWmiServices wmiService, ISccmClientServices sccmClientService, INetworkServices networkServices, IFileAndFolderServices fileAndFolderServices) : base(logger, networkServices, fileAndFolderServices) { WmiService = wmiService; SccmClientService = sccmClientService; }
public static Parser<DoNotAwaitAction> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { if (indentLevel < 0) { throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel"); } audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); return from _ in Parse.IgnoreCase("don't") from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce() from ___ in Parse.IgnoreCase("wait:") from ____ in VerticalSeparationParser.Parser.AtLeastOnce() from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService) let child = new SequenceAction(actions) select new DoNotAwaitAction( loggerService, child); }
public ExerciseProgramViewModelBuilder() { this.loggerService = new LoggerServiceMock(MockBehavior.Loose); this.schedulerService = new SchedulerServiceMock(MockBehavior.Loose); this.hostScreen = new ScreenMock(MockBehavior.Loose); this.model = new ExerciseProgramBuilder(); }
public static Parser<IAction> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { if (indentLevel < 0) { throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel"); } audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); return BreakActionParser.GetParser(delayService, speechService) .Or<IAction>(MetronomeActionParser.GetParser(audioService, delayService, loggerService)) .Or<IAction>(PrepareActionParser.GetParser(delayService, speechService)) .Or<IAction>(SayActionParser.GetParser(speechService)) .Or<IAction>(WaitActionParser.GetParser(delayService)) .Or<IAction>(DoNotAwaitActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)) .Or<IAction>(ParallelActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)) .Or<IAction>(SequenceActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)); }
public iCloudExerciseDocumentService(ILoggerService loggerService) { Ensure.ArgumentNotNull(loggerService, nameof(loggerService)); this.logger = loggerService.GetLogger(this.GetType()); this.exerciseDocument = new BehaviorSubject<string>(null); this.sync = new object(); }
public DashboardController(IGlobalService <Article> articleService, IGlobalService <Comment> commentService, IGlobalService <Share> shareService, IGlobalService <Author> authorService, IHttpContextAccessor httpContextAccessor, ILoggerService logger, IWebHostEnvironment webHostEnvironment, IGlobalService <Tag> tagService) { _articleService = articleService; _commentService = commentService; _shareService = shareService; _authorService = authorService; _logger = logger; _httpContextAccessor = httpContextAccessor; _webHostEnvironment = webHostEnvironment; _tagService = tagService; }
/// <summary> /// Compiles a source string with Roslyn /// </summary> /// <param name="sourceString"></param> /// <returns></returns> public static Assembly CompileAssemblyFromStrings(string sourceString, Assembly currentCustomAssembly, ILoggerService logger = null) { var syntaxTree = CSharpSyntaxTree.ParseText(sourceString); string assemblyName = Guid.NewGuid().ToString(); var references = GetAssemblyReferences(currentCustomAssembly); var compilation = CSharpCompilation.Create( assemblyName, new[] { syntaxTree }, references, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); Assembly assembly = null; try { assembly = CompileAndLoadAssembly(compilation); } catch (Exception ex) { logger?.LogString(ex.ToString(), Logtype.Error); } return(assembly); }
public HomeController(IProductsService products, IPadsService pads, ICitiesService cities, ITagsService tags, ICategoriesService categories, ICouriersService couriers, IFeedbacksService feedbacks, IOrdersService orders, IBulletinsService bulletins, IBlogService blog, IConfiguration configuration, ILoggerService loggerService) { this.products = products; this.pads = pads; this.cities = cities; this.tags = tags; this.categories = categories; this.couriers = couriers; this.feedbacks = feedbacks; this.orders = orders; this.bulletins = bulletins; this.blog = blog; this.configuration = configuration; this.logger = loggerService; }
public MetronomeActionBuilder WithLoggerService(ILoggerService loggerService) => this.With(ref this.loggerService, loggerService);
/// <summary> /// Init User service /// </summary> /// <param name="context">Database Context</param> /// <param name="logger">Logger Service</param> /// <param name="utils">Utils Service</param> /// <param name="mapper">Mapper</param> public UserService(DatabaseContext context, ILoggerService logger, IUtilsService utils, IMapper mapper) : base(context, logger, utils, mapper, "User") { }
public TutorialPage4ViewModel(INavigationService navigationService, ILoggerService loggerService, IExposureNotificationService exposureNotificationService) : base(navigationService) { this.loggerService = loggerService; this.exposureNotificationService = exposureNotificationService; }
public HelpPage4ViewModel(INavigationService navigationService, ILoggerService loggerService) : base(navigationService) { Title = Resources.AppResources.HelpPage4Title; this.loggerService = loggerService; }
/// <summary> /// Initializes a new instance of the <see cref="ActionController"/> class. /// </summary> /// <param name="loggerService">The logger service.</param> /// <param name="actionsService">The actions service.</param> public ActionController(ILoggerService loggerService, IActionsService actionsService) : base(loggerService) { this.actionsService = actionsService; }
public TransactionTaxController(ITransactionTaxService transactionTaxService, IIdentityServerRequest serverRequest, IMapper mapper, IIdentityService identityService, IHttpContextAccessor httpContextAccessor, ILoggerService logger) { _mapper = mapper; _serverRequest = serverRequest; _repo = transactionTaxService; _identityService = identityService; _httpContextAccessor = httpContextAccessor; _logger = logger; }
public WccLite(string path, ILoggerService loggerService) { _wccPath = path; _logger = loggerService; }
public void Initialize() { this.traderRep = Substitute.For <ITraderRepository>(); this.provider = Substitute.For <IPhraseProvider>(); this.logger = Substitute.For <ILoggerService>(); }
public UpdateService([Inject("filelogger")] ILoggerService loggerService) { this.loggerService = loggerService; }
/// <summary> /// Constructor of AllFileHandler - all parameters are injected /// </summary> /// <param name="container">The injected container of the application</param> /// <param name="loggerService">The injected logger service of the application</param> public AllFileHandler(IUnityContainer container, ILoggerService loggerService) { _container = container; _loggerService = loggerService; _dialog = new SaveFileDialog(); }
protected HubController(T service, ILogger <HubController <T> > logger, ILoggerService loggerApiService) { this._service = service; this._logger = logger; this._loggerApiService = loggerApiService; }
/// <summary> /// /// </summary> /// <param name="outpath"></param> public void Write(string outpath, ILoggerService logger = null) { logger?.LogString($"[TextureCache] Begin writing.", Logtype.Important); logger?.LogString($"[TextureCache] Found {Files.Count} files.", Logtype.Important); int page = 0; using (var cacheFileStream = new FileStream(outpath, FileMode.Create, FileAccess.Write)) using (var cacheWriter = new BinaryWriter(cacheFileStream)) { // write files #region Write Compressed Files foreach (var ti in Files) { ti.ParentFile = outpath; var ddsfile = ti.FullName; if (!File.Exists(ddsfile)) { continue; } // checks long ddssize = -1; // get dds file size //TODO: make this better using (var readfs = new FileStream(ddsfile, FileMode.Open, FileAccess.Read)) { ddssize = readfs.Length - 128; } if (ti.IsCube != 0) { if (ddssize % 6 != 0) { throw new CacheWritingException($"{ti.Name} incorrect cubemap (not divisible by 6)."); } } ti.UncompressedSize = (uint)ddssize; var ddsoffset = (uint)128; // dds header size var startoffset = cacheFileStream.Position; // check for alignment if (cacheFileStream.Position % 4096 != 0) { throw new CacheWritingException($"{ti.Name} Improperly aligned (pos: {cacheFileStream.Position})."); } // cubemaps if (ti.IsCube != 0) { // dds cube textures are structured in 6 faces (each with mipmaps) // files in the texture cache are structured by mipmaps (each with 6 faces) // sigh... using (var file = MemoryMappedFile.CreateFromFile(ddsfile, FileMode.Open)) { #region Main Image // get main image var imgsize = DDSUtils.CalculateMipMapSize(ti.BaseWidth, ti.BaseHeight, ti.Format); ti.PageOffset = (uint)(cacheFileStream.Position / 4096); // all faces and mipmaps get compressed at once using (var allfacesms = new MemoryStream()) { for (int i = 0; i < 6; i++) { var faceoffset = 128 + ddssize / 6 * i; using (var vs = file.CreateViewStream(faceoffset, imgsize, MemoryMappedFileAccess.Read)) { vs.CopyTo(allfacesms); } } // compress the assembled stream of all faces ti.Size = 6 * imgsize; ti.ZSize = (uint)WriteImgFromStream(allfacesms, cacheWriter, (byte)(ti.NumMipOffsets)).Item1; } #endregion #region MipMaps // no mipmaps means NumMipOffsets is 0 var totalmipmapsizeuptonow = 0; for (int i = 0; i < ti.NumMipOffsets; i++) { uint mipWidth = (uint)(ti.BaseWidth / (Math.Pow(2, i + 1))); uint mipHeight = (uint)(ti.BaseHeight / (Math.Pow(2, i + 1))); var mipsize = DDSUtils.CalculateMipMapSize(mipWidth, mipHeight, ti.Format); // last 6 mips are concatenated into one compressed buffer // TODO: non-square textures. fml if (mipWidth == 32) { mipsize = 696; } byte idx = (byte)(ti.NumMipOffsets - 1 - i); // all faces and mipmaps get compressed at once using (var allmips = new MemoryStream()) { for (int j = 0; j < 6; j++) { // find correct mip: divide dds by 6 + the main size + the size of all mips before the current one var mipoffset = (ddssize / 6 * j) + (ti.Size / 6) + (totalmipmapsizeuptonow); using (var vs = file.CreateViewStream(mipoffset, mipsize, MemoryMappedFileAccess.Read)) { vs.CopyTo(allmips); } } // compress the assembled stream of all mipmaps totalmipmapsizeuptonow += (int)mipsize; mipsize *= 6; //TODO var(zsize, offset) = WriteImgFromStream(allmips, cacheWriter, idx); ti.MipMapInfo.Add(new MipmapInfo(offset, (uint)zsize, (uint)mipsize, idx)); MipOffsets.Add((uint)offset); } ti.MipOffsetIndex = MipOffsets.Count; ddsoffset += mipsize; } #endregion } } else { using (var file = MemoryMappedFile.CreateFromFile(ddsfile, FileMode.Open)) { #region Main Image // get main image ti.Size = DDSUtils.CalculateMipMapSize(ti.BaseWidth, ti.BaseHeight, ti.Format); ti.PageOffset = (uint)(cacheFileStream.Position / 4096); // compress image using (var vs = file.CreateViewStream(ddsoffset, ti.Size, MemoryMappedFileAccess.Read)) { ti.ZSize = (uint)WriteImgFromStream(vs, cacheWriter, (byte)(ti.NumMipOffsets)).Item1; } #endregion #region MipMaps // no mipmaps means NumMipOffsets is 0 for (int i = 0; i < ti.NumMipOffsets; i++) { uint mipWidth = (uint)(ti.BaseWidth / (Math.Pow(2, i + 1))); uint mipHeight = (uint)(ti.BaseHeight / (Math.Pow(2, i + 1))); var mipsize = DDSUtils.CalculateMipMapSize(mipWidth, mipHeight, ti.Format); // last 6 mips are concatenated into one compressed buffer // TODO: non-square textures. fml if (mipWidth == 32) { mipsize = 696; } byte idx = (byte)(ti.NumMipOffsets - 1 - i); // compress image and write to cache using (var viewstream = file.CreateViewStream(ddsoffset, mipsize, MemoryMappedFileAccess.Read)) { var(zsize, offset) = WriteImgFromStream(viewstream, cacheWriter, idx); ti.MipMapInfo.Add(new MipmapInfo(offset, (uint)zsize, (uint)mipsize, idx)); MipOffsets.Add((uint)offset); } ti.MipOffsetIndex = MipOffsets.Count; ddsoffset += mipsize; } #endregion } } //TODO: check if the complete dds file is read // padding to next page (4096 byte pages) var endoffset = cacheFileStream.Position; page = (int)(endoffset / 4096); var paddinglen = (4096 * (page + 1)) - endoffset; var padding = new byte[paddinglen]; cacheWriter.Write(padding); ti.CompressedSize = (uint)(endoffset - startoffset); logger?.LogString($"Written {ti.Name}", Logtype.Normal); } #endregion // calculate final stats UsedPages = (uint)page + 1; EntryCount = (uint)Files.Count; MipTableEntryCount = (uint)MipOffsets.Count; // write tables #region Tables foreach (var mipOffset in MipOffsets) { cacheWriter.Write(mipOffset); } using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { // mipmaptable var startpos = ms.Position; var endpos = ms.Position; // string table //updates this.StringTableSize and all textureCacheItem.StringTableOffset //startpos = ms.Position; foreach (var textureCacheItem in Files) { var filename = textureCacheItem.Name; bw.WriteCR2WString(filename); textureCacheItem.StringTableOffset = (int)bw.BaseStream.Position; } endpos = ms.Position; StringTableSize = (uint)(endpos - startpos); // entry table startpos = ms.Position; foreach (var textureCacheItem in Files) { textureCacheItem.Write(bw); } endpos = ms.Position; Crc = CalculateChecksum(ms.ToArray()); ms.Seek(0, SeekOrigin.Begin); ms.CopyTo(cacheFileStream); } #endregion // write footer WriteFooter(cacheWriter); logger?.LogString($"[TextureCache] Writing sucessful.", Logtype.Success); } }
public LeasingDataRepo(ManagerDbContext context, IRemoveService removeService, ILoggerService logger) { Context = context; _removeService = removeService; _logger = logger; }
/// <summary> /// /// </summary> /// <param name="inputfolder"></param> public void LoadFiles(string inputfolder, ILoggerService logger = null) { var di = new DirectoryInfo(inputfolder); if (!di.Exists) { return; } var inputfiles = di.GetFiles("*.dds", SearchOption.AllDirectories) .Select(_ => _.FullName).ToList(); logger?.LogString($"[TextureCache] Begin caching.", Logtype.Important); logger?.LogString($"[TextureCache] Found {inputfiles.Count} files.", Logtype.Important); // clear data Files.Clear(); Names.Clear(); MipOffsets.Clear(); foreach (var filename in inputfiles) { var ext = Path.GetExtension(filename); switch (ext) { //case ".xbm": // { // // read cr2wfile // var cr2w = new CR2WFile() // { // FileName = filename, // }; // using (var cfs = new FileStream(filename, FileMode.Open, FileAccess.Read)) // using (var reader = new BinaryReader(cfs)) // { // var errorcode = cr2w.Read(reader); // if (errorcode != EFileReadErrorCodes.NoError) // continue; // } // // check if CBitmapTexture // if (!(cr2w.chunks.FirstOrDefault()?.data is CBitmapTexture xbm)) // { // continue; // } // break; // } case ".DDS": case ".dds": { var ddsheader = DDSUtils.ReadHeader(filename); var redpath = Path.ChangeExtension(filename, ddsheader.Iscubemap ? ".w2cube" : ".xbm"); var relativepath = redpath.Substring(di.FullName.Length + 1); #region Create Table Item var(type1, type2) = CommonImageTools.GetREDEngineByteFromEFormat(ddsheader.Format); if (ddsheader.Width % 2 != 0 || ddsheader.Height % 2 != 0) { continue; } var maxSide = Math.Max(ddsheader.Width, ddsheader.Height); //var minSide = Math.Min(ddsheader.Width, ddsheader.Height); var realmipscount = Math.Max(1, Math.Log10(maxSide / 32) / Math.Log10(2)); if (ddsheader.Mipscount == 1) //TODO: fix this { realmipscount = 0; } if (ddsheader.Mipscount == 0) //TODO: fix this { realmipscount = 0; } var ti = new TextureCacheItem(this) { Name = relativepath, FullName = filename, Hash = relativepath.HashStringKey(), /*------------- TextureCache Data ---------------*/ // NOTE: these need to be populated after writing the files ParentFile = "", //done StringTableOffset = -1, //done PageOffset = 0, //done CompressedSize = 0, //done UncompressedSize = 0, //done MipOffsetIndex = 0, //done /*------------- Image data ---------------*/ NumMipOffsets = (int)realmipscount, BaseAlignment = ddsheader.Bpp, BaseWidth = (ushort)ddsheader.Width, BaseHeight = (ushort)ddsheader.Height, Mipcount = (ushort)Math.Max(1, ddsheader.Mipscount), SliceCount = (ushort)ddsheader.Slicecount, //TODO TimeStamp = 0 /*(long)CDateTime.Now.ToUInt64()*/, //NOTE: Not even CDPR could be bothered to use their own Timestamps Type1 = type1, Type2 = type2, IsCube = ddsheader.Iscubemap ? (byte)1 : (byte)0, Unk1 = 0x00, //TODO: figure this out Format = CommonImageTools.GetEFormatFromREDEngineByte(type1) }; #endregion Files.Add(ti); Names.Add(ti.Name); logger?.LogString($"Cached {ti.Name}", Logtype.Normal); break; } } } logger?.LogString($"[TextureCache] Caching sucessful.", Logtype.Success); }
public HomeController(IEmailService emailService, IAddressService iPAddressService, ILoggerService loggerService) { _emailService = emailService; _iPAddressService = iPAddressService; _loggerService = loggerService; }
public FileController(IDownloadFileService downloadFileService, IAuthRepository authRepository, IDataAccessService dataAccessService, IFileService fileService, IFileHandle fileHandle, ILoggerService loggerService) { _downloadFileService = downloadFileService; _authRepository = authRepository; _dataAccessService = dataAccessService; _fileService = fileService; _fileHandle = fileHandle; _loggerService = loggerService; }
//private MvxCommand _topRightButtonCommand; protected BaseBasicTableListViewModelBase(ILoggerService loggerService, IPreferenceService preferenceService, IUserInteractionService userInteractionService) : base(loggerService, preferenceService, userInteractionService) { }
public ManualAddClientStrategy(ILoggerService loggerService, IUserInteractionManager userInteractionManager) { this.loggerService = loggerService; this.userInteractionManager = userInteractionManager; }
public HomeController(ILoggerService logger) { _logger = logger; }
public CompanyController(ICompanyRepository repository, ILoggerService loggerService, IMapper mapper) { _repository = repository; _loggerService = loggerService; _mapper = mapper; }
public WithdrawalController(IWithdrawalService repo, IIdentityService identityService, IMapper mapper, IHttpContextAccessor httpContextAccessor, ILoggerService logger, IIdentityServerRequest identityServer) { _repo = repo; _identityService = identityService; _mapper = mapper; _httpContextAccessor = httpContextAccessor; _logger = logger; _identityServer = identityServer; }
public SignatureVerifier(ICryptoService cryptoService, ILoggerService loggerService) { _cryptoService = cryptoService; _log = loggerService.GetLogger(nameof(SignatureVerifier)); }
public void Init(IBot bot, ILoggerService logger) { }
public Red3ModTools( ILoggerService loggerService ) { _logger = loggerService; }
public StudentController(IStudent student, ILoggerService logger, IClass @class) { _student = student; _logger = logger; _class = @class; }
public PlanoVooController(IPlanoVooAppService appService, ILoggerService loggerService) : base(appService, loggerService) { }
public CampusRepository() { _loggerService = new LoggerService(); }