public static bool IsFeaturePlusPackTakeLessThan100Percent(this IEnumerable<FeaturePack> featurePacks, FeaturePack forPack) { // Iterate through the pack features and obtain the take rate of the feature // The take rate of the features must be the aggregate of all packs containing the feature foreach (var packItem in forPack.DataItems) { // Skip everything except optional features if (!packItem.IsOptionalFeatureInGroup) { continue; } // Get the combined take rate of all packs that contain the feature var combinedPackTakeRate = featurePacks.Where(p => p.ModelId == forPack.ModelId && p.DataItems.Any(d => d.FeatureId == packItem.FeatureId.GetValueOrDefault())) .Sum(p => p.PackPercentageTakeRate); if (packItem.PercentageTakeRate + combinedPackTakeRate > 1) { return false; } } return true; }
public Workspace( FeaturePack features, string workspaceKind) : this( GetWorkspaceServiceProviderFactory(features).CreateWorkspaceServiceProvider(workspaceKind)) { }
public ValidationState(ValidationRule rule, FeaturePack pack) : this(rule) { TakeRateId = pack.TakeRateId; MarketId = pack.MarketId; ModelId = pack.ModelId; FeaturePackId = pack.FeaturePackId; PackName = pack.PackName; }
private MSBuildWorkspace( FeaturePack features, ImmutableDictionary <string, string> properties) : base(features, "MSBuildWorkspace") { // always make a copy of these build properties (no mutation please!) this.properties = properties ?? ImmutableDictionary <string, string> .Empty; this.SetSolutionProperties(solutionFilePath: null); }
public static bool IsFeatureTakeRateEquivalentToPack(this IEnumerable<FeaturePack> featurePacks, FeaturePack forPack) { // Iterate through the pack features and obtain the take rate of the feature // The take rate of the features must be the aggregate of all packs containing the feature foreach (var packItem in forPack.DataItems) { // Skip standard features, non-applicable features and optional features that may be chosen outside the pack if (packItem.IsStandardFeatureInGroup || packItem.IsOptionalFeatureInGroup || packItem.IsNonApplicableFeatureInGroup || packItem.IsUncodedFeature) { continue; } // Skip pack items that are in exclusive feature groups, as these will be picked up by other rules // If the item is in an exclusive feature group by itself (1 item in group), then we need to validate // Also if this item is a pack-only item, we need to validate, otherwise no other rules will pick this up if (!string.IsNullOrEmpty(packItem.ExclusiveFeatureGroup) && packItem.FeaturesInExclusiveFeatureGroup > 1 && !packItem.IsPackOnlyItem) { continue; } // Get the combined take rate of all packs that contain the feature var combinedPackTakeRate = featurePacks.Where(p => p.ModelId == forPack.ModelId && p.DataItems.Any(d => d.FeatureId == packItem.FeatureId.GetValueOrDefault())) .Sum(p => p.PackPercentageTakeRate); if (packItem.PercentageTakeRate != combinedPackTakeRate) { return false; } } return true; }
private static IWorkspaceServiceProviderFactory CreateWorkspaceServiceProviderFactory(FeaturePack features) { var exports = features.ComposeExports(); var factory = exports.GetExports <IWorkspaceServiceProviderFactory>().Single().Value; #if MEF // need to tell factory about export source since it is constructed via MEF and the export source is not part of the MEF composition. ((WorkspaceServiceProviderFactory)factory).SetExports(exports); #endif return(factory); }
internal static IWorkspaceServiceProviderFactory GetWorkspaceServiceProviderFactory(FeaturePack features) { IWorkspaceServiceProviderFactory factory; if (!factories.TryGetValue(features, out factory)) { factory = factories.GetValue(features, CreateWorkspaceServiceProviderFactory); } return(factory); }
public CustomWorkspace(FeaturePack features, string workspaceKind = WorkspaceKind.Host) : base(features, workspaceKind) { }
/// <summary> /// Create a new instance of a workspace that can be populated by opening solution and project files. /// </summary> /// <param name="properties">The MSBuild properties used when interpretting project files. /// These are the same properties that are passed to msbuild via the /property:<n>=<v> command line argument.</param> /// <param name="features">The feature pack used to configure this workspace.</param> public static MSBuildWorkspace Create(ImmutableDictionary <string, string> properties, FeaturePack features) { if (properties == null) { throw new ArgumentNullException("properties"); } if (features == null) { throw new ArgumentNullException("features"); } return(new MSBuildWorkspace(features, properties)); }
public static bool IsFeatureTakeRateEquivalentToPack(this IEnumerable <FeaturePack> featurePacks, FeaturePack forPack) { // Iterate through the pack features and obtain the take rate of the feature // The take rate of the features must be the aggregate of all packs containing the feature foreach (var packItem in forPack.DataItems) { // Skip standard features, non-applicable features and optional features that may be chosen outside the pack if (packItem.IsStandardFeatureInGroup || packItem.IsOptionalFeatureInGroup || packItem.IsNonApplicableFeatureInGroup || packItem.IsUncodedFeature) { continue; } // Skip pack items that are in exclusive feature groups, as these will be picked up by other rules // If the item is in an exclusive feature group by itself (1 item in group), then we need to validate // Also if this item is a pack-only item, we need to validate, otherwise no other rules will pick this up if (!string.IsNullOrEmpty(packItem.ExclusiveFeatureGroup) && packItem.FeaturesInExclusiveFeatureGroup > 1 && !packItem.IsPackOnlyItem) { continue; } // Get the combined take rate of all packs that contain the feature var combinedPackTakeRate = featurePacks.Where(p => p.ModelId == forPack.ModelId && p.DataItems.Any(d => d.FeatureId == packItem.FeatureId.GetValueOrDefault())) .Sum(p => p.PackPercentageTakeRate); if (packItem.PercentageTakeRate != combinedPackTakeRate) { return(false); } } return(true); }
public static bool IsFeaturePlusPackTakeLessThan100Percent(this IEnumerable <FeaturePack> featurePacks, FeaturePack forPack) { // Iterate through the pack features and obtain the take rate of the feature // The take rate of the features must be the aggregate of all packs containing the feature foreach (var packItem in forPack.DataItems) { // Skip everything except optional features if (!packItem.IsOptionalFeatureInGroup) { continue; } // Get the combined take rate of all packs that contain the feature var combinedPackTakeRate = featurePacks.Where(p => p.ModelId == forPack.ModelId && p.DataItems.Any(d => d.FeatureId == packItem.FeatureId.GetValueOrDefault())) .Sum(p => p.PackPercentageTakeRate); if (packItem.PercentageTakeRate + combinedPackTakeRate > 1) { return(false); } } return(true); }