예제 #1
0
        private void AssembliesLoader_DoWork(object sender, DoWorkEventArgs e)
        {
            Assemblies.Clear();

            // Add default assembly
            Assemblies.Add(new AssemblyInfo(typeof(Node).Assembly, true, false));

            // Load domain assemblies
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                AnalyzeAssembly(assembly, true);
            }

            // Load local plugins
            foreach (string path in Directory.GetFiles(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FlowTomator.*.dll"))
            {
                FileInfo fileInfo = new FileInfo(path);

                if (!fileInfo.Exists || Assemblies.Any(a => a.Path == fileInfo.FullName))
                {
                    continue;
                }

                try
                {
                    Assembly assembly = Assembly.ReflectionOnlyLoadFrom(path);
                    AnalyzeAssembly(assembly, false);
                }
                catch
                {
                    continue;
                }
            }
        }
예제 #2
0
        public void Refresh()
        {
            Assemblies.Clear();
            Assemblies.AddRange(ReadAssembly(TestAssembly, _workingDirectory));

            Console.WriteLine(ToString());
        }
예제 #3
0
        /// <summary>
        /// Performs the RefreshAssemblies command.
        /// </summary>
        /// <param name="parameter">The RefreshAssemblies command parameter.</param>
        private void DoRefreshAssembliesCommand(object parameter)
        {
            //  Clear the assemblies.
            Assemblies.Clear();

            //  Set the status text.
            RefreshAssembliesCommand.ReportProgress(
                () =>
            {
                StatusInfo = Resources.Msg_RefreshAssemblies_Progress;
            });

            //  Start the enumeration.
            var timeTaken = ApexBroker.GetModel <IGACManagerModel>().EnumerateAssemblies(
                assemblyDetails =>
            {
                //  Create an assembly view model from the detials.
                var viewModel = new GACAssemblyViewModel();
                viewModel.FromModel(assemblyDetails);

                //  Add it to the collection.
                Assemblies.Add(viewModel);
            });

            //  Set the resulting status info.
            RefreshAssembliesCommand.ReportProgress(
                () =>
            {
                AssembliesCollectionView = new ListCollectionView(Assemblies.ToList());

                AssembliesCollectionView.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
                AssembliesCollectionView.Filter += Filter;
                StatusInfo = string.Format(Resources.Msg_RefreshAssemblies_Success, Assemblies.Count, timeTaken.TotalMilliseconds);
            });
        }
예제 #4
0
 public void ReuseWithNewStream(Stream stream)
 {
     deserializedObjects.Clear();
     types.Clear();
     Methods.Clear();
     Assemblies.Clear();
     Modules.Clear();
     reader = new PrimitiveReader(stream, reader.IsBuffered);
 }
예제 #5
0
 public void ReuseWithNewStream(Stream stream)
 {
     postSerializationHooks.Clear();
     types.Clear();
     Methods.Clear();
     Assemblies.Clear();
     Modules.Clear();
     writer = new PrimitiveWriter(stream, writer.IsBuffered);
     identifier.Clear();
 }
예제 #6
0
 private void GetAssemblies()
 {
     if (HostingControl != null)
     {
         if (this.DesignMode)
             MessageBox.Show(String.Format("Getting Referenced Assemblies from {0}", HostingControl.Name));
         Assemblies.Clear();
         AssemblyName[] assemblyNames = HostingControl.GetType().Assembly.GetReferencedAssemblies();
         foreach (AssemblyName item in assemblyNames)
             Assemblies.Add(item.Name);
     }
 }
예제 #7
0
 public static void Clear()
 {
     gatheredUnrealTypes = false;
     Assemblies.Clear();
     AssembliesManagedTypes.Clear();
     AssembliesNativeTypes.Clear();
     AssemblySerializedModuleInfo.Clear();
     processedAssemblies.Clear();
     All.Clear();
     Managed.Clear();
     Native.Clear();
     AllByPath.Clear();
     ManagedByPath.Clear();
     NativeByPath.Clear();
 }
예제 #8
0
        public void Unload()
        {
            if (Domain != null)
            {
                Unloaded?.Invoke(this, Domain);

                AppDomain.Unload(Domain);
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
                Domain = null;
            }

            Unloaded = null;

            Assemblies.Clear();
            Classes = new RemoteClass[0];
        }
예제 #9
0
        public void Load(string root)
        {
            _root = Path.Combine(root);

            if (!Directory.Exists(_root))
            {
                throw new Exception("Folder not exist");
            }

            Assemblies.Clear();
            NuGetPackages.Clear();

            var allProjects = Directory.GetFiles(_root, "*.csproj", SearchOption.AllDirectories);

            foreach (var projFile in allProjects)
            {
                var projNode = XDocument.Load(projFile).Root;
                var projName = System.IO.Path.GetFileName(projFile);

                foreach (var ig in projNode.Elements().Where(e => e.Name.LocalName == "ItemGroup"))
                {
                    foreach (var r in ig.Elements().Where(e => e.Name.LocalName == "Reference"))
                    {
                        AddReference(r, projName, projFile);
                    }

                    foreach (var r in ig.Elements().Where(e => e.Name.LocalName == "Content"))
                    {
                        AddLink(r, projName, projFile);
                    }

                    foreach (var r in ig.Elements().Where(e => e.Name.LocalName == "PackageReference"))
                    {
                        AddPackageReference(r, projName, projFile);
                    }
                }
            }

            Assemblies.Sort((a, b) => a.IsLocal != b.IsLocal ? (a.IsLocal ? 1 : -1) : (a.Name != b.Name ? a.Name.CompareTo(b.Name) : a.ActualPath.CompareTo(b.ActualPath)));

            NuGetPackages.Sort((a, b) => a.IsConsistent != b.IsConsistent ? (a.IsConsistent ? 1 : -1) : a.Name.CompareTo(b.Name));
        }
예제 #10
0
        private RuleResult PreCheck(IMetadataTokenProvider obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj", "Cannot check a null object");
            }

            Reset();
            AssemblyDefinition assembly = obj.GetAssembly();

            if (!Assemblies.Contains(assembly))
            {
                Assemblies.Clear();
                Assemblies.Add(assembly);
                Engines.Build(Assemblies);
            }
            CurrentTarget = obj;

            return(IgnoreList.IsIgnored(CurrentRule, obj) ? RuleResult.DoesNotApply : RuleResult.Success);
        }
예제 #11
0
 /// <summary>
 /// Clears all plugin assemblies and type info.
 /// </summary>
 public void UnInit()
 {
     Assemblies.Clear();
     ConstructorCache.Clear();
 }
예제 #12
0
 /// <summary>
 /// Clears all plugin assemblies and type info.
 /// </summary>
 public void Uninit()
 {
     Assemblies.Clear();
 }
예제 #13
0
 /// <summary>
 /// Clears the cache
 /// </summary>
 public void Clear()
 {
     Assemblies.Clear();
     Types.Clear();
     Localizables.Clear();
 }
예제 #14
0
        public void Initialize(IEnumerable <ProjectAssembly> tracking)
        {
            try
            {
                var pas        = tracking as ProjectAssembly[] ?? tracking.ToArray();
                var opas       = pas.OrderBy(a => a.FullPath).ThenBy(a => a.RelativePath).ToArray();
                var projFolder = ToolboxApp.Project.State.ProjectFolder;
                if (string.IsNullOrWhiteSpace(projFolder))
                {
                    return;
                }

                Assemblies.Clear();

                // Assemblies.AddRange() causes exception?
                foreach (var pa in opas)
                {
                    Assemblies.Add(pa);
                }

                // find assemblies in project folder
                var comparer = new ProjectAssemblyComparer();
                var allFiles = Directory.GetFiles(projFolder, $"*{SupportedFileTypes.AssemblyExtension}", SearchOption.AllDirectories);
                var found    = new List <ProjectAssembly>();

                foreach (var file in allFiles)
                {
                    var rp = file.Replace(projFolder, string.Empty);

                    var assembly = new ProjectAssembly
                    {
                        FullPath     = file,
                        RelativePath = rp,
                        FileName     = Path.GetFileName(file),
                        Directory    = Path.GetDirectoryName(rp)
                    };

                    found.Add(assembly);
                }

                var orderedFound = found.OrderBy(a => a.FullPath).ThenBy(a => a.RelativePath);

                // add assemblies in project folder
                foreach (var assembly in orderedFound)
                {
                    if (!Assemblies.Contains(assembly, comparer))
                    {
                        Assemblies.Add(assembly);
                    }
                }

                // check if project file exists and include assemblies
                if (_fs.FileExist(ToolboxApp.Project.State.XenProjectFilePath))
                {
                    var proj   = new XenProjectFile(_fs);
                    var loaded = proj.Load(ToolboxApp.Project.State.XenProjectFilePath);

                    if (!loaded)
                    {
                        ToolboxApp.Log.Warn($"Unable to load project file: {ToolboxApp.Project.State.XenProjectFilePath}.");
                    }

                    if (proj.Assemblies != null)
                    {
                        foreach (var pa in proj.Assemblies)
                        {
                            var fp = $"{ToolboxApp.Project.State.XenProjectFilePath}{pa.RelativePath}";
                            if (string.IsNullOrWhiteSpace(fp))
                            {
                                continue;
                            }

                            var match = Assemblies.FirstOrDefault(a => a.FullPath == fp);
                            if (match != null)
                            {
                                match.Include = true;
                            }
                        }
                    }
                }
                else
                {
                    ToolboxApp.Log.Info($"{ToolboxApp.Project.State.XenProjectFilePath} doesn't exist.");
                }
            }
            catch (Exception ex)
            {
                ToolboxApp.Log.Error(ex, "Error retrieving project assemblies.");
            }
        }