/// <summary> /// init <see cref="Wechaty"/> with <see cref="WechatyOptions"/> /// </summary> /// <param name="options"></param> /// <param name="loggerFactory"></param> public Wechaty(WechatyOptions options, ILoggerFactory loggerFactory) { _options = options; _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <Wechaty>(); if (_logger.IsEnabled(LogLevel.Trace)) { _logger.LogTrace("constructor() WechatyOptions.profile DEPRECATED. use WechatyOptions.name instead."); } if (string.IsNullOrWhiteSpace(options.Name) && !string.IsNullOrWhiteSpace(options.Profile)) { if (_logger.IsEnabled(LogLevel.Trace)) { _logger.LogTrace("constructor()"); } } _memory = _options.Memory; Id = Guid.NewGuid().ToString(); State = new StateSwitch("Wechaty", loggerFactory.CreateLogger <StateSwitch>()); _readyState = new StateSwitch("WechatyReady", loggerFactory.CreateLogger <StateSwitch>()); Contact = new ContactRepository(loggerFactory.CreateLogger <Contact>(), this, loggerFactory.CreateLogger <ContactRepository>()); Tag = new TagRepository(loggerFactory.CreateLogger <Tag>(), this, loggerFactory.CreateLogger <TagRepository>()); ContactSelf = new ContactSelfRepository(loggerFactory.CreateLogger <ContactSelf>(), this, loggerFactory.CreateLogger <ContactSelfRepository>()); Friendship = new FriendshipRepository(loggerFactory.CreateLogger <Friendship>(), this, loggerFactory.CreateLogger <FriendshipRepository>()); Message = new MessageRepository(loggerFactory.CreateLogger <Message>(), this, loggerFactory.CreateLogger <MessageRepository>()); Image = new ImageRepository(loggerFactory.CreateLogger <Image>(), this, loggerFactory.CreateLogger <ImageRepository>()); RoomInvitation = new RoomInvitationRepository(loggerFactory.CreateLogger <RoomInvitation>(), this, loggerFactory.CreateLogger <RoomInvitationRepository>()); Room = new RoomRepository(loggerFactory.CreateLogger <Room>(), this, loggerFactory.CreateLogger <RoomRepository>()); UrlLink = new UrlLinkRepository(this, loggerFactory.CreateLogger <UrlLinkRepository>()); MiniProgram = new MiniProgramRepository(); InstallGlobalPlugin(); }
public MiniProgramService() { _repo = new MiniProgramRepository(); }