protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) { JsonProperty prop = base.CreateProperty(member, memberSerialization); if (prop.ToString() == "DataCreate") { prop.Ignored = true; } if (prop.ToString() == "DateCreate") { prop.Ignored = true; } return(prop); }
/// <summary> /// 将枚举类型转化为JSON字符串 /// </summary> /// <returns></returns> public static string GetJson(Type type) { List <ReadEnum> list = EnumHelper.GetEnumList(type); JsonProperty property = new JsonProperty(); foreach (ReadEnum item in list) { JsonObject jsonItem = new JsonObject(); jsonItem.AddProperty("Name", item.Name); jsonItem.AddProperty("Value", item.Value); jsonItem.AddProperty("Description", item.Description); property.Add(jsonItem); } return(property.ToString()); }
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) { JsonProperty property = base.CreateProperty(member, memberSerialization); // substituting message in MutualAidDetail if (property.DeclaringType == typeof(MutualAidDetail) && property.PropertyName == "Message") { foreach (Type T in runtime) { Type derive = T; string t = property.UnderlyingName; string y = property.ToString(); // Get Property name based on derived type if (derive == typeof(AidRequested)) { property.PropertyName = Constants.MaidPrefix + "--" + "AidRequested"; property.ShouldSerialize = instance => { return(true); }; } else if (derive == typeof(AidResponding)) { property.PropertyName = Constants.MaidPrefix + "--" + "AidResponding"; property.ShouldSerialize = instance => { return(true); }; } } } // substituting request in RequestedResources if (property.DeclaringType == typeof(RequestedResources) && property.PropertyName == "resource") { foreach (Type T in runtime) { Type derive = T; // setting new name based on runtime type if (derive == typeof(SpecificResource)) { property.PropertyName = Constants.MaidPrefix + "--" + "AidRequestedSpecificResource"; property.ShouldSerialize = instance => { return(true); }; } else if (derive == typeof(GenericResource)) { property.PropertyName = Constants.MaidPrefix + "--" + "AidRequestedGenericResource"; property.ShouldSerialize = instance => { return(true); }; } else if (derive == typeof(MissionNeed)) { property.PropertyName = Constants.MaidPrefix + "--" + "AidRequestedMissionNeed"; property.ShouldSerialize = instance => { return(true); }; } } } // substituting request in RespondingResources if (property.DeclaringType == typeof(RespondingResource) && property.PropertyName == "resource") { foreach (Type T in runtime) { Type derive = T; // setting new name based on runtime type if (derive == typeof(Person)) { property.PropertyName = Constants.MaidPrefix + "--" + "AidRespondingPerson"; property.ShouldSerialize = instance => { return(true); }; } else if (derive == typeof(Equipment)) { property.PropertyName = Constants.MaidPrefix + "--" + "AidRespondingEquipment"; property.ShouldSerialize = instance => { return(true); }; } } } // substituting AreaRegion in LocationExtension if (property.DeclaringType == typeof(LocationExtension) && property.PropertyName == "AreaRegion") { foreach (Type T in runtime) { Type derive = T; // setting new name based on runtime type if (derive == typeof(LocationEllipse)) { property.PropertyName = Constants.MofPrefix + "--" + "LocationEllipse"; property.ShouldSerialize = instance => { return(true); }; } else if (derive == typeof(LocationExternalPolygon)) { property.PropertyName = Constants.MofPrefix + "--" + "LocationExternalPolygon"; property.ShouldSerialize = instance => { return(true); }; } else if (derive == typeof(LocationLineString)) { property.PropertyName = Constants.MofPrefix + "--" + "LocationLineString"; property.ShouldSerialize = instance => { return(true); }; } } } return(property); }