Exemplo n.º 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);
		}
Exemplo n.º 2
0
		public static string ToString(this XamlContext ctx, XElement elem, XamlType type) {
			type.ResolveNamespace(elem, ctx);
			return ctx.ToString(elem, type.ToXName(ctx));
		}