/// <summary> /// Adds a property to the structural type. /// </summary> /// <param name="property">The property to add.</param> public void AddProperty(PropertyInfoSlim property) { if (property == null) { throw new ArgumentNullException(nameof(property)); } if (_properties.IsFrozen) { throw new InvalidOperationException("The structural type has been frozen. Cannot add property to frozen structural type."); } _properties.Items.Add(property); }
private static string MakeStructuralProperty(PropertyInfoSlim property, string type, ReadOnlyCollection <string> propertyIndexParameters) { var keyPrefix = !property.CanWrite ? "Key " : ""; if (property.IndexParameterTypes.Count > 0) { var indexParameters = string.Join(", ", propertyIndexParameters); return(string.Format(CultureInfo.InvariantCulture, "{0}{1}[{2}] : {3}", keyPrefix, property.Name, indexParameters, type)); } else { return(string.Format(CultureInfo.InvariantCulture, "{0}{1} : {2}", keyPrefix, property.Name, type)); } }
protected override string VisitProperty(PropertyInfoSlim property) { var declaringType = _typePrinter.Visit(property.DeclaringType); var indexParameters = property.IndexParameterTypes; if (indexParameters != null && indexParameters.Count > 0) { var indexParameterTypes = string.Join(", ", _typePrinter.Visit(property.IndexParameterTypes)); return(string.Format(CultureInfo.InvariantCulture, "{0}.{1}[{2}]", declaringType, property.Name, indexParameterTypes)); } else { return(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", declaringType, property.Name)); } }