Esempio n. 1
0
		public ILSpyTreeNode CreateNode(Resource resource)
		{
			EmbeddedResource er = resource as EmbeddedResource;
			if (er != null)
				return CreateNode(er.Name, er.GetResourceStream());
			return null;
		}
Esempio n. 2
0
		Stream LoadBaml(Resource res, string name)
		{
			EmbeddedResource er = res as EmbeddedResource;
			if (er != null) {
				Stream s = er.GetResourceStream();
				s.Position = 0;
				ResourceReader reader;
				try {
					reader = new ResourceReader(s);
				}
				catch (ArgumentException) {
					return null;
				}
				foreach (DictionaryEntry entry in reader.Cast<DictionaryEntry>().OrderBy(e => e.Key.ToString())) {
					if (entry.Key.ToString() == name) {
						if (entry.Value is Stream)
							return (Stream)entry.Value;
						if (entry.Value is byte[])
							return new MemoryStream((byte[])entry.Value);
					}
				}
			}
			
			return null;
		}
Esempio n. 3
0
 internal QueryableResource(Resource resource, QueryableModule module)
 {
     _assembly = module.Assembly;
     _module = module;
     _name = Utility.ToString(resource.Name);
     _resourceType = Utility.ConvertEnum<ResourceType>(resource.ResourceType);
     _isPublic = resource.IsPublic;
 }
Esempio n. 4
0
		public ILSpyTreeNode CreateNode(Resource resource)
		{
			EmbeddedResource er = resource as EmbeddedResource;
			if (er != null && er.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) {
				return new ResourcesFileTreeNode(er);
			}
			return null;
		}
Esempio n. 5
0
 public static ILSpyTreeNode Create(Resource resource)
 {
     ILSpyTreeNode result = null;
     foreach (var factory in App.CompositionContainer.GetExportedValues<IResourceNodeFactory>()) {
         result = factory.CreateNode(resource);
         if (result != null)
             break;
     }
     return result ?? new ResourceTreeNode(resource);
 }
Esempio n. 6
0
        public ILSpyTreeNode CreateNode(Mono.Cecil.Resource resource)
        {
            EmbeddedResource er = resource as EmbeddedResource;

            if (er != null)
            {
                return(CreateNode(er.Name, er.GetResourceStream()));
            }
            return(null);
        }
        static bool IsMonoTouchResource(Resource resource)
        {
            if (!(resource is EmbeddedResource))
                return false;

            var name = resource.Name;

            if (name.StartsWith ("__monotouch_content_", StringComparison.OrdinalIgnoreCase))
                return true;

            if (name.StartsWith ("__monotouch_page_", StringComparison.OrdinalIgnoreCase))
                return true;

            return false;
        }
Esempio n. 8
0
        private static void ReplaceResource(
            ModuleDefinition module,
            int resIndex,
            Resource resource,
            MemoryStream memoryStream,
            ResourceWriter rw)
        {
            module.Resources.RemoveAt(resIndex);
            rw.Generate();
            var array = memoryStream.ToArray();
            memoryStream.Position = 0;
            var newEmbeded = new EmbeddedResource(resource.Name, resource.Attributes, array);

            module.Resources.Insert(resIndex, newEmbeded);
        }
Esempio n. 9
0
 public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
 {
     Mono.Cecil.Resource resource = (Mono.Cecil.Resource)dataObject;
     nodeInfo.Label = resource.Name;
     nodeInfo.Icon  = Context.GetIcon(Stock.ResourceFileIcon);
 }
Esempio n. 10
0
        public void Add(Resource resource)
        {
            Contract.Requires(resource != null, "resource is null");

            do
            {
                AssemblyLinkedResource alr = resource as AssemblyLinkedResource;
                if (alr != null)
                {
                    m_resources.Add(new AssemblyResourceItem(alr));
                    break;
                }

                EmbeddedResource er = resource as EmbeddedResource;
                if (er != null)
                {
                    m_resources.Add(new EmbeddedResourceItem(er));
                    break;
                }

                LinkedResource lr = resource as LinkedResource;
                if (lr != null)
                {
                    m_resources.Add(new LinkedResourceItem(lr));
                    break;
                }

                Contract.Assert(false, "bad resource type: " + resource.GetType());
            }
            while (false);
        }
 public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
 {
     Mono.Cecil.Resource resource = (Mono.Cecil.Resource)dataObject;
     label = resource.Name;
     icon  = Context.GetIcon(Stock.ResourceFileIcon);
 }
Esempio n. 12
0
 public ResourceEventArgs(Resource item)
 {
     m_item = item;
 }
Esempio n. 13
0
		public void Insert (int index, Resource value)
		{
			List.Insert (index, value);
		}
Esempio n. 14
0
		public bool Contains (Resource value)
		{
			return m_items.Contains (value);
		}
Esempio n. 15
0
partial         void logRenamingResource(Resource resource, string newName);
 public ResourceTreeNode(Resource r)
 {
     this.LazyLoading = true;
     this.r = r;
 }
        public void InitResource(Resource r)
        {
            BaseAssemblyResolver bar = GlobalAssemblyResolver.Instance as BaseAssemblyResolver;
            bool savedRaiseResolveException = true;
            try
            {
                if (bar != null)
                {
                    savedRaiseResolveException = bar.RaiseResolveException;
                    bar.RaiseResolveException = false;
                }

                detailsTabPage.SuspendLayout();

                dgResource.SuspendLayout();
                _dtResource.Rows.Clear();

                if (r == null)
                {
                    return;
                }

                _dtResource.BeginLoadData();

                ShowResource(r);

                if (dgResource.DataSource == null)
                    dgResource.DataSource = _dtResource;

                _dtResource.EndLoadData();
            }
            catch
            {
                throw;
            }
            finally
            {
                if (bar != null)
                {
                    bar.RaiseResolveException = savedRaiseResolveException;
                }
                dgResource.ResumeLayout();
                detailsTabPage.ResumeLayout();
            }
        }
 private void ShowResource(Resource r)
 {
     switch (r.ResourceType)
     {
         case ResourceType.Embedded:
             ShowResource((EmbeddedResource)r);
             break;
         case ResourceType.AssemblyLinked:
             ShowResource((AssemblyLinkedResource)r);
             break;
         case ResourceType.Linked:
             ShowResource((LinkedResource)r);
             break;
         default:
             throw new NotSupportedException("Resource type is not supported: " + r.ResourceType.ToString());
     }
 }
        public static Reflector.CodeModel.IResource Cecil2Reflector(Resource r, ModuleDefinition md)
        {
            Reflector.CodeModel.IModule m = Cecil2Reflector(md);
            if (m == null) return null;

            string erName = r.Name;
            
            foreach (Reflector.CodeModel.IResource r2 in m.Assembly.Resources)
            {
                if (r2.Name == erName)
                {
                    return r2;
                }
            }
            return null;
        }     
Esempio n. 20
0
 public RenameInfo(Resource resource, TypeInfo typeInfo, string newResourceName)
 {
     this.resource = resource;
     this.typeInfo = typeInfo;
     this.newResourceName = newResourceName;
 }
Esempio n. 21
0
		public int IndexOf (Resource value)
		{
			return m_items.IndexOf (value);
		}
Esempio n. 22
0
		public ResourceTreeNode(Resource r)
		{
			if (r == null)
				throw new ArgumentNullException("r");
			this.r = r;
		}
Esempio n. 23
0
 public ResourceReference(Resource res)
 {
     this.res = res;
 }
Esempio n. 24
0
		public void Remove (Resource value)
		{
			if (OnResourceRemoved != null && this.Contains (value))
				OnResourceRemoved (this, new ResourceEventArgs (value));
			m_items.Remove (value);
		}
Esempio n. 25
0
		/// <summary>
		/// Rename a resource
		/// </summary>
		/// <param name="resource">Resource definition</param>
		/// <param name="name">new name</param>
		private static void RenameResource(Resource resource, string name)
		{
			resource.Name = name;
		}
Esempio n. 26
0
		public void Add (Resource value)
		{
			if (OnResourceAdded != null && !this.Contains (value))
				OnResourceAdded (this, new ResourceEventArgs (value));
			m_items.Add (value);
		}
Esempio n. 27
0
		public bool Contains (Resource value)
		{
			return List.Contains (value);
		}
Esempio n. 28
0
		public void Insert (int index, Resource value)
		{
			if (OnResourceAdded != null && !this.Contains (value))
				OnResourceAdded (this, new ResourceEventArgs (value));
			m_items.Insert (index, value);
		}
Esempio n. 29
0
 public static Resource InjectResource(this ModuleDefinition module, Resource resource)
 {
     if (!module.Resources.Contains(resource))
         module.Resources.Add(resource);
     return resource;
 }
Esempio n. 30
0
        public ILSpyTreeNode FindResourceNode(Resource resource)
        {
            if (resource == null)
                return null;
            foreach (AssemblyTreeNode node in this.Children)
            {
                if (node.LoadedAssembly.IsLoaded)
                {
                    node.EnsureLazyChildren();
                    foreach (var item in node.Children.OfType<ResourceListTreeNode>())
                    {
                        var founded = item.Children.OfType<ResourceTreeNode>().Where(x => x.Resource == resource).FirstOrDefault();
                        if (founded != null)
                            return founded;

                        var foundedResEntry = item.Children.OfType<ResourceEntryNode>().Where(x => resource.Name.Equals(x.Text)).FirstOrDefault();
                        if (foundedResEntry != null)
                            return foundedResEntry;
                    }
                }
            }
            return null;
        }
Esempio n. 31
0
		public void Add (Resource value)
		{
			List.Add (value);
		}
 private void BuildResource(DynamicModule module, Resource resource)
 {
     resource.Accept(new DynamicResourceBuilder(module));
 }
Esempio n. 33
0
		public int IndexOf (Resource value)
		{
			return List.IndexOf (value);
		}
 public override string GetNodeName(ITreeNavigator thisNode, object dataObject)
 {
     Mono.Cecil.Resource resource = (Mono.Cecil.Resource)dataObject;
     return(resource.Name);
 }
Esempio n. 35
0
		public void Remove (Resource value)
		{
			List.Remove (value);
		}
Esempio n. 36
0
 public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
 {
     Mono.Cecil.Resource resource = (Mono.Cecil.Resource)dataObject;
     nodeInfo.Label = Ide.TypeSystem.Ambience.EscapeText(resource.Name);
     nodeInfo.Icon  = Context.GetIcon(Stock.ResourceFileIcon);
 }