diff --git a/ODataConnectedService/ODataConnectedService.Tests.sln b/ODataConnectedService/ODataConnectedService.Tests.sln new file mode 100644 index 0000000..0943779 --- /dev/null +++ b/ODataConnectedService/ODataConnectedService.Tests.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ODataConnectedService", "src\ODataConnectedService.csproj", "{A8BC5B8E-9AB7-4257-B8F1-E7C62169F9B5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ODataConnectedService.Tests", "test\ODataConnectedService.Tests\ODataConnectedService.Tests.csproj", "{903B31D0-BE14-4D9E-BA76-186FA82B3A37}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8BC5B8E-9AB7-4257-B8F1-E7C62169F9B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8BC5B8E-9AB7-4257-B8F1-E7C62169F9B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8BC5B8E-9AB7-4257-B8F1-E7C62169F9B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8BC5B8E-9AB7-4257-B8F1-E7C62169F9B5}.Release|Any CPU.Build.0 = Release|Any CPU + {903B31D0-BE14-4D9E-BA76-186FA82B3A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {903B31D0-BE14-4D9E-BA76-186FA82B3A37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {903B31D0-BE14-4D9E-BA76-186FA82B3A37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {903B31D0-BE14-4D9E-BA76-186FA82B3A37}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FD696714-8F52-4A00-93F4-43C843F184DB} + EndGlobalSection +EndGlobal diff --git a/ODataConnectedService/src/CodeGeneration/BaseCodeGenDescriptor.cs b/ODataConnectedService/src/CodeGeneration/BaseCodeGenDescriptor.cs index c209a8e..927cc90 100644 --- a/ODataConnectedService/src/CodeGeneration/BaseCodeGenDescriptor.cs +++ b/ODataConnectedService/src/CodeGeneration/BaseCodeGenDescriptor.cs @@ -50,7 +50,7 @@ public BaseCodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext this.ServiceConfiguration = ((ODataConnectedServiceInstance)this.Context.ServiceInstance).ServiceConfig; } - private void Init() + protected virtual void Init() { var componentModel = (IComponentModel)Shell.Package.GetGlobalService(typeof(SComponentModel)); this.PackageInstallerServices = componentModel.GetService(); diff --git a/ODataConnectedService/src/CodeGeneration/CodeGenDescriptorFactory.cs b/ODataConnectedService/src/CodeGeneration/CodeGenDescriptorFactory.cs new file mode 100644 index 0000000..2587b5f --- /dev/null +++ b/ODataConnectedService/src/CodeGeneration/CodeGenDescriptorFactory.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Globalization; +using EnvDTE; +using Microsoft.VisualStudio.ConnectedServices; +using Microsoft.OData.ConnectedService.Templates; + +namespace Microsoft.OData.ConnectedService.CodeGeneration +{ + class CodeGenDescriptorFactory: ICodeGenDescriptorFactory + { + public BaseCodeGenDescriptor Create(Version edmxVersion, string metadataUri, ConnectedServiceHandlerContext context, Project project) + { + if (edmxVersion == Common.Constants.EdmxVersion1 + || edmxVersion == Common.Constants.EdmxVersion2 + || edmxVersion == Common.Constants.EdmxVersion3) + { + return CreateV3CodeGenDescriptor(metadataUri, context, project); + } + else if (edmxVersion == Common.Constants.EdmxVersion4) + { + return CreateV4CodeGenDescriptor(metadataUri, context, project); + } + throw new Exception(string.Format(CultureInfo.InvariantCulture, "Not supported Edmx Version {0}", edmxVersion.ToString())); + } + + protected virtual BaseCodeGenDescriptor CreateV3CodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project) + { + return new V3CodeGenDescriptor(metadataUri, context, project); + } + + protected virtual BaseCodeGenDescriptor CreateV4CodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project) + { + return new V4CodeGenDescriptor(metadataUri, context, project, new ODataT4CodeGeneratorFactory()); + } + } +} diff --git a/ODataConnectedService/src/CodeGeneration/ICodeGenDescriptorFactory.cs b/ODataConnectedService/src/CodeGeneration/ICodeGenDescriptorFactory.cs new file mode 100644 index 0000000..cdff867 --- /dev/null +++ b/ODataConnectedService/src/CodeGeneration/ICodeGenDescriptorFactory.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using EnvDTE; +using Microsoft.VisualStudio.ConnectedServices; + +namespace Microsoft.OData.ConnectedService.CodeGeneration +{ + interface ICodeGenDescriptorFactory + { + BaseCodeGenDescriptor Create(Version edmxVersion, string metadataUri, ConnectedServiceHandlerContext context, Project project); + } +} diff --git a/ODataConnectedService/src/CodeGeneration/V4CodeGenDescriptor.cs b/ODataConnectedService/src/CodeGeneration/V4CodeGenDescriptor.cs index c42814c..95bbae5 100644 --- a/ODataConnectedService/src/CodeGeneration/V4CodeGenDescriptor.cs +++ b/ODataConnectedService/src/CodeGeneration/V4CodeGenDescriptor.cs @@ -15,14 +15,17 @@ namespace Microsoft.OData.ConnectedService.CodeGeneration { internal class V4CodeGenDescriptor : BaseCodeGenDescriptor { - public V4CodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project) + public V4CodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project, IODataT4CodeGeneratorFactory codeGeneratorFactory) : base(metadataUri, context, project) { - this.ClientNuGetPackageName = Common.Constants.V4ClientNuGetPackage; - this.ClientDocUri = Common.Constants.V4DocUri; - this.ServiceConfiguration = base.ServiceConfiguration as ServiceConfigurationV4; + ClientNuGetPackageName = Common.Constants.V4ClientNuGetPackage; + ClientDocUri = Common.Constants.V4DocUri; + ServiceConfiguration = base.ServiceConfiguration as ServiceConfigurationV4; + CodeGeneratorFactory = codeGeneratorFactory; } + private IODataT4CodeGeneratorFactory CodeGeneratorFactory { get; set; } + private new ServiceConfigurationV4 ServiceConfiguration { get; set; } public override async Task AddNugetPackages() @@ -66,7 +69,7 @@ private async Task AddT4File() text = Regex.Replace(text, "(public const string TargetLanguage = )\"OutputLanguage\";", "$1\"CSharp\";"); text = Regex.Replace(text, "(public const bool EnableNamingAlias = )true;", "$1" + this.ServiceConfiguration.EnableNamingAlias.ToString().ToLower(CultureInfo.InvariantCulture) + ";"); text = Regex.Replace(text, "(public const bool IgnoreUnexpectedElementsAndAttributes = )true;", "$1" + this.ServiceConfiguration.IgnoreUnexpectedElementsAndAttributes.ToString().ToLower(CultureInfo.InvariantCulture) + ";"); - + text = Regex.Replace(text, "(public const bool MakeTypesInternal = )false;", "$1" + ServiceConfiguration.MakeTypesInternal.ToString().ToLower(CultureInfo.InvariantCulture) + ";"); await writer.WriteAsync(text); await writer.FlushAsync(); } @@ -78,13 +81,14 @@ private async Task AddT4File() private async Task AddGeneratedCSharpCode() { - ODataT4CodeGenerator t4CodeGenerator = new ODataT4CodeGenerator(); + ODataT4CodeGenerator t4CodeGenerator = CodeGeneratorFactory.Create(); t4CodeGenerator.MetadataDocumentUri = MetadataUri; t4CodeGenerator.UseDataServiceCollection = this.ServiceConfiguration.UseDataServiceCollection; t4CodeGenerator.TargetLanguage = ODataT4CodeGenerator.LanguageOption.CSharp; t4CodeGenerator.IgnoreUnexpectedElementsAndAttributes = this.ServiceConfiguration.IgnoreUnexpectedElementsAndAttributes; t4CodeGenerator.EnableNamingAlias = this.ServiceConfiguration.EnableNamingAlias; t4CodeGenerator.NamespacePrefix = this.ServiceConfiguration.NamespacePrefix; + t4CodeGenerator.MakeTypesInternal = ServiceConfiguration.MakeTypesInternal; string tempFile = Path.GetTempFileName(); diff --git a/ODataConnectedService/src/Models/ServiceConfiguration.cs b/ODataConnectedService/src/Models/ServiceConfiguration.cs index 56bcc7c..b9a6a2b 100644 --- a/ODataConnectedService/src/Models/ServiceConfiguration.cs +++ b/ODataConnectedService/src/Models/ServiceConfiguration.cs @@ -14,6 +14,7 @@ internal class ServiceConfiguration public bool UseNameSpacePrefix { get; set; } public string NamespacePrefix { get; set; } public bool UseDataServiceCollection { get; set; } + public bool MakeTypesInternal { get; set; } } internal class ServiceConfigurationV4 : ServiceConfiguration diff --git a/ODataConnectedService/src/ODataConnectedService.csproj b/ODataConnectedService/src/ODataConnectedService.csproj index 54a0c2a..c127546 100644 --- a/ODataConnectedService/src/ODataConnectedService.csproj +++ b/ODataConnectedService/src/ODataConnectedService.csproj @@ -22,6 +22,7 @@ false true 14.0 + @@ -36,11 +37,11 @@ Properties Microsoft.OData.ConnectedService Microsoft.OData.ConnectedService - v4.5 + v4.7.2 512 false Program - C:\Program Files (x86)\Microsoft Visual Studio $(VisualStudioVersion)\Common7\IDE\devenv.exe + $(DevEnvDir)devenv.exe /rootSuffix exp true true @@ -161,6 +162,8 @@ + + @@ -175,11 +178,13 @@ + True True ODataT4CodeGenerator.tt + diff --git a/ODataConnectedService/src/ODataConnectedServiceHandler.cs b/ODataConnectedService/src/ODataConnectedServiceHandler.cs index 5ff7e60..5875790 100644 --- a/ODataConnectedService/src/ODataConnectedServiceHandler.cs +++ b/ODataConnectedService/src/ODataConnectedServiceHandler.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; -using System.Globalization; using System.Threading; using System.Threading.Tasks; using EnvDTE; @@ -16,51 +15,44 @@ namespace Microsoft.OData.ConnectedService [ConnectedServiceHandlerExport(Common.Constants.ProviderId, AppliesTo = "CSharp")] internal class ODataConnectedServiceHandler : ConnectedServiceHandler { - public override async Task AddServiceInstanceAsync(ConnectedServiceHandlerContext context, CancellationToken ct) - { - Project project = ProjectHelper.GetProjectFromHierarchy(context.ProjectHierarchy); - ODataConnectedServiceInstance codeGenInstance = (ODataConnectedServiceInstance)context.ServiceInstance; + private ICodeGenDescriptorFactory codeGenDescriptorFactory; + public ODataConnectedServiceHandler(): this(new CodeGenDescriptorFactory()) {} - var codeGenDescriptor = await GenerateCode(codeGenInstance.MetadataTempFilePath, codeGenInstance.ServiceConfig.EdmxVersion, context, project); + public ODataConnectedServiceHandler(ICodeGenDescriptorFactory codeGenDescriptorFactory) + : base() + { + this.codeGenDescriptorFactory = codeGenDescriptorFactory; + } - context.SetExtendedDesignerData(codeGenInstance.ServiceConfig); + public override async Task AddServiceInstanceAsync(ConnectedServiceHandlerContext context, CancellationToken ct) + { + var codeGenDescriptor = await SaveServiceInstanceAsync(context); var result = new AddServiceInstanceResult( context.ServiceInstance.Name, new Uri(codeGenDescriptor.ClientDocUri)); - return result; } public override async Task UpdateServiceInstanceAsync(ConnectedServiceHandlerContext context, CancellationToken ct) { - Project project = ProjectHelper.GetProjectFromHierarchy(context.ProjectHierarchy); - ODataConnectedServiceInstance codeGenInstance = (ODataConnectedServiceInstance)context.ServiceInstance; - - var codeGenDescriptor = await GenerateCode(codeGenInstance.ServiceConfig.Endpoint, codeGenInstance.ServiceConfig.EdmxVersion, context, project); - context.SetExtendedDesignerData(codeGenInstance.ServiceConfig); + await SaveServiceInstanceAsync(context); return new UpdateServiceInstanceResult(); } - private static async Task GenerateCode(string metadataUri, Version edmxVersion, ConnectedServiceHandlerContext context, Project project) + private async Task SaveServiceInstanceAsync(ConnectedServiceHandlerContext context) { - BaseCodeGenDescriptor codeGenDescriptor; + Project project = ProjectHelper.GetProjectFromHierarchy(context.ProjectHierarchy); + ODataConnectedServiceInstance serviceInstance = (ODataConnectedServiceInstance)context.ServiceInstance; - if (edmxVersion == Common.Constants.EdmxVersion1 - || edmxVersion == Common.Constants.EdmxVersion2 - || edmxVersion == Common.Constants.EdmxVersion3) - { - codeGenDescriptor = new V3CodeGenDescriptor(metadataUri, context, project); - } - else if (edmxVersion == Common.Constants.EdmxVersion4) - { - codeGenDescriptor = new V4CodeGenDescriptor(metadataUri, context, project); - } - else - { - throw new Exception(string.Format(CultureInfo.InvariantCulture, "Not supported Edmx Version {0}", edmxVersion.ToString())); - } + var codeGenDescriptor = await GenerateCode(serviceInstance.ServiceConfig.Endpoint, serviceInstance.ServiceConfig.EdmxVersion, context, project); + context.SetExtendedDesignerData(serviceInstance.ServiceConfig); + return codeGenDescriptor; + } + private async Task GenerateCode(string metadataUri, Version edmxVersion, ConnectedServiceHandlerContext context, Project project) + { + BaseCodeGenDescriptor codeGenDescriptor = codeGenDescriptorFactory.Create(edmxVersion, metadataUri, context, project); await codeGenDescriptor.AddNugetPackages(); await codeGenDescriptor.AddGeneratedClientCode(); return codeGenDescriptor; diff --git a/ODataConnectedService/src/ODataConnectedServiceProvider.cs b/ODataConnectedService/src/ODataConnectedServiceProvider.cs index b4c47b1..e44591e 100644 --- a/ODataConnectedService/src/ODataConnectedServiceProvider.cs +++ b/ODataConnectedService/src/ODataConnectedServiceProvider.cs @@ -15,13 +15,13 @@ internal class ODataConnectedServiceProvider : ConnectedServiceProvider { public ODataConnectedServiceProvider() { - this.Name = "OData Connected Service"; - this.Category = "OData"; - this.Description = "OData Connected Service for V1-V4"; - this.Icon = new BitmapImage(new Uri("pack://application:,,/" + this.GetType().Assembly.ToString() + ";component/Resources/Icon.png")); - this.CreatedBy = "OData"; - this.Version = new Version(0, 2, 0); - this.MoreInfoUri = new Uri("https://github.com/odata/lab"); + Name = "OData Connected Service"; + Category = "OData"; + Description = "OData Connected Service for V1-V4"; + Icon = new BitmapImage(new Uri("pack://application:,,/" + this.GetType().Assembly.ToString() + ";component/Resources/Icon.png")); + CreatedBy = "OData"; + Version = new Version(0, 4, 0); + MoreInfoUri = new Uri("https://github.com/odata/lab"); } public override Task CreateConfiguratorAsync(ConnectedServiceProviderContext context) diff --git a/ODataConnectedService/src/ODataConnectedServiceWizard.cs b/ODataConnectedService/src/ODataConnectedServiceWizard.cs index dfff4c0..153ea60 100644 --- a/ODataConnectedService/src/ODataConnectedServiceWizard.cs +++ b/ODataConnectedService/src/ODataConnectedServiceWizard.cs @@ -3,8 +3,6 @@ using System; using System.Threading.Tasks; -using EnvDTE; -using Microsoft.OData.ConnectedService.Common; using Microsoft.OData.ConnectedService.Models; using Microsoft.OData.ConnectedService.ViewModels; using Microsoft.OData.ConnectedService.Views; @@ -83,6 +81,7 @@ public ODataConnectedServiceWizard(ConnectedServiceProviderContext context) advancedSettingsViewModel.IgnoreUnexpectedElementsAndAttributes = serviceConfig.IgnoreUnexpectedElementsAndAttributes; advancedSettingsViewModel.EnableNamingAlias = serviceConfig.EnableNamingAlias; advancedSettingsViewModel.IncludeT4File = serviceConfig.IncludeT4File; + advancedSettingsViewModel.MakeTypesInternal = serviceConfig.MakeTypesInternal; advancedSettings.IncludeT4File.IsEnabled = false; } } @@ -132,6 +131,7 @@ private ServiceConfiguration CreateServiceConfiguration() serviceConfiguration.UseDataServiceCollection = AdvancedSettingsViewModel.UseDataServiceCollection; serviceConfiguration.GeneratedFileNamePrefix = AdvancedSettingsViewModel.GeneratedFileName; serviceConfiguration.UseNameSpacePrefix = AdvancedSettingsViewModel.UseNamespacePrefix; + serviceConfiguration.MakeTypesInternal = AdvancedSettingsViewModel.MakeTypesInternal; if (AdvancedSettingsViewModel.UseNamespacePrefix && !string.IsNullOrEmpty(AdvancedSettingsViewModel.NamespacePrefix)) { serviceConfiguration.NamespacePrefix = AdvancedSettingsViewModel.NamespacePrefix; diff --git a/ODataConnectedService/src/Properties/AssemblyInfo.cs b/ODataConnectedService/src/Properties/AssemblyInfo.cs index 4a87d33..9fe57b2 100644 --- a/ODataConnectedService/src/Properties/AssemblyInfo.cs +++ b/ODataConnectedService/src/Properties/AssemblyInfo.cs @@ -4,6 +4,7 @@ using System; using System.Reflection; using System.Resources; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -37,3 +38,5 @@ [assembly: AssemblyVersion("0.3.0.0")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: NeutralResourcesLanguageAttribute("en")] + +[assembly: InternalsVisibleTo("ODataConnectedService.Tests")] diff --git a/ODataConnectedService/src/Templates/IODataT4CodeGeneratorFactory.cs b/ODataConnectedService/src/Templates/IODataT4CodeGeneratorFactory.cs new file mode 100644 index 0000000..417a72b --- /dev/null +++ b/ODataConnectedService/src/Templates/IODataT4CodeGeneratorFactory.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +namespace Microsoft.OData.ConnectedService.Templates +{ + interface IODataT4CodeGeneratorFactory + { + ODataT4CodeGenerator Create(); + } +} diff --git a/ODataConnectedService/src/Templates/ODataT4CodeGenerator.cs b/ODataConnectedService/src/Templates/ODataT4CodeGenerator.cs index 554bb28..72e422b 100644 --- a/ODataConnectedService/src/Templates/ODataT4CodeGenerator.cs +++ b/ODataConnectedService/src/Templates/ODataT4CodeGenerator.cs @@ -1,7 +1,7 @@ // ------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version: 15.0.0.0 +// Runtime Version: 16.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -31,7 +31,7 @@ namespace Microsoft.OData.ConnectedService.Templates /// /// Class to produce the template output /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")] internal partial class ODataT4CodeGenerator : ODataT4CodeGeneratorBase { /// @@ -61,7 +61,8 @@ The above copyright notice and this permission notice shall be included in all c UseDataServiceCollection = this.UseDataServiceCollection, TargetLanguage = this.TargetLanguage, EnableNamingAlias = this.EnableNamingAlias, - IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes + IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes, + MakeTypesInternal = this.MakeTypesInternal }; } else @@ -77,7 +78,8 @@ The above copyright notice and this permission notice shall be included in all c UseDataServiceCollection = this.UseDataServiceCollection, TargetLanguage = this.TargetLanguage, EnableNamingAlias = this.EnableNamingAlias, - IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes + IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes, + MakeTypesInternal = this.MakeTypesInternal }; } @@ -150,6 +152,10 @@ public static class Configuration // This flag indicates whether to ignore unexpected elements and attributes in the metadata document and generate // the client code if any. The value must be set to true or false. public const bool IgnoreUnexpectedElementsAndAttributes = true; + + // If set to true, generated types will have an "internal" class modifier ("Friend" in VB) instead of "public" + // thereby making them invisible outside the assembly + public const bool MakeTypesInternal = false; } public static class Customization @@ -237,7 +243,7 @@ public string MetadataDocumentUri { value = uri.Scheme + "://" + uri.Authority + uri.AbsolutePath; value = value.TrimEnd('/'); - if (!value.EndsWith("$metadata", StringComparison.CurrentCulture)) + if (!value.EndsWith("$metadata")) { value += "/$metadata"; } @@ -321,6 +327,16 @@ public bool IgnoreUnexpectedElementsAndAttributes set; } +/// +/// true to use the "internal" access modifier ("Friend" in VB) on generated types, +/// otherwise "public" is used +/// +public bool MakeTypesInternal +{ + get; + set; +} + /// /// Generate code targeting a specific .Net Framework language. /// @@ -336,18 +352,18 @@ public enum LanguageOption /// /// Set the UseDataServiceCollection property with the given value. /// -/// The value to set. -public void ValidateAndSetUseDataServiceCollectionFromString(string stringValue) +/// The value to set. +public void ValidateAndSetUseDataServiceCollectionFromString(string inputValue) { bool boolValue; - if (!bool.TryParse(stringValue, out boolValue)) + if (!bool.TryParse(inputValue, out boolValue)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the UseDataServiceCollection parameter because it is not a valid boolean value.", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the UseDataServiceCollection parameter because it is not a valid boolean value.", inputValue)); } this.UseDataServiceCollection = boolValue; @@ -356,18 +372,18 @@ public void ValidateAndSetUseDataServiceCollectionFromString(string stringValue) /// /// Tries to set the TargetLanguage property with the given value. /// -/// The value to set. -public void ValidateAndSetTargetLanguageFromString(string stringValue) +/// The value to set. +public void ValidateAndSetTargetLanguageFromString(string inputValue) { LanguageOption option; - if (!Enum.TryParse(stringValue, true, out option)) + if (!Enum.TryParse(inputValue, true, out option)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the TargetLanguage parameter because it is not a valid LanguageOption. The supported LanguageOptions are \"CSharp\" and \"VB\".", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the TargetLanguage parameter because it is not a valid LanguageOption. The supported LanguageOptions are \"CSharp\" and \"VB\".", inputValue)); } this.TargetLanguage = option; @@ -376,18 +392,18 @@ public void ValidateAndSetTargetLanguageFromString(string stringValue) /// /// Set the EnableNamingAlias property with the given value. /// -/// The value to set. -public void ValidateAndSetEnableNamingAliasFromString(string stringValue) +/// The value to set. +public void ValidateAndSetEnableNamingAliasFromString(string inputValue) { bool boolValue; - if (!bool.TryParse(stringValue, out boolValue)) + if (!bool.TryParse(inputValue, out boolValue)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the EnableNamingAlias parameter because it is not a valid boolean value.", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the EnableNamingAlias parameter because it is not a valid boolean value.", inputValue)); } this.EnableNamingAlias = boolValue; @@ -396,23 +412,43 @@ public void ValidateAndSetEnableNamingAliasFromString(string stringValue) /// /// Set the IgnoreUnexpectedElementsAndAttributes property with the given value. /// -/// The value to set. -public void ValidateAndSetIgnoreUnexpectedElementsAndAttributesFromString(string stringValue) +/// The value to set. +public void ValidateAndSetIgnoreUnexpectedElementsAndAttributesFromString(string inputValue) { bool boolValue; - if (!bool.TryParse(stringValue, out boolValue)) + if (!bool.TryParse(inputValue, out boolValue)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the IgnoreUnexpectedElementsAndAttributes parameter because it is not a valid boolean value.", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the IgnoreUnexpectedElementsAndAttributes parameter because it is not a valid boolean value.", inputValue)); } this.IgnoreUnexpectedElementsAndAttributes = boolValue; } +/// +/// Set the MakeTypesInternal property with the given value. +/// +/// The value to set. +public void ValidateAndSetMakeTypesInternalFromString(string inputValue) +{ + bool parsedValue; + if (!bool.TryParse(inputValue, out parsedValue)) + { + // ******************************************************************************************************** + // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator + // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter + // value then hit Ctrl-S to save the .tt file to refresh the code generation. + // ******************************************************************************************************** + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the MakeTypesInternal parameter because it is not a valid boolean value.", inputValue)); + } + + this.MakeTypesInternal = parsedValue; +} + /// /// Reads the parameter values from the Configuration class and applies them. /// @@ -424,6 +460,7 @@ private void ApplyParametersFromConfigurationClass() this.ValidateAndSetTargetLanguageFromString(Configuration.TargetLanguage); this.EnableNamingAlias = Configuration.EnableNamingAlias; this.IgnoreUnexpectedElementsAndAttributes = Configuration.IgnoreUnexpectedElementsAndAttributes; + this.MakeTypesInternal = Configuration.MakeTypesInternal; } /// @@ -471,6 +508,12 @@ private void ApplyParametersFromCommandLine() { this.ValidateAndSetIgnoreUnexpectedElementsAndAttributesFromString(ignoreUnexpectedElementsAndAttributes); } + + string makeTypesInternal = this.Host.ResolveParameterValue("notempty", "notempty", "MakeTypesInternal"); + if (!string.IsNullOrEmpty(makeTypesInternal)) + { + this.ValidateAndSetMakeTypesInternalFromString(makeTypesInternal); + } } /// @@ -780,6 +823,16 @@ public bool UseDataServiceCollection get; set; } + + /// + /// true to use internal access modifier for generated classes, otherwise they will be made public. + /// This is useful if you don't want the generated classes to be visible outside the assembly + /// + public bool MakeTypesInternal + { + get; + set; + } /// /// Specifies which specific .Net Framework language the generated code will target. @@ -1040,6 +1093,8 @@ public ODataClientTemplate(CodeGenerationContext context) internal abstract string GlobalPrefix { get; } internal abstract string SystemTypeTypeName { get; } internal abstract string AbstractModifier { get; } + internal abstract string PublicAccessModifier { get; } + internal abstract string InternalAccessModifier { get; } internal abstract string DataServiceActionQueryTypeName { get; } internal abstract string DataServiceActionQuerySingleOfTStructureTemplate { get; } internal abstract string DataServiceActionQueryOfTStructureTemplate { get; } @@ -1185,6 +1240,12 @@ internal HashSet ClrReferenceTypes { get { } } private HashSet clrReferenceTypes; + internal string ClassAccessModifier { + get { + return this.context.MakeTypesInternal ? this.InternalAccessModifier : this.PublicAccessModifier; + } + } + /// /// Generates code for the OData client. /// @@ -1238,26 +1299,23 @@ internal void WriteNamespace(string fullNamespace) Dictionary> structuredBaseTypeMap = new Dictionary>(); foreach(IEdmSchemaType type in schemaElements.OfType()) { - IEdmEnumType enumType = type as IEdmEnumType; - if (enumType != null) + if (type is IEdmEnumType enumType) { this.WriteEnumType(enumType); } else { - IEdmComplexType complexType = type as IEdmComplexType; - if (complexType != null) + if (type is IEdmComplexType complexType) { this.WriteComplexType(complexType, boundOperationsMap); } - else + else if (type is IEdmEntityType entityType) { - IEdmEntityType entityType = type as IEdmEntityType; this.WriteEntityType(entityType, boundOperationsMap); } IEdmStructuredType structuredType = type as IEdmStructuredType; - if (structuredType.BaseType != null) + if (structuredType?.BaseType != null) { List derivedTypes; if (!structuredBaseTypeMap.TryGetValue(structuredType.BaseType, out derivedTypes)) @@ -2455,14 +2513,14 @@ public void WriteLine(string textToAppend) /// public void Write(string format, params object[] args) { - this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + this.Write(string.Format(CultureInfo.InvariantCulture, format, args)); } /// /// Write formatted text directly into the generated output /// public void WriteLine(string format, params object[] args) { - this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); + this.WriteLine(string.Format(CultureInfo.InvariantCulture, format, args)); } /// /// Raise an error @@ -2746,76 +2804,77 @@ internal static string PascalCase(string text) /// The clr type name of the type reference. internal static string GetClrTypeName(IEdmTypeReference edmTypeReference, bool useDataServiceCollection, ODataClientTemplate clientTemplate, CodeGenerationContext context, bool addNullableTemplate = true, bool needGlobalPrefix = true, bool isOperationParameter = false) { - string clrTypeName; IEdmType edmType = edmTypeReference.Definition; - IEdmPrimitiveType edmPrimitiveType = edmType as IEdmPrimitiveType; - if (edmPrimitiveType != null) + if (edmType is IEdmPrimitiveType edmPrimitiveType) { - clrTypeName = Utils.GetClrTypeName(edmPrimitiveType, clientTemplate); + var clrTypeName = Utils.GetClrTypeName(edmPrimitiveType, clientTemplate); if (edmTypeReference.IsNullable && !clientTemplate.ClrReferenceTypes.Contains(edmPrimitiveType.PrimitiveKind) && addNullableTemplate) { - clrTypeName = string.Format(CultureInfo.InvariantCulture, clientTemplate.SystemNullableStructureTemplate, clrTypeName); + clrTypeName = GetNullableClrTypeName(clrTypeName, clientTemplate); } + return clrTypeName; } - else + if (edmType is IEdmComplexType edmComplexType) { - IEdmComplexType edmComplexType = edmType as IEdmComplexType; - if (edmComplexType != null) - { - clrTypeName = context.GetPrefixedFullName(edmComplexType, + var clrTypeName = context.GetPrefixedFullName(edmComplexType, context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmComplexType.Name)) : clientTemplate.GetFixedName(edmComplexType.Name), clientTemplate); + return clrTypeName; + } + if (edmType is IEdmEnumType edmEnumType) + { + var clrTypeName = context.GetPrefixedFullName(edmEnumType, + context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEnumType.Name)) : clientTemplate.GetFixedName(edmEnumType.Name), clientTemplate, needGlobalPrefix); + if (edmTypeReference.IsNullable && addNullableTemplate) + { + clrTypeName = GetNullableClrTypeName(clrTypeName, clientTemplate); } - else + return clrTypeName; + } + if (edmType is IEdmEntityType edmEntityType) + { + var clrTypeName = context.GetPrefixedFullName(edmEntityType, + context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEntityType.Name)) : clientTemplate.GetFixedName(edmEntityType.Name), clientTemplate); + return clrTypeName; + } + if (edmType is IEdmTypeDefinition edmTypeDefinition) + { + var underlyingType = edmTypeDefinition.UnderlyingType; + var clrTypeName = Utils.GetClrTypeName(underlyingType, clientTemplate); + if (edmTypeReference.IsNullable && !clientTemplate.ClrReferenceTypes.Contains(underlyingType.PrimitiveKind) && addNullableTemplate) { - IEdmEnumType edmEnumType = edmType as IEdmEnumType; - if (edmEnumType != null) - { - clrTypeName = context.GetPrefixedFullName(edmEnumType, - context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEnumType.Name)) : clientTemplate.GetFixedName(edmEnumType.Name), clientTemplate, needGlobalPrefix); - if (edmTypeReference.IsNullable && addNullableTemplate) - { - clrTypeName = string.Format(CultureInfo.InvariantCulture, clientTemplate.SystemNullableStructureTemplate, clrTypeName); - } - } - else - { - IEdmEntityType edmEntityType = edmType as IEdmEntityType; - if (edmEntityType != null) - { - clrTypeName = context.GetPrefixedFullName(edmEntityType, - context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEntityType.Name)) : clientTemplate.GetFixedName(edmEntityType.Name), clientTemplate); - } - else - { - IEdmCollectionType edmCollectionType = (IEdmCollectionType)edmType; - IEdmTypeReference elementTypeReference = edmCollectionType.ElementType; - IEdmPrimitiveType primitiveElementType = elementTypeReference.Definition as IEdmPrimitiveType; - if (primitiveElementType != null) - { - clrTypeName = Utils.GetClrTypeName(primitiveElementType, clientTemplate); - } - else - { - IEdmSchemaElement schemaElement = (IEdmSchemaElement)elementTypeReference.Definition; - clrTypeName = context.GetPrefixedFullName(schemaElement, - context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(schemaElement.Name)) : clientTemplate.GetFixedName(schemaElement.Name), clientTemplate); - } - - string collectionTypeName = isOperationParameter - ? clientTemplate.ICollectionOfTStructureTemplate - : (useDataServiceCollection - ? (elementTypeReference.TypeKind() == EdmTypeKind.Entity - ? clientTemplate.DataServiceCollectionStructureTemplate - : clientTemplate.ObservableCollectionStructureTemplate) - : clientTemplate.ObjectModelCollectionStructureTemplate); - - clrTypeName = string.Format(CultureInfo.InvariantCulture, collectionTypeName, clrTypeName); - } - } + clrTypeName = GetNullableClrTypeName(clrTypeName, clientTemplate); } + return clrTypeName; + } + if (edmType is IEdmCollectionType edmCollectionType) + { + string clrTypeName = null; + IEdmTypeReference elementTypeReference = edmCollectionType.ElementType; + IEdmPrimitiveType primitiveElementType = elementTypeReference.Definition as IEdmPrimitiveType; + if (primitiveElementType != null) + { + clrTypeName = Utils.GetClrTypeName(primitiveElementType, clientTemplate); + } + else + { + IEdmSchemaElement schemaElement = (IEdmSchemaElement)elementTypeReference.Definition; + clrTypeName = context.GetPrefixedFullName(schemaElement, + context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(schemaElement.Name)) : clientTemplate.GetFixedName(schemaElement.Name), clientTemplate); + } + + string collectionTypeName = isOperationParameter + ? clientTemplate.ICollectionOfTStructureTemplate + : (useDataServiceCollection + ? (elementTypeReference.TypeKind() == EdmTypeKind.Entity + ? clientTemplate.DataServiceCollectionStructureTemplate + : clientTemplate.ObservableCollectionStructureTemplate) + : clientTemplate.ObjectModelCollectionStructureTemplate); + + clrTypeName = string.Format(CultureInfo.InvariantCulture, collectionTypeName, clrTypeName); + return clrTypeName; } - return clrTypeName; + throw new Exception($"Could not get CLR type name for EDM type '{edmTypeReference.FullName()}'"); } /// @@ -2957,6 +3016,17 @@ internal static string GetPropertyInitializationValue(IEdmProperty property, boo return clientTemplate.NewModifier + clrTypeName + constructorParameters; } } + + /// + /// Gets the corresponding nullable type name for the given clr type + /// + /// Original CLR type name. + /// ODataClientTemplate instance that call this method. + /// The nullable version of the specified type name. + internal static string GetNullableClrTypeName(string clrTypeName, ODataClientTemplate clientTemplate) + { + return string.Format(CultureInfo.InvariantCulture, clientTemplate.SystemNullableStructureTemplate, clrTypeName); + } /// /// Gets the clr type name from the give Edm primitive type. @@ -3124,6 +3194,8 @@ public ODataClientCSharpTemplate(CodeGenerationContext context) internal override string GlobalPrefix { get {return "global::"; } } internal override string SystemTypeTypeName { get { return "global::System.Type"; } } internal override string AbstractModifier { get { return " abstract"; } } + internal override string PublicAccessModifier { get { return "public"; } } + internal override string InternalAccessModifier { get { return "internal"; } } internal override string DataServiceActionQueryTypeName { get { return "global::Microsoft.OData.Client.DataServiceActionQuery"; } } internal override string DataServiceActionQuerySingleOfTStructureTemplate { get { return "global::Microsoft.OData.Client.DataServiceActionQuerySingle<{0}>"; } } internal override string DataServiceActionQueryOfTStructureTemplate { get { return "global::Microsoft.OData.Client.DataServiceActionQuery<{0}>"; } } @@ -3171,10 +3243,10 @@ public ODataClientCSharpTemplate(CodeGenerationContext context) internal override string GeometryMultiPolygonTypeName { get { return "global::Microsoft.Spatial.GeometryMultiPolygon"; } } internal override string GeometryMultiLineStringTypeName { get { return "global::Microsoft.Spatial.GeometryMultiLineString"; } } internal override string GeometryMultiPointTypeName { get { return "global::Microsoft.Spatial.GeometryMultiPoint"; } } - internal override string DateTypeName { get { return "global::Microsoft.OData.Edm.Library.Date"; } } + internal override string DateTypeName { get { return "global::Microsoft.OData.Edm.Date"; } } internal override string DateTimeOffsetTypeName { get { return "global::System.DateTimeOffset"; } } internal override string DurationTypeName { get { return "global::System.TimeSpan"; } } - internal override string TimeOfDayTypeName { get { return "global::Microsoft.OData.Edm.Library.TimeOfDay"; } } + internal override string TimeOfDayTypeName { get { return "global::Microsoft.OData.Edm.TimeOfDay"; } } internal override string XmlConvertClassName { get { return "global::System.Xml.XmlConvert"; } } internal override string EnumTypeName { get { return "global::System.Enum"; } } internal override string FixPattern { get { return "@{0}"; } } @@ -3262,7 +3334,11 @@ internal override void WriteClassStartForEntityContainer(string originalContaine } -this.Write(" public partial class "); +this.Write(" "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); + +this.Write(" partial class "); this.Write(this.ToStringHelper.ToStringWithCulture(fixedContainerName)); @@ -3955,7 +4031,9 @@ internal override void WriteClassStartForStructuredType(string abstractModifier, } -this.Write(" public"); +this.Write(" "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); this.Write(this.ToStringHelper.ToStringWithCulture(abstractModifier)); @@ -4274,7 +4352,11 @@ internal override void WriteEnumDeclaration(string enumName, string originalEnum } -this.Write(" public enum "); +this.Write(" "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); + +this.Write(" enum "); this.Write(this.ToStringHelper.ToStringWithCulture(enumName)); @@ -4699,7 +4781,11 @@ internal override void WriteExtensionMethodsStart() { this.Write(" /// \r\n /// Class containing all extension methods\r\n /// \r\n public static class ExtensionMethods\r\n {\r\n"); + "ary>\r\n "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); + +this.Write(" static class ExtensionMethods\r\n {\r\n"); } @@ -5060,6 +5146,8 @@ public ODataClientVBTemplate(CodeGenerationContext context) internal override string GlobalPrefix { get { return string.Empty; } } internal override string SystemTypeTypeName { get { return "Global.System.Type"; } } internal override string AbstractModifier { get { return " MustInherit"; } } + internal override string PublicAccessModifier { get { return "Public"; } } + internal override string InternalAccessModifier { get { return "Friend"; } } internal override string DataServiceActionQueryTypeName { get { return "Global.Microsoft.OData.Client.DataServiceActionQuery"; } } internal override string DataServiceActionQuerySingleOfTStructureTemplate { get { return "Global.Microsoft.OData.Client.DataServiceActionQuerySingle(Of {0})"; } } internal override string DataServiceActionQueryOfTStructureTemplate { get { return "Global.Microsoft.OData.Client.DataServiceActionQuery(Of {0})"; } } @@ -5107,10 +5195,10 @@ public ODataClientVBTemplate(CodeGenerationContext context) internal override string GeometryMultiPolygonTypeName { get { return "Global.Microsoft.Spatial.GeometryMultiPolygon"; } } internal override string GeometryMultiLineStringTypeName { get { return "Global.Microsoft.Spatial.GeometryMultiLineString"; } } internal override string GeometryMultiPointTypeName { get { return "Global.Microsoft.Spatial.GeometryMultiPoint"; } } - internal override string DateTypeName { get { return "Global.Microsoft.OData.Edm.Library.Date"; } } + internal override string DateTypeName { get { return "Global.Microsoft.OData.Edm.Date"; } } internal override string DateTimeOffsetTypeName { get { return "Global.System.DateTimeOffset"; } } internal override string DurationTypeName { get { return "Global.System.TimeSpan"; } } - internal override string TimeOfDayTypeName { get { return "Global.Microsoft.OData.Edm.Library.TimeOfDay"; } } + internal override string TimeOfDayTypeName { get { return "Global.Microsoft.OData.Edm.TimeOfDay"; } } internal override string XmlConvertClassName { get { return "Global.System.Xml.XmlConvert"; } } internal override string EnumTypeName { get { return "Global.System.Enum"; } } internal override string FixPattern { get { return "[{0}]"; } } @@ -5215,7 +5303,11 @@ internal override void WriteClassStartForEntityContainer(string originalContaine } -this.Write(" Partial Public Class "); +this.Write(" Partial "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); + +this.Write(" Class "); this.Write(this.ToStringHelper.ToStringWithCulture(fixedContainerName)); @@ -5943,7 +6035,9 @@ internal override void WriteClassStartForStructuredType(string abstractModifier, } -this.Write(" Partial Public"); +this.Write(" Partial "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); this.Write(this.ToStringHelper.ToStringWithCulture(abstractModifier)); @@ -6272,7 +6366,11 @@ internal override void WriteEnumDeclaration(string enumName, string originalEnum } -this.Write(" Public Enum "); +this.Write(" "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); + +this.Write(" Enum "); this.Write(this.ToStringHelper.ToStringWithCulture(enumName)); @@ -6695,7 +6793,11 @@ internal override void WriteExtensionMethodsStart() { this.Write(" \'\'\' \r\n \'\'\' Class containing all extension methods\r\n \'\'\' \r\n Public Module ExtensionMethods\r\n"); + "ary>\r\n "); + +this.Write(this.ToStringHelper.ToStringWithCulture(ClassAccessModifier)); + +this.Write(" Module ExtensionMethods\r\n"); } @@ -6808,8 +6910,8 @@ internal override void WriteCastToMethods(string baseTypeName, string derivedTyp this.Write(this.ToStringHelper.ToStringWithCulture(derivedTypeFullName)); this.Write("\r\n \'\'\' \r\n \'\'\' source entity\r" + - "\n \r\n Public " + - "Function CastTo"); + "\n \r\n Public Fu" + + "nction CastTo"); this.Write(this.ToStringHelper.ToStringWithCulture(derivedTypeName)); @@ -7049,7 +7151,7 @@ internal override void WriteNamespaceEnd() /// /// Base class for this transformation /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")] internal class ODataT4CodeGeneratorBase { #region Fields diff --git a/ODataConnectedService/src/Templates/ODataT4CodeGenerator.tt b/ODataConnectedService/src/Templates/ODataT4CodeGenerator.tt index adde141..960fa16 100644 --- a/ODataConnectedService/src/Templates/ODataT4CodeGenerator.tt +++ b/ODataConnectedService/src/Templates/ODataT4CodeGenerator.tt @@ -24,6 +24,10 @@ public static class Configuration // This flag indicates whether to ignore unexpected elements and attributes in the metadata document and generate // the client code if any. The value must be set to true or false. public const bool IgnoreUnexpectedElementsAndAttributes = true; + + // If set to true, generated types will have an "internal" class modifier ("Friend" in VB) instead of "public" + // thereby making them invisible outside the assembly + public const bool MakeTypesInternal = false; } public static class Customization diff --git a/ODataConnectedService/src/Templates/ODataT4CodeGenerator.ttinclude b/ODataConnectedService/src/Templates/ODataT4CodeGenerator.ttinclude index a5c23bf..d51dcaa 100644 --- a/ODataConnectedService/src/Templates/ODataT4CodeGenerator.ttinclude +++ b/ODataConnectedService/src/Templates/ODataT4CodeGenerator.ttinclude @@ -47,7 +47,8 @@ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI UseDataServiceCollection = this.UseDataServiceCollection, TargetLanguage = this.TargetLanguage, EnableNamingAlias = this.EnableNamingAlias, - IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes + IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes, + MakeTypesInternal = this.MakeTypesInternal }; } else @@ -63,7 +64,8 @@ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI UseDataServiceCollection = this.UseDataServiceCollection, TargetLanguage = this.TargetLanguage, EnableNamingAlias = this.EnableNamingAlias, - IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes + IgnoreUnexpectedElementsAndAttributes = this.IgnoreUnexpectedElementsAndAttributes, + MakeTypesInternal = this.MakeTypesInternal }; } @@ -213,6 +215,16 @@ public bool IgnoreUnexpectedElementsAndAttributes set; } +/// +/// true to use the "internal" access modifier ("Friend" in VB) on generated types, +/// otherwise "public" is used +/// +public bool MakeTypesInternal +{ + get; + set; +} + /// /// Generate code targeting a specific .Net Framework language. /// @@ -228,18 +240,18 @@ public enum LanguageOption /// /// Set the UseDataServiceCollection property with the given value. /// -/// The value to set. -public void ValidateAndSetUseDataServiceCollectionFromString(string stringValue) +/// The value to set. +public void ValidateAndSetUseDataServiceCollectionFromString(string inputValue) { bool boolValue; - if (!bool.TryParse(stringValue, out boolValue)) + if (!bool.TryParse(inputValue, out boolValue)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the UseDataServiceCollection parameter because it is not a valid boolean value.", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the UseDataServiceCollection parameter because it is not a valid boolean value.", inputValue)); } this.UseDataServiceCollection = boolValue; @@ -248,18 +260,18 @@ public void ValidateAndSetUseDataServiceCollectionFromString(string stringValue) /// /// Tries to set the TargetLanguage property with the given value. /// -/// The value to set. -public void ValidateAndSetTargetLanguageFromString(string stringValue) +/// The value to set. +public void ValidateAndSetTargetLanguageFromString(string inputValue) { LanguageOption option; - if (!Enum.TryParse(stringValue, true, out option)) + if (!Enum.TryParse(inputValue, true, out option)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the TargetLanguage parameter because it is not a valid LanguageOption. The supported LanguageOptions are \"CSharp\" and \"VB\".", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the TargetLanguage parameter because it is not a valid LanguageOption. The supported LanguageOptions are \"CSharp\" and \"VB\".", inputValue)); } this.TargetLanguage = option; @@ -268,18 +280,18 @@ public void ValidateAndSetTargetLanguageFromString(string stringValue) /// /// Set the EnableNamingAlias property with the given value. /// -/// The value to set. -public void ValidateAndSetEnableNamingAliasFromString(string stringValue) +/// The value to set. +public void ValidateAndSetEnableNamingAliasFromString(string inputValue) { bool boolValue; - if (!bool.TryParse(stringValue, out boolValue)) + if (!bool.TryParse(inputValue, out boolValue)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the EnableNamingAlias parameter because it is not a valid boolean value.", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the EnableNamingAlias parameter because it is not a valid boolean value.", inputValue)); } this.EnableNamingAlias = boolValue; @@ -288,23 +300,43 @@ public void ValidateAndSetEnableNamingAliasFromString(string stringValue) /// /// Set the IgnoreUnexpectedElementsAndAttributes property with the given value. /// -/// The value to set. -public void ValidateAndSetIgnoreUnexpectedElementsAndAttributesFromString(string stringValue) +/// The value to set. +public void ValidateAndSetIgnoreUnexpectedElementsAndAttributesFromString(string inputValue) { bool boolValue; - if (!bool.TryParse(stringValue, out boolValue)) + if (!bool.TryParse(inputValue, out boolValue)) { // ******************************************************************************************************** // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter // value then hit Ctrl-S to save the .tt file to refresh the code generation. // ******************************************************************************************************** - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the IgnoreUnexpectedElementsAndAttributes parameter because it is not a valid boolean value.", stringValue)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the IgnoreUnexpectedElementsAndAttributes parameter because it is not a valid boolean value.", inputValue)); } this.IgnoreUnexpectedElementsAndAttributes = boolValue; } +/// +/// Set the MakeTypesInternal property with the given value. +/// +/// The value to set. +public void ValidateAndSetMakeTypesInternalFromString(string inputValue) +{ + bool parsedValue; + if (!bool.TryParse(inputValue, out parsedValue)) + { + // ******************************************************************************************************** + // To fix this error, if the current text transformation is run by the TextTemplatingFileGenerator + // custom tool inside Visual Studio, update the .odata.config file in the project with a valid parameter + // value then hit Ctrl-S to save the .tt file to refresh the code generation. + // ******************************************************************************************************** + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The value \"{0}\" cannot be assigned to the MakeTypesInternal parameter because it is not a valid boolean value.", inputValue)); + } + + this.MakeTypesInternal = parsedValue; +} + /// /// Reads the parameter values from the Configuration class and applies them. /// @@ -316,6 +348,7 @@ private void ApplyParametersFromConfigurationClass() this.ValidateAndSetTargetLanguageFromString(Configuration.TargetLanguage); this.EnableNamingAlias = Configuration.EnableNamingAlias; this.IgnoreUnexpectedElementsAndAttributes = Configuration.IgnoreUnexpectedElementsAndAttributes; + this.MakeTypesInternal = Configuration.MakeTypesInternal; } /// @@ -363,6 +396,12 @@ private void ApplyParametersFromCommandLine() { this.ValidateAndSetIgnoreUnexpectedElementsAndAttributesFromString(ignoreUnexpectedElementsAndAttributes); } + + string makeTypesInternal = this.Host.ResolveParameterValue("notempty", "notempty", "MakeTypesInternal"); + if (!string.IsNullOrEmpty(makeTypesInternal)) + { + this.ValidateAndSetMakeTypesInternalFromString(makeTypesInternal); + } } /// @@ -672,6 +711,16 @@ public class CodeGenerationContext get; set; } + + /// + /// true to use internal access modifier for generated classes, otherwise they will be made public. + /// This is useful if you don't want the generated classes to be visible outside the assembly + /// + public bool MakeTypesInternal + { + get; + set; + } /// /// Specifies which specific .Net Framework language the generated code will target. @@ -932,6 +981,8 @@ public abstract class ODataClientTemplate : TemplateBase internal abstract string GlobalPrefix { get; } internal abstract string SystemTypeTypeName { get; } internal abstract string AbstractModifier { get; } + internal abstract string PublicAccessModifier { get; } + internal abstract string InternalAccessModifier { get; } internal abstract string DataServiceActionQueryTypeName { get; } internal abstract string DataServiceActionQuerySingleOfTStructureTemplate { get; } internal abstract string DataServiceActionQueryOfTStructureTemplate { get; } @@ -1077,6 +1128,12 @@ public abstract class ODataClientTemplate : TemplateBase } } private HashSet clrReferenceTypes; + internal string ClassAccessModifier { + get { + return this.context.MakeTypesInternal ? this.InternalAccessModifier : this.PublicAccessModifier; + } + } + /// /// Generates code for the OData client. /// @@ -1130,26 +1187,23 @@ public abstract class ODataClientTemplate : TemplateBase Dictionary> structuredBaseTypeMap = new Dictionary>(); foreach(IEdmSchemaType type in schemaElements.OfType()) { - IEdmEnumType enumType = type as IEdmEnumType; - if (enumType != null) + if (type is IEdmEnumType enumType) { this.WriteEnumType(enumType); } else { - IEdmComplexType complexType = type as IEdmComplexType; - if (complexType != null) + if (type is IEdmComplexType complexType) { this.WriteComplexType(complexType, boundOperationsMap); } - else + else if (type is IEdmEntityType entityType) { - IEdmEntityType entityType = type as IEdmEntityType; this.WriteEntityType(entityType, boundOperationsMap); } IEdmStructuredType structuredType = type as IEdmStructuredType; - if (structuredType.BaseType != null) + if (structuredType?.BaseType != null) { List derivedTypes; if (!structuredBaseTypeMap.TryGetValue(structuredType.BaseType, out derivedTypes)) @@ -2638,76 +2692,77 @@ internal static class Utils /// The clr type name of the type reference. internal static string GetClrTypeName(IEdmTypeReference edmTypeReference, bool useDataServiceCollection, ODataClientTemplate clientTemplate, CodeGenerationContext context, bool addNullableTemplate = true, bool needGlobalPrefix = true, bool isOperationParameter = false) { - string clrTypeName; IEdmType edmType = edmTypeReference.Definition; - IEdmPrimitiveType edmPrimitiveType = edmType as IEdmPrimitiveType; - if (edmPrimitiveType != null) + if (edmType is IEdmPrimitiveType edmPrimitiveType) { - clrTypeName = Utils.GetClrTypeName(edmPrimitiveType, clientTemplate); + var clrTypeName = Utils.GetClrTypeName(edmPrimitiveType, clientTemplate); if (edmTypeReference.IsNullable && !clientTemplate.ClrReferenceTypes.Contains(edmPrimitiveType.PrimitiveKind) && addNullableTemplate) { - clrTypeName = string.Format(CultureInfo.InvariantCulture, clientTemplate.SystemNullableStructureTemplate, clrTypeName); + clrTypeName = GetNullableClrTypeName(clrTypeName, clientTemplate); } + return clrTypeName; } - else + if (edmType is IEdmComplexType edmComplexType) { - IEdmComplexType edmComplexType = edmType as IEdmComplexType; - if (edmComplexType != null) - { - clrTypeName = context.GetPrefixedFullName(edmComplexType, + var clrTypeName = context.GetPrefixedFullName(edmComplexType, context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmComplexType.Name)) : clientTemplate.GetFixedName(edmComplexType.Name), clientTemplate); + return clrTypeName; + } + if (edmType is IEdmEnumType edmEnumType) + { + var clrTypeName = context.GetPrefixedFullName(edmEnumType, + context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEnumType.Name)) : clientTemplate.GetFixedName(edmEnumType.Name), clientTemplate, needGlobalPrefix); + if (edmTypeReference.IsNullable && addNullableTemplate) + { + clrTypeName = GetNullableClrTypeName(clrTypeName, clientTemplate); } - else + return clrTypeName; + } + if (edmType is IEdmEntityType edmEntityType) + { + var clrTypeName = context.GetPrefixedFullName(edmEntityType, + context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEntityType.Name)) : clientTemplate.GetFixedName(edmEntityType.Name), clientTemplate); + return clrTypeName; + } + if (edmType is IEdmTypeDefinition edmTypeDefinition) + { + var underlyingType = edmTypeDefinition.UnderlyingType; + var clrTypeName = Utils.GetClrTypeName(underlyingType, clientTemplate); + if (edmTypeReference.IsNullable && !clientTemplate.ClrReferenceTypes.Contains(underlyingType.PrimitiveKind) && addNullableTemplate) { - IEdmEnumType edmEnumType = edmType as IEdmEnumType; - if (edmEnumType != null) - { - clrTypeName = context.GetPrefixedFullName(edmEnumType, - context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEnumType.Name)) : clientTemplate.GetFixedName(edmEnumType.Name), clientTemplate, needGlobalPrefix); - if (edmTypeReference.IsNullable && addNullableTemplate) - { - clrTypeName = string.Format(CultureInfo.InvariantCulture, clientTemplate.SystemNullableStructureTemplate, clrTypeName); - } - } - else - { - IEdmEntityType edmEntityType = edmType as IEdmEntityType; - if (edmEntityType != null) - { - clrTypeName = context.GetPrefixedFullName(edmEntityType, - context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEntityType.Name)) : clientTemplate.GetFixedName(edmEntityType.Name), clientTemplate); - } - else - { - IEdmCollectionType edmCollectionType = (IEdmCollectionType)edmType; - IEdmTypeReference elementTypeReference = edmCollectionType.ElementType; - IEdmPrimitiveType primitiveElementType = elementTypeReference.Definition as IEdmPrimitiveType; - if (primitiveElementType != null) - { - clrTypeName = Utils.GetClrTypeName(primitiveElementType, clientTemplate); - } - else - { - IEdmSchemaElement schemaElement = (IEdmSchemaElement)elementTypeReference.Definition; - clrTypeName = context.GetPrefixedFullName(schemaElement, - context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(schemaElement.Name)) : clientTemplate.GetFixedName(schemaElement.Name), clientTemplate); - } - - string collectionTypeName = isOperationParameter - ? clientTemplate.ICollectionOfTStructureTemplate - : (useDataServiceCollection - ? (elementTypeReference.TypeKind() == EdmTypeKind.Entity - ? clientTemplate.DataServiceCollectionStructureTemplate - : clientTemplate.ObservableCollectionStructureTemplate) - : clientTemplate.ObjectModelCollectionStructureTemplate); - - clrTypeName = string.Format(CultureInfo.InvariantCulture, collectionTypeName, clrTypeName); - } - } + clrTypeName = GetNullableClrTypeName(clrTypeName, clientTemplate); } + return clrTypeName; + } + if (edmType is IEdmCollectionType edmCollectionType) + { + string clrTypeName = null; + IEdmTypeReference elementTypeReference = edmCollectionType.ElementType; + IEdmPrimitiveType primitiveElementType = elementTypeReference.Definition as IEdmPrimitiveType; + if (primitiveElementType != null) + { + clrTypeName = Utils.GetClrTypeName(primitiveElementType, clientTemplate); + } + else + { + IEdmSchemaElement schemaElement = (IEdmSchemaElement)elementTypeReference.Definition; + clrTypeName = context.GetPrefixedFullName(schemaElement, + context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(schemaElement.Name)) : clientTemplate.GetFixedName(schemaElement.Name), clientTemplate); + } + + string collectionTypeName = isOperationParameter + ? clientTemplate.ICollectionOfTStructureTemplate + : (useDataServiceCollection + ? (elementTypeReference.TypeKind() == EdmTypeKind.Entity + ? clientTemplate.DataServiceCollectionStructureTemplate + : clientTemplate.ObservableCollectionStructureTemplate) + : clientTemplate.ObjectModelCollectionStructureTemplate); + + clrTypeName = string.Format(CultureInfo.InvariantCulture, collectionTypeName, clrTypeName); + return clrTypeName; } - return clrTypeName; + throw new Exception($"Could not get CLR type name for EDM type '{edmTypeReference.FullName()}'"); } /// @@ -2849,6 +2904,17 @@ internal static class Utils return clientTemplate.NewModifier + clrTypeName + constructorParameters; } } + + /// + /// Gets the corresponding nullable type name for the given clr type + /// + /// Original CLR type name. + /// ODataClientTemplate instance that call this method. + /// The nullable version of the specified type name. + internal static string GetNullableClrTypeName(string clrTypeName, ODataClientTemplate clientTemplate) + { + return string.Format(CultureInfo.InvariantCulture, clientTemplate.SystemNullableStructureTemplate, clrTypeName); + } /// /// Gets the clr type name from the give Edm primitive type. @@ -3016,6 +3082,8 @@ public sealed class ODataClientCSharpTemplate : ODataClientTemplate internal override string GlobalPrefix { get {return "global::"; } } internal override string SystemTypeTypeName { get { return "global::System.Type"; } } internal override string AbstractModifier { get { return " abstract"; } } + internal override string PublicAccessModifier { get { return "public"; } } + internal override string InternalAccessModifier { get { return "internal"; } } internal override string DataServiceActionQueryTypeName { get { return "global::Microsoft.OData.Client.DataServiceActionQuery"; } } internal override string DataServiceActionQuerySingleOfTStructureTemplate { get { return "global::Microsoft.OData.Client.DataServiceActionQuerySingle<{0}>"; } } internal override string DataServiceActionQueryOfTStructureTemplate { get { return "global::Microsoft.OData.Client.DataServiceActionQuery<{0}>"; } } @@ -3063,10 +3131,10 @@ public sealed class ODataClientCSharpTemplate : ODataClientTemplate internal override string GeometryMultiPolygonTypeName { get { return "global::Microsoft.Spatial.GeometryMultiPolygon"; } } internal override string GeometryMultiLineStringTypeName { get { return "global::Microsoft.Spatial.GeometryMultiLineString"; } } internal override string GeometryMultiPointTypeName { get { return "global::Microsoft.Spatial.GeometryMultiPoint"; } } - internal override string DateTypeName { get { return "global::Microsoft.OData.Edm.Library.Date"; } } + internal override string DateTypeName { get { return "global::Microsoft.OData.Edm.Date"; } } internal override string DateTimeOffsetTypeName { get { return "global::System.DateTimeOffset"; } } internal override string DurationTypeName { get { return "global::System.TimeSpan"; } } - internal override string TimeOfDayTypeName { get { return "global::Microsoft.OData.Edm.Library.TimeOfDay"; } } + internal override string TimeOfDayTypeName { get { return "global::Microsoft.OData.Edm.TimeOfDay"; } } internal override string XmlConvertClassName { get { return "global::System.Xml.XmlConvert"; } } internal override string EnumTypeName { get { return "global::System.Enum"; } } internal override string FixPattern { get { return "@{0}"; } } @@ -3137,7 +3205,7 @@ namespace <#= fullNamespace #> <#+ } #> - public partial class <#= fixedContainerName #> : global::Microsoft.OData.Client.DataServiceContext + <#= ClassAccessModifier #> partial class <#= fixedContainerName #> : global::Microsoft.OData.Client.DataServiceContext { <#+ } @@ -3560,7 +3628,7 @@ namespace <#= fullNamespace #> <#+ } #> - public<#= abstractModifier #> partial class <#= typeName #><#= baseTypeName #> + <#= ClassAccessModifier #><#= abstractModifier #> partial class <#= typeName #><#= baseTypeName #> { <#+ } @@ -3724,7 +3792,7 @@ namespace <#= fullNamespace #> <#+ } #> - public enum <#= enumName #><#= underlyingType #> + <#= ClassAccessModifier #> enum <#= enumName #><#= underlyingType #> { <#+ } @@ -3892,7 +3960,7 @@ namespace <#= fullNamespace #> /// /// Class containing all extension methods /// - public static class ExtensionMethods + <#= ClassAccessModifier #> static class ExtensionMethods { <#+ } @@ -4055,6 +4123,8 @@ public sealed class ODataClientVBTemplate : ODataClientTemplate internal override string GlobalPrefix { get { return string.Empty; } } internal override string SystemTypeTypeName { get { return "Global.System.Type"; } } internal override string AbstractModifier { get { return " MustInherit"; } } + internal override string PublicAccessModifier { get { return "Public"; } } + internal override string InternalAccessModifier { get { return "Friend"; } } internal override string DataServiceActionQueryTypeName { get { return "Global.Microsoft.OData.Client.DataServiceActionQuery"; } } internal override string DataServiceActionQuerySingleOfTStructureTemplate { get { return "Global.Microsoft.OData.Client.DataServiceActionQuerySingle(Of {0})"; } } internal override string DataServiceActionQueryOfTStructureTemplate { get { return "Global.Microsoft.OData.Client.DataServiceActionQuery(Of {0})"; } } @@ -4102,10 +4172,10 @@ public sealed class ODataClientVBTemplate : ODataClientTemplate internal override string GeometryMultiPolygonTypeName { get { return "Global.Microsoft.Spatial.GeometryMultiPolygon"; } } internal override string GeometryMultiLineStringTypeName { get { return "Global.Microsoft.Spatial.GeometryMultiLineString"; } } internal override string GeometryMultiPointTypeName { get { return "Global.Microsoft.Spatial.GeometryMultiPoint"; } } - internal override string DateTypeName { get { return "Global.Microsoft.OData.Edm.Library.Date"; } } + internal override string DateTypeName { get { return "Global.Microsoft.OData.Edm.Date"; } } internal override string DateTimeOffsetTypeName { get { return "Global.System.DateTimeOffset"; } } internal override string DurationTypeName { get { return "Global.System.TimeSpan"; } } - internal override string TimeOfDayTypeName { get { return "Global.Microsoft.OData.Edm.Library.TimeOfDay"; } } + internal override string TimeOfDayTypeName { get { return "Global.Microsoft.OData.Edm.TimeOfDay"; } } internal override string XmlConvertClassName { get { return "Global.System.Xml.XmlConvert"; } } internal override string EnumTypeName { get { return "Global.System.Enum"; } } internal override string FixPattern { get { return "[{0}]"; } } @@ -4188,7 +4258,7 @@ Namespace <#= fullNamespace #> <#+ } #> - Partial Public Class <#= fixedContainerName #> + Partial <#= ClassAccessModifier #> Class <#= fixedContainerName #> Inherits Global.Microsoft.OData.Client.DataServiceContext <#+ } @@ -4602,7 +4672,7 @@ Namespace <#= fullNamespace #> <#+ } #> - Partial Public<#= abstractModifier #> Class <#= typeName #><#= baseTypeName #> + Partial <#= ClassAccessModifier #><#= abstractModifier #> Class <#= typeName #><#= baseTypeName #> <#+ } @@ -4768,7 +4838,7 @@ Namespace <#= fullNamespace #> <#+ } #> - Public Enum <#= enumName #><#= underlyingType #> + <#= ClassAccessModifier #> Enum <#= enumName #><#= underlyingType #> <#+ } @@ -4927,7 +4997,7 @@ Namespace <#= fullNamespace #> ''' ''' Class containing all extension methods ''' - Public Module ExtensionMethods + <#= ClassAccessModifier #> Module ExtensionMethods <#+ } diff --git a/ODataConnectedService/src/Templates/ODataT4CodeGeneratorFactory.cs b/ODataConnectedService/src/Templates/ODataT4CodeGeneratorFactory.cs new file mode 100644 index 0000000..af6dca5 --- /dev/null +++ b/ODataConnectedService/src/Templates/ODataT4CodeGeneratorFactory.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +namespace Microsoft.OData.ConnectedService.Templates +{ + class ODataT4CodeGeneratorFactory: IODataT4CodeGeneratorFactory + { + public ODataT4CodeGenerator Create() + { + return new ODataT4CodeGenerator(); + } + } +} diff --git a/ODataConnectedService/src/ViewModels/AdvancedSettingsViewModel.cs b/ODataConnectedService/src/ViewModels/AdvancedSettingsViewModel.cs index d193f87..c7732be 100644 --- a/ODataConnectedService/src/ViewModels/AdvancedSettingsViewModel.cs +++ b/ODataConnectedService/src/ViewModels/AdvancedSettingsViewModel.cs @@ -17,6 +17,7 @@ internal class AdvancedSettingsViewModel : ConnectedServiceWizardPage public bool IgnoreUnexpectedElementsAndAttributes { get; set; } public string GeneratedFileName { get; set; } public bool IncludeT4File { get; set; } + public bool MakeTypesInternal { get; set; } public AdvancedSettingsViewModel() : base() { @@ -55,6 +56,7 @@ private void ResetDataContext() this.EnableNamingAlias = false; this.GeneratedFileName = Common.Constants.DefaultReferenceFileName; this.IncludeT4File = false; + MakeTypesInternal = false; } } } diff --git a/ODataConnectedService/src/Views/AdvancedSettings.xaml b/ODataConnectedService/src/Views/AdvancedSettings.xaml index cc40528..627b3ac 100644 --- a/ODataConnectedService/src/Views/AdvancedSettings.xaml +++ b/ODataConnectedService/src/Views/AdvancedSettings.xaml @@ -44,8 +44,12 @@ HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0, 5"> Ignore unknown elements (Whether to ignore unexpected elements and attributes in the metadata document and generate the client code if any.) + + Make generated types internal (Enable this if you don't want to expose the generated types outside of your assembly.) + + HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0, 15" FontWeight="Medium"/> diff --git a/ODataConnectedService/src/app.config b/ODataConnectedService/src/app.config index faa26ba..bc76694 100644 --- a/ODataConnectedService/src/app.config +++ b/ODataConnectedService/src/app.config @@ -1,15 +1,15 @@ - + - - + + - - + + - + diff --git a/ODataConnectedService/src/source.extension.vsixmanifest b/ODataConnectedService/src/source.extension.vsixmanifest index 3357965..cace2d2 100644 --- a/ODataConnectedService/src/source.extension.vsixmanifest +++ b/ODataConnectedService/src/source.extension.vsixmanifest @@ -1,25 +1,27 @@ - - - Microsoft - OData Connected Service - OData Connected Service for V1-V4 - https://github.com/odata/lab - License.txt - Resources\ExtensionIcon.png - OData Connected Service - - - - - - - - - - - - - + + + Microsoft + OData Connected Service + OData Connected Service for V1-V4 + https://github.com/odata/lab + License.txt + Resources\ExtensionIcon.png + OData Connected Service + + + + + + + + + + + + + + + diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctions.cs b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctions.cs new file mode 100644 index 0000000..44ada8d --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctions.cs @@ -0,0 +1,1298 @@ +//------------------------------------------------------------------------------ +// +// 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/21/2020 11:02:50 AM +namespace Microsoft.OData.Service.Sample.TrippinInMemory.Models +{ + /// + /// There are no comments for Container in the schema. + /// + public partial class Container : global::Microsoft.OData.Client.DataServiceContext + { + /// + /// Initialize a new Container object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public Container(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", "2.4.0")] + protected string ResolveNameFromType(global::System.Type clientType) + { + return clientType.FullName; + } + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery People + { + get + { + if ((this._People == null)) + { + this._People = base.CreateQuery("People"); + } + return this._People; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _People; + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airlines + { + get + { + if ((this._Airlines == null)) + { + this._Airlines = base.CreateQuery("Airlines"); + } + return this._Airlines; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airlines; + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airports + { + get + { + if ((this._Airports == null)) + { + this._Airports = base.CreateQuery("Airports"); + } + return this._Airports; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airports; + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToPeople(Person person) + { + base.AddObject("People", person); + } + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirlines(Airline airline) + { + base.AddObject("Airlines", airline); + } + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirports(Airport airport) + { + base.AddObject("Airports", airport); + } + /// + /// There are no comments for Me in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public PersonSingle Me + { + get + { + if ((this._Me == null)) + { + this._Me = new PersonSingle(this, "Me"); + } + return this._Me; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private PersonSingle _Me; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private abstract class GeneratedEdmModel + { + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private static global::Microsoft.OData.Edm.IEdmModel ParsedModel = LoadModelFromString(); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private const string Edmx = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static global::Microsoft.OData.Edm.IEdmModel GetInstance() + { + return ParsedModel; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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); + } + finally + { + ((global::System.IDisposable)(reader)).Dispose(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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 GetPersonWithMostFriends in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle GetPersonWithMostFriends() + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(this.CreateFunctionQuerySingle("", "GetPersonWithMostFriends", false)); + } + /// + /// There are no comments for GetNearestAirport in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle GetNearestAirport(double lat, double lon) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.CreateFunctionQuerySingle("", "GetNearestAirport", false, new global::Microsoft.OData.Client.UriOperationParameter("lat", lat), + new global::Microsoft.OData.Client.UriOperationParameter("lon", lon))); + } + /// + /// There are no comments for ResetDataSource in the schema. + /// + public global::Microsoft.OData.Client.DataServiceActionQuery ResetDataSource() + { + return new global::Microsoft.OData.Client.DataServiceActionQuery(this, this.BaseUri.OriginalString.Trim('/') + "/ResetDataSource"); + } + } + /// + /// There are no comments for PersonSingle in the schema. + /// + public partial class PersonSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Person in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + public partial class Person : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Person object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Person CreatePerson(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender) + { + Person person = new Person(); + person.UserName = userName; + person.Gender = gender; + return person; + } + /// + /// There are no comments for Property UserName in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string UserName + { + get + { + return this._UserName; + } + set + { + this.OnUserNameChanging(value); + this._UserName = value; + this.OnUserNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _UserName; + partial void OnUserNameChanging(string value); + partial void OnUserNameChanged(); + /// + /// There are no comments for Property Gender in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender Gender + { + get + { + return this._Gender; + } + set + { + this.OnGenderChanging(value); + this._Gender = value; + this.OnGenderChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender _Gender; + partial void OnGenderChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender value); + partial void OnGenderChanged(); + /// + /// There are no comments for Property Age in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Nullable Age + { + get + { + return this._Age; + } + set + { + this.OnAgeChanging(value); + this._Age = value; + this.OnAgeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Nullable _Age; + partial void OnAgeChanging(global::System.Nullable value); + partial void OnAgeChanged(); + /// + /// There are no comments for Property HomeAddress in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location HomeAddress + { + get + { + return this._HomeAddress; + } + set + { + this.OnHomeAddressChanging(value); + this._HomeAddress = value; + this.OnHomeAddressChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location _HomeAddress; + partial void OnHomeAddressChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location value); + partial void OnHomeAddressChanged(); + /// + /// There are no comments for Property Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Collections.ObjectModel.Collection Friends + { + get + { + return this._Friends; + } + set + { + this.OnFriendsChanging(value); + this._Friends = value; + this.OnFriendsChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Collections.ObjectModel.Collection _Friends = new global::System.Collections.ObjectModel.Collection(); + partial void OnFriendsChanging(global::System.Collections.ObjectModel.Collection value); + partial void OnFriendsChanged(); + /// + /// There are no comments for Property Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Collections.ObjectModel.Collection Trips + { + get + { + return this._Trips; + } + set + { + this.OnTripsChanging(value); + this._Trips = value; + this.OnTripsChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Collections.ObjectModel.Collection _Trips = new global::System.Collections.ObjectModel.Collection(); + partial void OnTripsChanging(global::System.Collections.ObjectModel.Collection value); + partial void OnTripsChanged(); + } + /// + /// There are no comments for AirlineSingle in the schema. + /// + public partial class AirlineSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airline in the schema. + /// + /// + /// AirlineCode + /// + [global::Microsoft.OData.Client.Key("AirlineCode")] + public partial class Airline : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Airline object. + /// + /// Initial value of AirlineCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airline CreateAirline(string airlineCode) + { + Airline airline = new Airline(); + airline.AirlineCode = airlineCode; + return airline; + } + /// + /// There are no comments for Property AirlineCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string AirlineCode + { + get + { + return this._AirlineCode; + } + set + { + this.OnAirlineCodeChanging(value); + this._AirlineCode = value; + this.OnAirlineCodeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _AirlineCode; + partial void OnAirlineCodeChanging(string value); + partial void OnAirlineCodeChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + } + /// + /// There are no comments for AirportSingle in the schema. + /// + public partial class AirportSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airport in the schema. + /// + /// + /// IcaoCode + /// + [global::Microsoft.OData.Client.Key("IcaoCode")] + public partial class Airport : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Airport object. + /// + /// Initial value of IcaoCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airport CreateAirport(string icaoCode) + { + Airport airport = new Airport(); + airport.IcaoCode = icaoCode; + return airport; + } + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// There are no comments for Property IcaoCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string IcaoCode + { + get + { + return this._IcaoCode; + } + set + { + this.OnIcaoCodeChanging(value); + this._IcaoCode = value; + this.OnIcaoCodeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _IcaoCode; + partial void OnIcaoCodeChanging(string value); + partial void OnIcaoCodeChanged(); + } + /// + /// There are no comments for Location in the schema. + /// + public partial class Location + { + /// + /// There are no comments for Property Address in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Address + { + get + { + return this._Address; + } + set + { + this.OnAddressChanging(value); + this._Address = value; + this.OnAddressChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Address; + partial void OnAddressChanging(string value); + partial void OnAddressChanged(); + /// + /// There are no comments for Property City in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City City + { + get + { + return this._City; + } + set + { + this.OnCityChanging(value); + this._City = value; + this.OnCityChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City _City; + partial void OnCityChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City value); + partial void OnCityChanged(); + } + /// + /// There are no comments for City in the schema. + /// + public partial class City + { + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + } + /// + /// There are no comments for TripSingle in the schema. + /// + public partial class TripSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Trip in the schema. + /// + /// + /// TripId + /// + [global::Microsoft.OData.Client.Key("TripId")] + public partial class Trip : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Trip object. + /// + /// Initial value of TripId. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Trip CreateTrip(int tripId) + { + Trip trip = new Trip(); + trip.TripId = tripId; + return trip; + } + /// + /// There are no comments for Property TripId in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public int TripId + { + get + { + return this._TripId; + } + set + { + this.OnTripIdChanging(value); + this._TripId = value; + this.OnTripIdChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private int _TripId; + partial void OnTripIdChanging(int value); + partial void OnTripIdChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + } + /// + /// There are no comments for FlightSingle in the schema. + /// + public partial class FlightSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle Airline + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Airline == null)) + { + this._Airline = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(this.Context, GetPath("Airline")); + } + return this._Airline; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle _Airline; + /// + /// There are no comments for From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle From + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._From == null)) + { + this._From = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("From")); + } + return this._From; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _From; + /// + /// There are no comments for To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle To + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._To == null)) + { + this._To = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("To")); + } + return this._To; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _To; + } + /// + /// There are no comments for Flight in the schema. + /// + [global::Microsoft.OData.Client.EntityType()] + public partial class Flight : PublicTransportation + { + /// + /// There are no comments for Property FlightNumber in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string FlightNumber + { + get + { + return this._FlightNumber; + } + set + { + this.OnFlightNumberChanging(value); + this._FlightNumber = value; + this.OnFlightNumberChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _FlightNumber; + partial void OnFlightNumberChanging(string value); + partial void OnFlightNumberChanged(); + /// + /// There are no comments for Property Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline Airline + { + get + { + return this._Airline; + } + set + { + this.OnAirlineChanging(value); + this._Airline = value; + this.OnAirlineChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline _Airline; + partial void OnAirlineChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline value); + partial void OnAirlineChanged(); + /// + /// There are no comments for Property From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport From + { + get + { + return this._From; + } + set + { + this.OnFromChanging(value); + this._From = value; + this.OnFromChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _From; + partial void OnFromChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnFromChanged(); + /// + /// There are no comments for Property To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport To + { + get + { + return this._To; + } + set + { + this.OnToChanging(value); + this._To = value; + this.OnToChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _To; + partial void OnToChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnToChanged(); + } + /// + /// There are no comments for EmployeeSingle in the schema. + /// + public partial class EmployeeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Peers + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Peers == null)) + { + this._Peers = Context.CreateQuery(GetPath("Peers")); + } + return this._Peers; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Peers; + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Employee in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + public partial class Employee : Person + { + /// + /// Create a new Employee object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + /// Initial value of Cost. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Employee CreateEmployee(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender, long cost) + { + Employee employee = new Employee(); + employee.UserName = userName; + employee.Gender = gender; + employee.Cost = cost; + return employee; + } + /// + /// There are no comments for Property Cost in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public long Cost + { + get + { + return this._Cost; + } + set + { + this.OnCostChanging(value); + this._Cost = value; + this.OnCostChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private long _Cost; + partial void OnCostChanging(long value); + partial void OnCostChanged(); + /// + /// There are no comments for Property Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Collections.ObjectModel.Collection Peers + { + get + { + return this._Peers; + } + set + { + this.OnPeersChanging(value); + this._Peers = value; + this.OnPeersChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Collections.ObjectModel.Collection _Peers = new global::System.Collections.ObjectModel.Collection(); + partial void OnPeersChanging(global::System.Collections.ObjectModel.Collection value); + partial void OnPeersChanged(); + } + /// + /// There are no comments for PersonGender in the schema. + /// + public enum PersonGender + { + Male = 0, + Female = 1, + Unknow = 2 + } + /// + /// Class containing all extension methods + /// + public static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// The value of airlineCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string airlineCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "AirlineCode", airlineCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// The value of icaoCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string icaoCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "IcaoCode", icaoCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// The value of tripId + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + int tripId) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "TripId", tripId } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle CastToFlight(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle(source.Context, query.GetPath(null)); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle CastToEmployee(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, query.GetPath(null)); + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctions.xml b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctions.xml new file mode 100644 index 0000000..92af564 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctions.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsDSC.cs b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsDSC.cs new file mode 100644 index 0000000..7a3c074 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsDSC.cs @@ -0,0 +1,1423 @@ +//------------------------------------------------------------------------------ +// +// 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/21/2020 11:33:16 AM +namespace Microsoft.OData.Service.Sample.TrippinInMemory.Models +{ + /// + /// There are no comments for Container in the schema. + /// + public partial class Container : global::Microsoft.OData.Client.DataServiceContext + { + /// + /// Initialize a new Container object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public Container(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", "2.4.0")] + protected string ResolveNameFromType(global::System.Type clientType) + { + return clientType.FullName; + } + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery People + { + get + { + if ((this._People == null)) + { + this._People = base.CreateQuery("People"); + } + return this._People; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _People; + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airlines + { + get + { + if ((this._Airlines == null)) + { + this._Airlines = base.CreateQuery("Airlines"); + } + return this._Airlines; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airlines; + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airports + { + get + { + if ((this._Airports == null)) + { + this._Airports = base.CreateQuery("Airports"); + } + return this._Airports; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airports; + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToPeople(Person person) + { + base.AddObject("People", person); + } + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirlines(Airline airline) + { + base.AddObject("Airlines", airline); + } + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirports(Airport airport) + { + base.AddObject("Airports", airport); + } + /// + /// There are no comments for Me in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public PersonSingle Me + { + get + { + if ((this._Me == null)) + { + this._Me = new PersonSingle(this, "Me"); + } + return this._Me; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private PersonSingle _Me; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private abstract class GeneratedEdmModel + { + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private static global::Microsoft.OData.Edm.IEdmModel ParsedModel = LoadModelFromString(); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private const string Edmx = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static global::Microsoft.OData.Edm.IEdmModel GetInstance() + { + return ParsedModel; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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); + } + finally + { + ((global::System.IDisposable)(reader)).Dispose(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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 GetPersonWithMostFriends in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle GetPersonWithMostFriends() + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(this.CreateFunctionQuerySingle("", "GetPersonWithMostFriends", false)); + } + /// + /// There are no comments for GetNearestAirport in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle GetNearestAirport(double lat, double lon) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.CreateFunctionQuerySingle("", "GetNearestAirport", false, new global::Microsoft.OData.Client.UriOperationParameter("lat", lat), + new global::Microsoft.OData.Client.UriOperationParameter("lon", lon))); + } + /// + /// There are no comments for ResetDataSource in the schema. + /// + public global::Microsoft.OData.Client.DataServiceActionQuery ResetDataSource() + { + return new global::Microsoft.OData.Client.DataServiceActionQuery(this, this.BaseUri.OriginalString.Trim('/') + "/ResetDataSource"); + } + } + /// + /// There are no comments for PersonSingle in the schema. + /// + public partial class PersonSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Person in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + public partial class Person : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Person object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Person CreatePerson(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender) + { + Person person = new Person(); + person.UserName = userName; + person.Gender = gender; + return person; + } + /// + /// There are no comments for Property UserName in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string UserName + { + get + { + return this._UserName; + } + set + { + this.OnUserNameChanging(value); + this._UserName = value; + this.OnUserNameChanged(); + this.OnPropertyChanged("UserName"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _UserName; + partial void OnUserNameChanging(string value); + partial void OnUserNameChanged(); + /// + /// There are no comments for Property Gender in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender Gender + { + get + { + return this._Gender; + } + set + { + this.OnGenderChanging(value); + this._Gender = value; + this.OnGenderChanged(); + this.OnPropertyChanged("Gender"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender _Gender; + partial void OnGenderChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender value); + partial void OnGenderChanged(); + /// + /// There are no comments for Property Age in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Nullable Age + { + get + { + return this._Age; + } + set + { + this.OnAgeChanging(value); + this._Age = value; + this.OnAgeChanged(); + this.OnPropertyChanged("Age"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Nullable _Age; + partial void OnAgeChanging(global::System.Nullable value); + partial void OnAgeChanged(); + /// + /// There are no comments for Property HomeAddress in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location HomeAddress + { + get + { + return this._HomeAddress; + } + set + { + this.OnHomeAddressChanging(value); + this._HomeAddress = value; + this.OnHomeAddressChanged(); + this.OnPropertyChanged("HomeAddress"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location _HomeAddress; + partial void OnHomeAddressChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location value); + partial void OnHomeAddressChanged(); + /// + /// There are no comments for Property Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceCollection Friends + { + get + { + return this._Friends; + } + set + { + this.OnFriendsChanging(value); + this._Friends = value; + this.OnFriendsChanged(); + this.OnPropertyChanged("Friends"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceCollection _Friends = new global::Microsoft.OData.Client.DataServiceCollection(null, global::Microsoft.OData.Client.TrackingMode.None); + partial void OnFriendsChanging(global::Microsoft.OData.Client.DataServiceCollection value); + partial void OnFriendsChanged(); + /// + /// There are no comments for Property Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceCollection Trips + { + get + { + return this._Trips; + } + set + { + this.OnTripsChanging(value); + this._Trips = value; + this.OnTripsChanged(); + this.OnPropertyChanged("Trips"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceCollection _Trips = new global::Microsoft.OData.Client.DataServiceCollection(null, global::Microsoft.OData.Client.TrackingMode.None); + partial void OnTripsChanging(global::Microsoft.OData.Client.DataServiceCollection value); + partial void OnTripsChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for AirlineSingle in the schema. + /// + public partial class AirlineSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airline in the schema. + /// + /// + /// AirlineCode + /// + [global::Microsoft.OData.Client.Key("AirlineCode")] + [global::Microsoft.OData.Client.EntitySet("Airlines")] + public partial class Airline : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Airline object. + /// + /// Initial value of AirlineCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airline CreateAirline(string airlineCode) + { + Airline airline = new Airline(); + airline.AirlineCode = airlineCode; + return airline; + } + /// + /// There are no comments for Property AirlineCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string AirlineCode + { + get + { + return this._AirlineCode; + } + set + { + this.OnAirlineCodeChanging(value); + this._AirlineCode = value; + this.OnAirlineCodeChanged(); + this.OnPropertyChanged("AirlineCode"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _AirlineCode; + partial void OnAirlineCodeChanging(string value); + partial void OnAirlineCodeChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for AirportSingle in the schema. + /// + public partial class AirportSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airport in the schema. + /// + /// + /// IcaoCode + /// + [global::Microsoft.OData.Client.Key("IcaoCode")] + [global::Microsoft.OData.Client.EntitySet("Airports")] + public partial class Airport : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Airport object. + /// + /// Initial value of IcaoCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airport CreateAirport(string icaoCode) + { + Airport airport = new Airport(); + airport.IcaoCode = icaoCode; + return airport; + } + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// There are no comments for Property IcaoCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string IcaoCode + { + get + { + return this._IcaoCode; + } + set + { + this.OnIcaoCodeChanging(value); + this._IcaoCode = value; + this.OnIcaoCodeChanged(); + this.OnPropertyChanged("IcaoCode"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _IcaoCode; + partial void OnIcaoCodeChanging(string value); + partial void OnIcaoCodeChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for Location in the schema. + /// + public partial class Location : global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// There are no comments for Property Address in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Address + { + get + { + return this._Address; + } + set + { + this.OnAddressChanging(value); + this._Address = value; + this.OnAddressChanged(); + this.OnPropertyChanged("Address"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Address; + partial void OnAddressChanging(string value); + partial void OnAddressChanged(); + /// + /// There are no comments for Property City in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City City + { + get + { + return this._City; + } + set + { + this.OnCityChanging(value); + this._City = value; + this.OnCityChanged(); + this.OnPropertyChanged("City"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City _City; + partial void OnCityChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City value); + partial void OnCityChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for City in the schema. + /// + public partial class City : global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for TripSingle in the schema. + /// + public partial class TripSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Trip in the schema. + /// + /// + /// TripId + /// + [global::Microsoft.OData.Client.Key("TripId")] + public partial class Trip : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Trip object. + /// + /// Initial value of TripId. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Trip CreateTrip(int tripId) + { + Trip trip = new Trip(); + trip.TripId = tripId; + return trip; + } + /// + /// There are no comments for Property TripId in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public int TripId + { + get + { + return this._TripId; + } + set + { + this.OnTripIdChanging(value); + this._TripId = value; + this.OnTripIdChanged(); + this.OnPropertyChanged("TripId"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private int _TripId; + partial void OnTripIdChanging(int value); + partial void OnTripIdChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for FlightSingle in the schema. + /// + public partial class FlightSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle Airline + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Airline == null)) + { + this._Airline = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(this.Context, GetPath("Airline")); + } + return this._Airline; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle _Airline; + /// + /// There are no comments for From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle From + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._From == null)) + { + this._From = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("From")); + } + return this._From; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _From; + /// + /// There are no comments for To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle To + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._To == null)) + { + this._To = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("To")); + } + return this._To; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _To; + } + /// + /// There are no comments for Flight in the schema. + /// + [global::Microsoft.OData.Client.EntityType()] + public partial class Flight : PublicTransportation + { + /// + /// There are no comments for Property FlightNumber in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string FlightNumber + { + get + { + return this._FlightNumber; + } + set + { + this.OnFlightNumberChanging(value); + this._FlightNumber = value; + this.OnFlightNumberChanged(); + this.OnPropertyChanged("FlightNumber"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _FlightNumber; + partial void OnFlightNumberChanging(string value); + partial void OnFlightNumberChanged(); + /// + /// There are no comments for Property Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline Airline + { + get + { + return this._Airline; + } + set + { + this.OnAirlineChanging(value); + this._Airline = value; + this.OnAirlineChanged(); + this.OnPropertyChanged("Airline"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline _Airline; + partial void OnAirlineChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline value); + partial void OnAirlineChanged(); + /// + /// There are no comments for Property From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport From + { + get + { + return this._From; + } + set + { + this.OnFromChanging(value); + this._From = value; + this.OnFromChanged(); + this.OnPropertyChanged("From"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _From; + partial void OnFromChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnFromChanged(); + /// + /// There are no comments for Property To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport To + { + get + { + return this._To; + } + set + { + this.OnToChanging(value); + this._To = value; + this.OnToChanged(); + this.OnPropertyChanged("To"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _To; + partial void OnToChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnToChanged(); + } + /// + /// There are no comments for EmployeeSingle in the schema. + /// + public partial class EmployeeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Peers + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Peers == null)) + { + this._Peers = Context.CreateQuery(GetPath("Peers")); + } + return this._Peers; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Peers; + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Employee in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + public partial class Employee : Person + { + /// + /// Create a new Employee object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + /// Initial value of Cost. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Employee CreateEmployee(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender, long cost) + { + Employee employee = new Employee(); + employee.UserName = userName; + employee.Gender = gender; + employee.Cost = cost; + return employee; + } + /// + /// There are no comments for Property Cost in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public long Cost + { + get + { + return this._Cost; + } + set + { + this.OnCostChanging(value); + this._Cost = value; + this.OnCostChanged(); + this.OnPropertyChanged("Cost"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private long _Cost; + partial void OnCostChanging(long value); + partial void OnCostChanged(); + /// + /// There are no comments for Property Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceCollection Peers + { + get + { + return this._Peers; + } + set + { + this.OnPeersChanging(value); + this._Peers = value; + this.OnPeersChanged(); + this.OnPropertyChanged("Peers"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceCollection _Peers = new global::Microsoft.OData.Client.DataServiceCollection(null, global::Microsoft.OData.Client.TrackingMode.None); + partial void OnPeersChanging(global::Microsoft.OData.Client.DataServiceCollection value); + partial void OnPeersChanged(); + } + /// + /// There are no comments for PersonGender in the schema. + /// + public enum PersonGender + { + Male = 0, + Female = 1, + Unknow = 2 + } + /// + /// Class containing all extension methods + /// + public static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// The value of airlineCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string airlineCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "AirlineCode", airlineCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// The value of icaoCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string icaoCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "IcaoCode", icaoCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// The value of tripId + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + int tripId) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "TripId", tripId } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle CastToFlight(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle(source.Context, query.GetPath(null)); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle CastToEmployee(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, query.GetPath(null)); + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsDSCWithInternalTypes.cs b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsDSCWithInternalTypes.cs new file mode 100644 index 0000000..d4ad726 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsDSCWithInternalTypes.cs @@ -0,0 +1,1423 @@ +//------------------------------------------------------------------------------ +// +// 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/21/2020 11:33:16 AM +namespace Microsoft.OData.Service.Sample.TrippinInMemory.Models +{ + /// + /// There are no comments for Container in the schema. + /// + internal partial class Container : global::Microsoft.OData.Client.DataServiceContext + { + /// + /// Initialize a new Container object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public Container(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", "2.4.0")] + protected string ResolveNameFromType(global::System.Type clientType) + { + return clientType.FullName; + } + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery People + { + get + { + if ((this._People == null)) + { + this._People = base.CreateQuery("People"); + } + return this._People; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _People; + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airlines + { + get + { + if ((this._Airlines == null)) + { + this._Airlines = base.CreateQuery("Airlines"); + } + return this._Airlines; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airlines; + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airports + { + get + { + if ((this._Airports == null)) + { + this._Airports = base.CreateQuery("Airports"); + } + return this._Airports; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airports; + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToPeople(Person person) + { + base.AddObject("People", person); + } + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirlines(Airline airline) + { + base.AddObject("Airlines", airline); + } + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirports(Airport airport) + { + base.AddObject("Airports", airport); + } + /// + /// There are no comments for Me in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public PersonSingle Me + { + get + { + if ((this._Me == null)) + { + this._Me = new PersonSingle(this, "Me"); + } + return this._Me; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private PersonSingle _Me; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private abstract class GeneratedEdmModel + { + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private static global::Microsoft.OData.Edm.IEdmModel ParsedModel = LoadModelFromString(); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private const string Edmx = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static global::Microsoft.OData.Edm.IEdmModel GetInstance() + { + return ParsedModel; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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); + } + finally + { + ((global::System.IDisposable)(reader)).Dispose(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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 GetPersonWithMostFriends in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle GetPersonWithMostFriends() + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(this.CreateFunctionQuerySingle("", "GetPersonWithMostFriends", false)); + } + /// + /// There are no comments for GetNearestAirport in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle GetNearestAirport(double lat, double lon) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.CreateFunctionQuerySingle("", "GetNearestAirport", false, new global::Microsoft.OData.Client.UriOperationParameter("lat", lat), + new global::Microsoft.OData.Client.UriOperationParameter("lon", lon))); + } + /// + /// There are no comments for ResetDataSource in the schema. + /// + public global::Microsoft.OData.Client.DataServiceActionQuery ResetDataSource() + { + return new global::Microsoft.OData.Client.DataServiceActionQuery(this, this.BaseUri.OriginalString.Trim('/') + "/ResetDataSource"); + } + } + /// + /// There are no comments for PersonSingle in the schema. + /// + internal partial class PersonSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Person in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + internal partial class Person : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Person object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Person CreatePerson(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender) + { + Person person = new Person(); + person.UserName = userName; + person.Gender = gender; + return person; + } + /// + /// There are no comments for Property UserName in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string UserName + { + get + { + return this._UserName; + } + set + { + this.OnUserNameChanging(value); + this._UserName = value; + this.OnUserNameChanged(); + this.OnPropertyChanged("UserName"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _UserName; + partial void OnUserNameChanging(string value); + partial void OnUserNameChanged(); + /// + /// There are no comments for Property Gender in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender Gender + { + get + { + return this._Gender; + } + set + { + this.OnGenderChanging(value); + this._Gender = value; + this.OnGenderChanged(); + this.OnPropertyChanged("Gender"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender _Gender; + partial void OnGenderChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender value); + partial void OnGenderChanged(); + /// + /// There are no comments for Property Age in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Nullable Age + { + get + { + return this._Age; + } + set + { + this.OnAgeChanging(value); + this._Age = value; + this.OnAgeChanged(); + this.OnPropertyChanged("Age"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Nullable _Age; + partial void OnAgeChanging(global::System.Nullable value); + partial void OnAgeChanged(); + /// + /// There are no comments for Property HomeAddress in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location HomeAddress + { + get + { + return this._HomeAddress; + } + set + { + this.OnHomeAddressChanging(value); + this._HomeAddress = value; + this.OnHomeAddressChanged(); + this.OnPropertyChanged("HomeAddress"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location _HomeAddress; + partial void OnHomeAddressChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location value); + partial void OnHomeAddressChanged(); + /// + /// There are no comments for Property Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceCollection Friends + { + get + { + return this._Friends; + } + set + { + this.OnFriendsChanging(value); + this._Friends = value; + this.OnFriendsChanged(); + this.OnPropertyChanged("Friends"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceCollection _Friends = new global::Microsoft.OData.Client.DataServiceCollection(null, global::Microsoft.OData.Client.TrackingMode.None); + partial void OnFriendsChanging(global::Microsoft.OData.Client.DataServiceCollection value); + partial void OnFriendsChanged(); + /// + /// There are no comments for Property Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceCollection Trips + { + get + { + return this._Trips; + } + set + { + this.OnTripsChanging(value); + this._Trips = value; + this.OnTripsChanged(); + this.OnPropertyChanged("Trips"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceCollection _Trips = new global::Microsoft.OData.Client.DataServiceCollection(null, global::Microsoft.OData.Client.TrackingMode.None); + partial void OnTripsChanging(global::Microsoft.OData.Client.DataServiceCollection value); + partial void OnTripsChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for AirlineSingle in the schema. + /// + internal partial class AirlineSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airline in the schema. + /// + /// + /// AirlineCode + /// + [global::Microsoft.OData.Client.Key("AirlineCode")] + [global::Microsoft.OData.Client.EntitySet("Airlines")] + internal partial class Airline : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Airline object. + /// + /// Initial value of AirlineCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airline CreateAirline(string airlineCode) + { + Airline airline = new Airline(); + airline.AirlineCode = airlineCode; + return airline; + } + /// + /// There are no comments for Property AirlineCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string AirlineCode + { + get + { + return this._AirlineCode; + } + set + { + this.OnAirlineCodeChanging(value); + this._AirlineCode = value; + this.OnAirlineCodeChanged(); + this.OnPropertyChanged("AirlineCode"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _AirlineCode; + partial void OnAirlineCodeChanging(string value); + partial void OnAirlineCodeChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for AirportSingle in the schema. + /// + internal partial class AirportSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airport in the schema. + /// + /// + /// IcaoCode + /// + [global::Microsoft.OData.Client.Key("IcaoCode")] + [global::Microsoft.OData.Client.EntitySet("Airports")] + internal partial class Airport : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Airport object. + /// + /// Initial value of IcaoCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airport CreateAirport(string icaoCode) + { + Airport airport = new Airport(); + airport.IcaoCode = icaoCode; + return airport; + } + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// There are no comments for Property IcaoCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string IcaoCode + { + get + { + return this._IcaoCode; + } + set + { + this.OnIcaoCodeChanging(value); + this._IcaoCode = value; + this.OnIcaoCodeChanged(); + this.OnPropertyChanged("IcaoCode"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _IcaoCode; + partial void OnIcaoCodeChanging(string value); + partial void OnIcaoCodeChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for Location in the schema. + /// + internal partial class Location : global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// There are no comments for Property Address in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Address + { + get + { + return this._Address; + } + set + { + this.OnAddressChanging(value); + this._Address = value; + this.OnAddressChanged(); + this.OnPropertyChanged("Address"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Address; + partial void OnAddressChanging(string value); + partial void OnAddressChanged(); + /// + /// There are no comments for Property City in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City City + { + get + { + return this._City; + } + set + { + this.OnCityChanging(value); + this._City = value; + this.OnCityChanged(); + this.OnPropertyChanged("City"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City _City; + partial void OnCityChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City value); + partial void OnCityChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for City in the schema. + /// + internal partial class City : global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for TripSingle in the schema. + /// + internal partial class TripSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Trip in the schema. + /// + /// + /// TripId + /// + [global::Microsoft.OData.Client.Key("TripId")] + internal partial class Trip : global::Microsoft.OData.Client.BaseEntityType, global::System.ComponentModel.INotifyPropertyChanged + { + /// + /// Create a new Trip object. + /// + /// Initial value of TripId. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Trip CreateTrip(int tripId) + { + Trip trip = new Trip(); + trip.TripId = tripId; + return trip; + } + /// + /// There are no comments for Property TripId in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public int TripId + { + get + { + return this._TripId; + } + set + { + this.OnTripIdChanging(value); + this._TripId = value; + this.OnTripIdChanged(); + this.OnPropertyChanged("TripId"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private int _TripId; + partial void OnTripIdChanging(int value); + partial void OnTripIdChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + this.OnPropertyChanged("Name"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// This event is raised when the value of the property is changed + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + /// + /// The value of the property is changed + /// + /// property name + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + protected virtual void OnPropertyChanged(string property) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); + } + } + } + /// + /// There are no comments for FlightSingle in the schema. + /// + internal partial class FlightSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle Airline + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Airline == null)) + { + this._Airline = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(this.Context, GetPath("Airline")); + } + return this._Airline; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle _Airline; + /// + /// There are no comments for From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle From + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._From == null)) + { + this._From = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("From")); + } + return this._From; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _From; + /// + /// There are no comments for To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle To + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._To == null)) + { + this._To = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("To")); + } + return this._To; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _To; + } + /// + /// There are no comments for Flight in the schema. + /// + [global::Microsoft.OData.Client.EntityType()] + internal partial class Flight : PublicTransportation + { + /// + /// There are no comments for Property FlightNumber in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string FlightNumber + { + get + { + return this._FlightNumber; + } + set + { + this.OnFlightNumberChanging(value); + this._FlightNumber = value; + this.OnFlightNumberChanged(); + this.OnPropertyChanged("FlightNumber"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _FlightNumber; + partial void OnFlightNumberChanging(string value); + partial void OnFlightNumberChanged(); + /// + /// There are no comments for Property Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline Airline + { + get + { + return this._Airline; + } + set + { + this.OnAirlineChanging(value); + this._Airline = value; + this.OnAirlineChanged(); + this.OnPropertyChanged("Airline"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline _Airline; + partial void OnAirlineChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline value); + partial void OnAirlineChanged(); + /// + /// There are no comments for Property From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport From + { + get + { + return this._From; + } + set + { + this.OnFromChanging(value); + this._From = value; + this.OnFromChanged(); + this.OnPropertyChanged("From"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _From; + partial void OnFromChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnFromChanged(); + /// + /// There are no comments for Property To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport To + { + get + { + return this._To; + } + set + { + this.OnToChanging(value); + this._To = value; + this.OnToChanged(); + this.OnPropertyChanged("To"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _To; + partial void OnToChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnToChanged(); + } + /// + /// There are no comments for EmployeeSingle in the schema. + /// + internal partial class EmployeeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Peers + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Peers == null)) + { + this._Peers = Context.CreateQuery(GetPath("Peers")); + } + return this._Peers; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Peers; + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Employee in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + internal partial class Employee : Person + { + /// + /// Create a new Employee object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + /// Initial value of Cost. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Employee CreateEmployee(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender, long cost) + { + Employee employee = new Employee(); + employee.UserName = userName; + employee.Gender = gender; + employee.Cost = cost; + return employee; + } + /// + /// There are no comments for Property Cost in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public long Cost + { + get + { + return this._Cost; + } + set + { + this.OnCostChanging(value); + this._Cost = value; + this.OnCostChanged(); + this.OnPropertyChanged("Cost"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private long _Cost; + partial void OnCostChanging(long value); + partial void OnCostChanged(); + /// + /// There are no comments for Property Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceCollection Peers + { + get + { + return this._Peers; + } + set + { + this.OnPeersChanging(value); + this._Peers = value; + this.OnPeersChanged(); + this.OnPropertyChanged("Peers"); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceCollection _Peers = new global::Microsoft.OData.Client.DataServiceCollection(null, global::Microsoft.OData.Client.TrackingMode.None); + partial void OnPeersChanging(global::Microsoft.OData.Client.DataServiceCollection value); + partial void OnPeersChanged(); + } + /// + /// There are no comments for PersonGender in the schema. + /// + internal enum PersonGender + { + Male = 0, + Female = 1, + Unknow = 2 + } + /// + /// Class containing all extension methods + /// + internal static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// The value of airlineCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string airlineCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "AirlineCode", airlineCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// The value of icaoCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string icaoCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "IcaoCode", icaoCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// The value of tripId + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + int tripId) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "TripId", tripId } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle CastToFlight(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle(source.Context, query.GetPath(null)); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle CastToEmployee(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, query.GetPath(null)); + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsWithInternalTypes.cs b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsWithInternalTypes.cs new file mode 100644 index 0000000..c94db59 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/EntitiesEnumsFunctionsWithInternalTypes.cs @@ -0,0 +1,1298 @@ +//------------------------------------------------------------------------------ +// +// 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/21/2020 11:02:50 AM +namespace Microsoft.OData.Service.Sample.TrippinInMemory.Models +{ + /// + /// There are no comments for Container in the schema. + /// + internal partial class Container : global::Microsoft.OData.Client.DataServiceContext + { + /// + /// Initialize a new Container object. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public Container(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", "2.4.0")] + protected string ResolveNameFromType(global::System.Type clientType) + { + return clientType.FullName; + } + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery People + { + get + { + if ((this._People == null)) + { + this._People = base.CreateQuery("People"); + } + return this._People; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _People; + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airlines + { + get + { + if ((this._Airlines == null)) + { + this._Airlines = base.CreateQuery("Airlines"); + } + return this._Airlines; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airlines; + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Airports + { + get + { + if ((this._Airports == null)) + { + this._Airports = base.CreateQuery("Airports"); + } + return this._Airports; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Airports; + /// + /// There are no comments for People in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToPeople(Person person) + { + base.AddObject("People", person); + } + /// + /// There are no comments for Airlines in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirlines(Airline airline) + { + base.AddObject("Airlines", airline); + } + /// + /// There are no comments for Airports in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public void AddToAirports(Airport airport) + { + base.AddObject("Airports", airport); + } + /// + /// There are no comments for Me in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public PersonSingle Me + { + get + { + if ((this._Me == null)) + { + this._Me = new PersonSingle(this, "Me"); + } + return this._Me; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private PersonSingle _Me; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private abstract class GeneratedEdmModel + { + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private static global::Microsoft.OData.Edm.IEdmModel ParsedModel = LoadModelFromString(); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private const string Edmx = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static global::Microsoft.OData.Edm.IEdmModel GetInstance() + { + return ParsedModel; + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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); + } + finally + { + ((global::System.IDisposable)(reader)).Dispose(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + 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 GetPersonWithMostFriends in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle GetPersonWithMostFriends() + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(this.CreateFunctionQuerySingle("", "GetPersonWithMostFriends", false)); + } + /// + /// There are no comments for GetNearestAirport in the schema. + /// + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle GetNearestAirport(double lat, double lon) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.CreateFunctionQuerySingle("", "GetNearestAirport", false, new global::Microsoft.OData.Client.UriOperationParameter("lat", lat), + new global::Microsoft.OData.Client.UriOperationParameter("lon", lon))); + } + /// + /// There are no comments for ResetDataSource in the schema. + /// + public global::Microsoft.OData.Client.DataServiceActionQuery ResetDataSource() + { + return new global::Microsoft.OData.Client.DataServiceActionQuery(this, this.BaseUri.OriginalString.Trim('/') + "/ResetDataSource"); + } + } + /// + /// There are no comments for PersonSingle in the schema. + /// + internal partial class PersonSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Person in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + internal partial class Person : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Person object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Person CreatePerson(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender) + { + Person person = new Person(); + person.UserName = userName; + person.Gender = gender; + return person; + } + /// + /// There are no comments for Property UserName in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string UserName + { + get + { + return this._UserName; + } + set + { + this.OnUserNameChanging(value); + this._UserName = value; + this.OnUserNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _UserName; + partial void OnUserNameChanging(string value); + partial void OnUserNameChanged(); + /// + /// There are no comments for Property Gender in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender Gender + { + get + { + return this._Gender; + } + set + { + this.OnGenderChanging(value); + this._Gender = value; + this.OnGenderChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender _Gender; + partial void OnGenderChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender value); + partial void OnGenderChanged(); + /// + /// There are no comments for Property Age in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Nullable Age + { + get + { + return this._Age; + } + set + { + this.OnAgeChanging(value); + this._Age = value; + this.OnAgeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Nullable _Age; + partial void OnAgeChanging(global::System.Nullable value); + partial void OnAgeChanged(); + /// + /// There are no comments for Property HomeAddress in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location HomeAddress + { + get + { + return this._HomeAddress; + } + set + { + this.OnHomeAddressChanging(value); + this._HomeAddress = value; + this.OnHomeAddressChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location _HomeAddress; + partial void OnHomeAddressChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location value); + partial void OnHomeAddressChanged(); + /// + /// There are no comments for Property Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Collections.ObjectModel.Collection Friends + { + get + { + return this._Friends; + } + set + { + this.OnFriendsChanging(value); + this._Friends = value; + this.OnFriendsChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Collections.ObjectModel.Collection _Friends = new global::System.Collections.ObjectModel.Collection(); + partial void OnFriendsChanging(global::System.Collections.ObjectModel.Collection value); + partial void OnFriendsChanged(); + /// + /// There are no comments for Property Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Collections.ObjectModel.Collection Trips + { + get + { + return this._Trips; + } + set + { + this.OnTripsChanging(value); + this._Trips = value; + this.OnTripsChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Collections.ObjectModel.Collection _Trips = new global::System.Collections.ObjectModel.Collection(); + partial void OnTripsChanging(global::System.Collections.ObjectModel.Collection value); + partial void OnTripsChanged(); + } + /// + /// There are no comments for AirlineSingle in the schema. + /// + internal partial class AirlineSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirlineSingle object. + /// + public AirlineSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airline in the schema. + /// + /// + /// AirlineCode + /// + [global::Microsoft.OData.Client.Key("AirlineCode")] + internal partial class Airline : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Airline object. + /// + /// Initial value of AirlineCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airline CreateAirline(string airlineCode) + { + Airline airline = new Airline(); + airline.AirlineCode = airlineCode; + return airline; + } + /// + /// There are no comments for Property AirlineCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string AirlineCode + { + get + { + return this._AirlineCode; + } + set + { + this.OnAirlineCodeChanging(value); + this._AirlineCode = value; + this.OnAirlineCodeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _AirlineCode; + partial void OnAirlineCodeChanging(string value); + partial void OnAirlineCodeChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + } + /// + /// There are no comments for AirportSingle in the schema. + /// + internal partial class AirportSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new AirportSingle object. + /// + public AirportSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Airport in the schema. + /// + /// + /// IcaoCode + /// + [global::Microsoft.OData.Client.Key("IcaoCode")] + internal partial class Airport : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Airport object. + /// + /// Initial value of IcaoCode. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Airport CreateAirport(string icaoCode) + { + Airport airport = new Airport(); + airport.IcaoCode = icaoCode; + return airport; + } + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + /// + /// There are no comments for Property IcaoCode in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string IcaoCode + { + get + { + return this._IcaoCode; + } + set + { + this.OnIcaoCodeChanging(value); + this._IcaoCode = value; + this.OnIcaoCodeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _IcaoCode; + partial void OnIcaoCodeChanging(string value); + partial void OnIcaoCodeChanged(); + } + /// + /// There are no comments for Location in the schema. + /// + internal partial class Location + { + /// + /// There are no comments for Property Address in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Address + { + get + { + return this._Address; + } + set + { + this.OnAddressChanging(value); + this._Address = value; + this.OnAddressChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Address; + partial void OnAddressChanging(string value); + partial void OnAddressChanged(); + /// + /// There are no comments for Property City in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City City + { + get + { + return this._City; + } + set + { + this.OnCityChanging(value); + this._City = value; + this.OnCityChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City _City; + partial void OnCityChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.City value); + partial void OnCityChanged(); + } + /// + /// There are no comments for City in the schema. + /// + internal partial class City + { + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + } + /// + /// There are no comments for TripSingle in the schema. + /// + internal partial class TripSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new TripSingle object. + /// + public TripSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Trip in the schema. + /// + /// + /// TripId + /// + [global::Microsoft.OData.Client.Key("TripId")] + internal partial class Trip : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Trip object. + /// + /// Initial value of TripId. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Trip CreateTrip(int tripId) + { + Trip trip = new Trip(); + trip.TripId = tripId; + return trip; + } + /// + /// There are no comments for Property TripId in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public int TripId + { + get + { + return this._TripId; + } + set + { + this.OnTripIdChanging(value); + this._TripId = value; + this.OnTripIdChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private int _TripId; + partial void OnTripIdChanging(int value); + partial void OnTripIdChanged(); + /// + /// There are no comments for Property Name in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string Name + { + get + { + return this._Name; + } + set + { + this.OnNameChanging(value); + this._Name = value; + this.OnNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _Name; + partial void OnNameChanging(string value); + partial void OnNameChanged(); + } + /// + /// There are no comments for FlightSingle in the schema. + /// + internal partial class FlightSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new FlightSingle object. + /// + public FlightSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle Airline + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Airline == null)) + { + this._Airline = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(this.Context, GetPath("Airline")); + } + return this._Airline; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle _Airline; + /// + /// There are no comments for From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle From + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._From == null)) + { + this._From = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("From")); + } + return this._From; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _From; + /// + /// There are no comments for To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle To + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._To == null)) + { + this._To = new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(this.Context, GetPath("To")); + } + return this._To; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle _To; + } + /// + /// There are no comments for Flight in the schema. + /// + [global::Microsoft.OData.Client.EntityType()] + internal partial class Flight : PublicTransportation + { + /// + /// There are no comments for Property FlightNumber in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string FlightNumber + { + get + { + return this._FlightNumber; + } + set + { + this.OnFlightNumberChanging(value); + this._FlightNumber = value; + this.OnFlightNumberChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _FlightNumber; + partial void OnFlightNumberChanging(string value); + partial void OnFlightNumberChanged(); + /// + /// There are no comments for Property Airline in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline Airline + { + get + { + return this._Airline; + } + set + { + this.OnAirlineChanging(value); + this._Airline = value; + this.OnAirlineChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline _Airline; + partial void OnAirlineChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline value); + partial void OnAirlineChanged(); + /// + /// There are no comments for Property From in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport From + { + get + { + return this._From; + } + set + { + this.OnFromChanging(value); + this._From = value; + this.OnFromChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _From; + partial void OnFromChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnFromChanged(); + /// + /// There are no comments for Property To in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport To + { + get + { + return this._To; + } + set + { + this.OnToChanging(value); + this._To = value; + this.OnToChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport _To; + partial void OnToChanging(global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport value); + partial void OnToChanged(); + } + /// + /// There are no comments for EmployeeSingle in the schema. + /// + internal partial class EmployeeSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new EmployeeSingle object. + /// + public EmployeeSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + /// + /// There are no comments for Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Peers + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Peers == null)) + { + this._Peers = Context.CreateQuery(GetPath("Peers")); + } + return this._Peers; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Peers; + /// + /// There are no comments for Friends in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Friends + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Friends == null)) + { + this._Friends = Context.CreateQuery(GetPath("Friends")); + } + return this._Friends; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Friends; + /// + /// There are no comments for Trips in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::Microsoft.OData.Client.DataServiceQuery Trips + { + get + { + if (!this.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + if ((this._Trips == null)) + { + this._Trips = Context.CreateQuery(GetPath("Trips")); + } + return this._Trips; + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::Microsoft.OData.Client.DataServiceQuery _Trips; + } + /// + /// There are no comments for Employee in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + internal partial class Employee : Person + { + /// + /// Create a new Employee object. + /// + /// Initial value of UserName. + /// Initial value of Gender. + /// Initial value of Cost. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Employee CreateEmployee(string userName, global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender gender, long cost) + { + Employee employee = new Employee(); + employee.UserName = userName; + employee.Gender = gender; + employee.Cost = cost; + return employee; + } + /// + /// There are no comments for Property Cost in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public long Cost + { + get + { + return this._Cost; + } + set + { + this.OnCostChanging(value); + this._Cost = value; + this.OnCostChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private long _Cost; + partial void OnCostChanging(long value); + partial void OnCostChanged(); + /// + /// There are no comments for Property Peers in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Collections.ObjectModel.Collection Peers + { + get + { + return this._Peers; + } + set + { + this.OnPeersChanging(value); + this._Peers = value; + this.OnPeersChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Collections.ObjectModel.Collection _Peers = new global::System.Collections.ObjectModel.Collection(); + partial void OnPeersChanging(global::System.Collections.ObjectModel.Collection value); + partial void OnPeersChanged(); + } + /// + /// There are no comments for PersonGender in the schema. + /// + internal enum PersonGender + { + Male = 0, + Female = 1, + Unknow = 2 + } + /// + /// Class containing all extension methods + /// + internal static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle specified by key from an entity set + /// + /// source entity set + /// The value of airlineCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string airlineCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "AirlineCode", airlineCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirlineSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle specified by key from an entity set + /// + /// source entity set + /// The value of icaoCode + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string icaoCode) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "IcaoCode", icaoCode } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle specified by key from an entity set + /// + /// source entity set + /// The value of tripId + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + int tripId) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "TripId", tripId } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.TripSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle CastToFlight(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.FlightSingle(source.Context, query.GetPath(null)); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee as global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Cast an entity of type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person to its derived type global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee + /// + /// source entity + public static global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle CastToEmployee(this global::Microsoft.OData.Client.DataServiceQuerySingle source) + { + global::Microsoft.OData.Client.DataServiceQuerySingle query = source.CastTo(); + return new global::Microsoft.OData.Service.Sample.TrippinInMemory.Models.EmployeeSingle(source.Context, query.GetPath(null)); + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/TypeDefinitions.xml b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/TypeDefinitions.xml new file mode 100644 index 0000000..090aaf1 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/TypeDefinitions.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/TypeDefinitionsParamsConvertedToUnderlyingType.cs b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/TypeDefinitionsParamsConvertedToUnderlyingType.cs new file mode 100644 index 0000000..4662561 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGenReferences/TypeDefinitionsParamsConvertedToUnderlyingType.cs @@ -0,0 +1,254 @@ +//------------------------------------------------------------------------------ +// +// 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/28/2020 3:05:18 PM +namespace Microsoft.OData.TestService +{ + /// + /// There are no comments for PersonSingle in the schema. + /// + public partial class PersonSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new PersonSingle object. + /// + public PersonSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Person in the schema. + /// + /// + /// UserName + /// + [global::Microsoft.OData.Client.Key("UserName")] + public partial class Person : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// Create a new Person object. + /// + /// Initial value of UserName. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public static Person CreatePerson(string userName) + { + Person person = new Person(); + person.UserName = userName; + return person; + } + /// + /// There are no comments for Property UserName in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string UserName + { + get + { + return this._UserName; + } + set + { + this.OnUserNameChanging(value); + this._UserName = value; + this.OnUserNameChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _UserName; + partial void OnUserNameChanging(string value); + partial void OnUserNameChanged(); + /// + /// There are no comments for Property WakeUpTime in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Nullable WakeUpTime + { + get + { + return this._WakeUpTime; + } + set + { + this.OnWakeUpTimeChanging(value); + this._WakeUpTime = value; + this.OnWakeUpTimeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Nullable _WakeUpTime; + partial void OnWakeUpTimeChanging(global::System.Nullable value); + partial void OnWakeUpTimeChanged(); + /// + /// There are no comments for ReminderView in the schema. + /// + public global::Microsoft.OData.Client.DataServiceQuery ReminderView(string StartDateTime, string EndDateTime, global::System.Nullable MaxCount) + { + global::System.Uri requestUri; + Context.TryGetUri(this, out requestUri); + return this.Context.CreateFunctionQuery(string.Join("/", global::System.Linq.Enumerable.Select(global::System.Linq.Enumerable.Skip(requestUri.Segments, this.Context.BaseUri.Segments.Length), s => s.Trim('/'))), "Microsoft.OData.TestService.ReminderView", false, new global::Microsoft.OData.Client.UriOperationParameter("StartDateTime", StartDateTime), + new global::Microsoft.OData.Client.UriOperationParameter("EndDateTime", EndDateTime), + new global::Microsoft.OData.Client.UriOperationParameter("MaxCount", MaxCount)); + } + } + /// + /// There are no comments for ReminderSingle in the schema. + /// + public partial class ReminderSingle : global::Microsoft.OData.Client.DataServiceQuerySingle + { + /// + /// Initialize a new ReminderSingle object. + /// + public ReminderSingle(global::Microsoft.OData.Client.DataServiceContext context, string path) + : base(context, path) { } + + /// + /// Initialize a new ReminderSingle object. + /// + public ReminderSingle(global::Microsoft.OData.Client.DataServiceContext context, string path, bool isComposable) + : base(context, path, isComposable) { } + + /// + /// Initialize a new ReminderSingle object. + /// + public ReminderSingle(global::Microsoft.OData.Client.DataServiceQuerySingle query) + : base(query) { } + + } + /// + /// There are no comments for Reminder in the schema. + /// + /// + /// Id + /// + [global::Microsoft.OData.Client.Key("Id")] + public partial class Reminder : global::Microsoft.OData.Client.BaseEntityType + { + /// + /// There are no comments for Property Id in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public global::System.Nullable Id + { + get + { + return this._Id; + } + set + { + this.OnIdChanging(value); + this._Id = value; + this.OnIdChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private global::System.Nullable _Id; + partial void OnIdChanging(global::System.Nullable value); + partial void OnIdChanged(); + /// + /// There are no comments for Property ReminderTime in the schema. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + public string ReminderTime + { + get + { + return this._ReminderTime; + } + set + { + this.OnReminderTimeChanging(value); + this._ReminderTime = value; + this.OnReminderTimeChanged(); + } + } + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.4.0")] + private string _ReminderTime; + partial void OnReminderTimeChanging(string value); + partial void OnReminderTimeChanged(); + } + /// + /// Class containing all extension methods + /// + public static class ExtensionMethods + { + /// + /// Get an entity of type global::Microsoft.OData.TestService.Person as global::Microsoft.OData.TestService.PersonSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.TestService.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.TestService.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.TestService.Person as global::Microsoft.OData.TestService.PersonSingle specified by key from an entity set + /// + /// source entity set + /// The value of userName + public static global::Microsoft.OData.TestService.PersonSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + string userName) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "UserName", userName } + }; + return new global::Microsoft.OData.TestService.PersonSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.TestService.Reminder as global::Microsoft.OData.TestService.ReminderSingle specified by key from an entity set + /// + /// source entity set + /// dictionary with the names and values of keys + public static global::Microsoft.OData.TestService.ReminderSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, global::System.Collections.Generic.Dictionary keys) + { + return new global::Microsoft.OData.TestService.ReminderSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// Get an entity of type global::Microsoft.OData.TestService.Reminder as global::Microsoft.OData.TestService.ReminderSingle specified by key from an entity set + /// + /// source entity set + /// The value of id + public static global::Microsoft.OData.TestService.ReminderSingle ByKey(this global::Microsoft.OData.Client.DataServiceQuery source, + global::System.Nullable id) + { + global::System.Collections.Generic.Dictionary keys = new global::System.Collections.Generic.Dictionary + { + { "Id", id } + }; + return new global::Microsoft.OData.TestService.ReminderSingle(source.Context, source.GetKeyPath(global::Microsoft.OData.Client.Serializer.GetKeyString(source.Context, keys))); + } + /// + /// There are no comments for ReminderView in the schema. + /// + public static global::Microsoft.OData.Client.DataServiceQuery ReminderView(this global::Microsoft.OData.Client.DataServiceQuerySingle source, string StartDateTime, string EndDateTime, global::System.Nullable MaxCount) + { + if (!source.IsComposable) + { + throw new global::System.NotSupportedException("The previous function is not composable."); + } + + return source.CreateFunctionQuery("Microsoft.OData.TestService.ReminderView", false, new global::Microsoft.OData.Client.UriOperationParameter("StartDateTime", StartDateTime), + new global::Microsoft.OData.Client.UriOperationParameter("EndDateTime", EndDateTime), + new global::Microsoft.OData.Client.UriOperationParameter("MaxCount", MaxCount)); + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/CodeGeneration/V4CodeGenDescriptorTest.cs b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGeneration/V4CodeGenDescriptorTest.cs new file mode 100644 index 0000000..493b76b --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/CodeGeneration/V4CodeGenDescriptorTest.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.IO; +using Microsoft.VisualStudio.ConnectedServices; +using EnvDTE; +using Moq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.OData.ConnectedService.CodeGeneration; +using Microsoft.OData.ConnectedService.Models; +using Microsoft.OData.ConnectedService.Templates; +using Microsoft.OData.ConnectedService.Tests.TestHelpers; + +namespace Microsoft.OData.ConnectedService.Tests.CodeGeneration +{ + [TestClass] + public class V4CodeGenDescriptorTest + { + readonly static string TestProjectRootPath = Path.Combine(Directory.GetCurrentDirectory(), "TempODataConnectedServiceTest"); + readonly static string ServicesRootFolder = "ConnectedServicesRoot"; + readonly static string MetadataUri = "http://service/$metadata"; + + [TestCleanup] + public void CleanUp() + { + try + { + Directory.Delete(TestProjectRootPath, true); + } + catch (DirectoryNotFoundException) { } + } + + [DataTestMethod] + [DataRow(true, true, true, "Prefix", true)] + [DataRow(false, false, false, null, false)] + public void TestAddGeneratedClientCode_PassesServiceConfigOptionsToCodeGenerator( + bool useDSC, bool ignoreUnexpected, bool enableNamingAlias, + string namespacePrefix, bool makeTypesInternal) + { + var handlerHelper = new TestConnectedServiceHandlerHelper(); + var codeGenFactory = new TestODataT4CodeGeneratorFactory(); + + var serviceConfig = new ServiceConfigurationV4() + { + UseDataServiceCollection = useDSC, + IgnoreUnexpectedElementsAndAttributes = ignoreUnexpected, + EnableNamingAlias = enableNamingAlias, + NamespacePrefix = namespacePrefix, + MakeTypesInternal = makeTypesInternal, + IncludeT4File = false + }; + var codeGenDescriptor = SetupCodeGenDescriptor(serviceConfig, "TestService", codeGenFactory, handlerHelper); + codeGenDescriptor.AddGeneratedClientCode().Wait(); + + var generator = codeGenFactory.LastCreatedInstance; + Assert.AreEqual(useDSC, generator.UseDataServiceCollection); + Assert.AreEqual(enableNamingAlias, generator.EnableNamingAlias); + Assert.AreEqual(ignoreUnexpected, generator.IgnoreUnexpectedElementsAndAttributes); + Assert.AreEqual(makeTypesInternal, generator.MakeTypesInternal); + Assert.AreEqual(namespacePrefix, generator.NamespacePrefix); + Assert.AreEqual(MetadataUri, generator.MetadataDocumentUri); + Assert.AreEqual(ODataT4CodeGenerator.LanguageOption.CSharp, generator.TargetLanguage); + } + + [TestMethod] + public void TestAddGeneratedClientCode_GeneratesAndSavesCodeFile() + { + var serviceName = "MyService"; + ServiceConfiguration serviceConfig = new ServiceConfigurationV4() + { + MakeTypesInternal = true, + UseDataServiceCollection = false, + ServiceName = serviceName, + GeneratedFileNamePrefix = "MyFile", + IncludeT4File = false + }; + var handlerHelper = new TestConnectedServiceHandlerHelper(); + var codeGenDescriptor = SetupCodeGenDescriptor(serviceConfig, serviceName, + new TestODataT4CodeGeneratorFactory(), handlerHelper); + codeGenDescriptor.AddGeneratedClientCode().Wait(); + using (var reader = new StreamReader(handlerHelper.AddedFileInputFileName)) + { + var generatedCode = reader.ReadToEnd(); + Assert.AreEqual("Generated code", generatedCode); + Assert.AreEqual(Path.Combine(TestProjectRootPath, ServicesRootFolder, serviceName, "MyFile.cs"), + handlerHelper.AddedFileTargetFilePath); + } + } + + static V4CodeGenDescriptor SetupCodeGenDescriptor(ServiceConfiguration serviceConfig, string serviceName, IODataT4CodeGeneratorFactory codeGenFactory, TestConnectedServiceHandlerHelper handlerHelper) + { + var referenceFolderPath = Path.Combine(TestProjectRootPath, ServicesRootFolder, serviceName); + Directory.CreateDirectory(referenceFolderPath); + Project project = CreateTestProject(TestProjectRootPath); + var serviceInstance = new ODataConnectedServiceInstance() + { + ServiceConfig = serviceConfig, + Name = serviceName + }; + handlerHelper.ServicesRootFolder = ServicesRootFolder; + ConnectedServiceHandlerContext context = new TestConnectedServiceHandlerContext(serviceInstance, handlerHelper); + + return new TestV4CodeGenDescriptor(MetadataUri, context, project, codeGenFactory); + } + + static Project CreateTestProject(string projectPath) + { + var fullPathPropertyMock = new Mock(); + fullPathPropertyMock.SetupGet(p => p.Value).Returns(projectPath); + var projectPropertiesMock = new Mock(); + projectPropertiesMock.Setup(p => p.Item(It.Is(s => s == "FullPath"))) + .Returns(fullPathPropertyMock.Object); + var projectMock = new Mock(); + projectMock.SetupGet(p => p.Properties) + .Returns(projectPropertiesMock.Object); + return projectMock.Object; + } + } + + class TestV4CodeGenDescriptor: V4CodeGenDescriptor + { + public TestV4CodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project, IODataT4CodeGeneratorFactory codeGenFactory) + : base(metadataUri, context, project, codeGenFactory) + { + } + protected override void Init() { } + } + + class TestODataT4CodeGenerator: ODataT4CodeGenerator + { + public override string TransformText() + { + return "Generated code"; + } + } + + class TestODataT4CodeGeneratorFactory : IODataT4CodeGeneratorFactory + { + public ODataT4CodeGenerator LastCreatedInstance { get; private set; } + public ODataT4CodeGenerator Create() + { + var generator = new TestODataT4CodeGenerator(); + LastCreatedInstance = generator; + return generator; + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/ODataConnectedService.Tests.csproj b/ODataConnectedService/test/ODataConnectedService.Tests/ODataConnectedService.Tests.csproj new file mode 100644 index 0000000..b1025b9 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/ODataConnectedService.Tests.csproj @@ -0,0 +1,85 @@ + + + + + Debug + AnyCPU + {903B31D0-BE14-4D9E-BA76-186FA82B3A37} + Library + Properties + ODataConnectedService.Tests + ODataConnectedService.Tests + v4.7.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + True + + + + + + + + + + + + + + + 2.0.0 + + + 4.13.1 + + + 1.3.2 + + + 1.3.2 + + + + + + + + {a8bc5b8e-9ab7-4257-b8f1-e7c62169f9b5} + ODataConnectedService + + + + + + + + + \ No newline at end of file diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/ODataConnectedServiceHandlerTest.cs b/ODataConnectedService/test/ODataConnectedService.Tests/ODataConnectedServiceHandlerTest.cs new file mode 100644 index 0000000..82dd99a --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/ODataConnectedServiceHandlerTest.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Threading; +using System.Threading.Tasks; +using EnvDTE; +using Microsoft.VisualStudio.ConnectedServices; +using Microsoft.VisualStudio.Shell.Interop; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.OData.ConnectedService.CodeGeneration; +using Microsoft.OData.ConnectedService.Models; +using Moq; +using Microsoft.OData.ConnectedService.Tests.TestHelpers; + +namespace Microsoft.OData.ConnectedService.Tests +{ + [TestClass] + public class ODataConnectedServiceHandlerTest + { + [DataTestMethod] + [DataRow("AddServiceInstanceAsync", 4, "V4")] + [DataRow("AddServiceInstanceAsync", 3, "V3")] + [DataRow("AddServiceInstanceAsync", 2, "V3")] + [DataRow("AddServiceInstanceAsync", 1, "V3")] + [DataRow("UpdateServiceInstanceAsync", 4, "V4")] + [DataRow("UpdateServiceInstanceAsync", 3, "V3")] + [DataRow("UpdateServiceInstanceAsync", 2, "V3")] + [DataRow("UpdateServiceInstanceAsync", 1, "V3")] + public void TestUpdateServiceInstance_GeneratesCodeAndSavesConfig(string method, int edmxVersion, string generatorVersion) + { + var descriptorFactory = new TestCodeGenDescriptorFactory(); + var serviceHandler = new ODataConnectedServiceHandler(descriptorFactory); + var serviceConfig = new ServiceConfiguration() + { + EdmxVersion = new Version(edmxVersion, 0, 0, 0), + ServiceName = "TestService", + UseDataServiceCollection = false, + MakeTypesInternal = true + }; + var tokenSource = new CancellationTokenSource(); + var context = SetupContext(serviceConfig); + (typeof(ODataConnectedServiceHandler).GetMethod(method).Invoke( + serviceHandler, new object[] { context, tokenSource.Token }) as Task).Wait(); + var descriptor = descriptorFactory.CreatedInstance as TestCodeGenDescriptor; + Assert.IsTrue(descriptor.AddedClientCode); + Assert.IsTrue(descriptor.AddedNugetPackages); + Assert.AreEqual(generatorVersion, descriptor.Version); + Assert.AreEqual(serviceConfig, context.SavedExtendedDesignData); + } + + static TestConnectedServiceHandlerContext SetupContext(ServiceConfiguration serviceConfig) + { + var serviceInstance = new ODataConnectedServiceInstance() + { + Name = "TestService", + MetadataTempFilePath = "http://service/$metadata", + ServiceConfig = serviceConfig + }; + var projectHierarchyMock = new Mock(); + object project; + projectHierarchyMock.Setup(h => h.GetProperty(It.IsAny(), It.IsAny(), out project)); + var context = new TestConnectedServiceHandlerContext( + serviceInstance: serviceInstance, projectHierarchy: projectHierarchyMock.Object); + return context; + } + } + + class TestCodeGenDescriptorFactory: CodeGenDescriptorFactory + { + public BaseCodeGenDescriptor CreatedInstance { get; private set; } + protected override BaseCodeGenDescriptor CreateV3CodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project) + { + var descriptor = new TestCodeGenDescriptor(metadataUri, context, project); + descriptor.Version = "V3"; + CreatedInstance = CreatedInstance ?? descriptor; + return descriptor; + } + + protected override BaseCodeGenDescriptor CreateV4CodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project) + { + var descriptor = new TestCodeGenDescriptor(metadataUri, context, project); + descriptor.Version = "V4"; + CreatedInstance = CreatedInstance ?? descriptor; + return descriptor; + } + } + + class TestCodeGenDescriptor : BaseCodeGenDescriptor + { + public TestCodeGenDescriptor(string metadataUri, ConnectedServiceHandlerContext context, Project project) + : base(metadataUri, context, project) + { + ClientDocUri = "https://odata.org"; + } + public string Version { get; set; } + public bool AddedClientCode { get; private set; } + public bool AddedNugetPackages { get; private set; } + + protected override void Init() { } + public override Task AddGeneratedClientCode() + { + AddedClientCode = true; + return Task.CompletedTask; + } + + public override Task AddNugetPackages() + { + AddedNugetPackages = true; + return Task.CompletedTask; + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/Properties/AssemblyInfo.cs b/ODataConnectedService/test/ODataConnectedService.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..42f20f3 --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("ODataConnectedService.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ODataConnectedService.Tests")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("903b31d0-be14-4d9e-ba76-186fa82b3a37")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTest.cs b/ODataConnectedService/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTest.cs new file mode 100644 index 0000000..2f2157b --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/Templates/ODataT4CodeGeneratorTest.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Reflection; +using System.Text.RegularExpressions; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.OData.ConnectedService.Templates; + +namespace Microsoft.OData.ConnectedService.Tests.Templates +{ + [TestClass] + public class ODataT4CodeGeneratorTest + { + [TestMethod] + public void TestEntitiesComplexTypesEnumsFunctions() + { + string edmx = LoadReferenceContent("EntitiesEnumsFunctions.xml"); + string expected = LoadReferenceContent("EntitiesEnumsFunctions.cs"); + var generator = new ODataT4CodeGenerator() + { + Edmx = edmx, + TargetLanguage = ODataT4CodeGenerator.LanguageOption.CSharp + }; + var output = generator.TransformText(); + VerifyGeneratedCode(expected, output); + } + + [TestMethod] + public void TestEntitiesComplexTypesEnumsFunctionsDSC() + { + string edmx = LoadReferenceContent("EntitiesEnumsFunctions.xml"); + string expected = LoadReferenceContent("EntitiesEnumsFunctionsDSC.cs"); + var generator = new ODataT4CodeGenerator() + { + Edmx = edmx, + TargetLanguage = ODataT4CodeGenerator.LanguageOption.CSharp, + UseDataServiceCollection = true + }; + var output = generator.TransformText(); + VerifyGeneratedCode(expected, output); + } + + [TestMethod] + public void TestEntitiesComplexTypesEnumFunctionsWithInternalTypes() + { + string edmx = LoadReferenceContent("EntitiesEnumsFunctions.xml"); + string expected = LoadReferenceContent("EntitiesEnumsFunctionsWithInternalTypes.cs"); + var generator = new ODataT4CodeGenerator() + { + Edmx = edmx, + TargetLanguage = ODataT4CodeGenerator.LanguageOption.CSharp, + MakeTypesInternal = true + + }; + var output = generator.TransformText(); + VerifyGeneratedCode(expected, output); + } + + [TestMethod] + public void TestEntitiesComplexTypesEnumFunctionsDSCWithInternalTypes() + { + string edmx = LoadReferenceContent("EntitiesEnumsFunctions.xml"); + string expected = LoadReferenceContent("EntitiesEnumsFunctionsDSCWithInternalTypes.cs"); + var generator = new ODataT4CodeGenerator() + { + Edmx = edmx, + TargetLanguage = ODataT4CodeGenerator.LanguageOption.CSharp, + UseDataServiceCollection = true, + MakeTypesInternal = true + + }; + var output = generator.TransformText(); + VerifyGeneratedCode(expected, output); + } + + [TestMethod] + public void TestTypeDefinitionParamsConvertedToUnderlyingType() + { + string edmx = LoadReferenceContent("TypeDefinitions.xml"); + string expected = LoadReferenceContent("TypeDefinitionsParamsConvertedToUnderlyingType.cs"); + var generator = new ODataT4CodeGenerator() + { + Edmx = edmx, + TargetLanguage = ODataT4CodeGenerator.LanguageOption.CSharp + }; + var output = generator.TransformText(); + VerifyGeneratedCode(expected, output); + } + + static Assembly Assembly = Assembly.GetExecutingAssembly(); + const string ReferenceResourcePrefix = "ODataConnectedService.Tests.CodeGenReferences."; + + static string LoadReferenceContent(string name) + { + var fullName = $"{ReferenceResourcePrefix}{name}"; + using (var stream = Assembly.GetManifestResourceStream(fullName)) + { + if (stream == null) + { + throw new Exception($"Embedded resource '{name}' not found."); + } + var reader = new StreamReader(stream); + return reader.ReadToEnd(); + } + } + + static void VerifyGeneratedCode(string expectedCode, string actualCode) + { + var normalizedExpected = NormalizeGeneratedCode(expectedCode); + var normalizedActual = NormalizeGeneratedCode(actualCode); + Assert.AreEqual(normalizedExpected, normalizedActual); + } + + static string NormalizeGeneratedCode(string code) + { + string normalized = Regex.Replace(code, "// Generation date:.*", string.Empty, RegexOptions.Multiline); + normalized = Regex.Replace(normalized, "'Generation date:.*", string.Empty, RegexOptions.Multiline); + normalized = Regex.Replace(normalized, "// Runtime Version:.*", string.Empty, RegexOptions.Multiline); + normalized = Regex.Replace(normalized, "' Runtime Version:.*", string.Empty, RegexOptions.Multiline); + //Remove the spaces from the string to avoid indentation change errors + normalized = Regex.Replace(normalized, @"\s+", ""); + return normalized; + } + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/TestHelpers/TestConnectedServiceHandlerContext.cs b/ODataConnectedService/test/ODataConnectedService.Tests/TestHelpers/TestConnectedServiceHandlerContext.cs new file mode 100644 index 0000000..68a994b --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/TestHelpers/TestConnectedServiceHandlerContext.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.VisualStudio.ConnectedServices; +using Microsoft.VisualStudio.Shell.Interop; +using Moq; + +namespace Microsoft.OData.ConnectedService.Tests.TestHelpers +{ + class TestConnectedServiceHandlerContext : ConnectedServiceHandlerContext + { + public TestConnectedServiceHandlerContext(ConnectedServiceInstance serviceInstance = null, + ConnectedServiceHandlerHelper handlerHelper = null, IVsHierarchy projectHierarchy = null) : base() + { + ServiceInstance = serviceInstance; + HandlerHelper = handlerHelper; + ProjectHierarchy = projectHierarchy; + + var mockLogger = new Mock(); + mockLogger.Setup(l => l.WriteMessageAsync(It.IsAny(), It.IsAny())) + .Returns(Task.CompletedTask); + Logger = mockLogger.Object; + } + + public object SavedExtendedDesignData { get; private set; } + + public override void SetExtendedDesignerData(TData data) + { + SavedExtendedDesignData = data; + } + public override IDictionary Args => + throw new System.NotImplementedException(); + + public override EditableXmlConfigHelper CreateEditableXmlConfigHelper() => + throw new System.NotImplementedException(); + + public override XmlConfigHelper CreateReadOnlyXmlConfigHelper() => + throw new System.NotImplementedException(); + + public override TData GetExtendedDesignerData() => + throw new System.NotImplementedException(); + } +} diff --git a/ODataConnectedService/test/ODataConnectedService.Tests/TestHelpers/TestConnectedServiceHandlerHelper.cs b/ODataConnectedService/test/ODataConnectedService.Tests/TestHelpers/TestConnectedServiceHandlerHelper.cs new file mode 100644 index 0000000..09b930e --- /dev/null +++ b/ODataConnectedService/test/ODataConnectedService.Tests/TestHelpers/TestConnectedServiceHandlerHelper.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.VisualStudio.ConnectedServices; + +namespace Microsoft.OData.ConnectedService.Tests.TestHelpers +{ + class TestConnectedServiceHandlerHelper : ConnectedServiceHandlerHelper + { + // used to access the temp file that the generated code was written to + public string AddedFileInputFileName { get; private set; } + // used to find out which file the final output would be written to + public string AddedFileTargetFilePath { get; private set; } + public string ServicesRootFolder { get; set; } + public override Task AddFileAsync(string fileName, string targetPath, AddFileOptions addFileOptions = null) + { + AddedFileInputFileName = fileName; + AddedFileTargetFilePath = targetPath; + return Task.FromResult(string.Empty); + } + public override IDictionary TokenReplacementValues { get; } + public override void AddAssemblyReference(string assemblyPath) => + throw new System.NotImplementedException(); + public override string GetServiceArtifactsRootFolder() => ServicesRootFolder; + public override string PerformTokenReplacement(string input, IDictionary additionalReplacementValues = null) => + throw new System.NotImplementedException(); + } +} diff --git a/README.md b/README.md index 88074a9..dde463e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ This repository is for exploring new ideas and developing early prototypes of va * [Source](https://github.com/OData/lab/tree/master/ODataConnectedService) * [Visual Studio Extension](https://visualstudiogallery.msdn.microsoft.com/b343d0eb-6493-44c2-b558-13a0408d013f) * FAQ + **Question**: The extension module is not loaded when debugging in the Visual Studio experimental instance, or it is not listed as part of the "Add Connected Service" options + **Workaround**: Disable signing by going to the Project Properties > Signing and disabling both "Sign the assembly" and "Delay sign only" options. **Question**: In Visual Studio 2017, upon configuring the service endpoint in the OData Connected Services extension and clicking "Finish", I get an error message that says "Value cannot be null.\r\nParameter name: path1". **Workaround**: Download the [Microsoft WCF ToolKit](https://download.microsoft.com/download/1/C/A/1CAA41C7-88B9-42D6-9E11-3C655656DAB1/WcfDataServices.exe) and install it. Then go to the registry and find the following key: `[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services]`. Create a duplicate of "VS 2010 Tooling" (if this doesn't exist, use "5.6" instead) named "VS 2014 Tooling". Then try again. (Special thanks to [mohsenno1](https://github.com/mohsenno1) for pointing this out.) @@ -21,6 +23,15 @@ This repository is for exploring new ideas and developing early prototypes of va **Question**: In Visual Studio 2017, upon configuring the service endpoint in the OData Connected Services extension and clicking "Finish", I get an error message that says "Cannot access". **Workaround**: Most reported issues for this error are related to authentication-based endpoints. This extension does not currently support authentication. To work around, download the metadata as a text file from the endpoint and then point the OData Connected Services URI to the downloaded file. +#### Unit Tests + +The `ODataConnectedService.Tests.sln` contains the unit tests for the OData connected service. The folder structure of the tests mirrors the folder structre +of the `ODataConnectedService` project. The base namespace for tests is `Microsoft.OData.ConnectedService.Tests`. Furthermore each test class has the same name +as the class it is testing, followed by the suffix `Test`. + +Example: for some class `Microsoft.OData.ConnectedService.X.Y` located in `src\X\Y.cs`, +the test class would be `Microsoft.OData.Tests.ConnectedService.Tests.X.YTest` located in `test\X\YTest.cs` + ### OData v4 Web API Scaffolding * [Source](https://github.com/OData/lab/tree/master/WebAPIODataV4Scaffolding)