public MixinSerializationHelper(SerializationInfo info, StreamingContext context)
        {
            ArgumentUtility.CheckNotNull("info", info);

            _context = context;

            var identifierDeserializer = new SerializationInfoConcreteMixinTypeIdentifierDeserializer(info, "__identifier");
            var identifier             = ConcreteMixinTypeIdentifier.Deserialize(identifierDeserializer);

            var pipelineIdentifier = info.GetString("__participantConfigurationID");
            var pipeline           = SafeServiceLocator.Current.GetInstance <IPipelineRegistry>().Get(pipelineIdentifier);

            var mixinType = pipeline.ReflectionService.GetAdditionalType(identifier);

            _baseMemberValues = (object[])info.GetValue("__baseMemberValues", typeof(object[]));

            // Usually, instantiate a deserialized object using GetSafeUninitializedObject.
            // However, _baseMemberValues being null means that the object itself manages its member deserialization via ISerializable. In such a case, we
            // need to use the deserialization constructor to instantiate the object.
            if (_baseMemberValues != null)
            {
                _deserializedObject = FormatterServices.GetSafeUninitializedObject(mixinType);
            }
            else
            {
                Assertion.IsTrue(typeof(ISerializable).IsAssignableFrom(mixinType));
                _deserializedObject = Activator.CreateInstance(
                    mixinType,
                    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
                    null,
                    new object[] { info, context },
                    null);
            }
            SerializationImplementer.RaiseOnDeserializing(_deserializedObject, _context);
        }
        public void GetObjectDataForGeneratedTypes_SerializesIdentifier()
        {
            CallGetObjectDataForGeneratedTypes(true);
            var identifierDeserializer = new SerializationInfoConcreteMixinTypeIdentifierDeserializer(_serializationInfo, "__identifier");

            var deserializedIdentifier = ConcreteMixinTypeIdentifier.Deserialize(identifierDeserializer);

            Assert.That(deserializedIdentifier, Is.EqualTo(_identifier));
        }
        public void SetUp()
        {
            _simpleMethod  = typeof(BaseType1).GetMethod("VirtualMethod", Type.EmptyTypes);
            _genericMethod = typeof(BaseType7).GetMethod("One");
            _methodOnGenericClosedWithReferenceType = typeof(GenericClassWithAllKindsOfMembers <string>).GetMethod("Method");
            _methodOnGenericClosedWithValueType     = typeof(GenericClassWithAllKindsOfMembers <int>).GetMethod("Method");

            _serializationInfo = new SerializationInfo(typeof(ConcreteMixinTypeIdentifier), new FormatterConverter());
            _serializer        = new SerializationInfoConcreteMixinTypeIdentifierSerializer(_serializationInfo, "identifier");
            _deserializer      = new SerializationInfoConcreteMixinTypeIdentifierDeserializer(_serializationInfo, "identifier");
        }