public static Attribute ForLowerCaseProperty() { return(new Attribute { Type = new Type(NamesService.GetExtensionTypeName("LowerCasePropertyAttribute")) }); }
public CollectionExecuteAsyncMethod(OdcmClass odcmClass) { Name = "ExecuteAsync"; Parameters = Parameter.Empty; ReturnType = new Type(new Identifier("global::System.Threading.Tasks", "Task"), new Type(NamesService.GetExtensionTypeName("IPagedCollection"), new Type(NamesService.GetConcreteInterfaceName(odcmClass)))); }
public EnsureQueryMethod(OdcmClass odcmClass) { IsPublic = false; Name = "EnsureQuery"; FetchedType = NamesService.GetPublicTypeName(odcmClass); QueryableSetType = new Type(NamesService.GetExtensionTypeName("ReadOnlyQueryableSet"), new Type(NamesService.GetPublicTypeName(odcmClass))); ReturnType = new Type(NamesService.GetExtensionTypeName("IReadOnlyQueryableSet"), new Type(NamesService.GetConcreteInterfaceName(odcmClass))); }
public static Field ForNavigationConcreteProperty(OdcmProperty property) { return(new Field { Name = NamesService.GetConcreteFieldName(property), Type = new Type(NamesService.GetExtensionTypeName("EntityCollectionImpl"), new Type(NamesService.GetConcreteTypeName((OdcmClass)property.Type))) }); }
private ConcreteNavigationCollectionProperty(OdcmProperty odcmProperty) : base(odcmProperty) { FieldName = NamesService.GetConcreteFieldName(odcmProperty); OdcmType = odcmProperty.Type; PrivateSet = true; Type = new Type(NamesService.GetExtensionTypeName("IPagedCollection"), new Type(NamesService.GetConcreteInterfaceName(odcmProperty.Type))); }
public static IEnumerable <Property> ForEntityContainer(OdcmClass odcmContainer) { return(Properties.ForEntityContainerInterface(odcmContainer) .Concat(new Property[] { new AutoProperty("Context", new Type(NamesService.GetExtensionTypeName("DataServiceContextWrapper")), privateSet: true) })); }
public static Field ForStructuralProperty(OdcmProperty property) { return(new Field { Name = NamesService.GetPropertyFieldName(property), Type = property.IsCollection ? new Type(NamesService.GetExtensionTypeName("NonEntityTypeCollectionImpl"), new Type(NamesService.GetConcreteTypeName(property.Type))) : TypeService.GetPropertyType(property) }); }
public static Interface ForCollection(OdcmClass odcmClass) { return(new Interface { Attributes = new[] { Attribute.ForLowerCaseProperty() }, Identifier = NamesService.GetCollectionInterfaceName(odcmClass), Namespace = odcmClass.Namespace, Methods = global::CSharpWriter.Methods.ForCollectionInterface(odcmClass), Indexers = IndexerSignature.ForCollectionInterface(odcmClass), Interfaces = new[] { new Type(NamesService.GetExtensionTypeName("IReadOnlyQueryableSetBase"), new Type(NamesService.GetConcreteInterfaceName(odcmClass))) } }); }
private void Write(CollectionConstructor collectionConstructor) { _("internal {0}(global::Microsoft.OData.Client.DataServiceQuery inner," + "{1} context," + "object entity," + "string path)" + ": base(inner, context, entity as {2}, path)", NamesService.GetCollectionTypeName(collectionConstructor.OdcmClass).Name, NamesService.GetExtensionTypeName("DataServiceContextWrapper"), NamesService.GetExtensionTypeName("EntityBase")); _("{"); _("}"); }
public static Class ForCollection(OdcmClass odcmClass) { return(new Class { AccessModifier = "internal ", BaseClass = new Type(NamesService.GetExtensionTypeName("QueryableSet"), new Type(NamesService.GetConcreteInterfaceName(odcmClass))), Constructors = global::CSharpWriter.Constructors.ForCollection(odcmClass), Interfaces = global::CSharpWriter.Interfaces.ForCollection(odcmClass), Identifier = NamesService.GetCollectionTypeName(odcmClass), Methods = global::CSharpWriter.Methods.ForCollection(odcmClass), Indexers = global::CSharpWriter.Indexers.ForCollection(odcmClass) }); }
public static IEnumerable <Type> ForConcreteInterface(OdcmClass odcmClass) { var retVal = new List <Type>(); var baseClass = odcmClass.Base as OdcmClass; var interfaceIdentifier = baseClass == null? NamesService.GetExtensionTypeName("IEntityBase") : NamesService.GetConcreteInterfaceName(baseClass); retVal.Add(new Type(interfaceIdentifier)); return(retVal); }
public static Class ForComplex(OdcmClass odcmClass) { return(new Class { AbstractModifier = odcmClass.IsAbstract ? "abstract " : string.Empty, AccessModifier = "public ", Constructors = global::CSharpWriter.Constructors.ForComplex(odcmClass), BaseClass = new Type(odcmClass.Base == null ? NamesService.GetExtensionTypeName("ComplexTypeBase") : NamesService.GetPublicTypeName(odcmClass.Base)), Fields = global::CSharpWriter.Fields.ForComplex(odcmClass), Identifier = NamesService.GetConcreteTypeName(odcmClass), Properties = global::CSharpWriter.Properties.ForComplex(odcmClass), }); }
public static Class ForFetcher(OdcmClass odcmClass) { return(new Class { AccessModifier = "internal ", BaseClass = new Type(odcmClass.Base == null ? NamesService.GetExtensionTypeName("RestShallowObjectFetcher") : NamesService.GetFetcherTypeName(odcmClass.Base)), Constructors = global::CSharpWriter.Constructors.ForFetcher(odcmClass), Fields = global::CSharpWriter.Fields.ForFetcher(odcmClass), Identifier = NamesService.GetFetcherTypeName(odcmClass), Interfaces = global::CSharpWriter.Interfaces.ForFetcher(odcmClass), Methods = global::CSharpWriter.Methods.ForFetcher(odcmClass), Properties = global::CSharpWriter.Properties.ForFetcher(odcmClass), }); }
private void Write(ConcreteNavigationCollectionProperty property) { WriteDeclaration(property); using (_builder.IndentBraced) { _("get"); using (_builder.IndentBraced) { _("return new {0}<{1}, {2}>(Context, ({3}<{2}>) {4});", NamesService.GetExtensionTypeName("PagedCollection"), NamesService.GetConcreteInterfaceName(property.OdcmType), NamesService.GetConcreteTypeName(property.OdcmType), NamesService.GetExtensionTypeName("EntityCollectionImpl"), property.FieldName); } } }
public static Class ForConcrete(OdcmClass odcmClass) { return(new Class { AbstractModifier = odcmClass.IsAbstract ? "abstract " : string.Empty, AccessModifier = "public ", Attributes = global::CSharpWriter.Attributes.ForConcrete(odcmClass), BaseClass = new Type(odcmClass.Base == null ? NamesService.GetExtensionTypeName("EntityBase") : NamesService.GetConcreteTypeName(odcmClass.Base)), Constructors = global::CSharpWriter.Constructors.ForConcrete(odcmClass), Fields = global::CSharpWriter.Fields.ForConcrete(odcmClass), Identifier = NamesService.GetConcreteTypeName(odcmClass), Interfaces = global::CSharpWriter.Interfaces.ForConcrete(odcmClass), Methods = global::CSharpWriter.Methods.ForConcrete(odcmClass), Properties = global::CSharpWriter.Properties.ForConcrete(odcmClass) }); }
private void Write(StructuralCollectionProperty property) { WriteDeclaration(property); using (_builder.IndentBraced) { _("get"); using (_builder.IndentBraced) { _("if (this.{0} == default({1}))", property.FieldName, property.Type); using (_builder.IndentBraced) { _("this.{0} = new {1}<{2}>();", property.FieldName, NamesService.GetExtensionTypeName("NonEntityTypeCollectionImpl"), property.InstanceType); _("this.{0}.SetContainer(() => GetContainingEntity(\"{1}\"));", property.FieldName, property.ModelName); } _("return this.{0};", property.FieldName); } _("set"); using (_builder.IndentBraced) { _("{0}.Clear();", property.FieldName); _("if (value != null)"); using (_builder.IndentBraced) { _("foreach (var i in value)"); using (_builder.IndentBraced) { _("{0}.Add(i);", property.FieldName); } } } } }
private void Write(ConcreteNavigationCollectionAccessorProperty property) { WriteDeclaration(property); using (_builder.IndentBraced) { _("get"); using (_builder.IndentBraced) { _("if (this.{0} == null)", property.FieldName); using (_builder.IndentBraced) { _("this.{0} = new {1}<{2}>();", property.FieldName, NamesService.GetExtensionTypeName("EntityCollectionImpl"), property.InstanceType); _("this.{0}.SetContainer(() => GetContainingEntity(\"{1}\"));", property.FieldName, property.ModelName); } _(""); _("return ({0})this.{1};", property.Type, property.FieldName); } _("set"); using (_builder.IndentBraced) { _("{0}.Clear();", property.FieldName); _("if (value != null)"); using (_builder.IndentBraced) { _("foreach (var i in value)"); using (_builder.IndentBraced) { _("{0}.Add(i);", property.FieldName); } } } } }
private void Write(EntityContainerConstructor entityContainerConstructor) { _("public {0}(global::System.Uri serviceRoot, global::System.Func<global::System.Threading.Tasks.Task<string>> accessTokenGetter)", entityContainerConstructor.Name); using (_builder.IndentBraced) { _("Context = new {0}(serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion.V4, accessTokenGetter);", NamesService.GetExtensionTypeName("DataServiceContextWrapper")); _("Context.MergeOption = global::Microsoft.OData.Client.MergeOption.OverwriteChanges;"); _("Context.ResolveName = new global::System.Func<global::System.Type, string>(this.ResolveNameFromType);"); _("Context.ResolveType = new global::System.Func<string, global::System.Type>(this.ResolveTypeFromName);"); _("this.OnContextCreated();"); _("Context.Format.LoadServiceModel = GeneratedEdmModel.GetInstance;"); _("Context.Format.UseJson();"); } _("partial void OnContextCreated();"); }