toRelativePaths( System.Collections.Generic.IEnumerable <Bam.Core.TokenizedString> paths) { var programFiles = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles); var programFilesX86 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86); var contatenated = new System.Text.StringBuilder(); foreach (var path in paths.Distinct()) { var pathString = path.ToString(); if (pathString.StartsWith(programFiles) || pathString.StartsWith(programFilesX86)) { contatenated.AppendFormat("{0};", pathString); continue; } var relative = Bam.Core.RelativePathUtilities.GetPath(pathString, this.Project.ProjectPath); if (!Bam.Core.RelativePathUtilities.IsPathAbsolute(relative)) { contatenated.Append("$(ProjectDir)"); } contatenated.AppendFormat("{0};", relative); } return(contatenated.ToString()); }
public override IResult Proces(dynamic value) { var result = CheckNull(this, value); if (!result.HasData) { return(result); } System.Collections.Generic.IEnumerable <Request.HttpFile> values = value; if (!values.Any()) { if (this.CanNull) { return(this.ResultCreate()); } else { return(this.ResultCreate(State, Message ?? string.Format("argument \"{0}\" can not null.", this.Member))); } } foreach (var item in values) { if (Size < (item.Value.Length / 1024)) { return(this.ResultCreate(-171, string.Format("File size max {0} KB.", Size))); } } var files = values.Distinct(Equality <Request.HttpFile> .CreateComparer(c => c.Key)).ToDictionary(c => c.Key, c => c.Value.StreamReadByte()); return(this.ResultCreate(files)); }
internal static string Replaces(System.Collections.Generic.IEnumerable <string> ids) { return($"Replaces:{System.Environment.NewLine}" + ids.Distinct().JoinLines()); }
AddSetting( string name, System.Collections.Generic.IEnumerable <Bam.Core.TokenizedString> value, string condition = null, bool inheritExisting = false, bool arePaths = false) { lock (this.Settings) { if (!value.Any()) { return; } var linearized = arePaths ? this.toRelativePaths(value) : new Bam.Core.TokenizedStringArray(value.Distinct()).ToString(';'); if (this.Settings.Any(item => item.Name == name && item.Condition == condition)) { var settingOption = this.Settings.First(item => item.Name == name && item.Condition == condition); if (settingOption.Value.Contains(linearized)) { return; } throw new Bam.Core.Exception("Cannot append {3}, to the option {0} as it already exists for condition {1}: {2}", name, condition, settingOption.Value.ToString(), linearized); } this.Settings.AddUnique(new VSSetting(name, inheritExisting ? System.String.Format("{0};%({1})", linearized, name) : linearized, condition)); } }