Exemplo n.º 1
0
        internal SerializedFile(IFileCollection collection, IAssemblyManager manager, SerializedFileScheme scheme)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }
            if (scheme == null)
            {
                throw new ArgumentNullException(nameof(scheme));
            }

            Collection      = collection;
            AssemblyManager = manager;
            FilePath        = scheme.FilePath;
            NameOrigin      = scheme.Name;
            Name            = FilenameUtils.FixFileIdentifier(scheme.Name);
            Flags           = scheme.Flags;

            Header   = scheme.Header;
            Metadata = scheme.Metadata;
        }
Exemplo n.º 2
0
 internal SerializedFile(IFileCollection collection, IAssemblyManager manager, SerializedFileScheme scheme)
 {
     if (scheme == null)
     {
         throw new ArgumentNullException(nameof(scheme));
     }
 }
Exemplo n.º 3
0
        public ArchiveFile ReadFile(IFileCollection collection, IAssemblyManager manager)
        {
            ArchiveFile archive = new ArchiveFile(collection, this);

            archive.AddFile(WebScheme, collection, manager);
            return(archive);
        }
Exemplo n.º 4
0
 public AssemblyLoader(IAssemblyManager manager, ILoad dlr)
 {
     Dlr = dlr;
      AssemblyManager = manager;
      AssemblyManager.AssemblyLoaded += assemblyManager_AssemblyLoaded;
      LoadedAssemblies = new List<IAssembly>();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Loads available assemblies.
        /// </summary>
        internal static void LoadAssemblies()
        {
            using (var container = ContextScopeProvider.CreateChildContainer())
            {
                if (container == null)
                {
                    throw new CmsException("Better CMS dependencies container is not initialized.");
                }

                if (HostingEnvironment.IsHosted)
                {
                    HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourcesVirtualPathProvider(container.Resolve <IEmbeddedResourcesProvider>()));
                }

                ControllerBuilder.Current.SetControllerFactory(container.Resolve <DefaultCmsControllerFactory>());
                ViewEngines.Engines.Insert(0, new EmbeddedResourcesViewEngine());

                IAssemblyManager assemblyManager = container.Resolve <IAssemblyManager>();

                // First add referenced modules...
                assemblyManager.AddReferencedModules();

                // ...then scan and register uploaded modules.
                assemblyManager.AddUploadedModules();

                var moduleRegistration = container.Resolve <IModulesRegistration>();
                moduleRegistration.InitializeModules();
            }
        }
        private ITypeDeclaration ResolveTypeDeclaration(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            IAssembly[] assemblyList = new IAssembly[assemblyManager.Assemblies.Count];
            assemblyManager.Assemblies.CopyTo(assemblyList, 0);

            if ((this.assembly != null) && (this.assembly.Length > 0))
            {
                IAssembly assembly = this.ResolveAssembly(assemblyManager, assemblyCache);
                assemblyList = (assembly != null) ? new IAssembly[] { assembly } : new IAssembly[0];
            }

            string typeName = this.item;

            foreach (IAssembly assembly in assemblyList)
            {
                foreach (IModule module in assembly.Modules)
                {
                    foreach (ITypeDeclaration typeDeclaration in module.Types)
                    {
                        foreach (ITypeDeclaration currentType in GetNestedTypeList(typeDeclaration))
                        {
                            string text = this.GetTypeReferenceText(currentType);
                            if (typeName == text)
                            {
                                return(currentType);
                            }
                        }
                    }
                }
            }

            return(null);
        }
        public BamlViewerWindow(IServiceProvider serviceProvider)
        {
            this.TabStop = false;

            this.assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));

            this.messageLabel           = new Label();
            this.messageLabel.FlatStyle = FlatStyle.System;
            this.messageLabel.AutoSize  = true;
            this.messageLabel.Text      = "Please load assemblies containing BAML resources into Reflector.";
            this.Controls.Add(this.messageLabel);

            this.browserTreeView              = new BrowserTreeView();
            this.browserTreeView.TabIndex     = 1;
            this.browserTreeView.Dock         = DockStyle.Top;
            this.browserTreeView.Height       = 200;
            this.browserTreeView.AfterSelect += new TreeViewEventHandler(this.BrowserTreeView_AfterSelect);

            this.splitter      = new Splitter();
            this.splitter.Dock = DockStyle.Top;

            this.textBox           = new RichTextBox();
            this.textBox.TabIndex  = 2;
            this.textBox.Font      = new Font("Courier New", SystemInformation.MenuFont.SizeInPoints);
            this.textBox.Dock      = DockStyle.Fill;
            this.textBox.Multiline = true;
            this.textBox.WordWrap  = false;
            this.textBox.Select(0, 0);
            this.textBox.ContextMenu = new ContextMenu(new MenuItem[] {
                new MenuItem("Select All", new EventHandler(this.TextBox_SelectAll)),
                new MenuItem("Copy", new EventHandler(this.TextBox_Copy))
            });
        }
        public object Resolve(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            switch (this.type)
            {
            case CodeIdentifierType.None:
                return(null);

            case CodeIdentifierType.Assembly:
                return(this.ResolveAssembly(assemblyManager, assemblyCache));

            case CodeIdentifierType.Module:
                return(this.ResolveModule(assemblyManager, assemblyCache));

            case CodeIdentifierType.Resource:
                return(this.ResolveResource(assemblyManager, assemblyCache));

            case CodeIdentifierType.Type:
                return(this.ResolveTypeDeclaration(assemblyManager, assemblyCache));

            case CodeIdentifierType.Field:
                return(this.ResolveFieldDeclaration(assemblyManager, assemblyCache));

            case CodeIdentifierType.Method:
                return(this.ResolveMethodDeclaration(assemblyManager, assemblyCache));

            case CodeIdentifierType.Property:
                return(this.ResolvePropertyDeclaration(assemblyManager, assemblyCache));

            case CodeIdentifierType.Event:
                return(this.ResolveEventDeclaration(assemblyManager, assemblyCache));
            }

            throw new NotSupportedException("Unable to resolve code identifier.");
        }
        private IAssembly ResolveAssembly(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            IAssemblyReference assemblyReference = this.ParseAssemblyReference(this.assembly, assemblyManager);

            for (int i = 0; i < assemblyManager.Assemblies.Count; i++)
            {
                IAssembly assembly = assemblyManager.Assemblies[i];
                if (assembly.Equals(assemblyReference))
                {
                    return(assembly);
                }
            }

            if (assemblyCache != null)
            {
                string location = assemblyCache.QueryLocation(assemblyReference, null);
                if ((location != null) && (location.Length > 0))
                {
                    IAssembly assembly = assemblyManager.LoadFile(location);
                    return(assembly);
                }
            }

            return(null);
        }
Exemplo n.º 10
0
 public void Load(IServiceProvider serviceProvider)
 {
     this.commandBarManager     = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
     this.assemblyManager       = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
     this.assemblyBrowser       = (IAssemblyBrowser)serviceProvider.GetService(typeof(IAssemblyBrowser));
     this.openTypeLibraryButton = this.commandBarManager.CommandBars["File"].Items.InsertButton(2, "Open &Type Library...", new EventHandler(this.OpenTypeLibraryButton_Click), Keys.T | Keys.Control);
 }
Exemplo n.º 11
0
 public Framework(IAssemblyManager assemblyManager, IModuleManager moduleManager, IServiceManager serviceManager, IBootstrapper bootstrapper)
 {
     this.assemblyManager = assemblyManager;
     this.moduleManager   = moduleManager;
     this.serviceManager  = serviceManager;
     this.bootstrapper    = bootstrapper;
 }
Exemplo n.º 12
0
        public SerializedFile ReadFile(IFileCollection collection, IAssemblyManager manager)
        {
            SerializedFile file = new SerializedFile(collection, manager, this);

            m_stream.Dispose();
            return(file);
        }
Exemplo n.º 13
0
    /// <summary>
    /// Initializes a new instance of the <see cref="DerivedTypeInformation"/> class.
    /// </summary>
    /// <param name="assemblyManager">The assembly manager.</param>
    /// <param name="visibility">The visibility.</param>
    public DerivedTypeInformation(IAssemblyManager assemblyManager, IVisibilityConfiguration visibility)
    {
      this.table = new Dictionary<ITypeReference, List<ITypeDeclaration>>();

      IAssembly[] assemblies = new IAssembly[assemblyManager.Assemblies.Count];
      assemblyManager.Assemblies.CopyTo(assemblies, 0);

      FastTypeEnumerator enumerator = new FastTypeEnumerator(assemblies);
      foreach (ITypeDeclaration typeDeclaration in enumerator.Types)
      {
        if (ReflectorHelper.IsVisible(typeDeclaration, visibility))
        {
          ITypeReference baseType = typeDeclaration.BaseType;
          if (baseType != null)
          {
            if (baseType.GenericType != null)
            {
              this.AddToTable(baseType.GenericType, typeDeclaration);
            }
            else
            {
              this.AddToTable(baseType, typeDeclaration);
            }
          }

          foreach (ITypeReference interfaceType in typeDeclaration.Interfaces)
          {
            this.AddToTable(interfaceType, typeDeclaration);
          }
        }
      }
    }
 public void Load(IServiceProvider serviceProvider)
 {
     this.windowManager        = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
     this.assemblyManager      = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
     this.configurationManager = (IConfigurationManager)serviceProvider.GetService(typeof(IConfigurationManager));
     this.windowManager.Load  += new EventHandler(windowManager_Load);
 }
Exemplo n.º 15
0
    public static void Main()
    {
        IServiceProvider serviceProvider = new ApplicationManager(null);

        IAssemblyManager assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));

        IAssembly assembly = assemblyManager.LoadFile(typeof(CodeModelExample).Module.FullyQualifiedName);

        Console.WriteLine("Assembly: " + assembly.ToString());

        foreach (IModule module in assembly.Modules)
        {
            Console.WriteLine("Module: " + module.Name);

            foreach (ITypeDeclaration typeDeclaration in module.Types)
            {
                Console.WriteLine("Type: " + typeDeclaration.Namespace + "." + typeDeclaration.Name);

                foreach (IMethodDeclaration methodDeclaration in typeDeclaration.Methods)
                {
                    Console.WriteLine("Method: " + methodDeclaration);

                    IMethodBody methodBody = methodDeclaration.Body as IMethodBody;
                    if (methodBody != null)
                    {
                        foreach (IInstruction instruction in methodBody.Instructions)
                        {
                            Console.Write("L" + instruction.Offset.ToString("X4", CultureInfo.InvariantCulture));
                            Console.Write(": ");
                            Console.Write(InstructionTable.GetInstructionName(instruction.Code));

                            if (instruction.Value != null)
                            {
                                Console.Write(" ");

                                if (instruction.Value is string)
                                {
                                    Console.Write("\"");
                                }

                                Console.Write(instruction.Value.ToString());

                                if (instruction.Value is string)
                                {
                                    Console.Write("\"");
                                }
                            }


                            Console.WriteLine();
                        }
                    }
                }
            }
        }

        assemblyManager.Unload(assembly);
    }
Exemplo n.º 16
0
    /// <summary>
    /// Initializes a new instance of the <see cref="DiagramViewerContainer"/> class.
    /// </summary>
    /// <param name="serviceProvider">The service provider.</param>
    public DiagramViewerContainer(IServiceProvider serviceProvider)
    {
      InitializeComponent();

      this.assemblyBrowser = serviceProvider.GetService(typeof(IAssemblyBrowser)) as IAssemblyBrowser;
      this.assemblyManager = serviceProvider.GetService(typeof(IAssemblyManager)) as IAssemblyManager;
      this.populator = new InstructionDataPopulator(this.assemblyManager);
      this.elementHost.Child = new DiagramViewer();
    }
Exemplo n.º 17
0
        public BundleFile ReadFile(IFileCollection collection, IAssemblyManager manager)
        {
            BundleFile bundle = new BundleFile(collection, this);

            foreach (FileScheme scheme in Schemes)
            {
                bundle.AddFile(scheme, collection, manager);
            }
            return(bundle);
        }
Exemplo n.º 18
0
        public WebFile ReadFile(IFileCollection collection, IAssemblyManager manager)
        {
            WebFile web = new WebFile(collection, this);

            foreach (FileScheme scheme in Schemes)
            {
                web.AddFile(scheme, collection, manager);
            }
            return(web);
        }
Exemplo n.º 19
0
 public void Load(IServiceProvider serviceProvider)
 {
     this.windowManager = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
     //this.windowManager.ShowMessage("Loading Perst!");
     this.assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
     this.commandBarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
     this.translatorManager = (ITranslatorManager)serviceProvider.GetService(typeof(ITranslatorManager));
     this.translator = this.translatorManager.CreateDisassembler(null, null);
     this.separator = this.commandBarManager.CommandBars["Tools"].Items.AddSeparator();
     this.button = this.commandBarManager.CommandBars["Tools"].Items.AddButton("&Detect Modify Bug", new EventHandler(this.PerstListButton_Click));
 }
Exemplo n.º 20
0
 public void Load(IServiceProvider serviceProvider)
 {
     this.windowManager = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
     //this.windowManager.ShowMessage("Loading Perst!");
     this.assemblyManager   = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
     this.commandBarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
     this.translatorManager = (ITranslatorManager)serviceProvider.GetService(typeof(ITranslatorManager));
     this.translator        = this.translatorManager.CreateDisassembler(null, null);
     this.separator         = this.commandBarManager.CommandBars["Tools"].Items.AddSeparator();
     this.button            = this.commandBarManager.CommandBars["Tools"].Items.AddButton("&Detect Modify Bug", new EventHandler(this.PerstListButton_Click));
 }
Exemplo n.º 21
0
        /// <summary>
        /// Loads the specified service provider.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        public void Load(IServiceProvider serviceProvider)
        {
            // Get AssemblyManager reference for reordering
            this.assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));

            // Create a command button, separator on the Tools menu and wire up the button click event
            this.commandBarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
            this.separator         = this.commandBarManager.CommandBars["Tools"].Items.AddSeparator();
            this.button            = this.commandBarManager.CommandBars["Tools"].Items.AddButton("Reorder Assemblies",
                                                                                                 new EventHandler(this.OrderAssemblyListButton_Click), Keys.Control | Keys.Shift | Keys.R);
        }
Exemplo n.º 22
0
 internal static void Run(IAssemblyManager aManager, IExecutor executor)
 {
     Console.WriteLine("Executing code from client's reference assembly");
     transportAssembly(aManager);
     Console.WriteLine();
     simpleInstructions(executor);
     Console.WriteLine();
     runtimeInfoGeneratorInstructions(executor);
     Console.WriteLine();
     clearAssemblyManager(aManager);
     Console.WriteLine();
 }
Exemplo n.º 23
0
 public static void Run(IAssemblyManager aManager, IExecutor executor)
 {
     Console.WriteLine("Executing code from host's own assembly");
     transportAssembly(aManager);
     Console.WriteLine();
     simpleInstructions(executor);
     Console.WriteLine();
     runtimeInfoGeneratorInstructions(executor);
     Console.WriteLine();
     clearAssemblyManager(aManager);
     Console.WriteLine();
 }
Exemplo n.º 24
0
        internal void AddFile(FileScheme scheme, IFileCollection collection, IAssemblyManager manager)
        {
            switch (scheme.SchemeType)
            {
            case FileEntryType.Serialized:
            {
                SerializedFileScheme serializedScheme = (SerializedFileScheme)scheme;
                SerializedFile       file             = serializedScheme.ReadFile(collection, manager);
                m_serializedFiles.Add(file);
                OnSerializedFileAdded(file);
            }
            break;

            case FileEntryType.Bundle:
            {
                BundleFileScheme bundleScheme = (BundleFileScheme)scheme;
                BundleFile       bundle       = bundleScheme.ReadFile(collection, manager);
                m_fileLists.Add(bundle);
                OnFileListAdded(bundle);
            }
            break;

            case FileEntryType.Archive:
            {
                ArchiveFileScheme archiveScheme = (ArchiveFileScheme)scheme;
                ArchiveFile       archive       = archiveScheme.ReadFile(collection, manager);
                m_fileLists.Add(archive);
                OnFileListAdded(archive);
            }
            break;

            case FileEntryType.Web:
            {
                WebFileScheme webScheme = (WebFileScheme)scheme;
                WebFile       webFile   = webScheme.ReadFile(collection, manager);
                m_fileLists.Add(webFile);
                OnFileListAdded(webFile);
            }
            break;

            case FileEntryType.Resource:
            {
                ResourceFileScheme resourceScheme = (ResourceFileScheme)scheme;
                ResourceFile       resource       = resourceScheme.ReadFile();
                m_resourceFiles.Add(resource);
                OnResourceFileAdded(resource);
            }
            break;

            default:
                throw new NotSupportedException(scheme.SchemeType.ToString());
            }
        }
Exemplo n.º 25
0
 public AssemblyManagerWrapper(IAssemblyManager assemblyManager, Action <string> requestAssemblyCallback)
 {
     if (assemblyManager == null)
     {
         throw new ArgumentNullException(nameof(assemblyManager));
     }
     if (requestAssemblyCallback == null)
     {
         throw new ArgumentNullException(nameof(requestAssemblyCallback));
     }
     m_assemblyManager         = assemblyManager;
     m_requestAssemblyCallback = requestAssemblyCallback;
 }
Exemplo n.º 26
0
        public void Load(IServiceProvider serviceProvider)
        {
            this._windowManager = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
            _assemblyBrowser = (IAssemblyBrowser)serviceProvider.GetService(typeof(IAssemblyBrowser));
            _assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));

            this._commandBarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
            _commandBarManager.CommandBars["Browser.Assembly"].Items.AddButton("Browse Assembly", BrowseAssemblyHandler);
            _commandBarManager.CommandBars["Browser.Assembly"].Items.AddButton("Browse Dependencies", BrowseDependenciesHandler);
            _commandBarManager.CommandBars["Browser.TypeDeclaration"].Items.AddButton("Browse Ancestry", BrowseAncestryHandler);
            _commandBarManager.CommandBars["Browser.TypeDeclaration"].Items.AddButton("Browse Interactions", BrowseInteractionsHandler);
            _commandBarManager.CommandBars["Browser.TypeDeclaration"].Items.AddButton("Visualize Descendants", VisualizeDescendantsHandler);
        }
Exemplo n.º 27
0
        public void Load(IServiceProvider serviceProvider)
        {
            this._windowManager = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
            _assemblyBrowser    = (IAssemblyBrowser)serviceProvider.GetService(typeof(IAssemblyBrowser));
            _assemblyManager    = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));

            this._commandBarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
            _commandBarManager.CommandBars["Browser.Assembly"].Items.AddButton("Browse Assembly", BrowseAssemblyHandler);
            _commandBarManager.CommandBars["Browser.Assembly"].Items.AddButton("Browse Dependencies", BrowseDependenciesHandler);
            _commandBarManager.CommandBars["Browser.TypeDeclaration"].Items.AddButton("Browse Ancestry", BrowseAncestryHandler);
            _commandBarManager.CommandBars["Browser.TypeDeclaration"].Items.AddButton("Browse Interactions", BrowseInteractionsHandler);
            _commandBarManager.CommandBars["Browser.TypeDeclaration"].Items.AddButton("Visualize Descendants", VisualizeDescendantsHandler);
        }
Exemplo n.º 28
0
        public SerializedFile ReadFile(IFileCollection collection, IAssemblyManager manager)
        {
            SerializedFile file = new SerializedFile(collection, manager, this);

            using (PartialStream stream = new PartialStream(m_stream, m_offset, m_size))
            {
                EndianType endianess = Header.SwapEndianess ? EndianType.BigEndian : EndianType.LittleEndian;
                using (EndianReader reader = new EndianReader(stream, endianess, stream.Position))
                {
                    file.Read(reader);
                }
            }
            return(file);
        }
Exemplo n.º 29
0
        private void LoadAssembies()
        {
            IServiceProvider serviceProvider  = new Reflector.ApplicationManager(new FakeReflectorWindowManager());
            IServiceProvider serviceProvider2 = new Reflector.ApplicationManager(new FakeReflectorWindowManager());
            IAssemblyManager assemblyManager  = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
            IAssemblyManager assemblyManager2 = (IAssemblyManager)serviceProvider2.GetService(typeof(IAssemblyManager));

            Oassm = assemblyManager.LoadFile(OriginalAssembly.ItemSpec);
            Nassm = assemblyManager2.LoadFile(NewAssembly.ItemSpec);
            if (Oassm == Nassm)
            {
                throw new ArgumentException();
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
         _assemblyBrowser   = null;
         _assemblyManager   = null;
         _languageManager   = null;
         _TranslatorManager = null;
     }
     base.Dispose(disposing);
 }
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if ( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
				_assemblyBrowser = null;
				_assemblyManager  = null;
				_languageManager = null;
				_TranslatorManager  = null;
			}
			base.Dispose( disposing );
		}
        public void Load(IServiceProvider serviceProvider)
        {
            CodeMetricWindow codeMetricWindow = new CodeMetricWindow(serviceProvider);

            this.windowManager       = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
            this.windowManager.Load += new EventHandler(this.WindowManager_Load);
            this.windowManager.Windows.Add("CodeMetricWindow", codeMetricWindow, "Code Metrics");

            this.assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
            this.assemblyCache   = (IAssemblyCache)serviceProvider.GetService(typeof(IAssemblyCache));

            this.commandBarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
            this.separator         = this.commandBarManager.CommandBars["Tools"].Items.AddSeparator();
            this.button            = this.commandBarManager.CommandBars["Tools"].Items.AddButton("&Code Metrics", new EventHandler(this.Button_Click), Keys.Control | Keys.E);
        }
Exemplo n.º 33
0
        /// <summary>
        /// Loads available assemblies.
        /// </summary>
        internal static void LoadAssemblies()
        {
            using (var container = ContextScopeProvider.CreateChildContainer())
            {
                if (container == null)
                {
                    throw new CmsException("Better CMS dependencies container is not initialized.");
                }

                if (HostingEnvironment.IsHosted)
                {
                    HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourcesVirtualPathProvider(container.Resolve <IEmbeddedResourcesProvider>()));
                }
                else
                {
                    throw new CmsException("Failed to register EmbeddedResourcesVirtualPathProvider as a virtual path provider.");
                }

                ControllerBuilder.Current.SetControllerFactory(container.Resolve <DefaultCmsControllerFactory>());

                IAssemblyManager assemblyManager = container.Resolve <IAssemblyManager>();

                // First add referenced modules...
                assemblyManager.AddReferencedModules();

                // ...then scan and register uploaded modules.
                assemblyManager.AddUploadedModules();

                var moduleRegistration = container.Resolve <IModulesRegistration>();
                moduleRegistration.InitializeModules();

                // Register precompiled views for all the assemblies
                var precompiledAssemblies = new List <PrecompiledViewAssembly>();
                moduleRegistration.GetModules().Select(m => m.ModuleDescriptor).Distinct().ForEach(
                    descriptor =>
                {
                    var precompiledAssembly = new PrecompiledViewAssembly(descriptor.GetType().Assembly, string.Format("~/Areas/{0}/", descriptor.AreaName))
                    {
                        UsePhysicalViewsIfNewer = false
                    };
                    precompiledAssemblies.Add(precompiledAssembly);
                });

                var engine = new CompositePrecompiledMvcEngine(precompiledAssemblies.ToArray());
                ViewEngines.Engines.Insert(0, engine);
                VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
            }
        }
 public FileDisassemblerHelper(
     IAssemblyManager assemblyManager,
     ITranslatorManager TranslatorManager,
     ILanguageManager languageManager,
     int projectType,
     string outputDirectory,
     WriteLineDelegate writeLineDelegate,
     SetProgressBarDelegate setProgressBarDelegate)
 {
     _assemblyManager = assemblyManager;
     _TranslatorManager = TranslatorManager;
     _languageManager = languageManager;
     _projectType = projectType;
     _outputDirectory = outputDirectory;
     WriteLine += writeLineDelegate;
     SetProgressBar += setProgressBarDelegate;
 }
Exemplo n.º 35
0
        internal SerializedFile(IFileCollection collection, IAssemblyManager manager, SerializedFileScheme scheme)
        {
            Collection      = collection ?? throw new ArgumentNullException(nameof(collection));
            AssemblyManager = manager ?? throw new ArgumentNullException(nameof(manager));
            FilePath        = scheme.FilePath;
            NameOrigin      = scheme.Name;
            Name            = FilenameUtils.FixFileIdentifier(scheme.Name);
            Flags           = scheme.Flags;

            Header   = scheme.Header;
            Metadata = scheme.Metadata;

            for (int i = 0; i < Metadata.Entries.Length; i++)
            {
                m_assetEntryLookup.Add(Metadata.Entries[i].PathID, i);
            }
        }
Exemplo n.º 36
0
        private static void transportAssembly(IAssemblyManager aManager)
        {
            Console.WriteLine("  Getting executing assembly");
            System.Reflection.Assembly assy         = System.Reflection.Assembly.GetExecutingAssembly();
            IObservable <AssemblyName> dependencies = Resolver.GetAllDependencies(assy.GetName());

            dependencies.Subscribe(an =>
            {
                String path = new Uri(an.CodeBase).LocalPath;
                Console.WriteLine("    Transmitting assembly as FileStream ({0} bytes, {1})", new FileInfo(path).Length, path);
                using (Stream assyFileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    Assembly msg = new Assembly {
                        AssemblyStream = assyFileStream, Name = an.Name, FullName = an.FullName
                    };
                    aManager.AddAssembly(msg);
                }
            });
        }
Exemplo n.º 37
0
        private static void transportAssembly(IAssemblyManager aManager)
        {
            Console.WriteLine("  Getting executing assembly");
            AssemblyName start = AssemblyName.GetAssemblyName("..\\..\\..\\Instructions.Reference.Client\\bin\\Debug\\Instructions.Reference.Client.dll");
            IObservable <AssemblyName> dependencies = Resolver.GetAllDependencies(start);

            dependencies.Subscribe(an =>
            {
                String path = new Uri(an.CodeBase).LocalPath;
                Console.WriteLine("    Transmitting assembly as FileStream ({0} bytes, {1})", new FileInfo(path).Length, path);
                using (Stream assyFileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    Dispatcher.Contracts.Message.Assembly msg = new Assembly {
                        AssemblyStream = assyFileStream, Name = an.Name, FullName = an.FullName
                    };
                    aManager.AddAssembly(msg);
                }
            });
        }
		public FileDisassemblerHelper(
			IAssemblyManager assemblyManager,
			ITranslatorManager TranslatorManager,
			ILanguageManager languageManager,
			int projectType,
			string outputDirectory,
			WriteLineDelegate writeLineDelegate,
			SetProgressBarDelegate setProgressBarDelegate, bool documentation, bool membersBody, bool publicOnly)
		{
			_assemblyManager = assemblyManager;
			_TranslatorManager = TranslatorManager;
			_languageManager = languageManager;
			_projectType = projectType;
			_outputDirectory = outputDirectory;
			this.documentation = documentation;
			this.membersBody = membersBody;
			this.publicOnly = publicOnly;
			WriteLine += writeLineDelegate;
			SetProgressBar += setProgressBarDelegate;
		}
Exemplo n.º 39
0
 public Reflector(IAssemblyManager manager, IAssemblyBrowser browser, IWindowManager windowManager)
 {
     this._manager = manager;
     this._browser = browser;
     _windowManager = windowManager;
 }
Exemplo n.º 40
0
 public SandboxAssemblyManager(IAssemblyManager orig)
 {
     _orig = orig;
     _orig.BeforeAddAssembly += beforeAddAssembly;
     _orig.BeforeAddType += beforeAddType;
 }
Exemplo n.º 41
0
 public void Dispose()
 {
     if (_orig != null)
     _orig.Dispose();
     _orig = null;
 }
Exemplo n.º 42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InstructionDataPopulator"/> class.
 /// </summary>
 /// <param name="assemblyManager">The assembly manager.</param>
 internal InstructionDataPopulator(IAssemblyManager assemblyManager)
 {
   this.assemblyManager = assemblyManager;
   IVisibilityConfiguration visibility = new OmniVisibilityConfiguration();
   this.derivedTypeInformation = new DerivedTypeInformation(this.assemblyManager, visibility);
 }
        //private IAssemblyResolver _originalResolver;

        public AssemblyResolver(IAssemblyManager assemblyManager)
        {
            //_originalResolver = assemblyManager.Resolver;
            _assemblyManager = assemblyManager;
        }
        public object Resolve(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            switch (this.type)
            {
                case CodeIdentifierType.None:
                    return null;

                case CodeIdentifierType.Assembly:
                    return this.ResolveAssembly(assemblyManager, assemblyCache);

                case CodeIdentifierType.Module:
                    return this.ResolveModule(assemblyManager, assemblyCache);

                case CodeIdentifierType.Resource:
                    return this.ResolveResource(assemblyManager, assemblyCache);

                case CodeIdentifierType.Type:
                    return this.ResolveTypeDeclaration(assemblyManager, assemblyCache);

                case CodeIdentifierType.Field:
                    return this.ResolveFieldDeclaration(assemblyManager, assemblyCache);

                case CodeIdentifierType.Method:
                    return this.ResolveMethodDeclaration(assemblyManager, assemblyCache);

                case CodeIdentifierType.Property:
                    return this.ResolvePropertyDeclaration(assemblyManager, assemblyCache);

                case CodeIdentifierType.Event:
                    return this.ResolveEventDeclaration(assemblyManager, assemblyCache);
            }

            throw new NotSupportedException("Unable to resolve code identifier.");
        }
        private IAssembly ResolveAssembly(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            IAssemblyReference assemblyReference = this.ParseAssemblyReference(this.assembly, assemblyManager);

            for (int i = 0; i < assemblyManager.Assemblies.Count; i++)
            {
                IAssembly assembly = assemblyManager.Assemblies[i];
                if (assembly.Equals(assemblyReference))
                {
                    return assembly;
                }
            }

            if (assemblyCache != null)
            {
                string location = assemblyCache.QueryLocation(assemblyReference, null);
                if ((location != null) && (location.Length > 0))
                {
                    IAssembly assembly = assemblyManager.LoadFile(location);
                    return assembly;
                }
            }

            return null;
        }
        private IModule ResolveModule(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            IAssembly assembly = this.ResolveAssembly(assemblyManager, assemblyCache);
            if (assembly != null)
            {
                string moduleName = this.item;

                foreach (IModule module in assembly.Modules)
                {
                    if (moduleName == module.Name)
                    {
                        return module;
                    }
                }
            }

            return null;
        }
        private IResource ResolveResource(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            IAssembly assembly = this.ResolveAssembly(assemblyManager, assemblyCache);
            if (assembly != null)
            {
                string resourceName = this.item;

                foreach (IResource resource in assembly.Resources)
                {
                    if (resourceName == resource.Name)
                    {
                        return resource;
                    }
                }
            }

            return null;
        }
        private ITypeDeclaration ResolveTypeDeclaration(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            IAssembly[] assemblyList = new IAssembly[assemblyManager.Assemblies.Count];
            assemblyManager.Assemblies.CopyTo(assemblyList, 0);

            if ((this.assembly != null) && (this.assembly.Length > 0))
            {
                IAssembly assembly = this.ResolveAssembly(assemblyManager, assemblyCache);
                assemblyList = (assembly != null) ? new IAssembly[] { assembly } : new IAssembly[0];
            }

            string typeName = this.item;

            foreach (IAssembly assembly in assemblyList)
            {
                foreach (IModule module in assembly.Modules)
                {
                    foreach (ITypeDeclaration typeDeclaration in module.Types)
                    {
                        foreach (ITypeDeclaration currentType in GetNestedTypeList(typeDeclaration))
                        {
                            string text = this.GetTypeReferenceText(currentType);
                            if (typeName == text)
                            {
                                return currentType;
                            }
                        }
                    }
                }
            }

            return null;
        }
        private IFieldDeclaration ResolveFieldDeclaration(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            ITypeDeclaration typeDeclaration = this.ResolveTypeDeclaration(assemblyManager, assemblyCache);
            if (typeDeclaration != null)
            {
                string fieldName = this.member;

                foreach (IFieldDeclaration fieldDeclaration in typeDeclaration.Fields)
                {
                    string text = this.GetFieldReferenceText(fieldDeclaration);
                    if (fieldName == text)
                    {
                        return fieldDeclaration;
                    }
                }
            }

            return null;
        }
        private IMethodDeclaration ResolveMethodDeclaration(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            ITypeDeclaration typeDeclaration = this.ResolveTypeDeclaration(assemblyManager, assemblyCache);
            if (typeDeclaration != null)
            {
                string methodName = this.member;

                foreach (IMethodDeclaration methodDeclaration in typeDeclaration.Methods)
                {
                    string text = this.GetMethodReferenceText(methodDeclaration);
                    if (methodName == text)
                    {
                        return methodDeclaration;
                    }
                }
            }

            return null;
        }
        private IPropertyDeclaration ResolvePropertyDeclaration(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            ITypeDeclaration typeDeclaration = this.ResolveTypeDeclaration(assemblyManager, assemblyCache);
            if (typeDeclaration != null)
            {
                string propertyName = this.member;

                foreach (IPropertyDeclaration propertyDeclaration in typeDeclaration.Properties)
                {
                    string text = this.GetPropertyReferenceText(propertyDeclaration);
                    if (propertyName == text)
                    {
                        return propertyDeclaration;
                    }
                }
            }

            return null;
        }
        private IAssemblyReference ParseAssemblyReference(string value, IAssemblyManager assemblyManager)
        {
            string[] assemblyNameParts = this.assembly.Split(new char[] { ':' });

            IAssembly assembly = new Assembly();
            assembly.AssemblyManager = assemblyManager;

            IModule module = new Module();
            module.Assembly = assembly;

            IAssemblyReference assemblyReference = new AssemblyReference();
            assemblyReference.Context = module;
            assemblyReference.Name = assemblyNameParts[0];
            assemblyReference.Version = ((assemblyNameParts.Length > 1) && (assemblyNameParts[1].Length > 0)) ? new Version(assemblyNameParts[1]) : new Version(0, 0, 0, 0);
            assemblyReference.PublicKeyToken = ((assemblyNameParts.Length > 2) && (assemblyNameParts[2].Length > 0)) ? ParseByteArray(assemblyNameParts[2]) : new byte[0];
            assemblyReference.Culture = ((assemblyNameParts.Length > 3) && (assemblyNameParts[3].Length > 0)) ? assemblyNameParts[3] : string.Empty;

            return assemblyReference;
        }
        private IEventDeclaration ResolveEventDeclaration(IAssemblyManager assemblyManager, IAssemblyCache assemblyCache)
        {
            ITypeDeclaration typeDeclaration = this.ResolveTypeDeclaration(assemblyManager, assemblyCache);
            if (typeDeclaration != null)
            {
                string eventName = this.member;

                foreach (IEventDeclaration eventDeclaration in typeDeclaration.Events)
                {
                    string text = this.GetEventReferenceText(eventDeclaration);
                    if (eventName == text)
                    {
                        return eventDeclaration;
                    }
                }
            }

            return null;
        }