protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (_partition != null && _study == null) { StudyNotFoundException exception = new StudyNotFoundException(_studyInstanceUid); ExceptionHandler.ThrowException(exception); } if (_partition == null) { PartitionNotFoundException exception = new PartitionNotFoundException(_serverae, "The Server Partition is null in Default.aspx -> OnPreRender()"); ExceptionHandler.ThrowException(exception); } if (_study == null) { StudyNotFoundException exception = new StudyNotFoundException(_studyInstanceUid); ExceptionHandler.ThrowException(exception); } else { SetPageTitle(String.Format("{0}:{1}", NameFormatter.Format(_study.PatientsName), _study.PatientId), false); } }
public void InvalidCharactersLanguageTest() { var nf = new NameFormatter(); var tn = nf.GetTableName("A#?", WordsExtraction.FromDictionary, InvariantNameFormat); Assert.AreEqual("A__", tn.ClassName); }
/// <summary> /// Creates the name of the procedure. /// </summary> /// <param name="dbProcedureName">Name of the db procedure.</param> /// <param name="dbSchema">The db schema.</param> /// <param name="nameFormat">The name format.</param> /// <returns></returns> protected virtual ProcedureName CreateProcedureName(string dbProcedureName, string dbSchema, NameFormat nameFormat) { var procedureName = NameFormatter.GetProcedureName(dbProcedureName, GetExtraction(dbProcedureName), nameFormat); procedureName.DbName = GetFullDbName(dbProcedureName, dbSchema); return(procedureName); }
/// <summary> /// Creates the name of the column. /// </summary> /// <param name="dbColumnName">Name of the db column.</param> /// <param name="dbTableName">Name of the db table.</param> /// <param name="dbSchema">The db schema.</param> /// <param name="nameAliases">The name aliases.</param> /// <param name="nameFormat">The name format.</param> /// <returns></returns> protected virtual ColumnName CreateColumnName(string dbColumnName, string dbTableName, string dbSchema, INameAliases nameAliases, NameFormat nameFormat) { var columnNameAlias = nameAliases != null?nameAliases.GetColumnMemberAlias(dbColumnName, dbTableName, dbSchema) : null; WordsExtraction extraction; if (columnNameAlias != null) { extraction = WordsExtraction.None; } else { extraction = GetExtraction(dbColumnName); columnNameAlias = dbColumnName; } var columnName = NameFormatter.GetColumnName(columnNameAlias, extraction, nameFormat); // The member name can not be the same as the class // we add a "1" (just like SqlMetal does) var tableName = CreateTableName(dbTableName, dbSchema, nameAliases, nameFormat); if (columnName.PropertyName == tableName.ClassName) { columnName.PropertyName = columnName.PropertyName + "1"; } if (startsWithNumber.IsMatch(columnName.PropertyName)) { columnName.PropertyName = "_" + columnName.PropertyName; } columnName.DbName = dbColumnName; return(columnName); }
/// <summary> /// Creates the name of the table given a name and schema /// </summary> /// <param name="dbTableName">Name of the db table.</param> /// <param name="dbSchema">The db schema.</param> /// <param name="nameAliases">The name aliases.</param> /// <param name="nameFormat">The name format.</param> /// <param name="extraction">The extraction.</param> /// <returns></returns> protected virtual TableName CreateTableName(string dbTableName, string dbSchema, INameAliases nameAliases, NameFormat nameFormat, WordsExtraction extraction) { // if we have an alias, use it, and don't try to analyze it (a human probably already did the job) var tableTypeAlias = nameAliases != null?nameAliases.GetTableTypeAlias(dbTableName, dbSchema) : null; if (tableTypeAlias != null) { extraction = WordsExtraction.None; } else { tableTypeAlias = dbTableName; } var tableName = NameFormatter.GetTableName(tableTypeAlias, extraction, nameFormat); // alias for member var tableMemberAlias = nameAliases != null?nameAliases.GetTableMemberAlias(dbTableName, dbSchema) : null; if (tableMemberAlias != null) { tableName.MemberName = tableMemberAlias; } tableName.DbName = GetFullDbName(dbTableName, dbSchema); return(tableName); }
protected override void OnCleanupVirtualHost(IModel model) { base.OnCleanupVirtualHost(model); model.ExchangeDelete(NameFormatter.GetMessageName(typeof(A)).ToString()); model.ExchangeDelete(NameFormatter.GetMessageName(typeof(B)).ToString()); }
protected override string GetCurrentPathDescription(CardItemViewModel current) { if (current == null) { return(null); } string delim = " \\ "; var sb = new StringBuilder(); var h = current.Holder; var p = h.GetPatient(); sb.Append(NameFormatter.GetFullName(p) ?? string.Format("Пациент ({0:dd.MM.yy hh:mm})", p.CreatedAt)); if (h is Course) { var c = h as Course; sb.AppendFormat("{0}курс {1}", delim, DateFormatter.GetIntervalString(c.Start, c.End)); } else if (h is Appointment) { var a = h as Appointment; sb.AppendFormat("{0}курс {1}{2}осмотр {3}", delim, DateFormatter.GetIntervalString(a.Course.Start, a.Course.End), delim, DateFormatter.GetDateString(a.DateAndTime)); } return(sb.ToString()); }
public void Format_WithDoubleEscapedEndFormatBraceWhichTerminatesString_ThrowsFormatException() { //arrange var o = new { foo = 123.45 }; //act, assert NameFormatter.Format("{foo}}}}", o); }
public void Format_WithDoubleEscapedEndFormatBrace_ThrowsFormatException() { //arrange var o = new { foo = 123.45 }; //act, assert NameFormatter.Format("{foo}}}}bar", o); }
public void Example() { var o = new { First = "John", Last = "Doe" }; string result = NameFormatter.Format("Full Name: {First} {Last}", o); //assert Assert.AreEqual("Full Name: John Doe", result); }
public void Format_WithFormatNameNotInObject_ThrowsFormatException() { //arrange var o = new { foo = 123.45 }; //act, assert NameFormatter.Format("{bar}", o); }
// --------------------- public BindingDescriptionList( BindingDescription.BindingType typeMask, bool addUnusedBindings, int axisInputSourceMask, NameFormatter menuNameFormatter) : base(16) { this.Setup(typeMask, addUnusedBindings, axisInputSourceMask, menuNameFormatter); }
/// <summary> /// Applies a format to the item /// </summary> /// <param name="item">Item to format</param> /// <param name="format">Format string</param> /// <returns>Formatted string</returns> public static string FormatNameAs(this object item, string format) { if (format == null) { throw new ArgumentNullException("format"); } return(NameFormatter.Format(format, item)); }
/// <summary> /// Creates the name of the association. /// </summary> /// <param name="dbManyName">Name of the db many.</param> /// <param name="dbManySchema">The db many schema.</param> /// <param name="dbOneName">Name of the db one.</param> /// <param name="dbOneSchema">The db one schema.</param> /// <param name="dbConstraintName">Name of the db constraint.</param> /// <param name="foreignKeyName">Name of the foreign key.</param> /// <param name="nameFormat">The name format.</param> /// <returns></returns> protected virtual AssociationName CreateAssociationName(string dbManyName, string dbManySchema, string dbOneName, string dbOneSchema, string dbConstraintName, string foreignKeyName, NameFormat nameFormat) { var associationName = NameFormatter.GetAssociationName(dbManyName, dbOneName, dbConstraintName, foreignKeyName, GetExtraction(dbManyName), nameFormat); associationName.DbName = GetFullDbName(dbManyName, dbManySchema); return(associationName); }
public void TestNameFormatter_Restore_Name_Valid_Name_3_Given() { string name = "Surname First_Name Second_Name Third_Name"; string expectedName = "First_Name Second_Name Third_Name Surname"; string result = NameFormatter.restoreName(name); Assert.AreEqual(expectedName, result); }
public void TestNameFormatter_Format_Name_Invalid_Name() { string name = "Invalid_Name"; string expectedName = "Invalid_Name"; string result = NameFormatter.formatName(name); Assert.AreEqual(expectedName, result); }
/// <summary> /// Uses the string as a format. /// </summary> /// <param name="format">A String reference</param> /// <param name="source">Object that should be formatted</param> /// <returns>Formatted string</returns> public static string FormatName(this string format, object source) { if (format == null) { throw new ArgumentNullException("format"); } return(NameFormatter.Format(format, source)); }
public void TestNameFormatter_Format_Name_Valid_Name_1_Given() { string name = "First_Name Surname"; string expectedName = "Surname First_Name"; string result = NameFormatter.formatName(name); Assert.AreEqual(expectedName, result); }
void LastNameCommaFirstName() { const string FIRST_NAME = "cedd"; const string LAST_NAME = "burge"; var actual = new NameFormatter().FullName(firstName: FIRST_NAME, lastName: LAST_NAME); Assert.Equal($"{LAST_NAME}, {FIRST_NAME}", actual); }
/// <summary> /// Loads database schema /// </summary> /// <param name="databaseName"></param> /// <param name="nameAliases"></param> /// <param name="nameFormat"></param> /// <param name="loadStoredProcedures"></param> /// <param name="contextNamespace"></param> /// <param name="entityNamespace"></param> /// <returns></returns> public virtual Database Load(string databaseName, INameAliases nameAliases, NameFormat nameFormat, bool loadStoredProcedures, string contextNamespace, string entityNamespace) { // check if connection is open. Note: we may use something more flexible if (Connection.State != ConnectionState.Open) { Connection.Open(); } // get the database name. If we don't have one, take it from connection string... if (string.IsNullOrEmpty(databaseName)) { databaseName = Connection.Database; } // ... and if connection string doesn't provide a name, then throw an error if (string.IsNullOrEmpty(databaseName)) { throw new ArgumentException("A database name is required. Please specify /database=<databaseName>"); } databaseName = GetDatabaseNameAliased(databaseName, nameAliases); var schemaName = NameFormatter.GetSchemaName(databaseName, GetExtraction(databaseName), nameFormat); var names = new Names(); var schema = new Database { Name = schemaName.DbName, Class = GetRuntimeClassName(schemaName.ClassName, nameAliases), BaseType = typeof(DataContext).FullName, ContextNamespace = contextNamespace, EntityNamespace = entityNamespace, }; // order is important, we must have: // 1. tables // 2. columns // 3. constraints LoadTables(schema, schemaName, Connection, nameAliases, nameFormat, names); LoadColumns(schema, schemaName, Connection, nameAliases, nameFormat, names); CheckColumnsName(schema); LoadConstraints(schema, schemaName, Connection, nameFormat, names); CheckConstraintsName(schema); if (loadStoredProcedures) { LoadStoredProcedures(schema, schemaName, Connection, nameFormat); } // names aren't checked here anymore, because this confuses DBML editor. // they will (for now) be checked before .cs generation // in the end, when probably will end up in mapping source (or somewhere around) //CheckNamesSafety(schema); // generate backing fields name (since we have here correct names) GenerateStorageAndMemberFields(schema); return(schema); }
public void Format_WithSubProperty_ReturnsValueOfSubProperty() { var o = new { foo = new { bar = 123.45 } }; //act string result = NameFormatter.Format("{foo.bar:#.#}ms", o); //assert Assert.AreEqual("123.5ms", result); }
public void Format_WithEmptyString_ReturnsEmptyString() { var o = new { foo = 123.45 }; //act string result = NameFormatter.Format(string.Empty, o); //assert Assert.AreEqual(string.Empty, result); }
public void Format_WithEndBraceFollowedByEscapedEndFormatBraceWhichTerminatesString_FormatsCorrectly() { var o = new { foo = 123.45 }; //act string result = NameFormatter.Format("{foo}}}", o); //assert Assert.AreEqual("123.45}", result); }
public void Format_WithFormatType_ReturnsFormattedExpression() { var o = new { foo = 123.45 }; //act string result = NameFormatter.Format("{foo:#.#}", o); //assert Assert.AreEqual("123.5", result); }
public void Format_WithEndBraceFollowedByDoubleEscapedEndFormatBrace_FormatsCorrectly() { var o = new { foo = 123.45 }; //act string result = NameFormatter.Format("{foo}}}}}bar", o); //assert Assert.AreEqual("123.45}}bar", result); }
public void Format_WithNoFormats_ReturnsFormatStringAsIs() { var o = new { foo = 123.45 }; //act string result = NameFormatter.Format("a b c", o); //assert Assert.AreEqual("a b c", result); }
public void Format_WithEscapeSequence_EscapesInnerCurlyBraces() { var o = new { foo = 123.45 }; //act string result = NameFormatter.Format("{{{foo}}}", o); //assert Assert.AreEqual("{123.45}", result); }
protected override void ProcessImpl(User user) { var service = new MaterialService(user); if (string.IsNullOrEmpty(Model.VisitName) || Preferences.AutoGenerateSiteVisitNames.Value) { Model.VisitName = NameFormatter.FormatSiteVisitName(Model); } service.UpdateSiteVisitRDE(Model); }
/** * Restore formatted names to original value * * @return Restored names as an array of strings */ private string[] restoreNames(string[] formattedInput) { string[] restoredNames = new string[formattedInput.Length]; for (int i = NameSorterDefs.ARRAY_BEGIN; i < formattedInput.Length; ++i) { restoredNames[i] = NameFormatter.restoreName(formattedInput[i]); } return(restoredNames); }
// -------------------- public void Setup( BindingDescription.BindingType typeMask, bool addUnusedBindings, int axisInputSourceMask, NameFormatter menuNameFormatter) { this.typeMask = typeMask; this.addUnusedBindings = addUnusedBindings; this.menuNameFormatter = menuNameFormatter; this.axisInputSourceMask = axisInputSourceMask; }
public AzureBlobService() { Formatter = new NameFormatter(); }