public void InitializeUnconstructedInstance(object mixinTarget, InitializationSemantics initializationSemantics)
        {
            ArgumentUtility.CheckNotNull("mixinTarget", mixinTarget);
            ArgumentUtility.CheckType <IMixinTarget> ("mixinTarget", mixinTarget);

            _pipelineRegistry.DefaultPipeline.ReflectionService.PrepareExternalUninitializedObject(mixinTarget, initializationSemantics);
        }
示例#2
0
        public void PrepareExternalUninitializedObject(object instance, InitializationSemantics initializationSemantics)
        {
            ArgumentUtility.CheckNotNull("instance", instance);

            var initializableInstance = instance as IInitializableObject;

            if (initializableInstance != null)
            {
                initializableInstance.Initialize(initializationSemantics);
            }
        }
示例#3
0
        private void CallInitializeMixins(
            object instance, InitializationSemantics initializationSemantics, bool extensionsInitializedValue = false, object[] mixinInstances = null)
        {
            Assert.That(instance, Is.InstanceOf <IInitializableObject>());

            // Forces re-initialization if set to false.
            PrivateInvoke.SetNonPublicField(instance, "__extensionsInitialized", extensionsInitializedValue);

            if (mixinInstances != null)
            {
                PrivateInvoke.SetNonPublicField(instance, "__extensions", mixinInstances);
            }

            // This code depends on the implementation detail that we simple call the "__InitializeMixins" method frome the TypePipe Initialize method.
            ((IInitializableObject)instance).Initialize(initializationSemantics);
        }
 /// <summary>
 /// Initializes a mixin target instance which was created without its constructor having been called.
 /// </summary>
 /// <param name="mixinTarget">The mixin target to initialize.</param>
 /// <param name="initializationSemantics">The semantics to apply during initialization.</param>
 /// <exception cref="ArgumentNullException">The mixin target is <see langword="null"/>.</exception>
 /// <remarks>This method is useful when a mixin target instance is created via <see cref="FormatterServices.GetSafeUninitializedObject"/>.</remarks>
 public static void InitializeUnconstructedInstance(object mixinTarget, InitializationSemantics initializationSemantics)
 {
     LazyStaticFields.TypeFactoryImplementation.InitializeUnconstructedInstance(mixinTarget, initializationSemantics);
 }