public static List<AzLibRole> GetRoles(ITasksSource tasksSource, IAzRoles roles, IAzTasks tasks)
{
List<AzLibRole> result = new List<AzLibRole>();
NamedTasks namedTasks = new NamedTasks(tasks);
List<string> usedTasks = new List<string>();
for (int it = 0; it < roles.Count; it++)
{
IAzRole role = (IAzRole)roles[it + 1];
IAzTask task = namedTasks.FindMatchingTask(role);
if (task != null)
{
result.Add(new AzLibRole(tasksSource, role, task));
// Keep trach of the used task
usedTasks.Add(task.Name);
}
else
{
result.Add(new AzLibRole(tasksSource, role));
}
}
for (int it = 0; it < tasks.Count; it++)
{
IAzTask task = (IAzTask)tasks[it + 1];
if (usedTasks.Contains(task.Name) == false)
{
if (InteropHelper.IsTrue(task.IsRoleDefinition))
result.Add(new AzLibRole(tasksSource, task));
}
}
return result;
}
public static List<AzLibOperation> GetOps(IAzOperations ops)
{
List<AzLibOperation> result = new List<AzLibOperation>();
for (int it = 0; it < ops.Count; it++)
{
result.Add(new AzLibOperation(ops[it + 1]));
}
return result;
}
public static List<AzLibScope> GetScopes(AzLibApplication app, IAzScopes scopes)
{
List<AzLibScope> result = new List<AzLibScope>();
for (int it = 0; it < scopes.Count; it++)
{
result.Add(new AzLibScope(scopes[it + 1], app));
}
return result;
}
public static List<AzLibApplication> GetApplications(IAzApplications apps)
{
List<AzLibApplication> result = new List<AzLibApplication>();
for (int it = 0; it < apps.Count; it++)
{
result.Add(new AzLibApplication(apps[it + 1]));
}
return result;
}
public static List<AzLibApplicationGroup> GetApplicationGroups(IAzApplicationGroups groups)
{
List<AzLibApplicationGroup> result = new List<AzLibApplicationGroup>();
for (int it = 0; it < groups.Count; it++)
{
result.Add(new AzLibApplicationGroup(groups[it + 1]));
}
return result;
}
public static AzLibClientContext GetContext(AzLibApplication app)
{
IAzClientContext context = app.Native.InitializeClientContextFromToken(0, null);
return new AzLibClientContext(context);
}
The above does not show, but the AzLibOperation (and tasks, roles, etc.) just are simple objects that are gets of the Name, Description, and ID from AzMan. It will be clear once you look at all the code...but let's take it one step at a time.
No comments:
Post a Comment