Beispiel #1
0
        private bool OpenAsXml()
        {
            var content = new StreamReader(_source.OpenRead()).ReadToEnd();

            ContentViewerService.ShowSourceCode(_fileName, SourceLanguageType.Xaml, content);
            return(true);
        }
Beispiel #2
0
        private static TreeNode GenerateNode(AssemblyStream entry, string header)
        {
            var ext = Path.GetExtension(header);

            if (!string.IsNullOrWhiteSpace(ext))
            {
                ext = ext.ToLowerInvariant();
            }

            if (ext == ".dll")
            {
                var definition = AssemblyDefinition.ReadAssembly(entry.OpenRead());
                return(new AssemblyNode(definition, entry));
            }

            return(new FileNode(entry, header));
        }
Beispiel #3
0
    // TODO: Ask/warn user whether he wants to load assembly! Introduce settings option to enable/disable warning, add "Don't remind" on warning dialog
    private void DoLoadType(TreeNode<Resource> view, Resource definition)
    {
      var assembly = new AssemblyPart().Load(_assemblySource.OpenRead());
      if (assembly == null) return;

      //var resourceEntryName = assembly.GetManifestResourceNames().First();
      //var rm = new ResourceManager(resourceEntryName.Replace(".resources", ""), assembly);
      var rm = new ResourceManager(definition.Name.Replace(".resources", ""), assembly);

      //Seems like some issue here, but without getting any stream next statement doesn't work....
      var dummy = rm.GetStream("app.xaml");

      var rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, false, true);
      if (rs == null) return;
      
      var enumerator = rs.GetEnumerator();
      while (enumerator.MoveNext())
      {
        //view.Items.Add(new SimpleNode(DefaultImages.AssemblyBrowser.FileMisc, (string)enumerator.Key));
        var resourceName = (string)enumerator.Key;
        var resourceStream = new EmbeddedResourceStream(rs, resourceName);
        view.Items.Add(new FileNode(resourceStream, resourceName));
      }
    }