/// <summary>
 /// Tracks if needed.
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="burden"></param>
 public override void Track(object instance, Burden burden)
 {
     if (nonTrackedTransientLifestyleType.Equals(burden.Model.CustomLifestyle)) {
         return;
     }
     base.Track(instance, burden);
 }
예제 #2
0
        public override void Track(object instance, Burden burden)
        {
            if (burden.Model.LifestyleType == LifestyleType.Custom
                && burden.Model.CustomLifestyle == typeof(UnmanagedLifestyleManager))
                return;

            base.Track(instance, burden);
        }
		/// <summary></summary>
		public override void Track(object instance, Burden burden) {
			ComponentModel model = burden.Model;
 
			// we skip the tracking for object marked with our custom Transient lifestyle manager
			if ((model.LifestyleType == LifestyleType.Custom) && (typeof(TrulyTransientLifestyle) == model.CustomLifestyle))
				return;
 
			base.Track(instance, burden);
		}
예제 #4
0
		public override object Create(CreationContext context, Burden burden)
		{
			var instance = InternalCreate(context, burden);
			burden.SetRootInstance(instance);

			OnCreation(Model, instance);

			return instance;
		}
		public void AddChild(Burden child)
		{
			children.Add(child);

			if (child.GraphRequiresDecommission)
			{
				childRequiresDecommission = true;
			}
		}
예제 #6
0
		private object PerformCreation(CreationContext context, Burden burden)
		{
			if (customActivator != null)
			{
				return customActivator.Create(context, burden);
			}

			return base.InternalCreate(context);
		}
        public override void Track(object instance, Burden burden)
        {
            if (instance.GetType().FullName.StartsWith("MassTransit") ||
                instance.Implements(typeof(Consumes<>.All)))
            {
                return;
            }

            base.Track(instance, burden);
        }
예제 #8
0
		private object InternalCreate(CreationContext context, Burden burden)
		{
			var createOnUIThread = (CreateOnUIThreadDelegate)Model.ExtendedProperties[Constants.CreateOnUIThead];

			if (createOnUIThread != null)
			{
				return createOnUIThread(c => performCreation(c, burden), context);
			}

			return base.InternalCreate(context);
		}
예제 #9
0
		public void AddChild(Burden child)
		{
			if (items == null)
			{
				items = new List<Burden>(Model.Dependents.Length);
			}
			items.Add(child);

			if (child.RequiresDecommission)
			{
				RequiresDecommission = true;
			}
		}
예제 #10
0
        public void AddChild(Burden child)
        {
            if (dependencies == null)
            {
                dependencies = new List <Burden>(Model.Dependents.Length);
            }
            dependencies.Add(child);

            if (child.RequiresDecommission)
            {
                decommission = Decommission.Yes;
            }
        }
예제 #11
0
		public void AddChild(Burden child)
		{
			if (items == null)
			{
				items = new List<Burden>(Model.Dependents.Length);
			}
			items.Add(child);

			if (child.RequiresPolicyRelease)
			{
				RequiresPolicyRelease = true;
			}
		}
예제 #12
0
        public override void Track(object instance, Burden burden)
        {
            ComponentModel model = burden.Model;

            // to modify the way Castle handles the Transient object uncomment the following lines
            //if (model.LifestyleType == LifestyleType.Transient)
            //   return;

            // we skip the tracking for object marked with our custom Transient lifestyle manager
            if ((model.LifestyleType == LifestyleType.Custom) &&
                (typeof (TrulyTransientLifestyleManager) == model.CustomLifestyle))
                return;

            base.Track(instance, burden);
        }
예제 #13
0
		public TrackedObjects(Burden[] trackedObjects, IReleasePolicy[] subScopes)
		{
			this.trackedObjects = trackedObjects;
			this.subScopes = subScopes;
		}
		private void Evict(Burden instance)
		{
			using (new EvictionScope(this))
				instance.Release();
		}
예제 #15
0
		public void AddChild(Burden child)
		{
			if (dependencies == null)
			{
				dependencies = new List<Burden>(Model.Dependents.Length);
			}
			dependencies.Add(child);

			if (child.RequiresDecommission)
			{
				decommission = Decommission.Yes;
			}
		}
예제 #16
0
		public static Exception TrackInstanceCalledMultipleTimes(object instance, Burden burden)
		{
			var message = new StringBuilder();
			message.AppendLine("Instance " + instance + " of component " + burden.Model.Name + " is already being tracked.");
			if (burden.Model.CustomComponentActivator == null)
			{
				if (burden.Model.LifestyleType != LifestyleType.Custom)
				{
					// unlikely, but hey, who knows
					message.Append("This looks like a bug in Windsor. Please report it.");
				}
				else
				{
					//no custom activator case - meaning the lifestyle is trying to pass the same instance around multiple times
					message.Append("The custom lifestyle " + burden.Model.CustomLifestyle +
					                   " seems to be buggy (or not configured properly), trying to track the same instances multiple times. Please report this to the author of the lifestyle.");
				}
			}
			else if (IsUsingFactoryMethod(burden.Model))
			{
				// .UsingFactoryMethod case
				if (burden.Model.LifestyleType == LifestyleType.Transient)
				{
					message.AppendLine("The factory method providing instances of the component is reusing instances, but the lifestyle of the component is " + burden.Model.LifestyleType +
					                   " which requires new instance each time.");
				}
				else if (burden.Model.LifestyleType == LifestyleType.Custom)
				{
					message.AppendLine("The factory method providing instances of the component is reusing instances, in a way that the custom lifestyle of the component (" + burden.Model.LifestyleType +
					                   ") does not expect.");
				}
				else
				{
					message.AppendLine("The factory method providing instances of the component is reusing instances, in a way that the lifestyle of the component (" + burden.Model.LifestyleType +
					                   ") does not expect.");
				}
				message.AppendLine("In most cases it is advised for the factory method not to be handling reuse of the instances, but to chose a lifestyle that does that appropriately.");
				message.Append(
					"Alternatively, if you do not wish for Windsor to track the objects coming from the factory change your regustration to '.UsingFactoryMethod(yourFactory, managedExternally: true)'");
			}
			else
			{
				// some other custom activator
				if (burden.Model.LifestyleType == LifestyleType.Transient)
				{
					message.AppendLine("The custom activator"+burden.Model.CustomComponentActivator+" is reusing instances, but the lifestyle of the component is " + burden.Model.LifestyleType +
					                   " which requires new instance each time.");
				}
				else if (burden.Model.LifestyleType == LifestyleType.Custom)
				{
					message.AppendLine("The custom activator" + burden.Model.CustomComponentActivator + " is reusing instances, in a way that the custom lifestyle of the component (" + burden.Model.LifestyleType +
					                   ") does not expect.");
				}
				else
				{
					message.AppendLine("The custom activator" + burden.Model.CustomComponentActivator + " is reusing instances, in a way that the lifestyle of the component (" + burden.Model.LifestyleType +
					                   ") does not expect.");
				}
				message.Append("In most cases it is advised for the activator not to be handling reuse of the instances, but to chose a lifestyle that does that appropriately.");
			}
			return new ComponentActivatorException(message.ToString(), burden.Model);
		}
예제 #17
0
            public override object Create(Castle.MicroKernel.Context.CreationContext context, Burden burden)
            {
                Console.WriteLine(burden);

                //return null;
                if (Enable)
                    //burden.SetRootInstance(f);
                    return base.Create(context, burden);
                else
                    return null;
            }
예제 #18
0
 public object Create(Castle.MicroKernel.Context.CreationContext context, Burden burden)
 {
     return null;
 }
예제 #19
0
			public ResolutionContext(CreationContext context, Burden burden)
			{
				this.context = context;
				this.burden = burden;
			}
예제 #20
0
		private void ExitResolutionContext(Burden burden)
		{
			handlerStack.Pop();

			if (burden == null)
			{
				return;
			}

			resolutionStack.Pop();

			if (resolutionStack.Count != 0)
			{
				resolutionStack.Peek().Burden.AddChild(burden);
			}
		}
예제 #21
0
		public void Track(object instance, Burden burden)
		{
		}