Otis says support for this is coming in 2.1 but I'm too impatient. So I give u: "RootNamespaceController" - TaskPerformer. Impressive name eh?
Add a task to append a namespace in ur preset, then add another to remove the namespace change.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using SD.LLBLGen.Pro.ApplicationCore;
using SD.LLBLGen.Pro.GeneratorCore;
namespace OAMPS.TaskPerformers
{
public class RootNamespaceController : TaskPerformerBase
{
bool result = false;
public override void Perform(SD.LLBLGen.Pro.ApplicationCore.IGenerator executingGenerator, SD.LLBLGen.Pro.ApplicationCore.ITask taskDefinition, Dictionary<string, SD.LLBLGen.Pro.ApplicationCore.Tasks.TaskParameter> parameters)
{
if (parameters == null)
{
throw new GeneratorAbortException("No parameters have been specified. Aborting generator.", taskDefinition);
}
if (parameters.Count <= 0)
{
throw new GeneratorAbortException("No parameters have been specified. Aborting generator.", taskDefinition);
}
string appendNamespace;
bool removeAppendendedNamespace = false;
if (!parameters.ContainsKey("appendNamespace"))
{
throw new GeneratorAbortException("Mandatory parameter 'appendNamespace' not found. Aborting generator.", taskDefinition);
}
appendNamespace = parameters["appendNamespace"].Value;
if (parameters.ContainsKey("removeAppendendedNamespace"))
removeAppendendedNamespace = parameters["removeAppendendedNamespace"].Value.ToLower(CultureInfo.InvariantCulture) == "true";
string ns = executingGenerator.ProjectDefinition.RootNameSpace;
if (removeAppendendedNamespace)
{
if (ns.EndsWith(appendNamespace))
executingGenerator.ProjectDefinition.RootNameSpace = ns.Substring(0, ns.Length - appendNamespace.Length - 1);
else
{
base.AddNewLogNode(taskDefinition.ElementLogNode, LogNodeType.ErrorDescription, "Namespace {0} not changed.", new object[] { executingGenerator.ProjectDefinition.RootNameSpace });
}
}
else
executingGenerator.ProjectDefinition.RootNameSpace = string.Concat(ns, ".", appendNamespace);
base.LogLine("Namespace changed to " + executingGenerator.ProjectDefinition.RootNameSpace, "RootNamespaceController", true, true);
base.AddNewLogNode(taskDefinition.ElementLogNode, LogNodeType.ActionDescription, "Namespace changed to {0}", new object[] { executingGenerator.ProjectDefinition.RootNameSpace });
result = true;
}
public override void Perform(SD.LLBLGen.Pro.ApplicationCore.IGenerator executingGenerator, SD.LLBLGen.Pro.ApplicationCore.ITask taskDefinition)
{
throw new GeneratorAbortException("No parameters have been specified. Aborting generator.", taskDefinition);
}
public override bool PerformResult
{
get { return result; }
}
}
}
Heres a sample task for ur custom tasks file:
<taskGroup name="Control namespace">
<task name="Append Namespace" assemblyFilename="OAMPS.TaskPerformers.dll" taskPerformerClass="OAMPS.TaskPerformers.RootNamespaceController">
<parameters>
<parameter name="appendNamespace" isOptional="false" description="The namespace to append." />
<parameter name="removeAppendendedNamespace" defaultValue="false" isOptional="false" description="True to remove the appended namespace or false to append it." />
</parameters>
</task>
<task name="Remove Namespace" assemblyFilename="OAMPS.TaskPerformers.dll" taskPerformerClass="OAMPS.TaskPerformers.RootNamespaceController">
<parameters>
<parameter name="appendNamespace" isOptional="false" description="The namespace to append." />
<parameter name="removeAppendendedNamespace" defaultValue="true" isOptional="false" description="True to remove the appended namespace or false to append it." />
</parameters>
</task>
</taskGroup>