From ef08797cbbf2e8b6809d88dd9142f95de61c8710 Mon Sep 17 00:00:00 2001 From: Micah Rairdon Date: Wed, 20 Jan 2021 01:41:27 -0500 Subject: [PATCH] Added support for reference models with a relative uri (#183) * Added support for reference models with a relative uri Fixes: #182 --- src/Templates/ODataT4CodeGenerator.cs | 17 +- src/Templates/ODataT4CodeGenerator.ttinclude | 17 +- .../MultiReferenceModelRelativeUri.cs | 1849 +++++++++++++++++ .../MultiReferenceModelRelativeUri.vb | 1741 ++++++++++++++++ .../MultiReferenceModelRelativeUri.xml | 83 + .../ODataConnectedService.Tests.csproj | 46 +- .../ODataT4CodeGeneratorTestDescriptors.cs | 26 + .../Templates/ODataT4CodeGeneratorTests.cs | 17 +- 8 files changed, 3790 insertions(+), 6 deletions(-) create mode 100644 test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.cs create mode 100644 test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.vb create mode 100644 test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.xml diff --git a/src/Templates/ODataT4CodeGenerator.cs b/src/Templates/ODataT4CodeGenerator.cs index c0536a27..0a459a0d 100644 --- a/src/Templates/ODataT4CodeGenerator.cs +++ b/src/Templates/ODataT4CodeGenerator.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version: 16.0.0.0 @@ -906,6 +906,12 @@ public class CodeGenerationContext /// Preconfigured WebProxy for fetching the metadata /// private WebProxy webProxy; + + /// + /// The metadata uri used for the original source edmx + /// + private Uri metadataUri; + private IList customHttpHeaders; /// /// Constructs an instance of . @@ -926,6 +932,7 @@ public CodeGenerationContext(Uri metadataUri, string namespacePrefix) public CodeGenerationContext(Uri metadataUri, string namespacePrefix, WebProxy proxy, IList CustomHttpHeaders) : this(GetEdmxStringFromMetadataPath(metadataUri, proxy, CustomHttpHeaders), namespacePrefix) { + this.metadataUri = metadataUri; webProxy = proxy; customHttpHeaders = CustomHttpHeaders; } @@ -1026,6 +1033,12 @@ public Func GetReferencedModelReaderFuncWrapper { return (uri) => { + Uri originalUri = uri; + if(!uri.IsAbsoluteUri) + { + // In the case that the reference model uri is relative we should create an absolute uri using the metadataUri as the base + uri = new Uri(metadataUri, uri.ToString()); + } using (XmlReader reader = GetReferencedModelReaderFunc(uri, webProxy, customHttpHeaders)) { if (reader == null) @@ -1039,7 +1052,7 @@ public Func GetReferencedModelReaderFuncWrapper this.ReferencesMap = new Dictionary(); } - this.ReferencesMap.Add(uri, element); + this.ReferencesMap.Add(originalUri, element); return element.CreateReader(ReaderOptions.None); } }; diff --git a/src/Templates/ODataT4CodeGenerator.ttinclude b/src/Templates/ODataT4CodeGenerator.ttinclude index ca11f644..3e1d31af 100644 --- a/src/Templates/ODataT4CodeGenerator.ttinclude +++ b/src/Templates/ODataT4CodeGenerator.ttinclude @@ -760,6 +760,12 @@ public class CodeGenerationContext /// Preconfigured WebProxy for fetching the metadata /// private WebProxy webProxy; + + /// + /// The metadata uri used for the original source edmx + /// + private Uri metadataUri; + private IList customHttpHeaders; /// /// Constructs an instance of . @@ -780,6 +786,7 @@ public class CodeGenerationContext public CodeGenerationContext(Uri metadataUri, string namespacePrefix, WebProxy proxy, IList CustomHttpHeaders) : this(GetEdmxStringFromMetadataPath(metadataUri, proxy, CustomHttpHeaders), namespacePrefix) { + this.metadataUri = metadataUri; webProxy = proxy; customHttpHeaders = CustomHttpHeaders; } @@ -880,6 +887,12 @@ public class CodeGenerationContext { return (uri) => { + Uri originalUri = uri; + if(!uri.IsAbsoluteUri) + { + // In the case that the reference model uri is relative we should create an absolute uri using the metadataUri as the base + uri = new Uri(metadataUri, uri.ToString()); + } using (XmlReader reader = GetReferencedModelReaderFunc(uri, webProxy, customHttpHeaders)) { if (reader == null) @@ -893,7 +906,7 @@ public class CodeGenerationContext this.ReferencesMap = new Dictionary(); } - this.ReferencesMap.Add(uri, element); + this.ReferencesMap.Add(originalUri, element); return element.CreateReader(ReaderOptions.None); } }; @@ -5822,4 +5835,4 @@ End Namespace <#+ } } -#> \ No newline at end of file +#> diff --git a/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.cs b/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.cs new file mode 100644 index 00000000..39a8c4ff --- /dev/null +++ b/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.cs @@ -0,0 +1,1849 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generation date: 1/16/2021 1:30:47 PM +namespace Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo +{ + /// + /// There are no comments for TruckDemoService in the schema. + /// + public partial class TruckDemoService : global::Microsoft.OData.Client.DataServiceContext + { + /// + /// Initialize a new TruckDemoService object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public TruckDemoService(global::System.Uri serviceRoot) : + base(serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion.V4) + { + this.ResolveName = new global::System.Func(this.ResolveNameFromType); + this.OnContextCreated(); + this.Format.LoadServiceModel = GeneratedEdmModel.GetInstance; + this.Format.UseJson(); + } + partial void OnContextCreated(); + /// + /// Since the namespace configured for this service reference + /// in Visual Studio is different from the one indicated in the + /// server schema, use type-mappers to map between the two. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected string ResolveNameFromType(global::System.Type clientType) + { + return clientType.FullName; + } + /// + /// Our Trucks + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.Client.DataServiceQuery Trucks + { + get + { + if ((this._Trucks == null)) + { + this._Trucks = base.CreateQuery("Trucks"); + } + return this._Trucks; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _Trucks; + /// + /// There are no comments for VehicleGPSSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.Client.DataServiceQuery VehicleGPSSet + { + get + { + if ((this._VehicleGPSSet == null)) + { + this._VehicleGPSSet = base.CreateQuery("VehicleGPSSet"); + } + return this._VehicleGPSSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _VehicleGPSSet; + /// + /// There are no comments for DerivedVehicleGPSSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.Client.DataServiceQuery DerivedVehicleGPSSet + { + get + { + if ((this._DerivedVehicleGPSSet == null)) + { + this._DerivedVehicleGPSSet = base.CreateQuery("DerivedVehicleGPSSet"); + } + return this._DerivedVehicleGPSSet; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _DerivedVehicleGPSSet; + /// + /// There are no comments for VehicleGPSSetInGPS in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.Client.DataServiceQuery VehicleGPSSetInGPS + { + get + { + if ((this._VehicleGPSSetInGPS == null)) + { + this._VehicleGPSSetInGPS = base.CreateQuery("VehicleGPSSetInGPS"); + } + return this._VehicleGPSSetInGPS; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _VehicleGPSSetInGPS; + /// + /// There are no comments for Trucks in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToTrucks(TruckType truckType) + { + base.AddObject("Trucks", truckType); + } + /// + /// There are no comments for VehicleGPSSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToVehicleGPSSet(global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType vehicleGPSType) + { + base.AddObject("VehicleGPSSet", vehicleGPSType); + } + /// + /// There are no comments for DerivedVehicleGPSSet in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToDerivedVehicleGPSSet(DerivedVehicleGPSType derivedVehicleGPSType) + { + base.AddObject("DerivedVehicleGPSSet", derivedVehicleGPSType); + } + /// + /// There are no comments for VehicleGPSSetInGPS in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToVehicleGPSSetInGPS(global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType vehicleGPSType) + { + base.AddObject("VehicleGPSSetInGPS", vehicleGPSType); + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private abstract class GeneratedEdmModel + { + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Collections.Generic.Dictionary ReferencesMap = new global::System.Collections.Generic.Dictionary() + { + {@"./MultiReferenceModelCoreTerms.xml", @" + + + + + + + + +"}, + {@"./MultiReferenceModelDeviceModelTerms.xml", @" + + + + + + + + + + + + +"}, + {@"./MultiReferenceModelGPS.xml", @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"}, + {@"./MultiReferenceModelLocation.xml", @" + + + + + + + + + + + + + + + + +"}, + {@"./MultiReferenceModelMap.xml", @" + + + + + + + + + +"}, + }; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::Microsoft.OData.Edm.IEdmModel ParsedModel = LoadModelFromString(); + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private const string Edmx = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static global::Microsoft.OData.Edm.IEdmModel GetInstance() + { + return ParsedModel; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Xml.XmlReader getReferencedModelFromMap(global::System.Uri uri) + { + string referencedEdmx; + if (ReferencesMap.TryGetValue(uri.OriginalString, out referencedEdmx)) + { + return CreateXmlReader(referencedEdmx); + } + + return null; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::Microsoft.OData.Edm.IEdmModel LoadModelFromString() + { + global::System.Xml.XmlReader reader = CreateXmlReader(Edmx); + try + { + return global::Microsoft.OData.Edm.Csdl.CsdlReader.Parse(reader, getReferencedModelFromMap); + } + finally + { + ((global::System.IDisposable)(reader)).Dispose(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Xml.XmlReader CreateXmlReader(string edmxToParse) + { + return global::System.Xml.XmlReader.Create(new global::System.IO.StringReader(edmxToParse)); + } + + } + /// + /// There are no comments for GetDefaultOutsideGeoFenceAlarm in the schema. + /// + public virtual global::Microsoft.OData.Client.DataServiceQuerySingle GetDefaultOutsideGeoFenceAlarm() + { + return this.CreateFunctionQuerySingle("", "GetDefaultOutsideGeoFenceAlarm", true); + } + /// + /// There are no comments for ResetVehicleSpeedToValue in the schema. + /// + public virtual global::Microsoft.OData.Client.DataServiceActionQuery ResetVehicleSpeedToValue(global::System.Nullable targetValue) + { + return new global::Microsoft.OData.Client.DataServiceActionQuery(this, this.BaseUri.OriginalString.Trim('/') + "/ResetVehicleSpeedToValue", new global::Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)); + } + } + /// + /// There are no comments for LocationAndFuel in the schema. + /// + public partial class LocationAndFuel + { + /// + /// There are no comments for Property FuelLevel in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable FuelLevel + { + get + { + return this._FuelLevel; + } + set + { + this.OnFuelLevelChanging(value); + this._FuelLevel = value; + this.OnFuelLevelChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _FuelLevel; + partial void OnFuelLevelChanging(global::System.Nullable value); + partial void OnFuelLevelChanged(); + /// + /// There are no comments for Property Location in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation Location + { + get + { + return this._Location; + } + set + { + this.OnLocationChanging(value); + this._Location = value; + this.OnLocationChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation _Location; + partial void OnLocationChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation value); + partial void OnLocationChanged(); + } + /// + /// Alarm: Truck Stopped! + /// + public partial class TruckStoppedAlarmType + { + /// + /// There are no comments for Property Severity in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable Severity + { + get + { + return this._Severity; + } + set + { + this.OnSeverityChanging(value); + this._Severity = value; + this.OnSeverityChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _Severity = 3; + partial void OnSeverityChanging(global::System.Nullable value); + partial void OnSeverityChanged(); + /// + /// There are no comments for Property LocationAndFuel in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.LocationAndFuel LocationAndFuel + { + get + { + return this._LocationAndFuel; + } + set + { + this.OnLocationAndFuelChanging(value); + this._LocationAndFuel = value; + this.OnLocationAndFuelChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.LocationAndFuel _LocationAndFuel; + partial void OnLocationAndFuelChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.LocationAndFuel value); + partial void OnLocationAndFuelChanged(); + } + /// + /// There are no comments for HeadUnitTypeSingle in the schema. + /// + public partial class HeadUnitTypeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new HeadUnitTypeSingle object. + /// + public HeadUnitTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new HeadUnitTypeSingle object. + /// + public HeadUnitTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new HeadUnitTypeSingle object. + /// + public HeadUnitTypeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for HeadUnitType in the schema. + /// + /// + /// SerialNo + /// + [global::Microsoft.OData.Client.Key("SerialNo")] + public partial class HeadUnitType : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new HeadUnitType object. + /// + /// Initial value of SerialNo. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static HeadUnitType CreateHeadUnitType(string serialNo) + { + HeadUnitType headUnitType = new HeadUnitType(); + headUnitType.SerialNo = serialNo; + return headUnitType; + } + /// + /// There are no comments for Property SerialNo in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual string SerialNo + { + get + { + return this._SerialNo; + } + set + { + this.OnSerialNoChanging(value); + this._SerialNo = value; + this.OnSerialNoChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _SerialNo; + partial void OnSerialNoChanging(string value); + partial void OnSerialNoChanged(); + /// + /// There are no comments for Property DimmingLevel in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable DimmingLevel + { + get + { + return this._DimmingLevel; + } + set + { + this.OnDimmingLevelChanging(value); + this._DimmingLevel = value; + this.OnDimmingLevelChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _DimmingLevel; + partial void OnDimmingLevelChanging(global::System.Nullable value); + partial void OnDimmingLevelChanged(); + } + /// + /// There are no comments for TruckTypeSingle in the schema. + /// + public partial class TruckTypeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new TruckTypeSingle object. + /// + public TruckTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new TruckTypeSingle object. + /// + public TruckTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new TruckTypeSingle object. + /// + public TruckTypeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for HeadUnit in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle HeadUnit + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._HeadUnit == null)) + { + this._HeadUnit = new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle(this.Context, GetPath("HeadUnit")); + } + return this._HeadUnit; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle _HeadUnit; + /// + /// There are no comments for VehicleGPS in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle VehicleGPS + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._VehicleGPS == null)) + { + this._VehicleGPS = new global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle(this.Context, GetPath("VehicleGPS")); + } + return this._VehicleGPS; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle _VehicleGPS; + } + /// + /// There are no comments for TruckType in the schema. + /// + /// + /// Key + /// + [global::Microsoft.OData.Client.Key("Key")] + public partial class TruckType : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new TruckType object. + /// + /// Initial value of Key. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static TruckType CreateTruckType(string key) + { + TruckType truckType = new TruckType(); + truckType.Key = key; + return truckType; + } + /// + /// There are no comments for Property Key in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual string Key + { + get + { + return this._Key; + } + set + { + this.OnKeyChanging(value); + this._Key = value; + this.OnKeyChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _Key; + partial void OnKeyChanging(string value); + partial void OnKeyChanged(); + /// + /// There are no comments for Property VIN in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual string VIN + { + get + { + return this._VIN; + } + set + { + this.OnVINChanging(value); + this._VIN = value; + this.OnVINChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _VIN; + partial void OnVINChanging(string value); + partial void OnVINChanged(); + /// + /// There are no comments for Property FuelLevel in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable FuelLevel + { + get + { + return this._FuelLevel; + } + set + { + this.OnFuelLevelChanging(value); + this._FuelLevel = value; + this.OnFuelLevelChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _FuelLevel; + partial void OnFuelLevelChanging(global::System.Nullable value); + partial void OnFuelLevelChanged(); + /// + /// There are no comments for Property ACState in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable ACState + { + get + { + return this._ACState; + } + set + { + this.OnACStateChanging(value); + this._ACState = value; + this.OnACStateChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _ACState; + partial void OnACStateChanging(global::System.Nullable value); + partial void OnACStateChanged(); + /// + /// There are no comments for Property TruckIsHomeFuelLevel in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable TruckIsHomeFuelLevel + { + get + { + return this._TruckIsHomeFuelLevel; + } + set + { + this.OnTruckIsHomeFuelLevelChanging(value); + this._TruckIsHomeFuelLevel = value; + this.OnTruckIsHomeFuelLevelChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _TruckIsHomeFuelLevel; + partial void OnTruckIsHomeFuelLevelChanging(global::System.Nullable value); + partial void OnTruckIsHomeFuelLevelChanged(); + /// + /// There are no comments for Property TruckStoppedAlarm in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckStoppedAlarmType TruckStoppedAlarm + { + get + { + return this._TruckStoppedAlarm; + } + set + { + this.OnTruckStoppedAlarmChanging(value); + this._TruckStoppedAlarm = value; + this.OnTruckStoppedAlarmChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckStoppedAlarmType _TruckStoppedAlarm; + partial void OnTruckStoppedAlarmChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckStoppedAlarmType value); + partial void OnTruckStoppedAlarmChanged(); + /// + /// There are no comments for Property OutsideGeoFenceAlarm in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType OutsideGeoFenceAlarm + { + get + { + return this._OutsideGeoFenceAlarm; + } + set + { + this.OnOutsideGeoFenceAlarmChanging(value); + this._OutsideGeoFenceAlarm = value; + this.OnOutsideGeoFenceAlarmChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType _OutsideGeoFenceAlarm; + partial void OnOutsideGeoFenceAlarmChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType value); + partial void OnOutsideGeoFenceAlarmChanged(); + /// + /// There are no comments for Property HeadUnit in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType HeadUnit + { + get + { + return this._HeadUnit; + } + set + { + this.OnHeadUnitChanging(value); + this._HeadUnit = value; + this.OnHeadUnitChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType _HeadUnit; + partial void OnHeadUnitChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType value); + partial void OnHeadUnitChanged(); + /// + /// There are no comments for Property VehicleGPS in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType VehicleGPS + { + get + { + return this._VehicleGPS; + } + set + { + this.OnVehicleGPSChanging(value); + this._VehicleGPS = value; + this.OnVehicleGPSChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType _VehicleGPS; + partial void OnVehicleGPSChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType value); + partial void OnVehicleGPSChanged(); + /// + /// Set the AC state + /// + public virtual global::Microsoft.OData.Client.DataServiceActionQuery SetACState(global::System.Nullable state) + { + global::Microsoft.OData.Client.EntityDescriptor resource = Context.EntityTracker.TryGetEntityDescriptor(this); + if (resource == null) + { + throw new global::System.Exception("cannot find entity"); + } + + return new global::Microsoft.OData.Client.DataServiceActionQuery(this.Context, resource.EditLink.OriginalString.Trim('/') + "/Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.SetACState", new global::Microsoft.OData.Client.BodyOperationParameter("state", state)); + } + /// + /// Turn off AC + /// + public virtual global::Microsoft.OData.Client.DataServiceActionQuery TurnOffAC() + { + global::Microsoft.OData.Client.EntityDescriptor resource = Context.EntityTracker.TryGetEntityDescriptor(this); + if (resource == null) + { + throw new global::System.Exception("cannot find entity"); + } + + return new global::Microsoft.OData.Client.DataServiceActionQuery(this.Context, resource.EditLink.OriginalString.Trim('/') + "/Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TurnOffAC"); + } + } + /// + /// There are no comments for DerivedVehicleGPSTypeSingle in the schema. + /// + public partial class DerivedVehicleGPSTypeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new DerivedVehicleGPSTypeSingle object. + /// + public DerivedVehicleGPSTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new DerivedVehicleGPSTypeSingle object. + /// + public DerivedVehicleGPSTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new DerivedVehicleGPSTypeSingle object. + /// + public DerivedVehicleGPSTypeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for DerivedVehicleGPSType in the schema. + /// + /// + /// Key + /// + [global::Microsoft.OData.Client.Key("Key")] + public partial class DerivedVehicleGPSType : global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType + { + /// + /// Create a new DerivedVehicleGPSType object. + /// + /// Initial value of Key. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static DerivedVehicleGPSType CreateDerivedVehicleGPSType(string key) + { + DerivedVehicleGPSType derivedVehicleGPSType = new DerivedVehicleGPSType(); + derivedVehicleGPSType.Key = key; + return derivedVehicleGPSType; + } + /// + /// There are no comments for Property DisplayName in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual string DisplayName + { + get + { + return this._DisplayName; + } + set + { + this.OnDisplayNameChanging(value); + this._DisplayName = value; + this.OnDisplayNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _DisplayName; + partial void OnDisplayNameChanging(string value); + partial void OnDisplayNameChanged(); + } + /// + /// Class containing all extension methods + /// + public static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle specified by key from an entity set + /// + /// source entity set + /// The value of serialNo + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + string serialNo) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "SerialNo", serialNo } + }; + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle specified by key from an entity set + /// + /// source entity set + /// The value of key + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + string key) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Key", key } + }; + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle specified by key from an entity set + /// + /// source entity set + /// The value of key + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + string key) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Key", key } + }; + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType to its derived type global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType + /// + /// source entity + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle CastToDerivedVehicleGPSType(this global::Microsoft.OData.Client.DataServiceQuerySingle _source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = _source.CastTo(); + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle(_source.Context, query.GetPath(null)); + } + /// + /// Set the AC state + /// + public static global::Microsoft.OData.Client.DataServiceActionQuery SetACState(this global::Microsoft.OData.Client.DataServiceQuerySingle _source, global::System.Nullable state) + { + if (!_source.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + + return new global::Microsoft.OData.Client.DataServiceActionQuery(_source.Context, _source.AppendRequestUri("Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.SetACState"), new global::Microsoft.OData.Client.BodyOperationParameter("state", state)); + } + /// + /// Turn off AC + /// + public static global::Microsoft.OData.Client.DataServiceActionQuery TurnOffAC(this global::Microsoft.OData.Client.DataServiceQuerySingle _source) + { + if (!_source.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + + return new global::Microsoft.OData.Client.DataServiceActionQuery(_source.Context, _source.AppendRequestUri("Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TurnOffAC")); + } + } +} +namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Core.V1 +{ +} +namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Vocabulary.V1 +{ +} +namespace Microsoft.OData.SampleService.Models.ModelRefDemo.GPS +{ + /// + /// There are no comments for GPSContainer in the schema. + /// + public partial class GPSContainer : global::Microsoft.OData.Client.DataServiceContext + { + /// + /// Initialize a new GPSContainer object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public GPSContainer(global::System.Uri serviceRoot) : + base(serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion.V4) + { + this.ResolveName = new global::System.Func(this.ResolveNameFromType); + this.OnContextCreated(); + this.Format.LoadServiceModel = GeneratedEdmModel.GetInstance; + this.Format.UseJson(); + } + partial void OnContextCreated(); + /// + /// Since the namespace configured for this service reference + /// in Visual Studio is different from the one indicated in the + /// server schema, use type-mappers to map between the two. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + protected string ResolveNameFromType(global::System.Type clientType) + { + return clientType.FullName; + } + /// + /// There are no comments for VehicleGPSSetInGPS in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.Client.DataServiceQuery VehicleGPSSetInGPS + { + get + { + if ((this._VehicleGPSSetInGPS == null)) + { + this._VehicleGPSSetInGPS = base.CreateQuery("VehicleGPSSetInGPS"); + } + return this._VehicleGPSSetInGPS; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.Client.DataServiceQuery _VehicleGPSSetInGPS; + /// + /// There are no comments for VehicleGPSSetInGPS in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual void AddToVehicleGPSSetInGPS(VehicleGPSType vehicleGPSType) + { + base.AddObject("VehicleGPSSetInGPS", vehicleGPSType); + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private abstract class GeneratedEdmModel + { + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Collections.Generic.Dictionary ReferencesMap = new global::System.Collections.Generic.Dictionary() + { + {@"./MultiReferenceModelCoreTerms.xml", @" + + + + + + + + +"}, + {@"./MultiReferenceModelDeviceModelTerms.xml", @" + + + + + + + + + + + + +"}, + {@"./MultiReferenceModelGPS.xml", @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"}, + {@"./MultiReferenceModelLocation.xml", @" + + + + + + + + + + + + + + + + +"}, + {@"./MultiReferenceModelMap.xml", @" + + + + + + + + + +"}, + }; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::Microsoft.OData.Edm.IEdmModel ParsedModel = LoadModelFromString(); + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private const string Edmx = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static global::Microsoft.OData.Edm.IEdmModel GetInstance() + { + return ParsedModel; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Xml.XmlReader getReferencedModelFromMap(global::System.Uri uri) + { + string referencedEdmx; + if (ReferencesMap.TryGetValue(uri.OriginalString, out referencedEdmx)) + { + return CreateXmlReader(referencedEdmx); + } + + return null; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::Microsoft.OData.Edm.IEdmModel LoadModelFromString() + { + global::System.Xml.XmlReader reader = CreateXmlReader(Edmx); + try + { + return global::Microsoft.OData.Edm.Csdl.CsdlReader.Parse(reader, getReferencedModelFromMap); + } + finally + { + ((global::System.IDisposable)(reader)).Dispose(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private static global::System.Xml.XmlReader CreateXmlReader(string edmxToParse) + { + return global::System.Xml.XmlReader.Create(new global::System.IO.StringReader(edmxToParse)); + } + + } + /// + /// There are no comments for ResetVehicleSpeedToValue in the schema. + /// + public virtual global::Microsoft.OData.Client.DataServiceActionQuery ResetVehicleSpeedToValue(global::System.Nullable targetValue) + { + return new global::Microsoft.OData.Client.DataServiceActionQuery(this, this.BaseUri.OriginalString.Trim('/') + "/ResetVehicleSpeedToValue", new global::Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)); + } + } + /// + /// There are no comments for GPSLostSignalAlarmType in the schema. + /// + public partial class GPSLostSignalAlarmType + { + /// + /// There are no comments for Property Severity in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable Severity + { + get + { + return this._Severity; + } + set + { + this.OnSeverityChanging(value); + this._Severity = value; + this.OnSeverityChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _Severity; + partial void OnSeverityChanging(global::System.Nullable value); + partial void OnSeverityChanged(); + /// + /// There are no comments for Property LastKnownLocation in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation LastKnownLocation + { + get + { + return this._LastKnownLocation; + } + set + { + this.OnLastKnownLocationChanging(value); + this._LastKnownLocation = value; + this.OnLastKnownLocationChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation _LastKnownLocation; + partial void OnLastKnownLocationChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation value); + partial void OnLastKnownLocationChanged(); + } + /// + /// There are no comments for VehicleGPSTypeSingle in the schema. + /// + public partial class VehicleGPSTypeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new VehicleGPSTypeSingle object. + /// + public VehicleGPSTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new VehicleGPSTypeSingle object. + /// + public VehicleGPSTypeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new VehicleGPSTypeSingle object. + /// + public VehicleGPSTypeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for VehicleGPSType in the schema. + /// + /// + /// Key + /// + [global::Microsoft.OData.Client.Key("Key")] + public partial class VehicleGPSType : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new VehicleGPSType object. + /// + /// Initial value of Key. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public static VehicleGPSType CreateVehicleGPSType(string key) + { + VehicleGPSType vehicleGPSType = new VehicleGPSType(); + vehicleGPSType.Key = key; + return vehicleGPSType; + } + /// + /// There are no comments for Property Key in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual string Key + { + get + { + return this._Key; + } + set + { + this.OnKeyChanging(value); + this._Key = value; + this.OnKeyChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _Key; + partial void OnKeyChanging(string value); + partial void OnKeyChanged(); + /// + /// There are no comments for Property VehicleSpeed in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable VehicleSpeed + { + get + { + return this._VehicleSpeed; + } + set + { + this.OnVehicleSpeedChanging(value); + this._VehicleSpeed = value; + this.OnVehicleSpeedChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _VehicleSpeed; + partial void OnVehicleSpeedChanging(global::System.Nullable value); + partial void OnVehicleSpeedChanged(); + /// + /// There are no comments for Property StartLocation in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation StartLocation + { + get + { + return this._StartLocation; + } + set + { + this.OnStartLocationChanging(value); + this._StartLocation = value; + this.OnStartLocationChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation _StartLocation; + partial void OnStartLocationChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation value); + partial void OnStartLocationChanged(); + /// + /// There are no comments for Property EndLocation in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation EndLocation + { + get + { + return this._EndLocation; + } + set + { + this.OnEndLocationChanging(value); + this._EndLocation = value; + this.OnEndLocationChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation _EndLocation; + partial void OnEndLocationChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation value); + partial void OnEndLocationChanged(); + /// + /// There are no comments for Property CurrentLocation in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation CurrentLocation + { + get + { + return this._CurrentLocation; + } + set + { + this.OnCurrentLocationChanging(value); + this._CurrentLocation = value; + this.OnCurrentLocationChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation _CurrentLocation; + partial void OnCurrentLocationChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation value); + partial void OnCurrentLocationChanged(); + /// + /// There are no comments for Property Map in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Map.MapType Map + { + get + { + return this._Map; + } + set + { + this.OnMapChanging(value); + this._Map = value; + this.OnMapChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Map.MapType _Map; + partial void OnMapChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Map.MapType value); + partial void OnMapChanged(); + /// + /// There are no comments for Property LostSignalAlarm in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GPSLostSignalAlarmType LostSignalAlarm + { + get + { + return this._LostSignalAlarm; + } + set + { + this.OnLostSignalAlarmChanging(value); + this._LostSignalAlarm = value; + this.OnLostSignalAlarmChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GPSLostSignalAlarmType _LostSignalAlarm; + partial void OnLostSignalAlarmChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GPSLostSignalAlarmType value); + partial void OnLostSignalAlarmChanged(); + /// + /// There are no comments for GetVehicleSpeed in the schema. + /// + public virtual global::Microsoft.OData.Client.DataServiceQuerySingle GetVehicleSpeed() + { + global::System.Uri requestUri; + Context.TryGetUri(this, out requestUri); + + return this.Context.CreateFunctionQuerySingle(string.Join("/", global::System.Linq.Enumerable.Select(global::System.Linq.Enumerable.Skip(requestUri.Segments, this.Context.BaseUri.Segments.Length), s => s.Trim('/'))), "Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GetVehicleSpeed", false); + } + /// + /// Reset VehicleSpeed to Zero + /// + public virtual global::Microsoft.OData.Client.DataServiceActionQuery ResetVehicleSpeed(global::System.Nullable targetValue) + { + global::Microsoft.OData.Client.EntityDescriptor resource = Context.EntityTracker.TryGetEntityDescriptor(this); + if (resource == null) + { + throw new global::System.Exception("cannot find entity"); + } + + return new global::Microsoft.OData.Client.DataServiceActionQuery(this.Context, resource.EditLink.OriginalString.Trim('/') + "/Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.ResetVehicleSpeed", new global::Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)); + } + } + /// + /// Class containing all extension methods + /// + public static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, global::System.Collections.Generic.IDictionary _keys) + { + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType as global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle specified by key from an entity set + /// + /// source entity set + /// The value of key + public static global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery _source, + string key) + { + global::System.Collections.Generic.IDictionary _keys = new global::System.Collections.Generic.Dictionary + { + { "Key", key } + }; + return new global::Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))); + } + /// + /// There are no comments for GetVehicleSpeed in the schema. + /// + public static global::Microsoft.OData.Client.DataServiceQuerySingle GetVehicleSpeed(this global::Microsoft.OData.Client.DataServiceQuerySingle _source) + { + if (!_source.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + + return _source.CreateFunctionQuerySingle("Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GetVehicleSpeed", false); + } + /// + /// Reset VehicleSpeed to Zero + /// + public static global::Microsoft.OData.Client.DataServiceActionQuery ResetVehicleSpeed(this global::Microsoft.OData.Client.DataServiceQuerySingle _source, global::System.Nullable targetValue) + { + if (!_source.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + + return new global::Microsoft.OData.Client.DataServiceActionQuery(_source.Context, _source.AppendRequestUri("Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.ResetVehicleSpeed"), new global::Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)); + } + } +} +namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Location +{ + /// + /// There are no comments for GeoLocation in the schema. + /// + public partial class GeoLocation + { + /// + /// There are no comments for Property Lat in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable Lat + { + get + { + return this._Lat; + } + set + { + this.OnLatChanging(value); + this._Lat = value; + this.OnLatChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _Lat; + partial void OnLatChanging(global::System.Nullable value); + partial void OnLatChanged(); + /// + /// There are no comments for Property Long in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable Long + { + get + { + return this._Long; + } + set + { + this.OnLongChanging(value); + this._Long = value; + this.OnLongChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _Long; + partial void OnLongChanging(global::System.Nullable value); + partial void OnLongChanged(); + } + /// + /// There are no comments for OutsideGeoFenceAlarmType in the schema. + /// + public partial class OutsideGeoFenceAlarmType + { + /// + /// There are no comments for Property Severity in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable Severity + { + get + { + return this._Severity; + } + set + { + this.OnSeverityChanging(value); + this._Severity = value; + this.OnSeverityChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _Severity; + partial void OnSeverityChanging(global::System.Nullable value); + partial void OnSeverityChanged(); + /// + /// There are no comments for Property Location in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation Location + { + get + { + return this._Location; + } + set + { + this.OnLocationChanging(value); + this._Location = value; + this.OnLocationChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation _Location; + partial void OnLocationChanging(global::Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation value); + partial void OnLocationChanged(); + } +} +namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Map +{ + /// + /// There are no comments for MapType in the schema. + /// + public partial class MapType + { + /// + /// There are no comments for Property ProviderName in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual string ProviderName + { + get + { + return this._ProviderName; + } + set + { + this.OnProviderNameChanging(value); + this._ProviderName = value; + this.OnProviderNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _ProviderName; + partial void OnProviderNameChanging(string value); + partial void OnProviderNameChanged(); + /// + /// There are no comments for Property Uri in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual string Uri + { + get + { + return this._Uri; + } + set + { + this.OnUriChanging(value); + this._Uri = value; + this.OnUriChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private string _Uri; + partial void OnUriChanging(string value); + partial void OnUriChanged(); + /// + /// There are no comments for Property MBytesDownloaded in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + public virtual global::System.Nullable MBytesDownloaded + { + get + { + return this._MBytesDownloaded; + } + set + { + this.OnMBytesDownloadedChanging(value); + this._MBytesDownloaded = value; + this.OnMBytesDownloadedChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")] + private global::System.Nullable _MBytesDownloaded; + partial void OnMBytesDownloadedChanging(global::System.Nullable value); + partial void OnMBytesDownloadedChanged(); + } +} diff --git a/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.vb b/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.vb new file mode 100644 index 00000000..fa47b722 --- /dev/null +++ b/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.vb @@ -0,0 +1,1741 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + + +'Generation date: 1/16/2021 1:39:28 PM +Namespace Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo + ''' + ''' There are no comments for TruckDemoService in the schema. + ''' + Partial Public Class TruckDemoService + Inherits Global.Microsoft.OData.Client.DataServiceContext + ''' + ''' Initialize a new TruckDemoService object. + ''' + _ + Public Sub New(ByVal serviceRoot As Global.System.Uri) + MyBase.New(serviceRoot, Global.Microsoft.OData.Client.ODataProtocolVersion.V4) + Me.ResolveName = AddressOf Me.ResolveNameFromType + Me.OnContextCreated + Me.Format.LoadServiceModel = AddressOf GeneratedEdmModel.GetInstance + Me.Format.UseJson() + End Sub + Partial Private Sub OnContextCreated() + End Sub + _ + Private Shared ROOTNAMESPACE As String = GetType(TruckDemoService).Namespace.Remove(GetType(TruckDemoService).Namespace.LastIndexOf("Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo")) + ''' + ''' Since the namespace configured for this service reference + ''' in Visual Studio is different from the one indicated in the + ''' server schema, use type-mappers to map between the two. + ''' + _ + Protected Function ResolveNameFromType(ByVal clientType As Global.System.Type) As String + Return clientType.FullName.Substring(ROOTNAMESPACE.Length) + End Function + ''' + ''' Our Trucks + ''' + _ + Public Overridable ReadOnly Property Trucks() As Global.Microsoft.OData.Client.DataServiceQuery(Of TruckType) + Get + If (Me._Trucks Is Nothing) Then + Me._Trucks = MyBase.CreateQuery(Of TruckType)("Trucks") + End If + Return Me._Trucks + End Get + End Property + _ + Private _Trucks As Global.Microsoft.OData.Client.DataServiceQuery(Of TruckType) + ''' + ''' There are no comments for VehicleGPSSet in the schema. + ''' + _ + Public Overridable ReadOnly Property VehicleGPSSet() As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + Get + If (Me._VehicleGPSSet Is Nothing) Then + Me._VehicleGPSSet = MyBase.CreateQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType)("VehicleGPSSet") + End If + Return Me._VehicleGPSSet + End Get + End Property + _ + Private _VehicleGPSSet As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + ''' + ''' There are no comments for DerivedVehicleGPSSet in the schema. + ''' + _ + Public Overridable ReadOnly Property DerivedVehicleGPSSet() As Global.Microsoft.OData.Client.DataServiceQuery(Of DerivedVehicleGPSType) + Get + If (Me._DerivedVehicleGPSSet Is Nothing) Then + Me._DerivedVehicleGPSSet = MyBase.CreateQuery(Of DerivedVehicleGPSType)("DerivedVehicleGPSSet") + End If + Return Me._DerivedVehicleGPSSet + End Get + End Property + _ + Private _DerivedVehicleGPSSet As Global.Microsoft.OData.Client.DataServiceQuery(Of DerivedVehicleGPSType) + ''' + ''' There are no comments for VehicleGPSSetInGPS in the schema. + ''' + _ + Public Overridable ReadOnly Property VehicleGPSSetInGPS() As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + Get + If (Me._VehicleGPSSetInGPS Is Nothing) Then + Me._VehicleGPSSetInGPS = MyBase.CreateQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType)("VehicleGPSSetInGPS") + End If + Return Me._VehicleGPSSetInGPS + End Get + End Property + _ + Private _VehicleGPSSetInGPS As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + ''' + ''' There are no comments for Trucks in the schema. + ''' + _ + Public Overridable Sub AddToTrucks(ByVal truckType As TruckType) + MyBase.AddObject("Trucks", truckType) + End Sub + ''' + ''' There are no comments for VehicleGPSSet in the schema. + ''' + _ + Public Overridable Sub AddToVehicleGPSSet(ByVal vehicleGPSType As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + MyBase.AddObject("VehicleGPSSet", vehicleGPSType) + End Sub + ''' + ''' There are no comments for DerivedVehicleGPSSet in the schema. + ''' + _ + Public Overridable Sub AddToDerivedVehicleGPSSet(ByVal derivedVehicleGPSType As DerivedVehicleGPSType) + MyBase.AddObject("DerivedVehicleGPSSet", derivedVehicleGPSType) + End Sub + ''' + ''' There are no comments for VehicleGPSSetInGPS in the schema. + ''' + _ + Public Overridable Sub AddToVehicleGPSSetInGPS(ByVal vehicleGPSType As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + MyBase.AddObject("VehicleGPSSetInGPS", vehicleGPSType) + End Sub + _ + Private MustInherit Class GeneratedEdmModel + _ + Private Shared ReferencesMap As Global.System.Collections.Generic.Dictionary(Of String, String) = New Global.System.Collections.Generic.Dictionary(Of String, String) From + { + {"./MultiReferenceModelCoreTerms.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelDeviceModelTerms.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelGPS.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelLocation.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelMap.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""} + } + _ + Private Shared ParsedModel As Global.Microsoft.OData.Edm.IEdmModel = LoadModelFromString + _ + Private Const Edmx As String = "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + "" + _ + Public Shared Function GetInstance() As Global.Microsoft.OData.Edm.IEdmModel + Return ParsedModel + End Function + _ + Private Shared Function getReferencedModelFromMap(ByVal uri As Global.System.Uri) As Global.System.Xml.XmlReader + Dim referencedEdmx As String = Nothing + If (ReferencesMap.TryGetValue(uri.OriginalString, referencedEdmx)) Then + Return CreateXmlReader(referencedEdmx) + End If + Return Nothing + End Function + _ + Private Shared Function LoadModelFromString() As Global.Microsoft.OData.Edm.IEdmModel + Dim reader As Global.System.Xml.XmlReader = CreateXmlReader(Edmx) + Try + Return Global.Microsoft.OData.Edm.Csdl.CsdlReader.Parse(reader, AddressOf getReferencedModelFromMap) + Finally + CType(reader,Global.System.IDisposable).Dispose + End Try + End Function + _ + Private Shared Function CreateXmlReader(ByVal edmxToParse As String) As Global.System.Xml.XmlReader + Return Global.System.Xml.XmlReader.Create(New Global.System.IO.StringReader(edmxToParse)) + End Function + End Class + ''' + ''' There are no comments for GetDefaultOutsideGeoFenceAlarm in the schema. + ''' + Public Overridable Function GetDefaultOutsideGeoFenceAlarm() As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType) + Return Me.CreateFunctionQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType)("", "/GetDefaultOutsideGeoFenceAlarm", True) + End Function + ''' + ''' There are no comments for ResetVehicleSpeedToValue in the schema. + ''' + Public Overridable Function ResetVehicleSpeedToValue(targetValue As Global.System.Nullable(Of Double)) As Global.Microsoft.OData.Client.DataServiceActionQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType)(Me, Me.BaseUri.OriginalString.Trim("/"C) + "/ResetVehicleSpeedToValue", New Global.Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)) + End Function + End Class + ''' + ''' There are no comments for LocationAndFuel in the schema. + ''' + Partial Public Class LocationAndFuel + ''' + ''' There are no comments for Property FuelLevel in the schema. + ''' + _ + Public Overridable Property FuelLevel() As Global.System.Nullable(Of Double) + Get + Return Me._FuelLevel + End Get + Set + Me.OnFuelLevelChanging(value) + Me._FuelLevel = value + Me.OnFuelLevelChanged + End Set + End Property + _ + Private _FuelLevel As Global.System.Nullable(Of Double) + Partial Private Sub OnFuelLevelChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnFuelLevelChanged() + End Sub + ''' + ''' There are no comments for Property Location in the schema. + ''' + _ + Public Overridable Property Location() As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Get + Return Me._Location + End Get + Set + Me.OnLocationChanging(value) + Me._Location = value + Me.OnLocationChanged + End Set + End Property + _ + Private _Location As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Partial Private Sub OnLocationChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation) + End Sub + Partial Private Sub OnLocationChanged() + End Sub + End Class + ''' + ''' Alarm: Truck Stopped! + ''' + Partial Public Class TruckStoppedAlarmType + ''' + ''' There are no comments for Property Severity in the schema. + ''' + _ + Public Overridable Property Severity() As Global.System.Nullable(Of Integer) + Get + Return Me._Severity + End Get + Set + Me.OnSeverityChanging(value) + Me._Severity = value + Me.OnSeverityChanged + End Set + End Property + _ + Private _Severity As Global.System.Nullable(Of Integer) = 3 + Partial Private Sub OnSeverityChanging(ByVal value As Global.System.Nullable(Of Integer)) + End Sub + Partial Private Sub OnSeverityChanged() + End Sub + ''' + ''' There are no comments for Property LocationAndFuel in the schema. + ''' + _ + Public Overridable Property LocationAndFuel() As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.LocationAndFuel + Get + Return Me._LocationAndFuel + End Get + Set + Me.OnLocationAndFuelChanging(value) + Me._LocationAndFuel = value + Me.OnLocationAndFuelChanged + End Set + End Property + _ + Private _LocationAndFuel As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.LocationAndFuel + Partial Private Sub OnLocationAndFuelChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.LocationAndFuel) + End Sub + Partial Private Sub OnLocationAndFuelChanged() + End Sub + End Class + ''' + ''' There are no comments for HeadUnitTypeSingle in the schema. + ''' + Partial Public Class HeadUnitTypeSingle + Inherits Global.Microsoft.OData.Client.DataServiceQuerySingle(Of HeadUnitType) + ''' + ''' Initialize a new HeadUnitTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String) + MyBase.New(context, path) + End Sub + + ''' + ''' Initialize a new HeadUnitTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String, ByVal isComposable As Boolean) + MyBase.New(context, path, isComposable) + End Sub + + ''' + ''' Initialize a new HeadUnitTypeSingle object. + ''' + Public Sub New(ByVal query As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of HeadUnitType)) + MyBase.New(query) + End Sub + End Class + ''' + ''' There are no comments for HeadUnitType in the schema. + ''' + ''' + ''' SerialNo + ''' + _ + Partial Public Class HeadUnitType + Inherits Global.Microsoft.OData.Client.BaseEntityType + ''' + ''' Create a new HeadUnitType object. + ''' + ''' Initial value of SerialNo. + _ + Public Shared Function CreateHeadUnitType(ByVal serialNo As String) As HeadUnitType + Dim headUnitType As HeadUnitType = New HeadUnitType() + headUnitType.SerialNo = serialNo + Return headUnitType + End Function + ''' + ''' There are no comments for Property SerialNo in the schema. + ''' + _ + Public Overridable Property SerialNo() As String + Get + Return Me._SerialNo + End Get + Set + Me.OnSerialNoChanging(value) + Me._SerialNo = value + Me.OnSerialNoChanged + End Set + End Property + _ + Private _SerialNo As String + Partial Private Sub OnSerialNoChanging(ByVal value As String) + End Sub + Partial Private Sub OnSerialNoChanged() + End Sub + ''' + ''' There are no comments for Property DimmingLevel in the schema. + ''' + _ + Public Overridable Property DimmingLevel() As Global.System.Nullable(Of Double) + Get + Return Me._DimmingLevel + End Get + Set + Me.OnDimmingLevelChanging(value) + Me._DimmingLevel = value + Me.OnDimmingLevelChanged + End Set + End Property + _ + Private _DimmingLevel As Global.System.Nullable(Of Double) + Partial Private Sub OnDimmingLevelChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnDimmingLevelChanged() + End Sub + End Class + ''' + ''' There are no comments for TruckTypeSingle in the schema. + ''' + Partial Public Class TruckTypeSingle + Inherits Global.Microsoft.OData.Client.DataServiceQuerySingle(Of TruckType) + ''' + ''' Initialize a new TruckTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String) + MyBase.New(context, path) + End Sub + + ''' + ''' Initialize a new TruckTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String, ByVal isComposable As Boolean) + MyBase.New(context, path, isComposable) + End Sub + + ''' + ''' Initialize a new TruckTypeSingle object. + ''' + Public Sub New(ByVal query As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of TruckType)) + MyBase.New(query) + End Sub + ''' + ''' There are no comments for HeadUnit in the schema. + ''' + _ + Public Overridable ReadOnly Property HeadUnit() As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle + Get + If Not Me.IsComposable Then + Throw New Global.System.NotSupportedException("The previous function is not composable.") + End If + If (Me._HeadUnit Is Nothing) Then + Me._HeadUnit = New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle(Me.Context, GetPath("HeadUnit")) + End If + Return Me._HeadUnit + End Get + End Property + _ + Private _HeadUnit As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle + ''' + ''' There are no comments for VehicleGPS in the schema. + ''' + _ + Public Overridable ReadOnly Property VehicleGPS() As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle + Get + If Not Me.IsComposable Then + Throw New Global.System.NotSupportedException("The previous function is not composable.") + End If + If (Me._VehicleGPS Is Nothing) Then + Me._VehicleGPS = New Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle(Me.Context, GetPath("VehicleGPS")) + End If + Return Me._VehicleGPS + End Get + End Property + _ + Private _VehicleGPS As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle + End Class + ''' + ''' There are no comments for TruckType in the schema. + ''' + ''' + ''' Key + ''' + _ + Partial Public Class TruckType + Inherits Global.Microsoft.OData.Client.BaseEntityType + ''' + ''' Create a new TruckType object. + ''' + ''' Initial value of Key. + _ + Public Shared Function CreateTruckType(ByVal key As String) As TruckType + Dim truckType As TruckType = New TruckType() + truckType.Key = key + Return truckType + End Function + ''' + ''' There are no comments for Property Key in the schema. + ''' + _ + Public Overridable Property Key() As String + Get + Return Me._Key + End Get + Set + Me.OnKeyChanging(value) + Me._Key = value + Me.OnKeyChanged + End Set + End Property + _ + Private _Key As String + Partial Private Sub OnKeyChanging(ByVal value As String) + End Sub + Partial Private Sub OnKeyChanged() + End Sub + ''' + ''' There are no comments for Property VIN in the schema. + ''' + _ + Public Overridable Property VIN() As String + Get + Return Me._VIN + End Get + Set + Me.OnVINChanging(value) + Me._VIN = value + Me.OnVINChanged + End Set + End Property + _ + Private _VIN As String + Partial Private Sub OnVINChanging(ByVal value As String) + End Sub + Partial Private Sub OnVINChanged() + End Sub + ''' + ''' There are no comments for Property FuelLevel in the schema. + ''' + _ + Public Overridable Property FuelLevel() As Global.System.Nullable(Of Double) + Get + Return Me._FuelLevel + End Get + Set + Me.OnFuelLevelChanging(value) + Me._FuelLevel = value + Me.OnFuelLevelChanged + End Set + End Property + _ + Private _FuelLevel As Global.System.Nullable(Of Double) + Partial Private Sub OnFuelLevelChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnFuelLevelChanged() + End Sub + ''' + ''' There are no comments for Property ACState in the schema. + ''' + _ + Public Overridable Property ACState() As Global.System.Nullable(Of Boolean) + Get + Return Me._ACState + End Get + Set + Me.OnACStateChanging(value) + Me._ACState = value + Me.OnACStateChanged + End Set + End Property + _ + Private _ACState As Global.System.Nullable(Of Boolean) + Partial Private Sub OnACStateChanging(ByVal value As Global.System.Nullable(Of Boolean)) + End Sub + Partial Private Sub OnACStateChanged() + End Sub + ''' + ''' There are no comments for Property TruckIsHomeFuelLevel in the schema. + ''' + _ + Public Overridable Property TruckIsHomeFuelLevel() As Global.System.Nullable(Of Double) + Get + Return Me._TruckIsHomeFuelLevel + End Get + Set + Me.OnTruckIsHomeFuelLevelChanging(value) + Me._TruckIsHomeFuelLevel = value + Me.OnTruckIsHomeFuelLevelChanged + End Set + End Property + _ + Private _TruckIsHomeFuelLevel As Global.System.Nullable(Of Double) + Partial Private Sub OnTruckIsHomeFuelLevelChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnTruckIsHomeFuelLevelChanged() + End Sub + ''' + ''' There are no comments for Property TruckStoppedAlarm in the schema. + ''' + _ + Public Overridable Property TruckStoppedAlarm() As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckStoppedAlarmType + Get + Return Me._TruckStoppedAlarm + End Get + Set + Me.OnTruckStoppedAlarmChanging(value) + Me._TruckStoppedAlarm = value + Me.OnTruckStoppedAlarmChanged + End Set + End Property + _ + Private _TruckStoppedAlarm As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckStoppedAlarmType + Partial Private Sub OnTruckStoppedAlarmChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckStoppedAlarmType) + End Sub + Partial Private Sub OnTruckStoppedAlarmChanged() + End Sub + ''' + ''' There are no comments for Property OutsideGeoFenceAlarm in the schema. + ''' + _ + Public Overridable Property OutsideGeoFenceAlarm() As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType + Get + Return Me._OutsideGeoFenceAlarm + End Get + Set + Me.OnOutsideGeoFenceAlarmChanging(value) + Me._OutsideGeoFenceAlarm = value + Me.OnOutsideGeoFenceAlarmChanged + End Set + End Property + _ + Private _OutsideGeoFenceAlarm As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType + Partial Private Sub OnOutsideGeoFenceAlarmChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.OutsideGeoFenceAlarmType) + End Sub + Partial Private Sub OnOutsideGeoFenceAlarmChanged() + End Sub + ''' + ''' There are no comments for Property HeadUnit in the schema. + ''' + _ + Public Overridable Property HeadUnit() As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType + Get + Return Me._HeadUnit + End Get + Set + Me.OnHeadUnitChanging(value) + Me._HeadUnit = value + Me.OnHeadUnitChanged + End Set + End Property + _ + Private _HeadUnit As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType + Partial Private Sub OnHeadUnitChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType) + End Sub + Partial Private Sub OnHeadUnitChanged() + End Sub + ''' + ''' There are no comments for Property VehicleGPS in the schema. + ''' + _ + Public Overridable Property VehicleGPS() As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType + Get + Return Me._VehicleGPS + End Get + Set + Me.OnVehicleGPSChanging(value) + Me._VehicleGPS = value + Me.OnVehicleGPSChanged + End Set + End Property + _ + Private _VehicleGPS As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType + Partial Private Sub OnVehicleGPSChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + End Sub + Partial Private Sub OnVehicleGPSChanged() + End Sub + ''' + ''' Set the AC state + ''' + Public Overridable Function SetACState(state As Global.System.Nullable(Of Boolean)) As Global.Microsoft.OData.Client.DataServiceActionQuery + Dim resource As Global.Microsoft.OData.Client.EntityDescriptor = Context.EntityTracker.TryGetEntityDescriptor(Me) + If resource Is Nothing Then + Throw New Global.System.Exception("cannot find entity") + End If + + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(Me.Context, resource.EditLink.OriginalString.Trim("/"C) + "/Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.SetACState", New Global.Microsoft.OData.Client.BodyOperationParameter("state", state)) + End Function + ''' + ''' Turn off AC + ''' + Public Overridable Function TurnOffAC() As Global.Microsoft.OData.Client.DataServiceActionQuery + Dim resource As Global.Microsoft.OData.Client.EntityDescriptor = Context.EntityTracker.TryGetEntityDescriptor(Me) + If resource Is Nothing Then + Throw New Global.System.Exception("cannot find entity") + End If + + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(Me.Context, resource.EditLink.OriginalString.Trim("/"C) + "/Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TurnOffAC") + End Function + End Class + ''' + ''' There are no comments for DerivedVehicleGPSTypeSingle in the schema. + ''' + Partial Public Class DerivedVehicleGPSTypeSingle + Inherits Global.Microsoft.OData.Client.DataServiceQuerySingle(Of DerivedVehicleGPSType) + ''' + ''' Initialize a new DerivedVehicleGPSTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String) + MyBase.New(context, path) + End Sub + + ''' + ''' Initialize a new DerivedVehicleGPSTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String, ByVal isComposable As Boolean) + MyBase.New(context, path, isComposable) + End Sub + + ''' + ''' Initialize a new DerivedVehicleGPSTypeSingle object. + ''' + Public Sub New(ByVal query As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of DerivedVehicleGPSType)) + MyBase.New(query) + End Sub + End Class + ''' + ''' There are no comments for DerivedVehicleGPSType in the schema. + ''' + ''' + ''' Key + ''' + _ + Partial Public Class DerivedVehicleGPSType + Inherits Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType + ''' + ''' Create a new DerivedVehicleGPSType object. + ''' + ''' Initial value of Key. + _ + Public Shared Function CreateDerivedVehicleGPSType(ByVal key As String) As DerivedVehicleGPSType + Dim derivedVehicleGPSType As DerivedVehicleGPSType = New DerivedVehicleGPSType() + derivedVehicleGPSType.Key = key + Return derivedVehicleGPSType + End Function + ''' + ''' There are no comments for Property DisplayName in the schema. + ''' + _ + Public Overridable Property DisplayName() As String + Get + Return Me._DisplayName + End Get + Set + Me.OnDisplayNameChanging(value) + Me._DisplayName = value + Me.OnDisplayNameChanged + End Set + End Property + _ + Private _DisplayName As String + Partial Private Sub OnDisplayNameChanging(ByVal value As String) + End Sub + Partial Private Sub OnDisplayNameChanged() + End Sub + End Class + ''' + ''' Class containing all extension methods + ''' + Public Module ExtensionMethods + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType as Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' dictionary with the names and values of keys + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType), ByVal _keys As Global.System.Collections.Generic.IDictionary(Of String, Object)) As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType as Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' The value of serialNo + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitType), + serialNo As String) As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle + Dim _keys As Global.System.Collections.Generic.IDictionary(Of String, Object) = New Global.System.Collections.Generic.Dictionary(Of String, Object)() From + { + { "SerialNo", serialNo } + } + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.HeadUnitTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType as Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' dictionary with the names and values of keys + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType), ByVal _keys As Global.System.Collections.Generic.IDictionary(Of String, Object)) As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType as Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' The value of key + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType), + key As String) As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle + Dim _keys As Global.System.Collections.Generic.IDictionary(Of String, Object) = New Global.System.Collections.Generic.Dictionary(Of String, Object)() From + { + { "Key", key } + } + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType as Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' dictionary with the names and values of keys + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType), ByVal _keys As Global.System.Collections.Generic.IDictionary(Of String, Object)) As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType as Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' The value of key + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType), + key As String) As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle + Dim _keys As Global.System.Collections.Generic.IDictionary(Of String, Object) = New Global.System.Collections.Generic.Dictionary(Of String, Object)() From + { + { "Key", key } + } + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' Cast an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType to its derived type Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType + ''' + ''' source entity + + Public Function CastToDerivedVehicleGPSType(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType)) As Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle + Dim query As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType) = _source.CastTo(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSType)() + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.DerivedVehicleGPSTypeSingle(_source.Context, query.GetPath(Nothing)) + End Function + ''' + ''' Set the AC state + ''' + + Public Function SetACState(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType), state As Global.System.Nullable(Of Boolean)) As Global.Microsoft.OData.Client.DataServiceActionQuery + If Not _source.IsComposable Then + Throw New Global.System.NotSupportedException("The previous function is not composable.") + End If + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(_source.Context, _source.AppendRequestUri("Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.SetACState"), New Global.Microsoft.OData.Client.BodyOperationParameter("state", state)) + End Function + ''' + ''' Turn off AC + ''' + + Public Function TurnOffAC(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TruckType)) As Global.Microsoft.OData.Client.DataServiceActionQuery + If Not _source.IsComposable Then + Throw New Global.System.NotSupportedException("The previous function is not composable.") + End If + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(_source.Context, _source.AppendRequestUri("Microsoft.OData.SampleService.Models.ModelRefDemo.TruckDemo.TurnOffAC")) + End Function + End Module +End Namespace +Namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Core.V1 +End Namespace +Namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Vocabulary.V1 +End Namespace +Namespace Microsoft.OData.SampleService.Models.ModelRefDemo.GPS + ''' + ''' There are no comments for GPSContainer in the schema. + ''' + Partial Public Class GPSContainer + Inherits Global.Microsoft.OData.Client.DataServiceContext + ''' + ''' Initialize a new GPSContainer object. + ''' + _ + Public Sub New(ByVal serviceRoot As Global.System.Uri) + MyBase.New(serviceRoot, Global.Microsoft.OData.Client.ODataProtocolVersion.V4) + Me.ResolveName = AddressOf Me.ResolveNameFromType + Me.OnContextCreated + Me.Format.LoadServiceModel = AddressOf GeneratedEdmModel.GetInstance + Me.Format.UseJson() + End Sub + Partial Private Sub OnContextCreated() + End Sub + _ + Private Shared ROOTNAMESPACE As String = GetType(GPSContainer).Namespace.Remove(GetType(GPSContainer).Namespace.LastIndexOf("Microsoft.OData.SampleService.Models.ModelRefDemo.GPS")) + ''' + ''' Since the namespace configured for this service reference + ''' in Visual Studio is different from the one indicated in the + ''' server schema, use type-mappers to map between the two. + ''' + _ + Protected Function ResolveNameFromType(ByVal clientType As Global.System.Type) As String + Return clientType.FullName.Substring(ROOTNAMESPACE.Length) + End Function + ''' + ''' There are no comments for VehicleGPSSetInGPS in the schema. + ''' + _ + Public Overridable ReadOnly Property VehicleGPSSetInGPS() As Global.Microsoft.OData.Client.DataServiceQuery(Of VehicleGPSType) + Get + If (Me._VehicleGPSSetInGPS Is Nothing) Then + Me._VehicleGPSSetInGPS = MyBase.CreateQuery(Of VehicleGPSType)("VehicleGPSSetInGPS") + End If + Return Me._VehicleGPSSetInGPS + End Get + End Property + _ + Private _VehicleGPSSetInGPS As Global.Microsoft.OData.Client.DataServiceQuery(Of VehicleGPSType) + ''' + ''' There are no comments for VehicleGPSSetInGPS in the schema. + ''' + _ + Public Overridable Sub AddToVehicleGPSSetInGPS(ByVal vehicleGPSType As VehicleGPSType) + MyBase.AddObject("VehicleGPSSetInGPS", vehicleGPSType) + End Sub + _ + Private MustInherit Class GeneratedEdmModel + _ + Private Shared ReferencesMap As Global.System.Collections.Generic.Dictionary(Of String, String) = New Global.System.Collections.Generic.Dictionary(Of String, String) From + { + {"./MultiReferenceModelCoreTerms.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelDeviceModelTerms.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelGPS.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelLocation.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""}, + {"./MultiReferenceModelMap.xml", "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + ""} + } + _ + Private Shared ParsedModel As Global.Microsoft.OData.Edm.IEdmModel = LoadModelFromString + _ + Private Const Edmx As String = "" & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + " " & _ + "" + _ + Public Shared Function GetInstance() As Global.Microsoft.OData.Edm.IEdmModel + Return ParsedModel + End Function + _ + Private Shared Function getReferencedModelFromMap(ByVal uri As Global.System.Uri) As Global.System.Xml.XmlReader + Dim referencedEdmx As String = Nothing + If (ReferencesMap.TryGetValue(uri.OriginalString, referencedEdmx)) Then + Return CreateXmlReader(referencedEdmx) + End If + Return Nothing + End Function + _ + Private Shared Function LoadModelFromString() As Global.Microsoft.OData.Edm.IEdmModel + Dim reader As Global.System.Xml.XmlReader = CreateXmlReader(Edmx) + Try + Return Global.Microsoft.OData.Edm.Csdl.CsdlReader.Parse(reader, AddressOf getReferencedModelFromMap) + Finally + CType(reader,Global.System.IDisposable).Dispose + End Try + End Function + _ + Private Shared Function CreateXmlReader(ByVal edmxToParse As String) As Global.System.Xml.XmlReader + Return Global.System.Xml.XmlReader.Create(New Global.System.IO.StringReader(edmxToParse)) + End Function + End Class + ''' + ''' There are no comments for ResetVehicleSpeedToValue in the schema. + ''' + Public Overridable Function ResetVehicleSpeedToValue(targetValue As Global.System.Nullable(Of Double)) As Global.Microsoft.OData.Client.DataServiceActionQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType) + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType)(Me, Me.BaseUri.OriginalString.Trim("/"C) + "/ResetVehicleSpeedToValue", New Global.Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)) + End Function + End Class + ''' + ''' There are no comments for GPSLostSignalAlarmType in the schema. + ''' + Partial Public Class GPSLostSignalAlarmType + ''' + ''' There are no comments for Property Severity in the schema. + ''' + _ + Public Overridable Property Severity() As Global.System.Nullable(Of Integer) + Get + Return Me._Severity + End Get + Set + Me.OnSeverityChanging(value) + Me._Severity = value + Me.OnSeverityChanged + End Set + End Property + _ + Private _Severity As Global.System.Nullable(Of Integer) + Partial Private Sub OnSeverityChanging(ByVal value As Global.System.Nullable(Of Integer)) + End Sub + Partial Private Sub OnSeverityChanged() + End Sub + ''' + ''' There are no comments for Property LastKnownLocation in the schema. + ''' + _ + Public Overridable Property LastKnownLocation() As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Get + Return Me._LastKnownLocation + End Get + Set + Me.OnLastKnownLocationChanging(value) + Me._LastKnownLocation = value + Me.OnLastKnownLocationChanged + End Set + End Property + _ + Private _LastKnownLocation As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Partial Private Sub OnLastKnownLocationChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation) + End Sub + Partial Private Sub OnLastKnownLocationChanged() + End Sub + End Class + ''' + ''' There are no comments for VehicleGPSTypeSingle in the schema. + ''' + Partial Public Class VehicleGPSTypeSingle + Inherits Global.Microsoft.OData.Client.DataServiceQuerySingle(Of VehicleGPSType) + ''' + ''' Initialize a new VehicleGPSTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String) + MyBase.New(context, path) + End Sub + + ''' + ''' Initialize a new VehicleGPSTypeSingle object. + ''' + Public Sub New(ByVal context As Global.Microsoft.OData.Client.DataServiceContext, ByVal path As String, ByVal isComposable As Boolean) + MyBase.New(context, path, isComposable) + End Sub + + ''' + ''' Initialize a new VehicleGPSTypeSingle object. + ''' + Public Sub New(ByVal query As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of VehicleGPSType)) + MyBase.New(query) + End Sub + End Class + ''' + ''' There are no comments for VehicleGPSType in the schema. + ''' + ''' + ''' Key + ''' + _ + Partial Public Class VehicleGPSType + Inherits Global.Microsoft.OData.Client.BaseEntityType + ''' + ''' Create a new VehicleGPSType object. + ''' + ''' Initial value of Key. + _ + Public Shared Function CreateVehicleGPSType(ByVal key As String) As VehicleGPSType + Dim vehicleGPSType As VehicleGPSType = New VehicleGPSType() + vehicleGPSType.Key = key + Return vehicleGPSType + End Function + ''' + ''' There are no comments for Property Key in the schema. + ''' + _ + Public Overridable Property Key() As String + Get + Return Me._Key + End Get + Set + Me.OnKeyChanging(value) + Me._Key = value + Me.OnKeyChanged + End Set + End Property + _ + Private _Key As String + Partial Private Sub OnKeyChanging(ByVal value As String) + End Sub + Partial Private Sub OnKeyChanged() + End Sub + ''' + ''' There are no comments for Property VehicleSpeed in the schema. + ''' + _ + Public Overridable Property VehicleSpeed() As Global.System.Nullable(Of Double) + Get + Return Me._VehicleSpeed + End Get + Set + Me.OnVehicleSpeedChanging(value) + Me._VehicleSpeed = value + Me.OnVehicleSpeedChanged + End Set + End Property + _ + Private _VehicleSpeed As Global.System.Nullable(Of Double) + Partial Private Sub OnVehicleSpeedChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnVehicleSpeedChanged() + End Sub + ''' + ''' There are no comments for Property StartLocation in the schema. + ''' + _ + Public Overridable Property StartLocation() As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Get + Return Me._StartLocation + End Get + Set + Me.OnStartLocationChanging(value) + Me._StartLocation = value + Me.OnStartLocationChanged + End Set + End Property + _ + Private _StartLocation As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Partial Private Sub OnStartLocationChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation) + End Sub + Partial Private Sub OnStartLocationChanged() + End Sub + ''' + ''' There are no comments for Property EndLocation in the schema. + ''' + _ + Public Overridable Property EndLocation() As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Get + Return Me._EndLocation + End Get + Set + Me.OnEndLocationChanging(value) + Me._EndLocation = value + Me.OnEndLocationChanged + End Set + End Property + _ + Private _EndLocation As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Partial Private Sub OnEndLocationChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation) + End Sub + Partial Private Sub OnEndLocationChanged() + End Sub + ''' + ''' There are no comments for Property CurrentLocation in the schema. + ''' + _ + Public Overridable Property CurrentLocation() As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Get + Return Me._CurrentLocation + End Get + Set + Me.OnCurrentLocationChanging(value) + Me._CurrentLocation = value + Me.OnCurrentLocationChanged + End Set + End Property + _ + Private _CurrentLocation As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Partial Private Sub OnCurrentLocationChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation) + End Sub + Partial Private Sub OnCurrentLocationChanged() + End Sub + ''' + ''' There are no comments for Property Map in the schema. + ''' + _ + Public Overridable Property Map() As Microsoft.OData.SampleService.Models.ModelRefDemo.Map.MapType + Get + Return Me._Map + End Get + Set + Me.OnMapChanging(value) + Me._Map = value + Me.OnMapChanged + End Set + End Property + _ + Private _Map As Microsoft.OData.SampleService.Models.ModelRefDemo.Map.MapType + Partial Private Sub OnMapChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Map.MapType) + End Sub + Partial Private Sub OnMapChanged() + End Sub + ''' + ''' There are no comments for Property LostSignalAlarm in the schema. + ''' + _ + Public Overridable Property LostSignalAlarm() As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GPSLostSignalAlarmType + Get + Return Me._LostSignalAlarm + End Get + Set + Me.OnLostSignalAlarmChanging(value) + Me._LostSignalAlarm = value + Me.OnLostSignalAlarmChanged + End Set + End Property + _ + Private _LostSignalAlarm As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GPSLostSignalAlarmType + Partial Private Sub OnLostSignalAlarmChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GPSLostSignalAlarmType) + End Sub + Partial Private Sub OnLostSignalAlarmChanged() + End Sub + ''' + ''' There are no comments for GetVehicleSpeed in the schema. + ''' + Public Overridable Function GetVehicleSpeed() As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Double) + Dim requestUri As Global.System.Uri = Nothing + Context.TryGetUri(Me, requestUri) + Return Me.Context.CreateFunctionQuerySingle(Of Double)(String.Join("/", Global.System.Linq.Enumerable.Select(Global.System.Linq.Enumerable.Skip(requestUri.Segments, Me.Context.BaseUri.Segments.Length), Function(s) s.Trim("/"C))), "/Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GetVehicleSpeed", False) + End Function + ''' + ''' Reset VehicleSpeed to Zero + ''' + Public Overridable Function ResetVehicleSpeed(targetValue As Global.System.Nullable(Of Double)) As Global.Microsoft.OData.Client.DataServiceActionQuery + Dim resource As Global.Microsoft.OData.Client.EntityDescriptor = Context.EntityTracker.TryGetEntityDescriptor(Me) + If resource Is Nothing Then + Throw New Global.System.Exception("cannot find entity") + End If + + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(Me.Context, resource.EditLink.OriginalString.Trim("/"C) + "/Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.ResetVehicleSpeed", New Global.Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)) + End Function + End Class + ''' + ''' Class containing all extension methods + ''' + Public Module ExtensionMethods + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType as Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' dictionary with the names and values of keys + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType), ByVal _keys As Global.System.Collections.Generic.IDictionary(Of String, Object)) As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' Get an entity of type Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType as Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle specified by key from an entity set + ''' + ''' source entity set + ''' The value of key + + Public Function ByKey(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuery(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType), + key As String) As Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle + Dim _keys As Global.System.Collections.Generic.IDictionary(Of String, Object) = New Global.System.Collections.Generic.Dictionary(Of String, Object)() From + { + { "Key", key } + } + Return New Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSTypeSingle(_source.Context, _source.GetKeyPath(Global.Microsoft.OData.Client.Serializer.GetKeyString(_source.Context, _keys))) + End Function + ''' + ''' There are no comments for GetVehicleSpeed in the schema. + ''' + + Public Function GetVehicleSpeed(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType)) As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Double) + If Not _source.IsComposable Then + Throw New Global.System.NotSupportedException("The previous function is not composable.") + End If + + Return _source.CreateFunctionQuerySingle(Of Double)("Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.GetVehicleSpeed", False) + End Function + ''' + ''' Reset VehicleSpeed to Zero + ''' + + Public Function ResetVehicleSpeed(ByVal _source As Global.Microsoft.OData.Client.DataServiceQuerySingle(Of Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.VehicleGPSType), targetValue As Global.System.Nullable(Of Double)) As Global.Microsoft.OData.Client.DataServiceActionQuery + If Not _source.IsComposable Then + Throw New Global.System.NotSupportedException("The previous function is not composable.") + End If + Return New Global.Microsoft.OData.Client.DataServiceActionQuery(_source.Context, _source.AppendRequestUri("Microsoft.OData.SampleService.Models.ModelRefDemo.GPS.ResetVehicleSpeed"), New Global.Microsoft.OData.Client.BodyOperationParameter("targetValue", targetValue)) + End Function + End Module +End Namespace +Namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Location + ''' + ''' There are no comments for GeoLocation in the schema. + ''' + Partial Public Class GeoLocation + ''' + ''' There are no comments for Property Lat in the schema. + ''' + _ + Public Overridable Property Lat() As Global.System.Nullable(Of Double) + Get + Return Me._Lat + End Get + Set + Me.OnLatChanging(value) + Me._Lat = value + Me.OnLatChanged + End Set + End Property + _ + Private _Lat As Global.System.Nullable(Of Double) + Partial Private Sub OnLatChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnLatChanged() + End Sub + ''' + ''' There are no comments for Property Long in the schema. + ''' + _ + Public Overridable Property [Long]() As Global.System.Nullable(Of Double) + Get + Return Me._Long + End Get + Set + Me.OnLongChanging(value) + Me._Long = value + Me.OnLongChanged + End Set + End Property + _ + Private _Long As Global.System.Nullable(Of Double) + Partial Private Sub OnLongChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnLongChanged() + End Sub + End Class + ''' + ''' There are no comments for OutsideGeoFenceAlarmType in the schema. + ''' + Partial Public Class OutsideGeoFenceAlarmType + ''' + ''' There are no comments for Property Severity in the schema. + ''' + _ + Public Overridable Property Severity() As Global.System.Nullable(Of Integer) + Get + Return Me._Severity + End Get + Set + Me.OnSeverityChanging(value) + Me._Severity = value + Me.OnSeverityChanged + End Set + End Property + _ + Private _Severity As Global.System.Nullable(Of Integer) + Partial Private Sub OnSeverityChanging(ByVal value As Global.System.Nullable(Of Integer)) + End Sub + Partial Private Sub OnSeverityChanged() + End Sub + ''' + ''' There are no comments for Property Location in the schema. + ''' + _ + Public Overridable Property Location() As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Get + Return Me._Location + End Get + Set + Me.OnLocationChanging(value) + Me._Location = value + Me.OnLocationChanged + End Set + End Property + _ + Private _Location As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation + Partial Private Sub OnLocationChanging(ByVal value As Microsoft.OData.SampleService.Models.ModelRefDemo.Location.GeoLocation) + End Sub + Partial Private Sub OnLocationChanged() + End Sub + End Class +End Namespace +Namespace Microsoft.OData.SampleService.Models.ModelRefDemo.Map + ''' + ''' There are no comments for MapType in the schema. + ''' + Partial Public Class MapType + ''' + ''' There are no comments for Property ProviderName in the schema. + ''' + _ + Public Overridable Property ProviderName() As String + Get + Return Me._ProviderName + End Get + Set + Me.OnProviderNameChanging(value) + Me._ProviderName = value + Me.OnProviderNameChanged + End Set + End Property + _ + Private _ProviderName As String + Partial Private Sub OnProviderNameChanging(ByVal value As String) + End Sub + Partial Private Sub OnProviderNameChanged() + End Sub + ''' + ''' There are no comments for Property Uri in the schema. + ''' + _ + Public Overridable Property Uri() As String + Get + Return Me._Uri + End Get + Set + Me.OnUriChanging(value) + Me._Uri = value + Me.OnUriChanged + End Set + End Property + _ + Private _Uri As String + Partial Private Sub OnUriChanging(ByVal value As String) + End Sub + Partial Private Sub OnUriChanged() + End Sub + ''' + ''' There are no comments for Property MBytesDownloaded in the schema. + ''' + _ + Public Overridable Property MBytesDownloaded() As Global.System.Nullable(Of Double) + Get + Return Me._MBytesDownloaded + End Get + Set + Me.OnMBytesDownloadedChanging(value) + Me._MBytesDownloaded = value + Me.OnMBytesDownloadedChanged + End Set + End Property + _ + Private _MBytesDownloaded As Global.System.Nullable(Of Double) + Partial Private Sub OnMBytesDownloadedChanging(ByVal value As Global.System.Nullable(Of Double)) + End Sub + Partial Private Sub OnMBytesDownloadedChanged() + End Sub + End Class +End Namespace diff --git a/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.xml b/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.xml new file mode 100644 index 00000000..5939cf9f --- /dev/null +++ b/test/ODataConnectedService.Tests/CodeGenReferences/MultiReferenceModelRelativeUri.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/ODataConnectedService.Tests/ODataConnectedService.Tests.csproj b/test/ODataConnectedService.Tests/ODataConnectedService.Tests.csproj index 9408413b..ed6e4ca0 100644 --- a/test/ODataConnectedService.Tests/ODataConnectedService.Tests.csproj +++ b/test/ODataConnectedService.Tests/ODataConnectedService.Tests.csproj @@ -151,8 +151,25 @@ - + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + @@ -175,6 +192,33 @@ Always + + + + + + + + + + + + + + + + + + + + + + + + + + + Always diff --git a/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTestDescriptors.cs b/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTestDescriptors.cs index 826ba796..a37b278e 100644 --- a/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTestDescriptors.cs +++ b/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTestDescriptors.cs @@ -146,6 +146,13 @@ internal static string GetFileContent(string fileName) return LoadContentFromBaseline(fileName); } + internal static string GetAbsoluteUriOfFile(string fileName) + { + var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); + var filePath = Path.Combine(outPutDirectory, $"CodeGenReferences\\{fileName}"); + return filePath; + } + private const string BaseName = "ODataConnectedService.Tests.CodeGenReferences."; private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); @@ -493,6 +500,25 @@ private static string LoadContentFromBaseline(string key) #endregion + #region MultiReferenceModelRelativeUri + + public static string EdmxWithMultiReferenceModelRelativeUriFilePath = GetAbsoluteUriOfFile("MultiReferenceModelRelativeUri.xml"); + + public static string MultiReferenceModelRelativeUriCSharp = LoadContentFromBaseline("MultiReferenceModelRelativeUri.cs"); + public static string MultiReferenceModelRelativeUriVB = LoadContentFromBaseline("MultiReferenceModelRelativeUri.vb"); + + public static ODataT4CodeGeneratorTestsDescriptor MultiReferenceModelRelativeUri = new ODataT4CodeGeneratorTestsDescriptor() + { + ExpectedResults = new Dictionary() + { + { ExpectedCSharp, MultiReferenceModelRelativeUriCSharp }, + { ExpectedVB, MultiReferenceModelRelativeUriVB }, + }, + Verify = (code, isCSharp, useDSC) => VerifyGeneratedCode(code, MultiReferenceModelRelativeUri.ExpectedResults, isCSharp, useDSC, "MultiReferenceModelRelativeUri"), + }; + + #endregion + #region UpperCamelCaseWithNamespacePrefix public static string EdmxUpperCamelCaseWithNamespacePrefix = LoadContentFromBaseline("UpperCamelCaseWithNamespacePrefix.xml"); diff --git a/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTests.cs b/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTests.cs index 0885f33b..29e0258d 100644 --- a/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTests.cs +++ b/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTests.cs @@ -361,6 +361,16 @@ public void CodeGenWithMultiReferenceModel() //ODataT4CodeGeneratorTestDescriptors.MultiReferenceModel.Verify(code, false/*isCSharp*/, true/*useDSC*/); } + [TestMethod] + public void CodeGenWithMultiReferenceModelRelativeUri() + { + string code = CodeGenWithT4Template(ODataT4CodeGeneratorTestDescriptors.MultiReferenceModelRelativeUri.Metadata, null, true, false, metadataDocumentUri: ODataT4CodeGeneratorTestDescriptors.EdmxWithMultiReferenceModelRelativeUriFilePath ); + ODataT4CodeGeneratorTestDescriptors.MultiReferenceModelRelativeUri.Verify(code, true /*isCSharp*/, false /*useDSC*/); + + code = CodeGenWithT4Template(ODataT4CodeGeneratorTestDescriptors.MultiReferenceModelRelativeUri.Metadata, null, false, false, metadataDocumentUri: ODataT4CodeGeneratorTestDescriptors.EdmxWithMultiReferenceModelRelativeUriFilePath); + ODataT4CodeGeneratorTestDescriptors.MultiReferenceModelRelativeUri.Verify(code, false/*isCSharp*/, false/*useDSC*/); + } + [TestMethod] public void CodeGenWithUpperCamelCaseWithNamespacePrefix() { @@ -538,7 +548,7 @@ private static string CodeGenWithT4Template(string edmx, string namespacePrefix, bool useDataServiceCollection, bool enableNamingAlias = false, bool ignoreUnexpectedElementsAndAttributes = false, Func, XmlReader> getReferencedModelReaderFunc = null, - bool appendDSCSuffix = false, string MetadataFilePath = null, bool generateMultipleFiles = false, + bool appendDSCSuffix = false, string MetadataFilePath = null, bool generateMultipleFiles = false, string metadataDocumentUri = null, IEnumerable excludedSchemaTypes = default(List)) { @@ -568,6 +578,11 @@ private static string CodeGenWithT4Template(string edmx, string namespacePrefix, ExcludedSchemaTypes = excludedSchemaTypes }; + if (!String.IsNullOrEmpty(metadataDocumentUri)) + { + t4CodeGenerator.MetadataDocumentUri = metadataDocumentUri; + } + if (!String.IsNullOrEmpty(MetadataFilePath)) { t4CodeGenerator.MetadataFilePath = MetadataFilePath;