public override IEnumerable <ICodeRequest> GetCodeRequests() { var cr = new DependsOnModuleCodeRequest(ModuleName, Why); cr.OnAliasChanged += request => UseAlias = request.UseAlias; return(new ICodeRequest[] { cr }); }
private void TranslateClass_AddModuleRequests(ClassTranslationInfo classTranslationInfo, PyCodeModule pyModule) { var moduleCodeRequests = new List <DependsOnModuleCodeRequest>(); var codeRequests = (pyModule as ICodeRelated).GetCodeRequests().ToArray(); { var classCodeRequests = (from request in codeRequests.OfType <ClassCodeRequest>() select request.ClassName.FullName) .Distinct() .ToArray(); foreach (var req in classCodeRequests) { var m = Info.ClassTranslations.Values.Where(i => i.PyName.FullName == req).ToArray(); if (m.Length != 1) { throw new NotSupportedException(); } var mm = m[0]; if (mm.DontIncludeModuleForClassMembers) { continue; } var includeModule = mm.IncludeModule; if (includeModule == null || mm.ModuleName == pyModule.ModuleName) { continue; } var h = new DependsOnModuleCodeRequest(includeModule, "class request: " + req); moduleCodeRequests.Add(h); } } { // converts DependsOnModuleCodeRequest var moduleRequests = (from i in codeRequests.OfType <DependsOnModuleCodeRequest>() where i.ModuleName != null select i).Concat(moduleCodeRequests).ToArray(); if (moduleRequests.Any()) { foreach (var mReq in moduleRequests) { var ati = Info.GetOrMakeTranslationInfo(classTranslationInfo.Type.Assembly); if (mReq.ModuleName == null || mReq.ModuleName == pyModule.ModuleName) { continue; } var usedAliasWhileImport = AppendImportModuleCodeRequest(mReq.ModuleName, pyModule, ati); mReq.UseAlias = usedAliasWhileImport; } } } }