public static string GetDesignStringWithSubstitutions(Column dataColumn, Column isTextColumn, Substitutions substitutions = null, int commandTimeout = -1) { var dataColumnName = GetColumnName(dataColumn); var isTextColumnName = GetColumnName(isTextColumn); var cmdText = $"SELECT {dataColumnName},{isTextColumnName} FROM MasterDesign"; var cmd = VoteDb.GetCommand(cmdText, commandTimeout); var table = new DataTable(); using (var cn = VoteDb.GetOpenConnection()) { cmd.Connection = cn; DbDataAdapter adapter = new MySqlDataAdapter(cmd as MySqlCommand); adapter.Fill(table); } if (table.Rows.Count != 1) { return(string.Empty); } var text = (table.Rows[0][dataColumnName] as string).SafeString(); if (Convert.ToBoolean(table.Rows[0][isTextColumnName])) { text = text.ReplaceNewLinesWithBreakTags(); } if (substitutions == null) { substitutions = new Substitutions(); } return(substitutions.Substitute(text)); }
/// <summary> /// Get Substitutions for the given data range /// </summary> /// <param name="startDate">The Begin Date of the Substitutions to filter</param> /// <param name="endDate">The End Date of the Substitutions to filter</param> /// <param name="departmentId">The ID of the Department (default = 0)</param> /// <returns>The Substitution(s)</returns> public async Task <Substitution[]> GetSubstitution(long startDate, long endDate, int departmentId = 0) { //Get the JSON Substitutions substitutions = new Substitutions { @params = new Substitutions.Params { startDate = startDate, endDate = endDate, departmentId = departmentId } }; //Send and receive JSON from WebUntis string requestJson = JsonConvert.SerializeObject(substitutions); string responseJson = await SendJsonAndWait(requestJson, _url, SessionId); //Parse JSON to Class SubstitutionResult result = JsonConvert.DeserializeObject <SubstitutionResult>(responseJson); string errorMsg = wus.LastError.Message; if (!SuppressErrors && errorMsg != null) { Logger.Append(Logger.LogLevel.Error, errorMsg); throw new WebUntisException(errorMsg); } //Return the Substitutions return(result.result); }
public override async ValueTask VisitTypeParameter(ITypeParameterSymbol symbol) { if (_availableTypeParameterNames.Contains(symbol.Name)) { return; } switch (symbol.ConstraintTypes.Length) { case 0: // If there are no constraint then there is no replacement required. return; case 1: // If there is one constraint which is a INamedTypeSymbol then return the INamedTypeSymbol // because the TypeParameter is expected to be of that type // else return the original symbol if (symbol.ConstraintTypes.ElementAt(0) is INamedTypeSymbol namedType) { Substitutions.Add(symbol, namedType); } return; } var commonDerivedType = await DetermineCommonDerivedTypeAsync(symbol) .ConfigureAwait(false); if (commonDerivedType != null) { Substitutions.Add(symbol, commonDerivedType); } }
public void Rewind(int oldSize) { if (Substitutions.Count > oldSize) { Substitutions.RemoveRange(oldSize, Substitutions.Count - oldSize); } }
/** * Performs substitutions on the spec. See individual elements for * details on what gets substituted. * * @param substituter * @return The substituted spec. */ public GadgetSpec substitute(Substitutions substituter) { GadgetSpec spec = new GadgetSpec(this); spec.modulePrefs = modulePrefs.substitute(substituter); if (userPrefs.Count == 0) { spec.userPrefs = new List <UserPref>(); } else { List <UserPref> prefs = new List <UserPref>(); foreach (UserPref pref in userPrefs) { prefs.Add(pref.substitute(substituter)); } spec.userPrefs = prefs; } Dictionary <String, View> viewMap = new Dictionary <String, View>(views.Count); foreach (View view in views.Values) { viewMap.Add(view.getName(), view.substitute(substituter)); } spec.views = viewMap; return(spec); }
public void Execute() { if (_missingInputs.Any()) { Logger.Trace("Missing Inputs:"); Logger.Trace("---------------"); _missingInputs.Each(x => Console.WriteLine(x)); throw new MissingInputException(_missingInputs.ToArray()); } Logger.Starting(_steps.Count); _substitutions.Trace(Logger); _substitutions.Set(INSTRUCTIONS, GetInstructions().Replace("\"", "'")); _steps.Each(x => { Logger.TraceStep(x); x.Alter(this); }); if (Solution != null) { Logger.Trace("Saving solution to {0}", Solution.Filename); Solution.Save(); } Substitutions.WriteTo(Root.AppendPath(Substitutions.ConfigFile)); WriteNugetImports(); Logger.Finish(); }
/** * Substitutes the icon fields according to the spec. * * @param substituter * @return The substituted icon */ public Icon substitute(Substitutions substituter) { Icon icon = new Icon(this); icon.content = substituter.substituteString(Substitutions.Type.MESSAGE, content); return(icon); }
public void Execute() { if (_missingInputs.Any()) { Logger.Trace("Missing Inputs:"); Logger.Trace("---------------"); _missingInputs.Each(x => Console.WriteLine(x)); ThrowExceptions.Custom(Exc.GetStackTrace(), type, Exc.CallingMethod(), "MissingInput: " + Exc.Join(",", _missingInputs)); } Logger.Starting(_steps.Count); _substitutions.Trace(Logger); _substitutions.Set(INSTRUCTIONS, GetInstructions().Replace("\"", "'")); _steps.Each(x => { Logger.TraceStep(x); x.Alter(this); }); if (Solution != null) { Logger.Trace("Saving solution to {0}", Solution.Filename); Solution.Save(); } Substitutions.WriteTo(Root.AppendPath(Substitutions.ConfigFile)); WriteNugetImports(); Logger.Finish(); }
public SoccerLineupDetailsViewModel(Team team, IChangeManager changeManager, CollectionFactory collections) { _changeManager = changeManager; _teamModel = team; Collections = collections; Team = new TeamViewModel(team, _changeManager, Collections); SoccerPlayerViewModel.IsSelectedPropertyChanged += SoccerPlayerViewModel_IsSelectedPropertyChanged; Substitutions = Team.Squad.Where(p => (RotationTeam)p.RotationTeam.Value == RotationTeam.Substitute).ToSquadList(); if (Substitutions.Count < 7) { Substitutions.Add(new SoccerPlayerViewModel() { Name = new EditableCellViewModel(string.Empty, _changeManager), Position = new ComboBoxCellViewModel(null, null, _changeManager) }); } Substitutions.RemoveFirstNames(); Substitutions.ArrangePositionRoleAsec(); Reserves = Team.Squad.Where(p => (RotationTeam)p.RotationTeam.Value == RotationTeam.Reserves).ToSquadList(); Reserves.RemoveFirstNames(); Reserves.ArrangePositionRoleAsec(); DragDropPlayer = new RelayCommand <SoccerPlayerViewModel>(DragOrDropFieldPlayer); }
/// <summary> /// /// </summary> protected virtual string CoreTransliterate(string value) { if (string.IsNullOrEmpty(value)) { return(value); } value = value.Normalize(NormalizationForm.FormC); StringBuilder sb = new(value.Length * 4); int maxLength = SubstitutionLength; for (int i = 0; i < value.Length;) { bool skip = true; for (int length = maxLength; length > 0; --length) { if (i + length > value.Length) { continue; } if (Substitutions.TryGetValue(value.Substring(i, length), out string chunk)) { skip = false; TransliterationCase cs = Case(value, i); if (cs == TransliterationCase.Lower) { chunk = chunk.ToLowerInvariant(); } else if (cs == TransliterationCase.Upper) { chunk = chunk.ToUpperInvariant(); } else { chunk = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(chunk); } sb.Append(chunk); i += length; } } if (skip) { sb.Append(value[i]); i += 1; } } return(sb.ToString()); }
public bool IsSubstituteOf(IUser who, IUser whom) { return(Substitutions.GetAll().Where(x => Equals(x.User, whom) && Equals(x.Substitute, who) && x.Status == CoreEntities.DatabookEntry.Status.Active && (!x.StartDate.HasValue || Calendar.Today >= x.StartDate) && (!x.EndDate.HasValue || Calendar.Today <= x.EndDate)).Any()); }
public void set_if_none_will_write_if_no_previous_value() { var substitutions = new Substitutions(); substitutions.SetIfNone("key", "different"); substitutions.ValueFor("key").ShouldEqual("different"); }
public static void addSubstitutions(Substitutions substituter, String dir) { bool rtl = RTL.Equals(dir); substituter.addSubstitution(Substitutions.Type.BIDI, START_EDGE, rtl ? RIGHT : LEFT); substituter.addSubstitution(Substitutions.Type.BIDI, END_EDGE, rtl ? LEFT : RIGHT); substituter.addSubstitution(Substitutions.Type.BIDI, DIR, rtl ? RTL : LTR); substituter.addSubstitution(Substitutions.Type.BIDI, REVERSE_DIR, rtl ? LTR : RTL); }
public void AddSubstitution(string key, string value) { if (Substitutions == null) { Substitutions = new Dictionary <string, string>(); } Substitutions.Add(key, value); }
public void set_if_none_will_not_override_if_it_exists() { var substitutions = new Substitutions(); substitutions.Set("key", "something"); substitutions.SetIfNone("key", "different"); substitutions.ValueFor("key").ShouldEqual("something"); }
public void set_overrides() { var substitutions = new Substitutions(); substitutions.Set("key", "something"); substitutions.Set("key", "different"); substitutions.ValueFor("key").ShouldEqual("different"); }
public IQueryable <Sungero.Company.IEmployee> GetNotAutomatedEmployees(List <Sungero.Company.IEmployee> employees) { var notAutomatedEmployeesWoSubstitution = new List <Sungero.Company.IEmployee>(); var signOutEmployees = employees.Where(r => r.Login == null || r.Login.Status == CoreEntities.DatabookEntry.Status.Closed) .ToList(); foreach (var employee in signOutEmployees) { var substitutions = Substitutions.GetAll() .Where(x => Equals(x.User, employee) && x.IsSystem != true && x.Status == CoreEntities.DatabookEntry.Status.Active && (!x.StartDate.HasValue || Calendar.Today >= x.StartDate) && (!x.EndDate.HasValue || Calendar.Today <= x.EndDate)) .ToList(); if (!substitutions.Any()) { notAutomatedEmployeesWoSubstitution.Add(employee); } var substitutors = substitutions.Select(x => x.Substitute).ToList(); if (substitutors.Any(x => x.Login != null && x.Login.Status != CoreEntities.DatabookEntry.Status.Closed)) { continue; } while (substitutors.Count > 0) { substitutions = new List <ISubstitution>(); foreach (var substitutor in substitutors) { substitutions.AddRange(Substitutions.GetAll() .Where(x => Equals(x.User, substitutor) && x.IsSystem != true && x.Status == CoreEntities.DatabookEntry.Status.Active && (!x.StartDate.HasValue || Calendar.Today >= x.StartDate) && (!x.EndDate.HasValue || Calendar.Today <= x.EndDate))); } if (!substitutions.Any()) { notAutomatedEmployeesWoSubstitution.Add(employee); } substitutors = substitutions.Select(x => x.Substitute).ToList(); if (substitutors.Any(x => x.Login != null && x.Login.Status != CoreEntities.DatabookEntry.Status.Closed)) { notAutomatedEmployeesWoSubstitution.Add(employee); break; } } } return(notAutomatedEmployeesWoSubstitution.AsQueryable()); }
public override void Deleting(Sungero.Domain.DeletingEventArgs e) { var systemSubstitutions = Substitutions.GetAll().Where(s => s.IsSystem == true && (s.Substitute.Equals(_obj) || s.User.Equals(_obj))).ToList(); foreach (var substitution in systemSubstitutions) { Substitutions.Delete(substitution); } }
public ControlExample() { this.InitializeComponent(); Substitutions = new Substitutions(); //this.txtHeader.SetBinding(TextBlock.TextProperty, new Binding() { Source = this, Path=new PropertyPath("HeaderText"), Mode=BindingMode.TwoWay}); //this.ControlPresenter.SetBinding(ContentPresenter.ContentProperty, new Binding() { Source = this, Path = new PropertyPath("Example"), Mode=BindingMode.OneWay}); //this.OptionsPresenter.SetBinding(ContentPresenter.ContentProperty, new Binding() { Source = this, Path = new PropertyPath("Options"), Mode = BindingMode.OneWay }); }
public void set_value() { var substitutions = new Substitutions(); substitutions.Set("key", "something"); substitutions.Set("two", "twenty"); substitutions.ValueFor("key").ShouldEqual("something"); substitutions.ValueFor("two").ShouldEqual("twenty"); }
public IRecipientOption AddSubstitution(string key, string value) { if (Substitutions == null) { Substitutions = new Dictionary <string, string>(); } Substitutions.Add(key, value); return(this); }
public void get_content() { var substitutions = new Substitutions(); substitutions.Set("%MODEL%", "Foo.Bar"); var template = FileTemplate.Embedded("view.spark"); template.Contents(substitutions).ShouldContain("<viewdata model=\"Foo.Bar\" />"); }
public void UnionWith(SubstitutionCollection other) { Substitutions.AddRange(other.Substitutions); NextRelation = (NextRelation, other.NextRelation) switch { (NullLogicalValue _, var v) => v, (var v, NullLogicalValue _) => v, (var v1, var v2) => new LogicalDisjunctionValue(v1, v2) }; }
public void Reset() { VisitedModules.Clear(); Exports.Clear(); Substitutions.Clear(); StringBuilder.Clear(); if (StringBuilder.Capacity > 4096) { StringBuilder.Capacity = 4096; } }
/// <summary> /// Удалить системное замещение. /// </summary> /// <param name="substitutedUser">Пользователь, для которого надо удалить замещение.</param> /// <param name="substitute">Руководитель.</param> public static void DeleteSystemSubstitution(IUser substitutedUser, IUser substitute) { var deletedSubstitution = Substitutions.GetAll() .Where(s => Equals(s.Substitute, substitute) && Equals(s.User, substitutedUser) && s.IsSystem == true) .FirstOrDefault(); if (deletedSubstitution != null) { Substitutions.Delete(deletedSubstitution); } }
public static string GetDesignStringWithSubstitutions(Column dataColumn, Substitutions substitutions = null) { var text = GetColumn(dataColumn) as string; if (substitutions == null) { substitutions = new Substitutions(); } return(substitutions.Substitute(text)); }
public void apply_substitutions() { var substitutions = new Substitutions(); substitutions.Set("%KEY%", "the key"); substitutions.Set("%NAME%", "George Michael"); string text = "%KEY% is %NAME%"; substitutions.ApplySubstitutions(text) .ShouldEqual("the key is George Michael"); }
public static string Write(FileTemplate template, Location location, string inputModel) { var substitutions = new Substitutions(); substitutions.Set("%MODEL%", inputModel); var path = location.CurrentFolder.AppendPath(inputModel.Split('.').Last() + template.Extension); var contents = template.Contents(substitutions); new FileSystem().WriteStringToFile(path, contents); return(path); }
protected void Page_Load(object sender, EventArgs e) { var sub = new Substitutions() { StateCode = "AL", //PoliticianKey = tempEmailRow.PoliticianKey(), ElectionKey = "AL20121106GA", OfficeKey = "ALUSHouse4", IssueKey = "ALLBio", //PartyKey = tempEmailRow.PartyKey(), //PartyEmail = tempEmailRow.Email(), }.Substitute("##Vote-XX.org/Issue##"); }
/// <summary> /// Создать системное замещение. /// </summary> /// <param name="substitutedUser">Замещаемый пользователь.</param> /// <param name="substitute">Замещающий пользователь.</param> public static void CreateSystemSubstitution(IUser substitutedUser, IUser substitute) { if (Equals(substitutedUser, substitute)) { return; } var substitution = Substitutions.Create(); substitution.User = substitutedUser; substitution.Substitute = substitute; substitution.IsSystem = true; }
private static string GetDesignStringWithSubstitutions(Column dataColumn, Substitutions substitutions = null) { var dataColumnName = GetColumnName(dataColumn); var masterColumn = GetColumn(dataColumnName); var text = GetColumn(masterColumn) as string; if (substitutions == null) { substitutions = new Substitutions(); } return(substitutions.Substitute(text)); }
/** * Substitutes all hangman variables into the gadget spec. * * @return A new GadgetSpec, with all fields substituted as needed. */ public GadgetSpec substitute(GadgetContext context, GadgetSpec spec) { MessageBundle bundle = messageBundleFactory.getBundle(spec, context.getLocale(), context.getIgnoreCache()); String dir = bundle.getLanguageDirection(); Substitutions substituter = new Substitutions(); substituter.addSubstitutions(Substitutions.Type.MESSAGE, bundle.getMessages()); BidiSubstituter.addSubstitutions(substituter, dir); substituter.addSubstitution(Substitutions.Type.MODULE, "ID", context.getModuleId()); UserPrefSubstituter.addSubstitutions(substituter, spec, context.getUserPrefs()); return spec.substitute(substituter); }
public static void addSubstitutions(Substitutions substituter, GadgetSpec spec, UserPrefs values) { foreach (UserPref pref in spec.getUserPrefs()) { String name = pref.getName(); String value = values.getPref(name); if (value == null) { value = pref.getDefaultValue(); if (value == null) { value = ""; } } substituter.addSubstitution(Substitutions.Type.USER_PREF, name, HttpUtility.HtmlEncode(value)); } }
private Preload(Preload preload, Substitutions substituter) { _base = preload._base; views = preload.views; auth = preload.auth; signOwner = preload.signOwner; signViewer = preload.signViewer; href = _base.resolve(substituter.substituteUri(null, preload.href)); Dictionary<String, String> attributes = new Dictionary<string, string>(); foreach (var entry in preload.attributes) { attributes.Add(entry.Key, substituter.substituteString(null, entry.Value)); } this.attributes = attributes; }
/** * Produces a new ModulePrefs by substituting hangman variables from * substituter. See comments on individual fields to see what actually * has substitutions performed. * * @param substituter */ public ModulePrefs substitute(Substitutions substituter) { return new ModulePrefs(this, substituter); }
/** * Produces a new, substituted ModulePrefs */ private ModulePrefs(ModulePrefs prefs, Substitutions substituter) { _base = prefs._base; categories = prefs.getCategories(); features = prefs.getFeatures(); locales = prefs.getLocales(); oauth = prefs.oauth; List<Preload> preloads = new List<Preload>(); if (prefs.preloads != null) { foreach (Preload preload in prefs.preloads) { preloads.Add(preload.substitute(substituter)); } } this.preloads = preloads; List<Icon> icons = new List<Icon>(prefs.icons.Count); foreach (Icon icon in prefs.icons) { icons.Add(icon.substitute(substituter)); } this.icons = icons; Dictionary<String, LinkSpec> links = new Dictionary<String, LinkSpec>(prefs.links.Count); foreach (LinkSpec link in prefs.links.Values) { LinkSpec sub = link.substitute(substituter); links.Add(sub.getRel(), sub); } this.links = links; Dictionary<String, String> attributes = new Dictionary<String, String>(prefs.attributes.Count); foreach (var attr in prefs.attributes) { String substituted = substituter.substituteString(null, attr.Value); attributes.Add(attr.Key, substituted); } this.attributes = attributes; }
/** * Performs substitutions on the spec. See individual elements for * details on what gets substituted. * * @param substituter * @return The substituted spec. */ public GadgetSpec substitute(Substitutions substituter) { GadgetSpec spec = new GadgetSpec(this); spec.modulePrefs = modulePrefs.substitute(substituter); if (userPrefs.Count == 0) { spec.userPrefs = new List<UserPref>(); } else { List<UserPref> prefs = new List<UserPref>(); foreach (UserPref pref in userPrefs) { prefs.Add(pref.substitute(substituter)); } spec.userPrefs = prefs; } Dictionary<String, View> viewMap = new Dictionary<String, View>(views.Count); foreach (View view in views.Values) { viewMap.Add(view.getName(), view.substitute(substituter)); } spec.views = viewMap; return spec; }
/** * Substitutes the icon fields according to the spec. * * @param substituter * @return The substituted icon */ public Icon substitute(Substitutions substituter) { Icon icon = new Icon(this); icon.content = substituter.substituteString(Substitutions.Type.MESSAGE, content); return icon; }
private LinkSpec(LinkSpec rhs, Substitutions substitutions) { rel = substitutions.substituteString(null, rhs.rel); _base = rhs._base; href = _base.resolve(substitutions.substituteUri(null, rhs.href)); }
/** * Performs variable substitution on all visible elements. */ public LinkSpec substitute(Substitutions substitutions) { return new LinkSpec(this, substitutions); }
public Preload substitute(Substitutions substituter) { return new Preload(this, substituter); }