private void ConfigureAtrifact(IProvideArtifact artifact, ExecutionSequenceManager sequenceManager, ConDepSettings settings) { if (artifact is Artifact.Local) { var localSequence = sequenceManager.NewLocalSequence(artifact.GetType().Name); var localBuilder = new LocalOperationsBuilder(localSequence); ((Artifact.Local)artifact).Configure(localBuilder, settings); } else if (artifact is Artifact.Remote) { var remoteSequence = sequenceManager.NewRemoteSequence(artifact.GetType().Name); var remoteBuilder = new RemoteOperationsBuilder(remoteSequence); ((Artifact.Remote)artifact).Configure(remoteBuilder, settings); } }
public ConDepNoArtifactTierDefinedException(IProvideArtifact application, ConDepSettings settings) : base(string.Format("No Tiers defined for application {0}. You need to specify a tier using the {1} attribute on the {0} class. Tiers available in your configuration are {2}.", application.GetType().Name, typeof(TierAttribute).Name, string.Join(", ", settings.Config.Tiers.Select(x => x.Name)))) { }
private static void ValidateApplicationTier(IProvideArtifact application, ConDepSettings settings) { var hasTier = application.GetType().GetCustomAttributes(typeof(TierAttribute), false).Any(); if (!hasTier) { throw new ConDepNoArtifactTierDefinedException(application, settings); } var hasSingleTier = application.GetType().GetCustomAttributes(typeof(TierAttribute), false).SingleOrDefault() != null; if (!hasSingleTier) { throw new ConDepNoArtifactTierDefinedException(String.Format("Multiple tiers defined for {0}. Only one tier is allowed by Artifact.", application.GetType().Name)); } }
public bool HasDependenciesDefined(IProvideArtifact artifact) { var typeName = typeof(IDependOn <>).Name; var interfaces = artifact.GetType().GetInterfaces(); return(interfaces.Any(x => x.Name == typeName)); }
public IEnumerable <ServerConfig> GetServers(IProvideArtifact application, ConDepSettings settings) { if (settings.Config.UsingTiers) { ValidateApplicationTier(application, settings); var tier = application.GetType().GetCustomAttributes(typeof(TierAttribute), false).Single() as TierAttribute; return (settings.Config.Tiers.Single(x => x.Name.Equals(tier.TierName, StringComparison.OrdinalIgnoreCase)) .Servers); } return(settings.Config.Servers); }
public IEnumerable <ServerConfig> GetServers(IProvideArtifact application, ConDepSettings settings) { if (settings.Config.UsingTiers) { ValidateApplicationTier(application, settings); var tier = application.GetType().GetCustomAttributes(typeof(TierAttribute), false).Single() as TierAttribute; if (!settings.Config.Tiers.Exists(tier.TierName)) { throw new ConDepTierDoesNotExistInConfigException(string.Format("Tier {0} does not exist in {1}.env.config", tier.TierName, settings.Options.Environment)); } return (settings.Config.Tiers.Single(x => x.Name.Equals(tier.TierName, StringComparison.OrdinalIgnoreCase)) .Servers); } return(settings.Config.Servers); }
private IEnumerable <IProvideArtifact> GetDependeciesForArtifact(IProvideArtifact artifact, ConDepSettings settings) { var typeName = typeof(IDependOn <>).Name; var typeInterfaces = artifact.GetType().GetInterfaces(); var dependencies = typeInterfaces.Where(x => x.Name == typeName); var dependencyInstances = new List <IProvideArtifact>(); foreach (var infraInterface in dependencies) { var dependencyType = infraInterface.GetGenericArguments().Single(); var dependencyInstance = settings.Options.Assembly.CreateInstance(dependencyType.FullName) as IProvideArtifact; dependencyInstances.AddRange(new ArtifactDependencyHandler().GetDependeciesForArtifact(dependencyInstance, settings)); dependencyInstances.Add(dependencyInstance); } return(dependencyInstances); }