private string AnalyzeProperty(IClass supportedClass, ISupportedProperty property, out string typeName, out string getter, out string attributes) { var propertyName = (!String.IsNullOrEmpty(property.Property.Label) ? property.Property.Label : CreateName(property.Property.AsEntity <IResource>())); typeName = AnalyzePropertyType(property); attributes = String.Empty; bool singleValue = typeName.IndexOf("<") == -1; if ((!property.Writeable) && (!singleValue)) { var targetType = Regex.Replace( Regex.Replace(typeName, "ICollection|IList(?=<)", "List"), "System.Collections.IList", typeof(ArrayList).FullName); attributes = String.Format("private {0} _{1} = new {2}();{3}{3} ", typeName, propertyName.ToLowerCamelCase(), targetType, Environment.NewLine); } if ((_hydraUriParser != null) && (_hydraUriParser.IsApplicable(property.Property.Id.Uri) == UriParserCompatibility.None)) { attributes += String.Format("[RomanticWeb.Mapping.Attributes.{0}(\"{1}\")]", (singleValue ? "Property" : "Collection"), property.Property.Id); } getter = ((!property.Writeable) && (!singleValue) ? String.Format(" get {{ return _{0}; }} ", propertyName.ToLowerCamelCase()) : " get;" + (property.Writeable ? String.Empty : " ")); return(propertyName); }
private string AnalyzePropertyType(ISupportedProperty property) { var propertyTypeNamespace = "System"; var propertyTypeName = "Object"; if (!property.Property.Range.Any()) { return(String.Format("{0}.{1}", propertyTypeNamespace, propertyTypeName)); } IClass propertyType = property.Property.Range.First().AsEntity <IClass>(); propertyTypeName = CreateName(propertyType); propertyTypeNamespace = CreateNamespace(propertyType); return(String.Format("{0}.{1}", propertyTypeNamespace, propertyTypeName)); }
private string AnalyzePropertyType(ISupportedProperty property) { var propertyTypeNamespace = "System"; var propertyTypeName = "Object"; if (!property.Property.Range.Any()) { return String.Format("{0}.{1}", propertyTypeNamespace, propertyTypeName); } IClass propertyType = property.Property.Range.First().AsEntity<IClass>(); propertyTypeName = CreateName(propertyType); propertyTypeNamespace = CreateNamespace(propertyType); return String.Format("{0}.{1}", propertyTypeNamespace, propertyTypeName); }
private string AnalyzeProperty(IClass supportedClass, ISupportedProperty property, out string typeName, out string getter, out string attributes) { var propertyName = (!String.IsNullOrEmpty(property.Property.Label) ? property.Property.Label : CreateName(property.Property.AsEntity<IResource>())); typeName = AnalyzePropertyType(property); attributes = String.Empty; bool singleValue = typeName.IndexOf("<") == -1; if ((!property.Writeable) && (!singleValue)) { var targetType = Regex.Replace( Regex.Replace(typeName, "ICollection|IList(?=<)", "List"), "System.Collections.IList", typeof(ArrayList).FullName); attributes = String.Format("private {0} _{1} = new {2}();{3}{3} ", typeName, propertyName.ToLowerCamelCase(), targetType, Environment.NewLine); } if ((_hydraUriParser != null) && (_hydraUriParser.IsApplicable(property.Property.Id.Uri) == UriParserCompatibility.None)) { attributes += String.Format("[RomanticWeb.Mapping.Attributes.{0}(\"{1}\")]", (singleValue ? "Property" : "Collection"), property.Property.Id); } getter = ((!property.Writeable) && (!singleValue) ? String.Format(" get {{ return _{0}; }} ", propertyName.ToLowerCamelCase()) : " get;" + (property.Writeable ? String.Empty : " ")); return propertyName; }