public void Add(MappedMember member) { var serializationSettings = member.MappingState.SerializationSettings.Clone(); var vm = new ValueMember(member.MainValue, serializationSettings, member.Member, this.Type, _model); #if WINRT TypeInfo finalType = _typeInfo; #else Type finalType = this.Type; #endif PropertyInfo prop = Helpers.GetProperty(finalType, member.Member.Name + "Specified", true); MethodInfo getMethod = Helpers.GetGetMethod(prop, true, true); if (getMethod == null || getMethod.IsStatic) { prop = null; } if (prop != null) { vm.SetSpecified(getMethod, Helpers.GetSetMethod(prop, true, true)); } else { MethodInfo method = Helpers.GetInstanceMethod(finalType, "ShouldSerialize" + member.Member.Name, Helpers.EmptyTypes); if (method != null && method.ReturnType == _model.MapType(typeof(bool))) { vm.SetSpecified(method, null); } } Add(vm); }
public void Compile(Mappings result, ModuleDefinition module) { foreach (var typeDefinition in module.GetAllTypes()) { var type = new MappedType(typeDefinition.FullName, GetOrDefault(typeDefinition.Name)); foreach (var methodDefinition in typeDefinition.Methods) { if (methodDefinition.Name.IsObfuscated() && !Names.ContainsKey(methodDefinition.Name)) { continue; // dead method } var method = new MappedMethod(methodDefinition, GetOrDefault(methodDefinition.Name)); foreach (var parameterDefinition in methodDefinition.Parameters) { method.Parameters.Add(GetOrDefault(parameterDefinition.Name) ?? parameterDefinition.Name); } if (!methodDefinition.Name.IsObfuscated() && !method.Parameters.Any()) { continue; } type.Methods.Add(method); } foreach (var fieldDefinition in typeDefinition.Fields) { var field = new MappedMember(fieldDefinition.Name, GetOrDefault(fieldDefinition.Name) ?? fieldDefinition.Name.Clean()); if (!fieldDefinition.Name.IsObfuscated() && fieldDefinition.Name == field.Mapped) { continue; } type.Fields.Add(field); } foreach (var propertyDefinition in typeDefinition.Properties) { var field = new MappedMember(propertyDefinition.Name, GetOrDefault(propertyDefinition.Name)); if (!propertyDefinition.Name.IsObfuscated()) { continue; } type.Properties.Add(field); } if (!typeDefinition.Name.IsObfuscated() && !type.Fields.Any() && !type.Methods.Any() && !type.Properties.Any() && !type.Nested.Any()) { continue; } result.Types.Add(type); } }
public bool Equals(MappedMember obj, bool compareOriginal = true) { if (obj == null) { return(false); } return(Mapped == obj.Mapped && (!compareOriginal || (Original.Name == "^" && obj.Mapped != null) || Original.Equals(obj.Original))); }