コード例 #1
0
        public static void AddJsonKnown <T>(this DiscriminatorValues discriminatorValues)
        {
            var attrs = AttributesManager.GetJsonKnownAttributes(typeof(T));

            foreach (var attr in attrs)
            {
                var discriminator = attr.Discriminator ?? attr.Type.Name;
                discriminatorValues.AddType(attr.Type, discriminator);
            }
        }
コード例 #2
0
 public static void AddJsonKnownThis(this DiscriminatorValues discriminatorValues, Type[] inherited)
 {
     foreach (var type in inherited)
     {
         var attr = AttributesManager.GetJsonKnownThisAttribute(type);
         if (attr != null)
         {
             var discriminator = attr.Discriminator ?? type.Name;
             discriminatorValues.AddType(type, discriminator);
         }
     }
 }
コード例 #3
0
        public static void AddAutoDiscriminators(this DiscriminatorValues discriminatorValues, Type[] inherited)
        {
            foreach (var type in inherited)
            {
                if (discriminatorValues.Contains(type))
                {
                    continue;
                }

                discriminatorValues.AddType(type, type.Name);
            }
        }
コード例 #4
0
        internal static void AddJsonKnown <T>(this DiscriminatorValues discriminatorValues)
        {
            var attrs = AttributesManager.GetJsonKnownAttributes(typeof(T));

            foreach (var attr in attrs)
            {
                var discriminator = attr.Discriminator ?? attr.Type.Name;
                discriminatorValues.AddType(attr.Type, discriminator);
            }

            var fallbackTypeAttribute = AttributesManager.GetJsonKnownTypeFallbackAttribute(typeof(T));

            if (fallbackTypeAttribute != null)
            {
                discriminatorValues.AddFallbackType(fallbackTypeAttribute.FallbackType);
            }
        }