public override void Initialize(IInitializationContext context) { var backendOverride = context.GetOrCreateSetting <string>("GoogleV2", "ServiceUrl"); if (!backendOverride.IsNullOrWhiteSpace()) { _selectedUserBackend = backendOverride; _httpsServicePointTranslateTemplateUrl = _selectedUserBackend + HttpsServicePointTranslateTemplateUrl; XuaLogger.AutoTranslator.Info("The default backend for google translate was overwritten."); } else { _selectedUserBackend = DefaultUserBackend; _httpsServicePointTranslateTemplateUrl = _selectedUserBackend + HttpsServicePointTranslateTemplateUrl; } _translateRpcId = context.GetOrCreateSetting("GoogleV2", "RPCID", "MkEWBc"); _version = context.GetOrCreateSetting("GoogleV2", "VERSION", "boq_translate-webserver_20210323.10_p0"); _useSimplestSuggestion = context.GetOrCreateSetting("GoogleV2", "UseSimplest", false); context.DisableCertificateChecksFor(new Uri(_selectedUserBackend).Host, new Uri(_selectedUserBackend).Host); if (!SupportedLanguages.Contains(FixLanguage(context.SourceLanguage))) { throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported."); } if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage))) { throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported."); } }
/// <summary> /// See <see cref="Basis.BasisInitializer"/> /// </summary> /// <param name="c"></param> /// <returns></returns> public override Basis Initialize(IInitializationContext c) { XDGBasis xdgbasis; if (c.TryGetValue(this, out xdgbasis)) { return(xdgbasis); } if (c.GridData == null) { throw new ArgumentException(); } if (!c.GridData.GridID.Equals(base.GridGuid)) { throw new ArgumentException("Wrong grid."); } var lsTrk = TrackerInitializer.Initialize(c); XDGBasis xb = new XDGBasis(lsTrk, base.Degree); myInstance = xb; c.Add(this, xb); return(xb); }
public override void Initialize(IInitializationContext context) { var defaultPath = GetDefaultInstallationPath(); var path = context.GetOrCreateSetting("ezTrans", "InstallationPath", defaultPath); if (string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(defaultPath)) { context.SetSetting("ezTrans", "InstallationPath", defaultPath); path = defaultPath; } //subprocess path var exePath = Path.Combine(context.TranslatorDirectory, @"FullNET\ezTransXP.ExtProtocol.exe"); var fileExists = File.Exists(exePath); if (!fileExists) { throw new EndpointInitializationException($"Could not find any executable at '{exePath}'"); } ExecutablePath = exePath; //argument is ezTrans installation path Arguments = Convert.ToBase64String(Encoding.UTF8.GetBytes(path)); if (context.SourceLanguage != "ja") { throw new EndpointInitializationException("Current implementation only supports japanese-to-korean."); } if (context.DestinationLanguage != "ko") { throw new EndpointInitializationException("Current implementation only supports japanese-to-korean."); } }
public static void RegisterDependencies( this IInitializationContext context, InputObjectTypeDefinition definition) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (definition == null) { throw new ArgumentNullException(nameof(definition)); } RegisterDirectiveDependencies(context, definition); foreach (InputFieldDefinition field in definition.Fields) { if (field.Type != null) { context.RegisterDependency(field.Type, TypeDependencyKind.Default); } context.RegisterDependencyRange( field.Directives.Select(t => t.TypeReference), TypeDependencyKind.Completed); } }
public override void Initialize(IInitializationContext context) { base.Initialize(context); if (!SupportedLanguages.Contains(FixLanguage(context.SourceLanguage))) { throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported."); } if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage))) { throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported."); } var apiKey = context.GetOrCreateSetting(ConfigurationSectionName, "ApiKey", ""); var isFree = context.GetOrCreateSetting(ConfigurationSectionName, "Free", false); if (string.IsNullOrEmpty(apiKey)) { throw new EndpointInitializationException($"The endpoint requires an API key which has not been provided."); } ConfigForExternalProcess = string.Join("\n", new[] { apiKey, isFree.ToString() }); Arguments = Convert.ToBase64String(Encoding.UTF8.GetBytes("DeepLTranslate.ExtProtocol.ExtDeepLTranslateLegitimate, DeepLTranslate.ExtProtocol"), Base64FormattingOptions.None); }
public override void Initialize(IInitializationContext context) { var pathToLec = context.GetOrCreateSetting("LecPowerTranslator15", "InstallationPath", ""); if (string.IsNullOrEmpty(pathToLec)) { throw new Exception("The LecPowerTranslator15 requires the path to the installation folder."); } var exePath = Path.Combine(context.PluginDirectory, @"Translators\Lec.ExtProtocol.exe"); var fileExists = File.Exists(exePath); if (!fileExists) { throw new Exception($"Could not find any executable at '{exePath}'"); } ExecutablePath = exePath; Arguments = Convert.ToBase64String(Encoding.UTF8.GetBytes(pathToLec)); if (context.SourceLanguage != "ja") { throw new Exception("Current implementation only supports japanese-to-english."); } if (context.DestinationLanguage != "en") { throw new Exception("Current implementation only supports japanese-to-english."); } }
/// <summary> /// Called during initialization. Use this to initialize plugin or throw exception if impossible. /// /// Must set the ExecutablePath and optionally the Arguments property. /// </summary> public virtual void Initialize(IInitializationContext context) { _gameRoot = Paths.GameRoot; string exePath = null; if (ConfigurationSectionName != null) { exePath = context.GetOrCreateSetting <string>(ConfigurationSectionName, "ExecutableLocation", null); } if (string.IsNullOrEmpty(exePath)) { exePath = Path.Combine(context.TranslatorDirectory, @"FullNET\Common.ExtProtocol.Executor.exe"); } var fileExists = File.Exists(exePath); if (!fileExists) { throw new EndpointInitializationException($"Could not find any executable at '{exePath}'"); } ExecutablePath = exePath; }
public void Initialize(IInitializationContext context) { // reload all mappings, unless the current destination system matches that // of the mappings currently in the repository, in which case no action is // required; effectively, this ensures that the cached mappings are reused, // as long as the current segment's destination system is the same as that // of the previous one if (this.parent.context.DestinationSystem.Id != mappingsDestinationSystemId) { this.eventDispatcher.MappingsCaching(new MappingsCachingArgs()); mappings = this .parent .safeRepository .GetEntityMappings( this.parent.context.DestinationSystem.Id, (int)MappingState.Active, (int)MappingState.Deactivated) .ToDictionary( em => new SourceSystemEntityIdentity( em.EntityTypeId, em.SourceSystemId, em.SourceSystemEntityId), em => new MappingDataObject( em.Id, em.SourceSystemEntityId, em.DestinationSystemEntityId, em.SerializedEntityHash, (MappingOrigin)em.Origin, (MappingState)em.State)); mappingsDestinationSystemId = this.parent.context.DestinationSystem.Id; this.eventDispatcher.MappingsCached( new MappingsCachedArgs(mappings.Count)); } }
public override void Initialize(IInitializationContext context) { _appId = context.GetOrCreateSetting("Baidu", "BaiduAppId", ""); _appSecret = context.GetOrCreateSetting("Baidu", "BaiduAppSecret", ""); _delay = context.GetOrCreateSetting("Baidu", "DelaySeconds", 1.0f); if (string.IsNullOrEmpty(_appId)) { throw new EndpointInitializationException("The BaiduTranslate endpoint requires an App Id which has not been provided."); } if (string.IsNullOrEmpty(_appSecret)) { throw new EndpointInitializationException("The BaiduTranslate endpoint requires an App Secret which has not been provided."); } context.DisableCertificateChecksFor("api.fanyi.baidu.com"); if (!SupportedLanguages.ContainsKey(FixLanguage(context.SourceLanguage))) { throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported."); } if (!SupportedLanguages.ContainsKey(FixLanguage(context.DestinationLanguage))) { throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported."); } }
private void RegisterDependencies( IInitializationContext context, ObjectTypeDefinition definition) { var dependencies = new List <ITypeReference>(); context.RegisterDependencyRange( definition.Interfaces, TypeDependencyKind.Default); context.RegisterDependencyRange( definition.Fields.Select(t => t.Type), TypeDependencyKind.Default); context.RegisterDependencyRange( definition.Fields.SelectMany(t => t.Arguments) .Select(t => t.Type), TypeDependencyKind.Completed); context.RegisterDependencyRange( definition.Directives.Select(t => t.TypeReference), TypeDependencyKind.Completed); context.RegisterDependencyRange( definition.Fields.SelectMany(t => t.Directives) .Select(t => t.TypeReference), TypeDependencyKind.Completed); context.RegisterDependencyRange( definition.Fields.SelectMany(t => t.Arguments) .SelectMany(t => t.Directives) .Select(t => t.TypeReference), TypeDependencyKind.Completed); }
protected override void OnRegisterDependencies( IInitializationContext context, InterfaceTypeDefinition definition) { base.OnRegisterDependencies(context, definition); context.RegisterDependencies(definition); }
/// <summary> /// Loads a time-step from the database. /// </summary> /// <remarks> /// By using this method, it is ensured that the loaded/returned fields /// have the same DG polynomial degree as in the database. /// </remarks> public IEnumerable <DGField> LoadFields(ITimestepInfo info, IGridData grdDat, IEnumerable <string> NameFilter = null) { using (var tr = new FuncTrace()) { // check // ===== if (!info.Grid.ID.Equals(grdDat.GridID)) { throw new ArgumentException("Mismatch in Grid."); } // Instantiate // ========== IEnumerable <DGField.FieldInitializer> F2LoadInfo; if (NameFilter != null) { F2LoadInfo = info.FieldInitializers.Where(fi => NameFilter.Contains(fi.Identification, (a, b) => a.Equals(b))); } else { F2LoadInfo = info.FieldInitializers; } IInitializationContext ic = info.Database.Controller.GetInitializationContext(info); var fields = F2LoadInfo.Select(fi => fi.Initialize(ic)).ToArray(); List <DGField> fieldsFlattened = new List <DGField>(); TimestepInfo.FlattenHierarchy(fieldsFlattened, fields); this.LoadFieldData(info, grdDat, fieldsFlattened); return(fieldsFlattened); } }
protected override void OnRegisterDependencies( IInitializationContext context, InputObjectTypeDefinition definition) { base.OnRegisterDependencies(context, definition); SetTypeIdentity(typeof(FilterInputType <>)); }
private static void RegisterAdditionalDependencies( this IInitializationContext context, DefinitionBase definition) { context.RegisterDependencyRange( definition.Dependencies); }
public static void RegisterDependencies( this IInitializationContext context, ObjectTypeDefinition definition) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (definition == null) { throw new ArgumentNullException(nameof(definition)); } context.RegisterDependencyRange( definition.Interfaces, TypeDependencyKind.Default); RegisterDirectiveDependencies(context, definition); RegisterFieldDependencies(context, definition.Fields); foreach (ObjectFieldDefinition field in definition.Fields) { if (field.Member != null) { context.RegisterResolver( field.Name, field.Member, definition.ClrType, field.ResolverType); } } }
public override void Initialize(IInitializationContext context) { base.Initialize(context); MinDelay = context.GetOrCreateSetting("DeepL", "MinDelaySeconds", 2.0f); if (MinDelay < MinimumMinDelaySeconds) { XuaLogger.AutoTranslator.Warn($"[DeepL] Cannot set MinDelaySeconds below {MinimumMinDelaySeconds} second(s). Setting MinDelaySeconds={MinimumMinDelaySeconds}"); context.SetSetting("DeepL", "MinDelaySeconds", MinimumMinDelaySeconds); } MaxDelay = context.GetOrCreateSetting("DeepL", "MaxDelaySeconds", 7.0f); if (MaxDelay < MinimumMaxDelaySeconds) { XuaLogger.AutoTranslator.Warn($"[DeepL] Cannot set MaxDelaySeconds below {MinimumMaxDelaySeconds} second(s). Setting MaxDelaySeconds={MinimumMaxDelaySeconds}"); context.SetSetting("DeepL", "MaxDelaySeconds", MinimumMaxDelaySeconds); } if (!SupportedLanguages.Contains(FixLanguage(context.SourceLanguage))) { throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported."); } if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage))) { throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported."); } Arguments = Convert.ToBase64String(Encoding.UTF8.GetBytes("DeepLTranslate.ExtProtocol.ExtDeepLTranslate, DeepLTranslate.ExtProtocol"), Base64FormattingOptions.None); }
protected override InterfaceTypeDefinition CreateDefinition( IInitializationContext context) { var descriptor = InterfaceTypeDescriptor.New( context.DescriptorContext); _configure(descriptor); return descriptor.CreateDefinition(); }
protected virtual void OnAfterRegisterDependencies( IInitializationContext context, DefinitionBase definition, IDictionary <string, object?> contextData) { context.Interceptor.OnAfterRegisterDependencies( context, definition, contextData); }
protected override void OnRegisterDependencies( IInitializationContext context, EnumTypeDefinition definition) { base.OnRegisterDependencies(context, definition); context.RegisterDependencies(definition); SetTypeIdentity(typeof(EnumType <>)); }
protected override DirectiveTypeDefinition CreateDefinition( IInitializationContext context) { var descriptor = DirectiveTypeDescriptor.New <TDirective>( context.DescriptorContext); _conf(descriptor); return(descriptor.CreateDefinition()); }
protected override EnumTypeDefinition CreateDefinition( IInitializationContext context) { var descriptor = EnumTypeDescriptor.New <T>( DescriptorContext.Create(context.Services)); _configure(descriptor); return(descriptor.CreateDefinition()); }
protected override ObjectTypeDefinition CreateDefinition( IInitializationContext context) { var descriptor = ObjectTypeDescriptor.New <T>( context.DescriptorContext); _configure(descriptor); return(descriptor.CreateDefinition()); }
protected override UnionTypeDefinition CreateDefinition(IInitializationContext context) { var descriptor = UnionTypeDescriptor.New( DescriptorContext.Create(context.Services), typeof(T)); _configure(descriptor); return(descriptor.CreateDefinition()); }
public override void Initialize(IInitializationContext context) { context.DisableCertificateChecksFor("papago.naver.com"); if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage))) { throw new EndpointInitializationException($"The language '{context.DestinationLanguage}' is not supported by Papago Translate."); } }
private static void RegisterDirectiveDependencies <T>( this IInitializationContext context, TypeDefinitionBase <T> definition) where T : class, ISyntaxNode { context.RegisterDependencyRange( definition.Directives.Select(t => t.TypeReference), TypeDependencyKind.Completed); }
protected override InterfaceTypeDefinition CreateDefinition( IInitializationContext context) { var descriptor = InterfaceTypeDescriptor.FromSchemaType( context.DescriptorContext, GetType()); _configure(descriptor); return(descriptor.CreateDefinition()); }
protected override UnionTypeDefinition CreateDefinition( IInitializationContext context) { var descriptor = UnionTypeDescriptor.New( context.DescriptorContext, GetType()); _configure(descriptor); return(descriptor.CreateDefinition()); }
internal sealed override void Initialize(IInitializationContext context) { context.Interceptor.OnBeforeRegisterDependencies( context, null, _contextData); OnRegisterDependencies(context, _contextData); context.Interceptor.OnAfterRegisterDependencies( context, null, _contextData); base.Initialize(context); }
private void RegisterDependencies( IInitializationContext context, DirectiveTypeDefinition definition) { var dependencies = new List <ITypeReference>(); context.RegisterDependencyRange( definition.Arguments.Select(t => t.Type), TypeDependencyKind.Completed); }
public Expression BuildObjectBuildingExpressionTree(XElement element, IInitializationContext context) { var visitor = visitors.FirstOrDefault(v => v.MatchElement(element)); if (visitor != null) { return(visitor.VisitElement(element, context)); } throw new ConfirurationFileFormatException($"Unknown element {element.Name}"); }
///<summary> /// /// Initializes workflow with specified data context /// ///</summary> /// public bool Initialize(IDataContext context, IInitializationContext initializationContext) { solution = context.GetData<ISolution>(JetBrains.ReSharper.DataConstants.SOLUTION); psiLanguageType = context.GetData<PsiLanguageType>(DataConstants.PSI_LANGUAGE_TYPE); Assert.CheckNotNull(solution); bool emptyResult = false; UnusedReferencesSearchRequest request = new UnusedReferencesSearchRequest(solution); UnusedReferencesSearchDescriptor searchDescriptor = new UnusedReferencesSearchDescriptor(request); using(ReadLockCookie cookie = ReadLockCookie.Create()) { searchDescriptor.Search(); } emptyResult = request.EmptyResult; searchResults = request.Results; if (searchDescriptor.Items == null) return false; if (emptyResult) { EmptyResultsPane panel = new EmptyResultsPane(); page = panel; } else { ModulesChooserPane pane = new ModulesChooserPane(this); pane.AutoActivate = true; page = pane; } return true; }