Exemple #1
0
        public async void Init()
        {
            if (Project == null)
            {
                Helper.Notify("当前项目为空,请在左侧菜单选择“项目”节点", NotificationType.Error);
                return;
            }

            List <CodeModule> entities = new List <CodeModule>();
            await _provider.ExecuteScopedWorkAsync(provider =>
            {
                IDataContract contract = provider.GetRequiredService <IDataContract>();
                entities = contract.CodeModules.Where(m => m.ProjectId == Project.Id).OrderBy(m => m.Order).ToList();
                return(Task.CompletedTask);
            });

            Modules.Clear();
            foreach (CodeModule entity in entities)
            {
                ModuleViewModel model = _provider.GetRequiredService <ModuleViewModel>();
                model         = entity.MapTo(model);
                model.Project = Project;
                Modules.Add(model);
            }

            Helper.Output($"模块列表刷新成功,共{Modules.Count}个模块");
        }
Exemple #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void Initialize()
        {
            Modules.Clear();
            Roles.Clear();
            DispatcherHelper.RunAsync(() => {
                List <Role> roles = _UserService.QueryRoles();
                foreach (var r in roles)
                {
                    Roles.Add(new RoleModel(r));
                }

                List <Module> modules = _UserService.QueryModuleWithFunctions();

                foreach (var m in modules)
                {
                    var module = new ModuleModel(m);

                    if (m.Function != null && m.Function.Count > 0)
                    {
                        List <FunctionModel> functions = new List <FunctionModel>();
                        foreach (var f in m.Function)
                        {
                            functions.Add(new FunctionModel(f, 0));
                        }
                        module.Functions = functions;
                    }
                    Modules.Add(module);
                }
            });
        }
Exemple #3
0
        public async Task <ModuleBundlingResult> BundleAsync(ModuleFile[] rootFiles, CancellationToken token = default)
        {
            if (rootFiles == null)
            {
                throw new ArgumentNullException(nameof(rootFiles));
            }

            rootFiles = rootFiles.ToArray();

            try
            {
                await BundleCoreAsync(rootFiles, token).ConfigureAwait(false);

                // aggregate

                token.ThrowIfCancellationRequested();

                return(BuildResult(rootFiles));
            }
            finally
            {
                Modules.Clear();
                FileProviderPrefixes.Clear();
            }
        }
        public async Task ReloadAsync(CancellationToken cancellationToken = default)
        {
            foreach (var uri in Modules
                     .Where(m => m.Value.Value?.Name != BuiltinModuleName)
                     .Select(m => m.Value.Value?.Uri)
                     .ExcludeDefault())
            {
                GetRdt()?.UnlockDocument(uri);
            }

            // Preserve builtins, they don't need to be reloaded since interpreter does not change.
            if (Modules.TryGetValue(BuiltinModuleName, out var builtins))
            {
                Modules.Clear();
                Modules[BuiltinModuleName] = builtins;
            }

            await ReloadSearchPaths(cancellationToken);

            PathResolver = new PathResolver(_interpreter.LanguageVersion, Root, InterpreterPaths, _userPaths);

            var addedRoots = new HashSet <string> {
                Root
            };

            addedRoots.UnionWith(InterpreterPaths);
            addedRoots.UnionWith(_userPaths);
            ReloadModulePaths(addedRoots);
        }
Exemple #5
0
        public async Task ReloadAsync(CancellationToken cancellationToken = default)
        {
            foreach (var uri in Modules
                     .Where(m => m.Value.Value?.Name != BuiltinModuleName)
                     .Select(m => m.Value.Value?.Uri)
                     .ExcludeDefault())
            {
                GetRdt()?.UnlockDocument(uri);
            }

            // Preserve builtins, they don't need to be reloaded since interpreter does not change.
            var builtins = Modules[BuiltinModuleName];

            Modules.Clear();
            Modules[BuiltinModuleName] = builtins;

            PathResolver = new PathResolver(_interpreter.LanguageVersion);

            var addedRoots = new HashSet <string>();

            addedRoots.UnionWith(PathResolver.SetRoot(_root));

            var interpreterPaths = await GetSearchPathsAsync(cancellationToken);

            addedRoots.UnionWith(PathResolver.SetInterpreterSearchPaths(interpreterPaths));

            var userSearchPaths = _interpreter.Configuration.SearchPaths.Except(interpreterPaths, StringExtensions.PathsStringComparer);

            addedRoots.UnionWith(SetUserSearchPaths(userSearchPaths));
            ReloadModulePaths(addedRoots);
        }
Exemple #6
0
        public void Start()
        {
            IsReady = false;

            try
            {
                _runbookNameCache.Clear();

                Runbooks.Clear();
                Credentials.Clear();
                Schedules.Clear();
                Variables.Clear();
                Modules.Clear();
                Connections.Clear();
                Tags.Clear();

                Service.Load();

                foreach (var rb in Runbooks)
                {
                    _runbookNameCache.Add((rb.Tag as RunbookModelProxy).RunbookName);
                }

                Execute.OnUIThread(() => _statusManager.SetText(""));
            }
            catch (NotSupportedException)
            {
                // Ignore for now...
            }
        }
Exemple #7
0
        /// <summary>
        /// Remove the project from the package
        /// </summary>
        public void Remove()
        {
            if (Part == null)
            {
                return;
            }

            foreach (var rel in Part.GetRelationships())
            {
                _pck.DeleteRelationship(rel.Id);
            }
            if (_pck.PartExists(Uri))
            {
                _pck.DeletePart(Uri);
            }
            Part = null;
            Modules.Clear();
            References.Clear();
            Lcid          = 0;
            LcidInvoke    = 0;
            CodePage      = 0;
            MajorVersion  = 0;
            MinorVersion  = 0;
            HelpContextID = 0;
        }
Exemple #8
0
        public override void LoadSave(object obj)
        {
            ShipModuleServiceSave save = obj as ShipModuleServiceSave;

            if (save != null)
            {
                Modules.Clear();
                if (save.modules != null)
                {
                    foreach (var moduleSave in save.modules)
                    {
                        Modules.Add(new ShipModuleInfo(moduleSave));
                    }
                }
                else
                {
                    CreateEmptyModules();
                }
                save.Validate();
                ModuleCounters.Clear();
                ModuleCounters.CopyFrom(save.moduleCounters);

                IsLoaded = true;
            }
            else
            {
                LoadDefaults();
            }
        }
Exemple #9
0
        internal static List <Formula> InitializeFormulas()
        {
            // Shamelessly copied from Custom Troop Upgrades because it's my mod
            if (!Modules.IsEmpty())
            {
                Modules.Clear();
            }

            string[] moduleNames = Utilities.GetModulesNames();
            foreach (string moduleName in moduleNames)
            {
                ModuleInfo m = new ModuleInfo();
                m.LoadWithFullPath(ModuleHelper.GetModuleFullPath(moduleName));

                if (m.Id == "BattleRegeneration")
                {
                    Modules.Insert(0, m);                               // original mod should load first
                }
                else
                {
                    Modules.Add(m);
                }
            }

            formulas = new List <Formula>();
            CompileScripts("battleregen.cs", GenerateCSharpCode);
            CompileScripts("battleregen.vb", GenerateVisualBasicCode);
            return(formulas);
        }
Exemple #10
0
 private void CreateEmptyModules()
 {
     Modules.Clear();
     foreach (int moduleId in Services.ResourceService.Defaults.moduleIds)
     {
         Modules.Add(new ShipModuleInfo(moduleId));
     }
 }
 public void Reset()
 {
     lock (Mutex)
     {
         Modules.Clear();
         Initialized = false;
     }
 }
Exemple #12
0
 public Task ReloadAsync(CancellationToken cancellationToken = default)
 {
     Modules.Clear();
     PathResolver = new PathResolver(Interpreter.LanguageVersion, Root, _typeStubPaths, ImmutableArray <string> .Empty);
     ReloadModulePaths(_typeStubPaths.Prepend(Root), cancellationToken);
     cancellationToken.ThrowIfCancellationRequested();
     return(Task.CompletedTask);
 }
Exemple #13
0
 public void ReuseWithNewStream(Stream stream)
 {
     deserializedObjects.Clear();
     types.Clear();
     Methods.Clear();
     Assemblies.Clear();
     Modules.Clear();
     reader = new PrimitiveReader(stream, reader.IsBuffered);
 }
Exemple #14
0
        private void LoadFiles()
        {
            Modules.Clear();

            foreach (var file in Directory.GetFiles(_pathService.ModuleDirectory, "*.mod"))
            {
                Modules.Add(Path.GetFileNameWithoutExtension(file));
            }
        }
Exemple #15
0
 public void ReuseWithNewStream(Stream stream)
 {
     postSerializationHooks.Clear();
     types.Clear();
     Methods.Clear();
     Assemblies.Clear();
     Modules.Clear();
     writer = new PrimitiveWriter(stream, writer.IsBuffered);
     identifier.Clear();
 }
Exemple #16
0
 public void Dispose()
 {
     foreach (HUDModule module in Modules)
     {
         module.Dispose();
     }
     Modules.Clear();
     Modules = null;
     Player  = null;
 }
Exemple #17
0
 public void Load(string file)
 {
     if (false == IsLoaded)
     {
         Modules.Clear();
         var listItems = JsonConvert.DeserializeObject <List <ShipModuleJsonData> >(Resources.Load <TextAsset>(file).text);
         listItems.ForEach(item => Modules.Add(item.id, new ShipModuleData(item)));
         IsLoaded = true;
     }
 }
Exemple #18
0
 private void InitModules()
 {
     Modules.Clear();
     string[] mcodes = Settings.Default.ModuleCodes.Split('|');
     string[] items;
     for (int i = 1; i < mcodes.Length; i++)
     {
         items = mcodes[i].Split(':');
         Modules.Add(items[0], items[1]);
     }
 }
Exemple #19
0
        public void RefreshModules()
        {
            NativeProcess.Refresh();

            Modules.Clear();

            foreach (ProcessModule processModule in NativeProcess.Modules)
            {
                Modules.Add(processModule.ModuleName.ToLower(), new MemoryModule(processModule));
            }
        }
Exemple #20
0
        public void AddModules(ShelfModuleFive five)
        {
            Modules.Clear();
            if (five != null)
            {
                Modules.Add(five);
            }

            ShelfData    = new ShelfModulesInfo(Modules);
            m_needbanner = false;
            ShelfBanner  = String.Empty;
        }
Exemple #21
0
        public void RefreshModules()
        {
            Thread.Sleep(1000);

            NativeProcess.Refresh();

            Modules.Clear();

            foreach (ProcessModule processModule in NativeProcess.Modules)
            {
                Modules.Add(processModule.ModuleName.ToLower(), new MemoryModule(this, processModule));
            }
        }
Exemple #22
0
        public async Task ReloadAsync(CancellationToken cancellationToken = default)
        {
            foreach (var uri in Modules
                     .Where(m => m.Value.Value?.Name != BuiltinModuleName)
                     .Select(m => m.Value.Value?.Uri)
                     .ExcludeDefault())
            {
                GetRdt()?.UnlockDocument(uri);
            }

            // Preserve builtins, they don't need to be reloaded since interpreter does not change.
            var builtins = Modules[BuiltinModuleName];

            Modules.Clear();
            Modules[BuiltinModuleName] = builtins;

            PathResolver = new PathResolver(_interpreter.LanguageVersion);

            var addedRoots = new HashSet <string>();

            addedRoots.UnionWith(PathResolver.SetRoot(Root));

            InterpreterPaths = await GetSearchPathsAsync(cancellationToken);

            IEnumerable <string> userSearchPaths = Configuration.SearchPaths;

            InterpreterPaths = InterpreterPaths.Except(userSearchPaths, StringExtensions.PathsStringComparer).Where(p => !p.PathEquals(Root));

            if (Root != null)
            {
                var underRoot = userSearchPaths.ToLookup(p => _fs.IsPathUnderRoot(Root, p));
                userSearchPaths  = underRoot[true];
                InterpreterPaths = underRoot[false].Concat(InterpreterPaths);
            }

            _log?.Log(TraceEventType.Information, "Interpreter search paths:");
            foreach (var s in InterpreterPaths)
            {
                _log?.Log(TraceEventType.Information, $"    {s}");
            }

            _log?.Log(TraceEventType.Information, "User search paths:");
            foreach (var s in userSearchPaths)
            {
                _log?.Log(TraceEventType.Information, $"    {s}");
            }

            addedRoots.UnionWith(PathResolver.SetInterpreterSearchPaths(InterpreterPaths));
            addedRoots.UnionWith(SetUserSearchPaths(userSearchPaths));
            ReloadModulePaths(addedRoots);
        }
Exemple #23
0
 private void OnStateChange(KMGameInfo.State state)
 {
     currentState = state;
     setPins();
     if (currentState != KMGameInfo.State.PostGame)
     {
         arduinoConnection.Stop();
     }
     else
     {
         if (bombState == 0)
         {
             StopCoroutines(); arduinoConnection.sendMSG(String.Format("{0} {1} {2} 0 0 255", RP, GP, BP));
         }                                                                                                                      //For multiple bombs
     }
     if (currentState == KMGameInfo.State.Gameplay)
     {
         //if(arduinoConnection._connected) StartCoroutine(Test());
         bombState   = 0;
         lastStrikes = 0;
         lastSolves  = 0;
         strikeCounts.Clear();
         solveCounts.Clear();
         StartCoroutine(getField());
         StartCoroutine(Warning());
         StartCoroutine(OnStrike());
         StartCoroutine(OnSolve());
         StartCoroutine(CheckForBomb(true));
         StartCoroutine(FactoryCheck());
         StartCoroutine(getBomb());
         StartCoroutine(HandleReflectors());
     }
     else
     {
         currentModuleName = "";
         Modules.Clear();
         StopCoroutine(CheckForBomb(false));
         StopCoroutine(FactoryCheck());
         StopCoroutine(WaitUntilEndFactory());
         StopCoroutine(HandleReflectors());
         BombActive = false;
         Bombs.Clear();
         BombCommanders.Clear();
     }
     if (currentState == KMGameInfo.State.Quitting)
     {
         arduinoConnection.Disconnect();
     }
 }
        /// <summary>
        /// Retrieves modules list freshly from server.
        /// </summary>
        public virtual void RefreshModulesList()
        {
            LastResult = false;
            LastError  = "Error retrieving modules list.";

            Modules.Clear();

            try
            {
                string sData = Request("GET_MODULELIST\n");

                if (sData.Length > 0)
                {
                    var terms = sData.Split(' ');
                    if (terms[0] == "+OK")
                    {
                        if (terms.Length > 1)
                        {
                            int iNb = int.Parse(terms[1]);
                            if (terms.Length == (iNb * 4) + 2)
                            {
                                for (int i = 0; i < iNb; i++)
                                {
                                    int  iFirstArgument = (i * 4) + 2;
                                    byte bAddress       = byte.Parse(terms[iFirstArgument], System.Globalization.NumberStyles.HexNumber);
                                    var  iVersion       = terms[iFirstArgument + 1].Split('.').Select(x => int.Parse(x)).ToArray();
                                    byte bType          = byte.Parse(terms[iFirstArgument + 2], System.Globalization.NumberStyles.HexNumber);

                                    var module = ModuleFactory.CreateInstance(bType) as Module;
                                    module.ID            = bAddress;
                                    module.Major         = iVersion[0];
                                    module.Minor         = iVersion[1];
                                    module.Build         = iVersion[2];
                                    module.Description   = terms[iFirstArgument + 3];
                                    module.ActionRaised += Module_ActionRaised;
                                    Modules.Add(bAddress, module);
                                }
                                LastResult = true;
                                LastError  = string.Empty;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LastError = string.Format("Error retrieving modules list: {0}.", ex.Message);
            }
        }
Exemple #25
0
    public override void OnInspectorGUI()
    {
        if (!_modules)
            _modules = target as Modules;

        GUILayout.Space(20f);

        GUILayout.BeginVertical();

        List<Module> toRemove = new List<Module>();

        foreach (Module m in _modules)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label(m.GetName());
            if (GUILayout.Button("Remove", GUILayout.MaxWidth(60)))
            {
                Undo.RecordObject(_modules, "Removed Module");
                toRemove.Add(m);
            }

            GUILayout.EndHorizontal();

            EditorGUILayoutExtension.HorizontalLine();
        }

        _modules.Remove(toRemove);

        GUILayout.EndVertical();

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Add"))
        {
            LoadModuleSelector();
        }

        GUILayout.Space(35f);

        if (GUILayout.Button("Clear"))
        {
            Undo.RecordObject(_modules, "Cleared modules");

            _modules.Clear();
        }

        GUILayout.EndHorizontal();
    }
 public void CopyFrom(Permissions other)
 {
     Modules.Clear();
     foreach (var mp in other.Modules)
     {
         Modules.AddOrUpdate(mp.Key, mp.Value, (s, b) => mp.Value);
     }
     Commands.Clear();
     foreach (var cp in other.Commands)
     {
         Commands.AddOrUpdate(cp.Key, cp.Value, (s, b) => cp.Value);
     }
     FilterInvites = other.FilterInvites;
     FilterWords   = other.FilterWords;
 }
        public Task ReloadAsync(CancellationToken cancellationToken = default)
        {
            Modules.Clear();
            PathResolver = new PathResolver(_interpreter.LanguageVersion);

            var addedRoots = PathResolver.SetRoot(_root);

            ReloadModulePaths(addedRoots);

            addedRoots = PathResolver.SetInterpreterSearchPaths(_typeStubPaths);
            ReloadModulePaths(addedRoots);

            cancellationToken.ThrowIfCancellationRequested();
            return(Task.CompletedTask);
        }
Exemple #28
0
        private static void Refresh(IEnumerable <string> zipFiles)
        {
            using (new ProfileSection("Refresh product manager", typeof(ManifestHelper)))
            {
                ProfileSection.Argument("zipFiles", zipFiles);

                Products.Clear();
                Modules.Clear();
                foreach (string file in zipFiles)
                {
                    ProcessFile(file);
                }

                Modules.AddRange(Products.Where(p => !p.IsStandalone));
            }
        }
        public async Task ReloadAsync(CancellationToken cancellationToken = default)
        {
            foreach (var uri in Modules
                     .Where(m => m.Value.Value?.Name != BuiltinModuleName)
                     .Select(m => m.Value.Value?.Uri)
                     .ExcludeDefault())
            {
                GetRdt()?.UnlockDocument(uri);
            }

            // Preserve builtins, they don't need to be reloaded since interpreter does not change.
            var builtins = Modules[BuiltinModuleName];

            Modules.Clear();
            Modules[BuiltinModuleName] = builtins;

            PathResolver = new PathResolver(_interpreter.LanguageVersion);

            var addedRoots = new HashSet <string>();

            addedRoots.UnionWith(PathResolver.SetRoot(Root));

            var ps = _services.GetService <IProcessServices>();

            var paths = await GetInterpreterSearchPathsAsync(cancellationToken);

            var(interpreterPaths, userPaths) = PythonLibraryPath.ClassifyPaths(Root, _fs, paths, Configuration.SearchPaths);

            InterpreterPaths = interpreterPaths.Select(p => p.Path);
            var userSearchPaths = userPaths.Select(p => p.Path);

            _log?.Log(TraceEventType.Information, "Interpreter search paths:");
            foreach (var s in InterpreterPaths)
            {
                _log?.Log(TraceEventType.Information, $"    {s}");
            }

            _log?.Log(TraceEventType.Information, "User search paths:");
            foreach (var s in userSearchPaths)
            {
                _log?.Log(TraceEventType.Information, $"    {s}");
            }

            addedRoots.UnionWith(PathResolver.SetInterpreterSearchPaths(InterpreterPaths));
            addedRoots.UnionWith(PathResolver.SetUserSearchPaths(userSearchPaths));
            ReloadModulePaths(addedRoots);
        }
Exemple #30
0
 public void Dispose()
 {
     try
     {
         _discordClient?.Do((client) =>
         {
             if (client != null)
             {
                 client.MessageReceived -= MessageReceivedHandler;
                 client.JoinedGuild     -= JoinedGuildHandler;
                 client.LeftGuild       -= LeftGuildHandler;
             }
         });
     }
     catch { }
     try { Modules?.Clear(); } catch { }
 }