protected BixCore(string targetName) { var t = GetType(); while (t != null && t != typeof(BixCore <>)) { t = t.BaseType; } Aver.IsNotNull(t, "Internal error, BixCore<T> could not be found in derivation chain of {0}".Args(GetType().FullNameWithExpandedGenericArgs())); t = t.GetGenericArguments()[0]; //this is done here not to introduce extra virtual methods Attribute = BixAttribute.GetGuidTypeAttribute <TypedDoc, BixAttribute>(t); TargetedType = new TargetedType(targetName, t); }
/// <summary> /// Conditionally emits a BIX_DISCRIMINATOR field to the json map if the instance type is decorated with Bix attribute. /// Returns true when discriminator field was added /// </summary> public static bool EmitJsonBixDiscriminator(TypedDoc self, IDictionary <string, object> map) { if (self == null || map == null) { return(false); } var t = self.GetType(); var atr = BixAttribute.TryGetGuidTypeAttribute <TypedDoc, BixAttribute>(t); if (atr == null) { return(false); } map[BIX_DISCRIMINATOR] = atr.TypeGuid; return(true); }