예제 #1
0
		void RewriteClass(XamlContext ctx, XElement elem) {
			var type = elem.Annotation<XamlType>();
			if (type == null || type.ResolvedType == null)
				return;

			var typeDef = type.ResolvedType.ResolveTypeDef();
			var comparer = new AssemblyNameComparer(AssemblyNameComparerFlags.All);
			if (typeDef == null || !comparer.Equals(typeDef.DefinitionAssembly, ctx.Module.Assembly))
				return;

			var newType = typeDef.BaseType;
			var xamlType = new XamlType(newType.DefinitionAssembly, newType.ReflectionNamespace, newType.Name);
			xamlType.ResolveNamespace(elem, ctx);

			elem.Name = xamlType.ToXName(ctx);

			var attrName = ctx.GetXamlNsName("Class", elem);

			var attrs = elem.Attributes().ToList();
			if (typeDef.IsNotPublic) {
				var classModifierName = ctx.GetXamlNsName("ClassModifier", elem);
				attrs.Insert(0, new XAttribute(classModifierName, ctx.BamlDecompilerOptions.InternalClassModifier));
			}
			attrs.Insert(0, new XAttribute(attrName, type.ResolvedType.ReflectionFullName));
			elem.ReplaceAttributes(attrs);
		}
예제 #2
0
		public bool IsAttachedTo(XamlType type) {
			if (type == null || ResolvedMember == null || type.ResolvedType == null)
				return true;

			var declType = ResolvedMember.DeclaringType;
			var t = type.ResolvedType;
			var comparer = new SigComparer();
			do {
				if (comparer.Equals(t, declType))
					return false;
				t = t.GetBaseType();
			} while (t != null);
			return true;
		}
예제 #3
0
		public XamlType ResolveType(ushort id) {
			XamlType xamlType;
			if (typeMap.TryGetValue(id, out xamlType))
				return xamlType;

			ITypeDefOrRef type;
			IAssembly assembly;

			if (id > 0x7fff) {
				type = Baml.KnownThings.Types((KnownTypes)(-id));
				assembly = type.DefinitionAssembly;
			}
			else {
				var typeRec = Baml.TypeIdMap[id];
				assembly = Baml.ResolveAssembly(typeRec.AssemblyId);
				type = TypeNameParser.ParseReflectionThrow(Module, typeRec.TypeFullName, new DummyAssemblyRefFinder(assembly));
			}

			var clrNs = type.ReflectionNamespace;
			var xmlNs = XmlNs.LookupXmlns(assembly, clrNs);

			typeMap[id] = xamlType = new XamlType(assembly, clrNs, type.ReflectionName, GetXmlNamespace(xmlNs)) {
				ResolvedType = type
			};

			return xamlType;
		}
예제 #4
0
		public static string ToString(this XamlContext ctx, XElement elem, XamlType type) {
			type.ResolveNamespace(elem, ctx);
			return ctx.ToString(elem, type.ToXName(ctx));
		}
예제 #5
0
 public XamlExtension(XamlType type)
 {
     ExtensionType  = type;
     NamedArguments = new Dictionary <string, object>();
 }
예제 #6
0
 public XamlProperty(XamlType type, string name)
 {
     DeclaringType = type;
     PropertyName  = name;
 }
예제 #7
0
		public XamlExtension(XamlType type) {
			ExtensionType = type;
			NamedArguments = new Dictionary<string, object>();
		}
예제 #8
0
파일: XamlUtils.cs 프로젝트: mrdellis/dnSpy
 public static string ToString(this XamlContext ctx, XElement elem, XamlType type)
 {
     type.ResolveNamespace(elem, ctx);
     return(ctx.ToString(elem, type.ToXName(ctx)));
 }
예제 #9
0
		public XamlProperty(XamlType type, string name) {
			DeclaringType = type;
			PropertyName = name;
		}