Beispiel #1
0
        public void OnRecipeFinished(object sender, ProductionEventArgs e)
        {
            this.Log($"Production finished for {e.Recipe}");

            StopProduction(e.Recipe);

            var targetInventory = Exchange.GetTargetInventory(e.Recipe.Product);

            targetInventory.Add(e.Recipe.Product);

            if (e.Recipe.IsExternal)
            {
                this.Log($"Production stopping external recipe {e.Recipe}");

                foreach (var employee in e.Employees)
                {
                    Assignment.Unassign(employee);
                }
            }
            else
            {
                this.Log($"Production restarting for {e.Recipe}");
                StartProduction(e.Recipe);
            }
        }
        private static void OnProjectProduction(object sender, ProductionEventArgs e)
        {

            if ((e.EventType == ProductionEventType.ProducerStart) ||
                (e.EventType == ProductionEventType.SubProducerInitialize) ||
                (e.EventType == ProductionEventType.ModelLoad) ||
                (e.EventType == ProductionEventType.Warning) ||
                ((e.EventType & ProductionEventType.AlwaysDisplay) == ProductionEventType.AlwaysDisplay))
            {
                string message = null;

                if (e.EventType == ProductionEventType.Warning)
                {
                    message = e.Dictionary["message"] as string;
                }

                if ((message != null) && (message.Trim().Length == 0))
                {
                    Console.Write(".");
                    _inline = true;
                }
                else
                {
                    if (_inline)
                    {
                        Console.WriteLine();
                    }
                    if (e.EventType == ProductionEventType.Warning)
                    {
                        CodeFluent.Model.Common.ConsoleControl.SetStandardOutputCharacterAttributes(CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundGreen | CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundRed | CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundIntensity);
                    }
                    Console.WriteLine(e.GetDisplayName(sender, false));
                    if (e.EventType == ProductionEventType.Warning)
                    {
                        CodeFluent.Model.Common.ConsoleControl.SetStandardOutputCharacterAttributes(CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundWhite);
                    }
                    _inline = false;
                }
            }
            else
            {
                Console.Write(".");
                _inline = true;
            }

        }
        private static void SqlServerProducer_Production(object sender, ProductionEventArgs e)
        {
            SqlServerProducer sqlServerProducer = sender as SqlServerProducer;

            if (sqlServerProducer == null)
            {
                return;
            }

            if (_producers.Contains(sqlServerProducer))
            {
                return;
            }

            sqlServerProducer.EditorTargetDirectory = Path.Combine(sqlServerProducer.EditorTargetDirectory, _schema);
            _producers.Add(sqlServerProducer);
        }
        private static void DatabaseProducer_Production(object sender, ProductionEventArgs e)
        {
            DatabaseProducer databaseProducer = sender as DatabaseProducer;

            if (databaseProducer == null)
            {
                return;
            }

            if (_producers.Contains(databaseProducer))
            {
                return;
            }

            databaseProducer.EditorTargetDirectory = Path.Combine(databaseProducer.EditorTargetDirectory, _schema);
            _producers.Add(databaseProducer);
        }
        private static void OnProjectProduction(object sender, ProductionEventArgs e)
        {
            if ((e.EventType == ProductionEventType.ProducerStart) ||
                (e.EventType == ProductionEventType.SubProducerInitialize) ||
                (e.EventType == ProductionEventType.ModelLoad) ||
                (e.EventType == ProductionEventType.Warning) ||
                ((e.EventType & ProductionEventType.AlwaysDisplay) == ProductionEventType.AlwaysDisplay))
            {
                string message = null;

                if (e.EventType == ProductionEventType.Warning)
                {
                    message = e.Dictionary["message"] as string;
                }

                if ((message != null) && (message.Trim().Length == 0))
                {
                    Console.Write(".");
                    _inline = true;
                }
                else
                {
                    if (_inline)
                    {
                        Console.WriteLine();
                    }
                    if (e.EventType == ProductionEventType.Warning)
                    {
                        CodeFluent.Model.Common.ConsoleControl.SetStandardOutputCharacterAttributes(CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundGreen | CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundRed | CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundIntensity);
                    }
                    Console.WriteLine(e.GetDisplayName(sender, false));
                    if (e.EventType == ProductionEventType.Warning)
                    {
                        CodeFluent.Model.Common.ConsoleControl.SetStandardOutputCharacterAttributes(CodeFluent.Model.Common.ConsoleCharacterAttributes.ForegroundWhite);
                    }
                    _inline = false;
                }
            }
            else
            {
                Console.Write(".");
                _inline = true;
            }
        }
Beispiel #6
0
        private static void L_ProductionReceived(object sender, ProductionEventArgs e)
        {
            e.ResponseArray[18] = e.ProcessIndicator;
            e.ResponseArray[19] = e.SuccessIndicator;
            e.ResponseArray[20] = e.FaultCode;
            e.ResponseArray[21] = 308;

            e.ResponseArray[22] = e.P_Val_1;
            e.ResponseArray[23] = e.P_Val_2;
            e.ResponseArray[24] = e.P_Val_3;
            e.ResponseArray[25] = e.P_Val_4;
            e.ResponseArray[26] = e.P_Val_5;
            e.ResponseArray[27] = e.P_Val_6;
            e.ResponseArray[28] = e.P_Val_7;
            e.ResponseArray[29] = e.P_Val_8;
            e.ResponseArray[30] = e.P_Val_9;
            e.ResponseArray[31] = e.P_Val_10;
            e.ResponseArray[32] = e.P_Val_11;
            e.ResponseArray[33] = e.P_Val_12;
            e.ResponseArray[34] = e.P_Val_13;
            e.ResponseArray[35] = e.P_Val_14;
            e.ResponseArray[36] = e.P_Val_15;
            e.ResponseArray[37] = e.P_Val_16;
            e.ResponseArray[38] = e.P_Val_17;
            e.ResponseArray[39] = e.P_Val_18;
            e.ResponseArray[40] = e.P_Val_19;
            e.ResponseArray[41] = e.P_Val_20;
            e.ResponseArray[42] = e.P_Val_21;
            e.ResponseArray[43] = e.P_Val_22;
            e.ResponseArray[44] = e.P_Val_23;
            e.ResponseArray[45] = e.P_Val_24;
            e.ResponseArray[46] = e.P_Val_25;
            e.ResponseArray[47] = e.P_Val_26;
            e.ResponseArray[48] = e.P_Val_27;
            e.ResponseArray[49] = e.P_Val_28;

            var r = new ListenerResponse();

            r.ProductionResponse(e);
        }
Beispiel #7
0
        /// <summary>
        /// Updates Create objectives.
        /// </summary>
        /// <remarks>
        /// Creation and Production events share same event
        /// due to having the same ObjectiveType code.
        /// </remarks>
        /// <param name="args">An object of type CreationEventArgs or ProductionEventArgs, otherwise an exception will be issued to the logger.</param>
        private void OnCreatureCreatedOrProducedItem(EventArgs args)
        {
            Creature creature;
            int      itemId;
            string   skill;           // Is there a better way to check for skill match?

            CreationEventArgs   crargs = args as CreationEventArgs;
            ProductionEventArgs prargs = args as ProductionEventArgs;

            if (crargs != null)             // Try cast as CreationEventArgs
            {
                creature = crargs.Creature;
                itemId   = crargs.Item.Info.Id;
                skill    = crargs.Method.ToString();
            }
            else if (prargs != null)             // Try cast as ProductionEventArgs
            {
                // Cancel if it wasn't a success
                if (!prargs.Success)
                {
                    return;
                }

                creature = prargs.Creature;
                itemId   = prargs.ProductionData.ItemId;               // Use production data in case Item is null
                skill    = prargs.ProductionData.Category.ToString();
                if (skill == "Spinning")
                {
                    skill = "Weaving";                     // Shared SkillId.
                }
            }
            else             // Error: Cannot cast as either one.
            {
                Log.Exception(new InvalidCastException(String.Format("Unable to cast EventArgs as CreationEventArgs nor ProductionEventArgs (Quest Name: {0}, ID: {1})", this.Name, this.Id)));
                return;
            }

            var quests = creature.Quests.GetAllIncomplete(this.Id);

            foreach (var quest in quests)
            {
                if (!this.CanMakeProgress(creature, quest))
                {
                    continue;
                }

                var progress = quest.CurrentObjectiveOrLast;
                if (progress == null)
                {
                    return;
                }

                var objective = this.Objectives[progress.Ident];
                if (objective == null || objective.Type != ObjectiveType.Create)
                {
                    return;
                }

                var createObjective = (objective as QuestObjectiveCreate);
                if (!progress.Done && itemId == createObjective.ItemId && skill == createObjective.SkillId.ToString())
                {
                    var done = (++progress.Count == createObjective.Amount);
                    if (done)
                    {
                        quest.SetDone(progress.Ident);
                    }

                    UpdateQuest(creature, quest);

                    // Hot-fix for #390, after a creation objective might
                    // come a collect objective for the finished items,
                    // the new active objective has to be checked.
                    // This should happen generally, but some refactoring is
                    // in order, to not make such a mess out of it.
                    if (done)
                    {
                        this.CheckCurrentObjective(creature);
                    }
                }
            }
        }
Beispiel #8
0
		/// <summary>
		/// Raised when creature produces items, handles creation conditions.
		/// </summary>
		/// <param name="args"></param>
		private void OnCreatureProducedItem(ProductionEventArgs args)
		{
			var skill = args.Creature.Skills.Get(SkillId.ProductionMastery);
			if (skill == null) return;

			if (skill.Info.Rank >= SkillRank.RF && skill.Info.Rank <= SkillRank.RA)
			{
				if (args.Success)
					skill.Train(2); // Create any material through use of a skill.
				else
					skill.Train(3); // Fail at creating any material through use of a skill.

				return;
			}

			if (skill.Info.Rank == SkillRank.R9)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.Item.HasTag("/texture/03/|/texture/04/"))
						skill.Train(3); // Successfully weave Fine or Finest Fabric.
					else if (args.Item.HasTag("/copperingot/|/silveringot/"))
						skill.Train(4); // Successfully refine a Copper Ingot or a Silver Ingot.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R8)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.Item.HasTag("/silk/03/|/silk/04/"))
						skill.Train(3); // Successfully weave Fine or Finest Silk.
					else if (args.Item.HasTag("/silveringot/|/goldingot/"))
						skill.Train(4); // Successfully refine a Gold or Silver Ingot.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R7)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.Item.HasTag("/leather_strap/03/|/leather_strap/04/"))
						skill.Train(3); // Successfully cut a Fine or Finest Leather.
					else if (args.Item.HasTag("/goldingot/"))
						skill.Train(4); // Successfully refine a Gold or Silver Ingot.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R6)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.Item.HasTag("/leather_strap/03/|/leather_strap/04/"))
						skill.Train(3); // Successfully cut a Fine or Finest Leather.
					else if (args.Item.HasTag("/mythrilingot/"))
						skill.Train(4); // Successfully refine a Mythril Ingot.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R5)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/whiteherb/")))
						skill.Train(4); // Successfully make a potion using a White Herb.
					else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R7 && args.ProductionData.Rank <= SkillRank.R5)
						skill.Train(5); // Successfully handicraft any item from Rank 7 to Rank 5.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R4)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/goldenherb/")))
						skill.Train(4); // Successfully make a potion using a Golden Herb.
					else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R6 && args.ProductionData.Rank <= SkillRank.R4)
						skill.Train(5); // Successfully handicraft any item from Rank 6 to Rank 4.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R3)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/mandrake/")))
						skill.Train(4); // Successfully make a potion using a Mandrake.
					else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R5 && args.ProductionData.Rank <= SkillRank.R3)
						skill.Train(5); // Successfully handicraft any item from Rank 5 to Rank 3.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R2)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/antidoteherb/")))
						skill.Train(4); // Successfully make a potion using a Antidote Herb.
					else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R4 && args.ProductionData.Rank <= SkillRank.R2)
						skill.Train(5); // Successfully handicraft any item from Rank 4 to Rank 2.
				}
				return;
			}

			if (skill.Info.Rank == SkillRank.R1)
			{
				if (args.Success)
				{
					skill.Train(2); // Create any material through use of a skill.

					if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/poisonherb/")))
						skill.Train(3); // Successfully make a potion using a Poison Herb.
					else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R3 && args.ProductionData.Rank <= SkillRank.R1)
						skill.Train(4); // Successfully handicraft any item from Rank 3 to Rank 1.
				}
				return;
			}
		}
Beispiel #9
0
        /// <summary>
        /// Raised when creature produces items, handles creation conditions.
        /// </summary>
        /// <param name="args"></param>
        private void OnCreatureProducedItem(ProductionEventArgs args)
        {
            var skill = args.Creature.Skills.Get(SkillId.ProductionMastery);

            if (skill == null)
            {
                return;
            }

            if (skill.Info.Rank >= SkillRank.RF && skill.Info.Rank <= SkillRank.RA)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.
                }
                else
                {
                    skill.Train(3);                     // Fail at creating any material through use of a skill.
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R9)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.Item.HasTag("/texture/03/|/texture/04/"))
                    {
                        skill.Train(3);                         // Successfully weave Fine or Finest Fabric.
                    }
                    else if (args.Item.HasTag("/copperingot/|/silveringot/"))
                    {
                        skill.Train(4);                         // Successfully refine a Copper Ingot or a Silver Ingot.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R8)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.Item.HasTag("/silk/03/|/silk/04/"))
                    {
                        skill.Train(3);                         // Successfully weave Fine or Finest Silk.
                    }
                    else if (args.Item.HasTag("/silveringot/|/goldingot/"))
                    {
                        skill.Train(4);                         // Successfully refine a Gold or Silver Ingot.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R7)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.Item.HasTag("/leather_strap/03/|/leather_strap/04/"))
                    {
                        skill.Train(3);                         // Successfully cut a Fine or Finest Leather.
                    }
                    else if (args.Item.HasTag("/goldingot/"))
                    {
                        skill.Train(4);                         // Successfully refine a Gold or Silver Ingot.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R6)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.Item.HasTag("/leather_strap/03/|/leather_strap/04/"))
                    {
                        skill.Train(3);                         // Successfully cut a Fine or Finest Leather.
                    }
                    else if (args.Item.HasTag("/mythrilingot/"))
                    {
                        skill.Train(4);                         // Successfully refine a Mythril Ingot.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R5)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/whiteherb/")))
                    {
                        skill.Train(4);                         // Successfully make a potion using a White Herb.
                    }
                    else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R7 && args.ProductionData.Rank <= SkillRank.R5)
                    {
                        skill.Train(5);                         // Successfully handicraft any item from Rank 7 to Rank 5.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R4)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/goldenherb/")))
                    {
                        skill.Train(4);                         // Successfully make a potion using a Golden Herb.
                    }
                    else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R6 && args.ProductionData.Rank <= SkillRank.R4)
                    {
                        skill.Train(5);                         // Successfully handicraft any item from Rank 6 to Rank 4.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R3)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/mandrake/")))
                    {
                        skill.Train(4);                         // Successfully make a potion using a Mandrake.
                    }
                    else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R5 && args.ProductionData.Rank <= SkillRank.R3)
                    {
                        skill.Train(5);                         // Successfully handicraft any item from Rank 5 to Rank 3.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R2)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/antidoteherb/")))
                    {
                        skill.Train(4);                         // Successfully make a potion using a Antidote Herb.
                    }
                    else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R4 && args.ProductionData.Rank <= SkillRank.R2)
                    {
                        skill.Train(5);                         // Successfully handicraft any item from Rank 4 to Rank 2.
                    }
                }
                return;
            }

            if (skill.Info.Rank == SkillRank.R1)
            {
                if (args.Success)
                {
                    skill.Train(2);                     // Create any material through use of a skill.

                    if (args.ProductionData.Category == ProductionCategory.PotionMaking && args.ProductionData.Materials.Any(a => a.Tag.Contains("/herb/poisonherb/")))
                    {
                        skill.Train(3);                         // Successfully make a potion using a Poison Herb.
                    }
                    else if (args.ProductionData.Category == ProductionCategory.Handicraft && args.ProductionData.Rank >= SkillRank.R3 && args.ProductionData.Rank <= SkillRank.R1)
                    {
                        skill.Train(4);                         // Successfully handicraft any item from Rank 3 to Rank 1.
                    }
                }
                return;
            }
        }
        private static void SqlServerProducer_Production(object sender, ProductionEventArgs e)
        {
            SqlServerProducer sqlServerProducer = sender as SqlServerProducer;
            if (sqlServerProducer == null)
                return;

            if (_producers.Contains(sqlServerProducer))
                return;

            sqlServerProducer.EditorTargetDirectory = Path.Combine(sqlServerProducer.EditorTargetDirectory, _schema);
            _producers.Add(sqlServerProducer);
        }
        private static void DatabaseProducer_Production(object sender, ProductionEventArgs e)
        {
            DatabaseProducer databaseProducer = sender as DatabaseProducer;
            if (databaseProducer == null)
                return;

            if (_producers.Contains(databaseProducer))
                return;

            databaseProducer.EditorTargetDirectory = Path.Combine(databaseProducer.EditorTargetDirectory, _schema);
            _producers.Add(databaseProducer);
        }
Beispiel #12
0
        public virtual string Produce(bool addFile)
        {
            Hashtable dic = new Hashtable();

            dic.Add("Project", CodeDomProducer.Project);
            dic.Add("Producer", CodeDomProducer);
            dic.Add("TemplateProducer", this);
            string productionTargetPath = CodeDomProducer.GetProductionTargetPath(ProductionNode, FinalizeTargetPath(), IsWebType, false);
            string tempPath             = (CodeDomProducer.TargetProductionOptions & TargetProductionOptions.CreateTempFile) == TargetProductionOptions.None ? null : productionTargetPath + ".tmp";

            dic.Add("TargetPath", productionTargetPath);
            dic.Add("TempTargetPath", tempPath);
            if (!RaiseProducing(dic))
            {
                return(null);
            }

            try
            {
                if (tempPath == null)
                {
                    BaseProducer.CreateFileDirectory(productionTargetPath, CodeDomProducer);
                    BaseProducer.PathUnprotect(productionTargetPath, CodeDomProducer);
                }
                else
                {
                    BaseProducer.CreateFileDirectory(tempPath, CodeDomProducer);
                }

                bool append = false;
                if (File.Exists(productionTargetPath) && CodeDomProducer.IsGeneratedFile(productionTargetPath))
                {
                    if (tempPath != null)
                    {
                        IOUtilities.PathOverwrite(productionTargetPath, tempPath, true);
                    }
                    append = true;
                }
                string target = tempPath ?? productionTargetPath;
                try
                {
                    var unit = CreateCodeCompileUnit();
                    if (unit == null)
                    {
                        return(null);
                    }

                    IOUtilities.WrapSharingViolations(() =>
                    {
                        using (StreamWriter streamWriter = new StreamWriter(target, append, CodeDomProducer.OutputEncoding))
                        {
                            IndentedTextWriter indentedTextWriter = ((CodeDomProducer.ProductionFlags & ProductionFlags.RemoveDates) != ProductionFlags.RemoveDates ? new IndentedTextWriter(streamWriter) : new NoDiffIndentedTextWriter(streamWriter));
                            CodeDomProducer.CodeDomProvider.GenerateCodeFromCompileUnit(unit, indentedTextWriter, CodeDomProducer.CodeGeneratorOptions);
                        }
                    });
                }
                catch (Exception ex)
                {
                    CodeFluentRuntimeException violationException = IOUtilities.GetSharingViolationException(target, ex);
                    if (violationException != null)
                    {
                        throw violationException;
                    }

                    throw;
                }

                if (File.Exists(tempPath ?? productionTargetPath))
                {
                    CodeDomProducer.RaiseProduction(this, ProductionEventArgs.CreateFileWriteEvent(productionTargetPath, GetType().FullName));
                    if (tempPath != null)
                    {
                        BaseProducer.FileOverwrite(tempPath, productionTargetPath, CodeDomProducer, false);
                    }

                    CodeDomProducer.AddToGeneratedFiles(productionTargetPath);
                }
            }
            finally
            {
                if (tempPath != null && File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }
            }

            RaiseProduced();
            if (addFile)
            {
                CodeDomProducer.AddFileName(productionTargetPath);
            }

            return(productionTargetPath);
        }