├── .gitignore ├── .nuget └── packages.config ├── Foundation.ObjectHydrator.Tests ├── AttributeMappingMethodTests.cs ├── Foundation.ObjectHydrator.Tests.csproj ├── GeneratorTests.cs ├── GeneratorTests │ └── Generator_Tests.cs ├── HydratorTests │ ├── Hydrator_ComplexCustomer_Tests.cs │ ├── Hydrator_Do_Tests.cs │ ├── Hydrator_InjectedGenerator_Test.cs │ ├── Hydrator_SimpleAddress_Tests.cs │ ├── Hydrator_SimpleCustomer_Tests.cs │ └── InjectedGenerator.cs ├── POCOs │ ├── Address.cs │ ├── ComplexCustomer.cs │ ├── RestrictedDescriptionCustomer.cs │ └── SimpleCustomer.cs ├── Properties │ └── AssemblyInfo.cs ├── PropertyDecorationMethodTests.cs ├── SampleClass │ ├── Customer.cs │ └── CustomerNoAttibutes.cs └── packages.config ├── Foundation.ObjectHydrator ├── DefaultTypeMap.cs ├── EnumMap.cs ├── Foundation.ObjectHydrator.csproj ├── Generators │ ├── AlphaNumericGenerator.cs │ ├── AmericanAddressGenerator.cs │ ├── AmericanCityGenerator.cs │ ├── AmericanPhoneGenerator.cs │ ├── AmericanPostalCodeGenerator.cs │ ├── AmericanStateGenerator.cs │ ├── ArrayGenerator.cs │ ├── BooleanGenerator.cs │ ├── ByteArrayGenerator.cs │ ├── CCVGenerator.cs │ ├── CompanyNameGenerator.cs │ ├── CountryCodeGenerator.cs │ ├── CreditCardNumberGenerator.cs │ ├── CreditCardTypeGenerator.cs │ ├── CulturesGenerator.cs │ ├── DateTimeGenerator.cs │ ├── DefaultGenerator.cs │ ├── DoubleGenerator.cs │ ├── EmailAddressGenerator.cs │ ├── EnumGenerator.cs │ ├── FirstNameGenerator.cs │ ├── FromListGenerator.cs │ ├── FromListGetListGenerator.cs │ ├── FromListGetSingleGenerator.cs │ ├── GenderGenerator.cs │ ├── Generator.cs │ ├── GuidGenerator.cs │ ├── IPAddressGenerator.cs │ ├── IntegerGenerator.cs │ ├── LastNameGenerator.cs │ ├── ListGenerator.cs │ ├── NullGenerator.cs │ ├── PasswordGenerator.cs │ ├── TextGenerator.cs │ ├── TrackingNumberGenerator.cs │ ├── TypeGenerator.cs │ ├── TypeListGenerator.cs │ ├── UnitedKingdomCityGenerator.cs │ ├── UnitedKingdomCountyGenerator.cs │ ├── UnitedKingdomNationalInsuranceGenerator.cs │ ├── UnitedKingdomPhoneNumberGenerator.cs │ ├── UnitedKingdomPostcodeGenerator.cs │ └── WebsiteGenerator.cs ├── Hydrator.cs ├── Interfaces │ ├── IGenerator.cs │ ├── IMap.cs │ └── IMapping.cs ├── Map.cs ├── Mapping.cs ├── Properties │ └── AssemblyInfo.cs ├── RandomSingleton.cs ├── Readme.htm ├── _CreateNewNuGetPackage │ ├── Config.ps1 │ ├── DoNotModify │ │ ├── CreateNuGetPackage.ps1 │ │ ├── New-NuGetPackage.ps1 │ │ ├── NuGet.exe │ │ └── UploadNuGetPackage.ps1 │ └── RunMeToUploadNuGetPackage.cmd └── packages.config ├── Foundation.sln ├── LICENSE ├── Packages.dgml ├── README.md └── SampleWebApplication ├── AddCustomer.aspx ├── AddCustomer.aspx.cs ├── AddCustomer.aspx.designer.cs ├── Company.cs ├── Customer.cs ├── CustomerFakeLookup.aspx ├── CustomerFakeLookup.aspx.cs ├── CustomerFakeLookup.aspx.designer.cs ├── CustomerRealLookUp.aspx ├── CustomerRealLookUp.aspx.cs ├── CustomerRealLookUp.aspx.designer.cs ├── CustomerRepository.cs ├── Default.aspx ├── Default.aspx.cs ├── Default.aspx.designer.cs ├── Global.asax ├── Global.asax.cs ├── Menu.ascx ├── Menu.ascx.cs ├── Menu.ascx.designer.cs ├── Properties └── AssemblyInfo.cs ├── SampleWebApplication.csproj └── Web.config /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.pch 68 | *.pdb 69 | *.pgc 70 | *.pgd 71 | *.rsp 72 | *.sbr 73 | *.tlb 74 | *.tli 75 | *.tlh 76 | *.tmp 77 | *.tmp_proj 78 | *.log 79 | *.vspscc 80 | *.vssscc 81 | .builds 82 | *.pidb 83 | *.svclog 84 | *.scc 85 | 86 | # Chutzpah Test files 87 | _Chutzpah* 88 | 89 | # Visual C++ cache files 90 | ipch/ 91 | *.aps 92 | *.ncb 93 | *.opendb 94 | *.opensdf 95 | *.sdf 96 | *.cachefile 97 | *.VC.db 98 | *.VC.VC.opendb 99 | 100 | # Visual Studio profiler 101 | *.psess 102 | *.vsp 103 | *.vspx 104 | *.sap 105 | 106 | # Visual Studio Trace Files 107 | *.e2e 108 | 109 | # TFS 2012 Local Workspace 110 | $tf/ 111 | 112 | # Guidance Automation Toolkit 113 | *.gpState 114 | 115 | # ReSharper is a .NET coding add-in 116 | _ReSharper*/ 117 | *.[Rr]e[Ss]harper 118 | *.DotSettings.user 119 | 120 | # JustCode is a .NET coding add-in 121 | .JustCode 122 | 123 | # TeamCity is a build add-in 124 | _TeamCity* 125 | 126 | # DotCover is a Code Coverage Tool 127 | *.dotCover 128 | 129 | # AxoCover is a Code Coverage Tool 130 | .axoCover/* 131 | !.axoCover/settings.json 132 | 133 | # Visual Studio code coverage results 134 | *.coverage 135 | *.coveragexml 136 | 137 | # NCrunch 138 | _NCrunch_* 139 | .*crunch*.local.xml 140 | nCrunchTemp_* 141 | 142 | # MightyMoose 143 | *.mm.* 144 | AutoTest.Net/ 145 | 146 | # Web workbench (sass) 147 | .sass-cache/ 148 | 149 | # Installshield output folder 150 | [Ee]xpress/ 151 | 152 | # DocProject is a documentation generator add-in 153 | DocProject/buildhelp/ 154 | DocProject/Help/*.HxT 155 | DocProject/Help/*.HxC 156 | DocProject/Help/*.hhc 157 | DocProject/Help/*.hhk 158 | DocProject/Help/*.hhp 159 | DocProject/Help/Html2 160 | DocProject/Help/html 161 | 162 | # Click-Once directory 163 | publish/ 164 | 165 | # Publish Web Output 166 | *.[Pp]ublish.xml 167 | *.azurePubxml 168 | # Note: Comment the next line if you want to checkin your web deploy settings, 169 | # but database connection strings (with potential passwords) will be unencrypted 170 | *.pubxml 171 | *.publishproj 172 | 173 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 174 | # checkin your Azure Web App publish settings, but sensitive information contained 175 | # in these scripts will be unencrypted 176 | PublishScripts/ 177 | 178 | # NuGet Packages 179 | *.nupkg 180 | # The packages folder can be ignored because of Package Restore 181 | **/[Pp]ackages/* 182 | # except build/, which is used as an MSBuild target. 183 | !**/[Pp]ackages/build/ 184 | # Uncomment if necessary however generally it will be regenerated when needed 185 | #!**/[Pp]ackages/repositories.config 186 | # NuGet v3's project.json files produces more ignorable files 187 | *.nuget.props 188 | *.nuget.targets 189 | 190 | # Microsoft Azure Build Output 191 | csx/ 192 | *.build.csdef 193 | 194 | # Microsoft Azure Emulator 195 | ecf/ 196 | rcf/ 197 | 198 | # Windows Store app package directories and files 199 | AppPackages/ 200 | BundleArtifacts/ 201 | Package.StoreAssociation.xml 202 | _pkginfo.txt 203 | *.appx 204 | 205 | # Visual Studio cache files 206 | # files ending in .cache can be ignored 207 | *.[Cc]ache 208 | # but keep track of directories ending in .cache 209 | !*.[Cc]ache/ 210 | 211 | # Others 212 | ClientBin/ 213 | ~$* 214 | *~ 215 | *.dbmdl 216 | *.dbproj.schemaview 217 | *.jfm 218 | *.pfx 219 | *.publishsettings 220 | orleans.codegen.cs 221 | 222 | # Including strong name files can present a security risk 223 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 224 | #*.snk 225 | 226 | # Since there are multiple workflows, uncomment next line to ignore bower_components 227 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 228 | #bower_components/ 229 | 230 | # RIA/Silverlight projects 231 | Generated_Code/ 232 | 233 | # Backup & report files from converting an old project file 234 | # to a newer Visual Studio version. Backup files are not needed, 235 | # because we have git ;-) 236 | _UpgradeReport_Files/ 237 | Backup*/ 238 | UpgradeLog*.XML 239 | UpgradeLog*.htm 240 | ServiceFabricBackup/ 241 | 242 | # SQL Server files 243 | *.mdf 244 | *.ldf 245 | *.ndf 246 | 247 | # Business Intelligence projects 248 | *.rdl.data 249 | *.bim.layout 250 | *.bim_*.settings 251 | *.rptproj.rsuser 252 | 253 | # Microsoft Fakes 254 | FakesAssemblies/ 255 | 256 | 257 | # GhostDoc plugin setting file 258 | *.GhostDoc.xml 259 | 260 | # Node.js Tools for Visual Studio 261 | .ntvs_analysis.dat 262 | node_modules/ 263 | 264 | # Visual Studio 6 build log 265 | *.plg 266 | 267 | # Visual Studio 6 workspace options file 268 | *.opt 269 | 270 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 271 | *.vbw 272 | 273 | # Visual Studio LightSwitch build output 274 | **/*.HTMLClient/GeneratedArtifacts 275 | **/*.DesktopClient/GeneratedArtifacts 276 | **/*.DesktopClient/ModelManifest.xml 277 | **/*.Server/GeneratedArtifacts 278 | **/*.Server/ModelManifest.xml 279 | _Pvt_Extensions 280 | 281 | # Paket dependency manager 282 | .paket/paket.exe 283 | paket-files/ 284 | 285 | # FAKE - F# Make 286 | .fake/ 287 | 288 | # JetBrains Rider 289 | .idea/ 290 | *.sln.iml 291 | 292 | # CodeRush 293 | .cr/ 294 | 295 | # Python Tools for Visual Studio (PTVS) 296 | __pycache__/ 297 | *.pyc 298 | 299 | # Cake - Uncomment if you are using it 300 | # tools/** 301 | # !tools/packages.config 302 | 303 | # Tabs Studio 304 | *.tss 305 | 306 | # Telerik's JustMock configuration file 307 | *.jmconfig 308 | 309 | # BizTalk build output 310 | *.btp.cs 311 | *.btm.cs 312 | *.odx.cs 313 | *.xsd.cs 314 | 315 | # OpenCover UI analysis results 316 | OpenCover/ 317 | 318 | # Azure Stream Analytics local run output 319 | ASALocalRun/ 320 | 321 | # MSBuild Binary and Structured Log 322 | *.binlog 323 | 324 | # NVidia Nsight GPU debugger configuration file 325 | *.nvuser 326 | 327 | -------------------------------------------------------------------------------- /.nuget/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/AttributeMappingMethodTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using MbUnit.Framework; 6 | using Foundation.ObjectHydrator.Tests.SampleClass; 7 | 8 | namespace Foundation.ObjectHydrator.Tests 9 | { 10 | [TestFixture] 11 | public class AttributeMappingMethodTests 12 | { 13 | [Test] 14 | public void UsingAttributeMapSingle() 15 | { 16 | FillMe generator = new FillMe(); 17 | IList attmaplist = new List(); 18 | AttributeMap firstname = new AttributeMap { GeneratorName = "FirstName", PropName = "CustomerFirstName", GeneratorDefaultValue = "Ryan" }; 19 | attmaplist.Add(firstname); 20 | AttributeMap lastname = new AttributeMap { GeneratorName = "LastName", PropName = "CustomerLastName" }; 21 | attmaplist.Add(lastname); 22 | AttributeMap ordernumber = new AttributeMap { GeneratorName = "NumberGen", PropName = "CustomerNumberOfOrders" }; 23 | attmaplist.Add(ordernumber); 24 | AttributeMap phone = new AttributeMap { GeneratorName = "AmericanPhone", PropName = "CustomerPhone" }; 25 | attmaplist.Add(phone); 26 | AttributeMap isactive = new AttributeMap { GeneratorName = "BooleanGenerator", PropName = "CustomerIsActive", DefaultBoolValue = true }; 27 | attmaplist.Add(isactive); 28 | AttributeMap ipaddress = new AttributeMap { GeneratorName = "IPAddressGenerator", PropName = "CustomerIPAddress", GeneratorDefaultValue = "25...25" }; 29 | attmaplist.Add(ipaddress); 30 | AttributeMap address = new AttributeMap { GeneratorName = "AmericanAddress", PropName = "CustomerAddress" }; 31 | attmaplist.Add(address); 32 | IList mycustomer = generator.GetList(20, attmaplist); 33 | Assert.IsNotNull(mycustomer); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/Foundation.ObjectHydrator.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 9.0.30729 8 | 2.0 9 | {44E61D49-4DA0-448C-928E-2907951DD381} 10 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 11 | Library 12 | Properties 13 | Foundation.ObjectHydrator.Tests 14 | Foundation.ObjectHydrator.Tests 15 | v4.5 16 | 512 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 3.5 28 | 29 | publish\ 30 | true 31 | Disk 32 | false 33 | Foreground 34 | 7 35 | Days 36 | false 37 | false 38 | true 39 | 0 40 | 1.0.0.%2a 41 | false 42 | false 43 | true 44 | 45 | 46 | 47 | 48 | 49 | true 50 | full 51 | false 52 | bin\Debug\ 53 | DEBUG;TRACE 54 | prompt 55 | 4 56 | AllRules.ruleset 57 | false 58 | 59 | 60 | pdbonly 61 | true 62 | bin\Release\ 63 | TRACE 64 | prompt 65 | 4 66 | AllRules.ruleset 67 | false 68 | 69 | 70 | 71 | ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll 72 | 73 | 74 | 75 | 76 | 77 | 78 | 3.5 79 | 80 | 81 | 3.5 82 | 83 | 84 | 3.5 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | {8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA} 104 | Foundation.ObjectHydrator 105 | 106 | 107 | 108 | 109 | False 110 | Microsoft .NET Framework 4 %28x86 and x64%29 111 | true 112 | 113 | 114 | False 115 | .NET Framework 3.5 SP1 Client Profile 116 | false 117 | 118 | 119 | False 120 | .NET Framework 3.5 SP1 121 | false 122 | 123 | 124 | False 125 | Windows Installer 3.1 126 | true 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 136 | 137 | 138 | 139 | 146 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/HydratorTests/Hydrator_ComplexCustomer_Tests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using Foundation.ObjectHydrator.Generators; 4 | using Foundation.ObjectHydrator.Tests.POCOs; 5 | using NUnit.Framework; 6 | 7 | namespace Foundation.ObjectHydrator.Tests.HydratorTests 8 | { 9 | [TestFixture] 10 | public class Hydrator_ComplexCustomer_Tests 11 | { 12 | [Test] 13 | public void CanLoadSingleComplexCustomer() 14 | { 15 | int[] values = {1, 2, 3}; 16 | var args = new object[] {values}; 17 | var hydrator = new Hydrator() 18 | .With(x => x.HomeAddress, new TypeGenerator
()); 19 | var customer = hydrator.GetSingle(); 20 | Assert.IsNotNull(customer); 21 | Assert.IsNotNull(customer.HomeAddress, "CustomerAddress is null"); 22 | } 23 | 24 | [Test] 25 | public void CanGetListOfComplexCustomer() 26 | { 27 | int[] values = {1, 2, 3}; 28 | var args = new object[] {values}; 29 | var hydrator = new Hydrator() 30 | .With(x => x.HomeAddress, new TypeGenerator
()); 31 | var customerlist = hydrator.GetList(10); 32 | Assert.IsNotNull(customerlist); 33 | Assert.IsTrue(customerlist.Count == 10); 34 | Assert.IsNotNull(customerlist[1].HomeAddress, "CustomerAddress is null"); 35 | } 36 | 37 | 38 | [Test] 39 | public void CanLoadSingleComplexCustomerWithAddressList() 40 | { 41 | var listSize = 6; 42 | var args = new object[] {listSize}; 43 | 44 | var customer = new Hydrator() 45 | .With(x => x.Addresses, new ListGenerator
(listSize)) 46 | .With(x => x.FirstName, "Test") 47 | .GetSingle(); 48 | 49 | 50 | Assert.IsNotNull(customer); 51 | Assert.IsTrue(customer.Addresses.Count == listSize, 52 | string.Format("Customer.Address.Count [{0}] is not expected value of [{1}].", 53 | customer.Addresses.Count, listSize)); 54 | 55 | Trace.WriteLine("Addresses Generated..."); 56 | foreach (Address address in customer.Addresses) 57 | { 58 | Trace.WriteLine(address.AddressLine1); 59 | } 60 | } 61 | 62 | 63 | [Test] 64 | public void CanLoadSingleComplexCustomerWithPhoneList() 65 | { 66 | var listSize = 6; 67 | var args = new object[] {listSize}; 68 | 69 | var customer = new Hydrator() 70 | .With(x => x.PhoneNumbers, new ArrayGenerator(listSize, new AmericanPhoneGenerator())) 71 | .GetSingle(); 72 | 73 | 74 | Assert.IsNotNull(customer); 75 | Assert.IsTrue(customer.PhoneNumbers.Length == listSize, 76 | string.Format("customer.PhoneNumbers.Length [{0}] is not expected value of [{1}].", 77 | customer.PhoneNumbers.Length, listSize)); 78 | 79 | Trace.WriteLine("Addresses Generated..."); 80 | foreach (string ph in customer.PhoneNumbers) 81 | { 82 | Trace.WriteLine(ph); 83 | } 84 | } 85 | 86 | [Test] 87 | public void CanLoadSingleComplexCustomerWithRandomCountOfAddressList() 88 | { 89 | var args = new object[] {}; 90 | var hydrator = new Hydrator() 91 | .With(x => x.Addresses, ListGenerator
.RandomLength()); 92 | 93 | var customer = hydrator.GetSingle(); 94 | Assert.IsNotNull(customer); 95 | Assert.IsTrue(customer.Addresses.Count > 0); 96 | 97 | Trace.WriteLine("Addresses Generated..."); 98 | foreach (Address address in customer.Addresses) 99 | { 100 | Trace.WriteLine(address.AddressLine1); 101 | } 102 | } 103 | 104 | [Test] 105 | public void CanLoadSingleComplexCustomerWithCustumTypeMappers() 106 | { 107 | var lastNameDefault = "Lennon"; 108 | var hy = new Hydrator() 109 | .ForAll
(new Hydrator
()) 110 | .For>(new Map>().Using(new ListGenerator
(10))) 111 | .For(new Map().Matching(info => info.Name.ToLower() == "lastname").Using(lastNameDefault)) 112 | .GetSingle(); 113 | 114 | Assert.AreEqual(lastNameDefault, hy.LastName); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/HydratorTests/Hydrator_Do_Tests.cs: -------------------------------------------------------------------------------- 1 | using Foundation.ObjectHydrator.Generators; 2 | using Foundation.ObjectHydrator.Tests.POCOs; 3 | using NUnit.Framework; 4 | 5 | namespace Foundation.ObjectHydrator.Tests.HydratorTests 6 | { 7 | [TestFixture] 8 | public class Hydrator_Do_Tests 9 | { 10 | [Test] 11 | public void CanSetConstantValue() 12 | { 13 | const int expected = 90; 14 | 15 | var hydrator = new Hydrator() 16 | .WithFirstName(x => x.FirstName) 17 | .WithLastName(x => x.LastName) 18 | .WithCompanyName(x => x.Company) 19 | .Do(x => x.Locations = expected); 20 | 21 | var customer = hydrator.GetSingle(); 22 | 23 | Assert.IsNotNull(customer); 24 | Assert.AreEqual(customer.Locations, expected, "The value should have been set in the Do method"); 25 | } 26 | 27 | [Test] 28 | public void CanSetConstantValue_MultipleActions() 29 | { 30 | const string expected = "pop"; 31 | 32 | var hydrator = new Hydrator() 33 | .WithFirstName(x => x.FirstName) 34 | .WithLastName(x => x.LastName) 35 | .WithCompanyName(x => x.Company) 36 | .Do(x => x.Description = expected) 37 | .Do(x => x.Password = expected); 38 | 39 | var customer = hydrator.GetSingle(); 40 | 41 | Assert.IsNotNull(customer); 42 | Assert.AreEqual(customer.Description, expected, "The value should have been set in the Do method"); 43 | Assert.AreEqual(customer.Password, expected, "The value should have been set in the Do method"); 44 | } 45 | 46 | [Test] 47 | public void CanOverwriteOtherValue() 48 | { 49 | const string expected = "NotAFirstName"; 50 | 51 | var hydrator = new Hydrator() 52 | .WithFirstName(x => x.FirstName) 53 | .WithLastName(x => x.LastName) 54 | .WithCompanyName(x => x.Company) 55 | .Do(x => x.FirstName = expected); 56 | 57 | var customer = hydrator.GetSingle(); 58 | 59 | Assert.IsNotNull(customer); 60 | Assert.AreEqual(customer.FirstName, expected, "The value should have been set in the Do method"); 61 | } 62 | 63 | [Test] 64 | public void CanSetIgnoredProperty() 65 | { 66 | const string expected = "NotAFirstName"; 67 | 68 | var hydrator = new Hydrator() 69 | .Ignoring(x => x.FirstName) 70 | .Do(x => x.FirstName = expected); 71 | 72 | var customer = hydrator.GetSingle(); 73 | 74 | Assert.IsNotNull(customer); 75 | Assert.AreEqual(customer.FirstName, expected, "The value should have been set in the Do method"); 76 | } 77 | 78 | [Test] 79 | public void CanUseGenerator() 80 | { 81 | var countryGenerator = new CountryCodeGenerator(); 82 | 83 | var hydrator = new Hydrator() 84 | .Ignoring(x => x.Country) 85 | .Do(x => x.Country = countryGenerator.Generate()); 86 | 87 | var customer = hydrator.GetSingle(); 88 | 89 | Assert.IsNotNull(customer); 90 | Assert.IsNotNull(customer.Country, "The value should have been set in the Do method"); 91 | Assert.IsNotEmpty(customer.Country, "The value should have been set in the Do method"); 92 | } 93 | 94 | [Test] 95 | public void CanUseGenerator2() 96 | { 97 | var hydrator = new Hydrator() 98 | .Ignoring(x => x.Country) 99 | .Do(x => 100 | { 101 | var countryGenerator = new CountryCodeGenerator(); 102 | x.Country = countryGenerator.Generate(); 103 | }); 104 | 105 | var customer = hydrator.GetSingle(); 106 | 107 | Assert.IsNotNull(customer); 108 | Assert.IsNotNull(customer.Country, "The value should have been set in the Do method"); 109 | Assert.IsNotEmpty(customer.Country, "The value should have been set in the Do method"); 110 | } 111 | 112 | [Test] 113 | public void CanSetOnePropertyFromAnother() 114 | { 115 | var hydrator = new Hydrator() 116 | .WithFirstName(x => x.FirstName) 117 | .WithLastName(x => x.LastName) 118 | .WithCompanyName(x => x.Company) 119 | .Do(x => x.EmailAddress = string.Format("{0}.{1}@{2}.com", x.FirstName, x.LastName, x.Company)); 120 | 121 | var customer = hydrator.GetSingle(); 122 | 123 | Assert.IsNotNull(customer); 124 | Assert.AreEqual(customer.EmailAddress, string.Format("{0}.{1}@{2}.com", customer.FirstName, customer.LastName, customer.Company), "The value should have been set in the Do method"); 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/HydratorTests/Hydrator_InjectedGenerator_Test.cs: -------------------------------------------------------------------------------- 1 | using Foundation.ObjectHydrator.Tests.POCOs; 2 | using NUnit.Framework; 3 | 4 | namespace Foundation.ObjectHydrator.Tests.HydratorTests 5 | { 6 | [TestFixture] 7 | class Hydrator_InjectedGenerator_Test 8 | { 9 | [Test] 10 | public void SimpleTest() 11 | { 12 | var hydrator = new Hydrator
().WithCustomGenerator(x=>x.State, new InjectedGenerator()); 13 | 14 | var checkme = hydrator.GetSingle(); 15 | Assert.IsNotNull(checkme); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/HydratorTests/Hydrator_SimpleAddress_Tests.cs: -------------------------------------------------------------------------------- 1 | using Foundation.ObjectHydrator.Tests.POCOs; 2 | using NUnit.Framework; 3 | 4 | namespace Foundation.ObjectHydrator.Tests.HydratorTests 5 | { 6 | [TestFixture] 7 | public class Hydrator_SimpleAddress_Tests 8 | { 9 | [Test] 10 | public void SimpleTest() 11 | { 12 | var hydrator = new Hydrator
(); 13 | 14 | var checkme = hydrator.GetSingle(); 15 | Assert.IsNotNull(checkme); 16 | } 17 | 18 | [Test] 19 | public void CityTest() 20 | { 21 | var hydrator = new Hydrator
(); 22 | 23 | var checkme = hydrator.GetSingle(); 24 | Assert.IsNotNull(checkme); 25 | } 26 | 27 | [Test] 28 | public void StateTest() 29 | { 30 | var hydrator = new Hydrator
(); 31 | 32 | var checkme = hydrator.GetSingle(); 33 | Assert.IsNotNull(checkme); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/HydratorTests/InjectedGenerator.cs: -------------------------------------------------------------------------------- 1 | using Foundation.ObjectHydrator.Interfaces; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Foundation.ObjectHydrator.Tests.HydratorTests 6 | { 7 | class InjectedGenerator:IGenerator 8 | { 9 | private readonly Random random; 10 | private IList states = new List(); 11 | 12 | public InjectedGenerator() 13 | { 14 | random = RandomSingleton.Instance.Random; 15 | LoadStates(); 16 | } 17 | 18 | private void LoadStates() 19 | { 20 | states = new List 21 | { 22 | "AK", 23 | "CA" 24 | 25 | }; 26 | } 27 | public string Generate() 28 | { 29 | return states[random.Next(0, states.Count)]; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/POCOs/Address.cs: -------------------------------------------------------------------------------- 1 | namespace Foundation.ObjectHydrator.Tests.POCOs 2 | { 3 | public class Address 4 | { 5 | public string AddressLine1 { get; set; } 6 | public string AddressLine2 { get; set; } 7 | public string City { get; set; } 8 | public string State { get; set; } 9 | public string PostalCode { get; set; } 10 | public string Country { get; set; } 11 | 12 | public Address() 13 | { 14 | City = "Test City"; 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/POCOs/ComplexCustomer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Foundation.ObjectHydrator.Tests.POCOs 5 | { 6 | public enum CustomerType 7 | { 8 | Lead, 9 | Prospect, 10 | Active, 11 | Inactive 12 | } 13 | 14 | public class ComplexCustomer 15 | { 16 | public ComplexCustomer() 17 | { 18 | 19 | } 20 | 21 | public int Id { get; private set; } 22 | public string FirstName { get; set; } 23 | public string LastName { get; set; } 24 | public string Company { get; set; } 25 | public string Description { get; set; } 26 | public int Locations { get; set; } 27 | public DateTime IncorporatedOn { get; set; } 28 | public Double Revenue { get; set; } 29 | 30 | public Address WorkAddress { get; set; } 31 | public Address HomeAddress { get; set; } 32 | public IList
Addresses { get; set; } 33 | 34 | 35 | 36 | public string HomePhone { get; set; } 37 | public string WorkPhone { get; set; } 38 | public string[] PhoneNumbers { get; set; } 39 | 40 | public CustomerType Type { get; set; } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/POCOs/RestrictedDescriptionCustomer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace Foundation.ObjectHydrator.Tests.POCOs 5 | { 6 | public class RestrictedDescriptionCustomer 7 | { 8 | 9 | public string FirstName { get; set; } 10 | public string LastName { get; set; } 11 | public string Company { get; set; } 12 | [StringLength(5)] 13 | public string Description { get; set; } 14 | public int Locations { get; set; } 15 | public DateTime IncorporatedOn { get; set; } 16 | public Double Revenue { get; set; } 17 | public string homepage { get; set; } 18 | public string ipaddress { get; set; } 19 | public string gender { get; set; } 20 | public string creditcardtype { get; set; } 21 | public string Country { get; set; } 22 | private string _emailAddress; 23 | public string EmailAddress 24 | { 25 | get { return _emailAddress; } 26 | set 27 | { 28 | _emailAddress = value; 29 | } 30 | } 31 | private bool _isActive; 32 | public bool IsActive 33 | { 34 | get { return _isActive; } 35 | set 36 | { 37 | _isActive = value; 38 | } 39 | } 40 | 41 | public Guid UniqueId { get; set; } 42 | public byte[] Version { get; set; } 43 | public string CreditCardNumber { get; set; } 44 | public string TrackingNumber { get; set; } 45 | 46 | public string CCV { get; set; } 47 | private string _password; 48 | public string Password 49 | { 50 | get { return _password; } 51 | set 52 | { 53 | _password = value; 54 | } 55 | } 56 | 57 | public string placeholderstring { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/POCOs/SimpleCustomer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Foundation.ObjectHydrator.Tests.POCOs 4 | { 5 | public class SimpleCustomer 6 | { 7 | 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string Company { get; set; } 11 | public string Description { get; set; } 12 | public int Locations { get; set; } 13 | public DateTime IncorporatedOn { get; set; } 14 | public Double Revenue { get; set; } 15 | public string homepage { get; set; } 16 | public string ipaddress { get; set; } 17 | public string gender { get; set; } 18 | public string creditcardtype { get; set; } 19 | public string Country { get; set; } 20 | private string _emailAddress; 21 | public string EmailAddress 22 | { 23 | get { return _emailAddress; } 24 | set 25 | { 26 | _emailAddress = value; 27 | } 28 | } 29 | private bool _isActive; 30 | public bool IsActive 31 | { 32 | get { return _isActive; } 33 | set 34 | { 35 | _isActive = value; 36 | } 37 | } 38 | 39 | public Guid UniqueId { get; set; } 40 | public byte[] Version { get; set; } 41 | public string CreditCardNumber { get; set; } 42 | public string TrackingNumber { get; set; } 43 | 44 | public string CCV { get; set; } 45 | private string _password; 46 | public string Password 47 | { 48 | get { return _password; } 49 | set 50 | { 51 | _password = value; 52 | } 53 | } 54 | 55 | public string placeholderstring { get; set; } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Foundation.ObjectHydrator.Tests")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Foundation.ObjectHydrator.Tests")] 12 | [assembly: AssemblyCopyright("Copyright © 2009")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("795b8da7-cfed-42f9-a157-e7d1a421557a")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | [assembly: AssemblyVersion("1.0.0.0")] 34 | [assembly: AssemblyFileVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/PropertyDecorationMethodTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using MbUnit.Framework; 6 | using Foundation.ObjectHydrator.Tests.SampleClass; 7 | 8 | namespace Foundation.ObjectHydrator.Tests 9 | { 10 | 11 | [TestFixture] 12 | public class PropertyDecorationMethodTests 13 | { 14 | private FillMe generator = new FillMe(); 15 | 16 | 17 | [Test] 18 | public void AmericanAddressTest() 19 | { 20 | 21 | Customer mycustomer = generator.GetSingle(); 22 | Assert.IsNotNull(mycustomer.CustomerAddress); 23 | Assert.IsFalse(mycustomer.CustomerAddress == string.Empty); 24 | } 25 | 26 | [Test] 27 | public void AmericanCityTest() 28 | { 29 | 30 | Customer mycustomer = generator.GetSingle(); 31 | Assert.IsNotNull(mycustomer.CustomerCity); 32 | Assert.IsFalse(mycustomer.CustomerCity == string.Empty); 33 | } 34 | 35 | [Test] 36 | public void AmericanPhoneTest() 37 | { 38 | 39 | Customer mycustomer = generator.GetSingle(); 40 | Assert.IsNotNull(mycustomer.CustomerPhone); 41 | Assert.IsFalse(mycustomer.CustomerPhone == string.Empty); 42 | 43 | } 44 | 45 | [Test] 46 | public void AmericanPostalCodeTestNoPlusFour() 47 | { 48 | 49 | Customer mycustomer = generator.GetSingle(); 50 | Assert.IsNotNull(mycustomer.CustomerPostalCode); 51 | Assert.DoesNotContain(mycustomer.CustomerPostalCode, "-"); 52 | } 53 | 54 | [Test] 55 | public void AmericanStateGeneratorTest() 56 | { 57 | 58 | Customer mycustomer = generator.GetSingle(); 59 | Assert.IsNotNull(mycustomer.CustomerAmericanState); 60 | Assert.IsFalse(mycustomer.CustomerAmericanState == string.Empty); 61 | } 62 | 63 | [Test] 64 | public void BooleanGeneratorTest() 65 | { 66 | Customer mycustomer = generator.GetSingle(); 67 | Assert.IsNotNull(mycustomer.CustomerIsActive); 68 | 69 | } 70 | 71 | 72 | 73 | [Test] 74 | public void BusinessNameGeneratorTest() 75 | { 76 | Customer mycustomer = generator.GetSingle(); 77 | Assert.IsNotNull(mycustomer.CustomerBusinessName); 78 | Assert.IsFalse(mycustomer.CustomerBusinessName == string.Empty); 79 | } 80 | 81 | [Test] 82 | public void DateGenerator() 83 | { 84 | 85 | Customer mycustomer = generator.GetSingle(); 86 | Assert.IsNotNull(mycustomer.CustomerCreatedDate); 87 | 88 | } 89 | 90 | [Test] 91 | public void EmailAddressGenerator() 92 | { 93 | Customer mycustomer = generator.GetSingle(); 94 | Assert.IsNotNull(mycustomer.CustomerEmailAddress); 95 | Assert.IsFalse(mycustomer.CustomerEmailAddress == string.Empty); 96 | } 97 | 98 | [Test] 99 | public void EnumTest() 100 | { 101 | 102 | 103 | Customer mycust = generator.GetSingle(); 104 | Assert.IsNotNull(mycust); 105 | 106 | } 107 | 108 | [Test] 109 | public void SimpleFirstNameTest() 110 | { 111 | 112 | Customer mynewcustomer = generator.GetSingle(); 113 | Assert.IsNotNull(mynewcustomer.CustomerFirstName); 114 | Assert.IsFalse(mynewcustomer.CustomerFirstName == string.Empty); 115 | } 116 | 117 | 118 | [Test] 119 | public void SimpleLastNameTest() 120 | { 121 | 122 | Customer mynewcustomer = generator.GetSingle(); 123 | Assert.IsNotNull(mynewcustomer.CustomerLastName); 124 | Assert.IsFalse(mynewcustomer.CustomerLastName == string.Empty); 125 | } 126 | 127 | 128 | [Test] 129 | public void NumberGenerator() 130 | { 131 | 132 | Customer mycustomer = generator.GetSingle(); 133 | Assert.IsNotNull(mycustomer.CustomerNumberOfOrders); 134 | } 135 | 136 | [Test] 137 | public void WebsiteAddressGenerator() 138 | { 139 | Customer mycustomer = generator.GetSingle(); 140 | Assert.IsNotNull(mycustomer.CustomerWebsite); 141 | Assert.IsFalse(mycustomer.CustomerWebsite == string.Empty); 142 | } 143 | 144 | [Test] 145 | public void MultiTest() 146 | { 147 | 148 | IList mycustomerlist = generator.GetList(5); 149 | Assert.IsTrue(mycustomerlist.Count == 5); 150 | 151 | } 152 | 153 | 154 | [Test] 155 | public void SimpTest() 156 | { 157 | 158 | Customer cust = new Customer(); 159 | Customer gen = generator.SingleTest(cust); 160 | Assert.IsNotNull(gen.CustomerFirstName); 161 | 162 | } 163 | 164 | [Test] 165 | public void SimpTestBooleanPreFilled() 166 | { 167 | Customer cust = new Customer { CustomerIsActive = true }; 168 | Customer gen = generator.SingleTest(cust); 169 | Assert.IsTrue(gen.CustomerIsActive == true); 170 | 171 | } 172 | 173 | [Test] 174 | public void SimpleDoNotOverrideDefaultValueTest() 175 | { 176 | Customer cust = new Customer { CustomerFirstName = "Guido" }; 177 | Customer gen = generator.SingleTest(cust); 178 | Assert.IsTrue(gen.CustomerFirstName == "Guido"); 179 | } 180 | 181 | 182 | 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/SampleClass/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Foundation.ObjectHydrator.GeneratorTypes; 6 | 7 | namespace Foundation.ObjectHydrator.Tests.SampleClass 8 | { 9 | public class Customer 10 | { 11 | public enum Days { Sat = 1, Sun, Mon, Tue, Wed, Thu, Fri }; 12 | 13 | [FirstName("")] 14 | public string CustomerFirstName { get; set; } 15 | 16 | [LastName("Jones")] 17 | public string CustomerLastName { get; set; } 18 | 19 | [DateGen("1/1/2009","1/1/2010")] 20 | public DateTime CustomerCreatedDate { get; set; } 21 | 22 | [AmericanPhone("")] 23 | public string CustomerPhone { get; set; } 24 | 25 | [NumberGen(1,23)] 26 | public int CustomerNumberOfOrders { get; set; } 27 | 28 | [AmericanAddress("")] 29 | public string CustomerAddress { get; set; } 30 | 31 | [AmericanCity("")] 32 | public string CustomerCity { get; set; } 33 | 34 | [AmericanPostalCode(false)] 35 | public string CustomerPostalCode { get; set; } 36 | 37 | [EnumGen(typeof(Days))] 38 | public Days CustomerDay { get; set; } 39 | 40 | [BoolGen(false)] 41 | public bool? CustomerIsActive { get; set; } 42 | 43 | [AmericanState("")] 44 | public string CustomerAmericanState { get; set; } 45 | 46 | [EmailAddress("")] 47 | public string CustomerEmailAddress { get; set; } 48 | 49 | [BusinessName("")] 50 | public string CustomerBusinessName { get; set; } 51 | 52 | [WebsiteAddress("")] 53 | public string CustomerWebsite { get; set; } 54 | 55 | [IPAddress("25", "25", "25", "25")] 56 | public string CustomerIPAddress { get; set; } 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/SampleClass/CustomerNoAttibutes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Foundation.ObjectHydrator.Tests.SampleClass 7 | { 8 | class CustomerNoAttibutes 9 | { 10 | 11 | public string CustomerFirstName { get; set; } 12 | 13 | 14 | public string CustomerLastName { get; set; } 15 | 16 | 17 | public DateTime CustomerCreatedDate { get; set; } 18 | 19 | 20 | public string CustomerPhone { get; set; } 21 | 22 | public int CustomerNumberOfOrders { get; set; } 23 | 24 | public bool CustomerIsActive { get; set; } 25 | 26 | public string CustomerIPAddress { get; set; } 27 | 28 | public string CustomerAddress { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/DefaultTypeMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | using Foundation.ObjectHydrator.Generators; 5 | 6 | namespace Foundation.ObjectHydrator 7 | { 8 | public class DefaultTypeMap:List 9 | { 10 | public DefaultTypeMap() 11 | { 12 | Add(new Map().Using(new DateTimeGenerator())); 13 | Add(new Map().Using(new DoubleGenerator())); 14 | Add(new Map().Using(new DoubleGenerator())); 15 | Add(new Map().Using(new IntegerGenerator())); 16 | Add(new Map().Using(new IntegerGenerator())); 17 | Add(new Map().Using(new BooleanGenerator())); 18 | Add(new Map().Using(new GuidGenerator())); 19 | Add(new Map().Using(new ByteArrayGenerator(8))); 20 | Add(new EnumMap()); 21 | Add(new Map() 22 | .Matching(info => info.Name.ToLower() == "firstname" || info.Name.ToLower() == "fname") 23 | .Using(new FirstNameGenerator())); 24 | Add(new Map() 25 | .Matching(info => info.Name.ToLower() == "lastname" || info.Name.ToLower() == "lname") 26 | .Using(new LastNameGenerator())); 27 | Add(new Map() 28 | .Matching(info => info.Name.ToLower().Contains("email")) 29 | .Using(new EmailAddressGenerator())); 30 | Add(new Map() 31 | .Matching(info => info.Name.ToLower().Contains("password")) 32 | .Using(new PasswordGenerator())); 33 | Add(new Map() 34 | .Matching(info => info.Name.ToLower().Contains("trackingnumber")) 35 | .Using(new TrackingNumberGenerator("ups"))); 36 | Add(new Map() 37 | .Matching(info => info.Name.ToLower() == "ipaddress") 38 | .Using(new IPAddressGenerator())); 39 | Add(new Map() 40 | .Matching(info => info.Name.ToLower().Contains("country")) 41 | .Using(new CountryCodeGenerator())); 42 | Add(new Map() 43 | .Matching(info => info.Name.ToLower() == "gender") 44 | .Using(new GenderGenerator())); 45 | Add(new Map() 46 | .Matching(info => info.Name.ToLower() == "creditcardtype") 47 | .Using(new CreditCardTypeGenerator())); 48 | Add(new Map() 49 | .Matching(info => info.Name.ToLower().Contains("addressline") || info.Name.ToLower().Contains("address")) 50 | .Using(new AmericanAddressGenerator())); 51 | Add(new Map() 52 | .Matching(info => info.Name.ToLower().Contains("creditcard") || 53 | info.Name.ToLower().Contains("cardnum") || 54 | info.Name.ToLower().Contains("ccnumber")) 55 | .Using(new CreditCardNumberGenerator())); 56 | Add(new Map() 57 | .Matching(info => info.Name.ToLower().Contains("url") || 58 | info.Name.ToLower().Contains("website") || 59 | info.Name.ToLower().Contains("homepage")) 60 | .Using(new WebsiteGenerator())); 61 | Add(new Map() 62 | .Matching(info => info.Name.ToLower() == "city") 63 | .Using(new AmericanCityGenerator())); 64 | Add(new Map() 65 | .Matching(info => info.Name.ToLower() == "state") 66 | .Using(new AmericanStateGenerator())); 67 | Add(new Map() 68 | .Matching(info => info.Name.ToLower() == "company" || 69 | info.Name.ToLower() == "business" || 70 | info.Name.ToLower() == "companyname") 71 | .Using(new CompanyNameGenerator())); 72 | Add(new Map() 73 | .Matching(info => info.Name.ToLower() 74 | .Contains("descri")).Using(new TextGenerator(25))); 75 | Add(new Map() 76 | .Matching(info => info.Name.ToLower().Contains("phone")).Using( 77 | new AmericanPhoneGenerator())); 78 | Add(new Map() 79 | .Matching(info => info.Name.ToLower().Contains("zip") || info.Name.ToLower().Contains("postal")) 80 | .Using(new AmericanPostalCodeGenerator(25))); 81 | Add(new Map().Using(new TextGenerator(50))); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/EnumMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | using System.Reflection; 4 | using Foundation.ObjectHydrator.Generators; 5 | 6 | namespace Foundation.ObjectHydrator 7 | { 8 | public class EnumMap:IMap 9 | { 10 | 11 | #region IMap Members 12 | 13 | Type IMap.Type 14 | { 15 | get { return typeof(object); } 16 | } 17 | 18 | bool IMap.Match(PropertyInfo info) 19 | { 20 | return info.PropertyType.IsEnum; 21 | } 22 | 23 | IMapping IMap.Mapping(PropertyInfo info) 24 | { 25 | return new Mapping(info, new EnumGenerator(Enum.GetValues(info.PropertyType))); 26 | } 27 | 28 | #endregion 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Foundation.ObjectHydrator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA} 9 | Library 10 | Properties 11 | Foundation.ObjectHydrator 12 | Foundation.ObjectHydrator 13 | v4.5 14 | 512 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 3.5 26 | 27 | publish\ 28 | true 29 | Disk 30 | false 31 | Foreground 32 | 7 33 | Days 34 | false 35 | false 36 | true 37 | 0 38 | 1.0.0.%2a 39 | false 40 | false 41 | true 42 | 43 | 44 | 45 | true 46 | full 47 | false 48 | bin\Debug\ 49 | DEBUG;TRACE 50 | prompt 51 | 4 52 | AllRules.ruleset 53 | false 54 | 55 | 56 | pdbonly 57 | true 58 | bin\Release\ 59 | TRACE 60 | prompt 61 | 4 62 | AllRules.ruleset 63 | false 64 | 65 | 66 | 67 | 68 | 69 | 3.5 70 | 71 | 72 | 3.5 73 | 74 | 75 | 3.5 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | Always 136 | 137 | 138 | 139 | 140 | 141 | False 142 | .NET Framework 3.5 SP1 Client Profile 143 | false 144 | 145 | 146 | False 147 | .NET Framework 3.5 SP1 148 | true 149 | 150 | 151 | False 152 | Windows Installer 3.1 153 | true 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | REM Create a NuGet package for this project and place the .nupkg file in the project's output directory. 167 | REM If you see this in Visual Studio's Error List window, check the Output window's Build tab for the actual error. 168 | ECHO Creating NuGet package in Post-Build event... 169 | PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '$(ProjectDir)_CreateNewNuGetPackage\DoNotModify\CreateNuGetPackage.ps1' -ProjectFilePath '$(ProjectPath)' -OutputDirectory '$(TargetDir)' -BuildConfiguration '$(ConfigurationName)' -BuildPlatform '$(PlatformName)'" 170 | 171 | 178 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/AlphaNumericGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class AlphaNumericGenerator : IGenerator 8 | { 9 | Random random; 10 | private int stringLength; 11 | 12 | public AlphaNumericGenerator(int length) 13 | { 14 | random = RandomSingleton.Instance.Random; 15 | stringLength = length; 16 | } 17 | 18 | public string Generate() 19 | { 20 | var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 21 | 22 | var result = new string( 23 | Enumerable.Repeat(chars, stringLength) 24 | .Select(s => s[random.Next(s.Length)]) 25 | .ToArray()); 26 | 27 | return result; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/AmericanCityGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | /// 8 | /// Produces a random American City 9 | /// 10 | public class AmericanCityGenerator:IGenerator 11 | { 12 | /// 13 | /// Instance of Random Singleton 14 | /// 15 | Random random; 16 | 17 | /// 18 | /// Local var for citynames 19 | /// 20 | IList citynames = new List(); 21 | 22 | /// 23 | /// Default Constructor 24 | /// 25 | public AmericanCityGenerator() 26 | { 27 | random = RandomSingleton.Instance.Random; 28 | LoadCityNames(); 29 | } 30 | 31 | /// 32 | /// Populates the citynames list with names of cities 33 | /// 34 | private void LoadCityNames() 35 | { 36 | citynames = new List() { "indianapolis", 37 | "portland", 38 | "los angeles", 39 | "grand rapids", 40 | "houston", 41 | "columbus", 42 | "albuquerque", 43 | "phoenix", 44 | "nashville", 45 | "springfield", 46 | "chicago", 47 | "charlotte", 48 | "san antonio", 49 | "austin", 50 | "louisville", 51 | "seattle", 52 | "jacksonville", 53 | "new york", 54 | "las vegas", 55 | "colorado springs", 56 | "orlando", 57 | "madison", 58 | "evansville", 59 | "santa ana", 60 | "omaha", 61 | "brooklyn", 62 | "san diego", 63 | "newark", 64 | "dallas", 65 | "lexington", 66 | "dayton", 67 | "wilmington", 68 | "washington", 69 | "miami", 70 | "cincinnati", 71 | "columbia", 72 | "tacoma", 73 | "milwaukee", 74 | "philadelphia", 75 | "richmond", 76 | "bakersfield", 77 | "fort wayne", 78 | "baltimore", 79 | "pittsburgh", 80 | "arlington", 81 | "long beach", 82 | "wichita", 83 | "san francisco", 84 | "jackson", 85 | "toledo", 86 | "muskegon", 87 | "terre haute", 88 | "san jose", 89 | "salem", 90 | "atlanta", 91 | "lancaster", 92 | "greenville", 93 | "fort worth", 94 | "huntington beach", 95 | "greensboro", 96 | "tucson", 97 | "franklin", 98 | "vancouver", 99 | "akron", 100 | "huntington", 101 | "minneapolis", 102 | "marion", 103 | "orange", 104 | "denver", 105 | "rochester", 106 | "mesa", 107 | "tampa", 108 | "lafayette", 109 | "cleveland", 110 | "spokane", 111 | "bloomington", 112 | "lebanon", 113 | "kansas city", 114 | "el paso", 115 | "anaheim", 116 | "aurora", 117 | "peoria", 118 | "battle creek", 119 | "glendale", 120 | "lakewood", 121 | "canton", 122 | "monroe", 123 | "lincoln", 124 | "oklahoma city", 125 | "alexandria", 126 | "henderson", 127 | "cedar rapids", 128 | "memphis", 129 | "knoxville", 130 | "wyoming", 131 | "charleston", 132 | "irvine", 133 | "rockford", 134 | "sacramento", 135 | "des moines", 136 | "marietta", 137 | "middletown", 138 | "clarksville", 139 | "anderson", 140 | "ashland", 141 | "bellevue", 142 | "auburn", 143 | "shreveport", 144 | "raleigh", 145 | "hillsboro", 146 | "clinton", 147 | "westminster", 148 | "cape coral", 149 | "chattanooga", 150 | "tulsa", 151 | "beaverton", 152 | "traverse city", 153 | "beaumont", 154 | "athens", 155 | "decatur", 156 | "naples", 157 | "eugene", 158 | "garden grove", 159 | "reading", 160 | "manchester", 161 | "albany", 162 | "lansing", 163 | "riverside", 164 | "savannah", 165 | "fullerton", 166 | "gainesville", 167 | "bronx", 168 | "lakeland", 169 | "fremont", 170 | "buffalo", 171 | "fort myers", 172 | "costa mesa", 173 | "chandler", 174 | "fayetteville", 175 | "burlington", 176 | "dover", 177 | "st. louis", 178 | "tallahassee", 179 | "scottsdale", 180 | "holland", 181 | "new castle", 182 | "bowling green", 183 | "olympia", 184 | "greenwood", 185 | "pasadena", 186 | "kalamazoo", 187 | "murfreesboro", 188 | "oakland", 189 | "plano", 190 | "mobile", 191 | "norwalk", 192 | "fredericksburg", 193 | "concord", 194 | "sarasota", 195 | "troy", 196 | "york", 197 | "flint", 198 | "roanoke", 199 | "hendersonville", 200 | "santa rosa", 201 | "mansfield", 202 | "covington", 203 | "georgetown", 204 | "corpus christi", 205 | "medford", 206 | "elkhart", 207 | "smyrna", 208 | "danville", 209 | "huntsville", 210 | "davenport", 211 | "florence", 212 | "greenfield", 213 | "cambridge", 214 | "lawrenceville", 215 | "kent", 216 | "kenosha", 217 | "mount vernon", 218 | "milford", 219 | "shelbyville", 220 | "birmingham", 221 | "rio rancho", 222 | "montgomery", 223 | "hamilton", 224 | "hudson", 225 | "fresno", 226 | "harrisburg", 227 | "bradenton", 228 | "warren", 229 | "carmel", 230 | "independence", 231 | "pensacola", 232 | "yakima", 233 | "saint paul", 234 | "bedford", 235 | "st. paul", 236 | "plymouth", 237 | "mission viejo", 238 | "ocala", 239 | "iowa city", 240 | "kentwood", 241 | "gilbert", 242 | "augusta", 243 | "tempe", 244 | "virginia beach", 245 | "littleton", 246 | "frankfort", 247 | "oxford", 248 | "plainfield", 249 | "winchester", 250 | "winston salem", 251 | "noblesville", 252 | "puyallup", 253 | "south bend", 254 | "wooster", 255 | "baton rouge", 256 | "everett", 257 | "antioch", 258 | "carrollton", 259 | "lima", 260 | "silver spring", 261 | "durham", 262 | "chillicothe", 263 | "tyler", 264 | "marysville", 265 | "spring hill", 266 | "bristol", 267 | "sioux city", 268 | "racine", 269 | "fairfield", 270 | "marshall", 271 | "lowell", 272 | "oceanside", 273 | "torrance", 274 | "brunswick", 275 | "portage", 276 | "milton", 277 | "spring", 278 | "newport", 279 | "adrian", 280 | "englewood", 281 | "garland", 282 | "billings", 283 | "stockton", 284 | "sanford", 285 | "tustin", 286 | "muncie", 287 | "corona", 288 | "longview", 289 | "waukesha", 290 | "salisbury", 291 | "brandon", 292 | "leesburg", 293 | "hastings", 294 | "princeton", 295 | "farmington", 296 | "appleton", 297 | "elgin", 298 | "quincy", 299 | "denton", 300 | "sandusky", 301 | "detroit", 302 | "summerville", 303 | "duluth", 304 | "saint louis", 305 | "sparta", 306 | "west chester", 307 | "medina", 308 | "midland", 309 | "roswell", 310 | "gig harbor", 311 | "little rock", 312 | "topeka", 313 | "whittier", 314 | "boston", 315 | "johnstown", 316 | "asheville", 317 | "grandville", 318 | "woodstock", 319 | "somerset", 320 | "newburgh", 321 | "gastonia", 322 | "lake forest", 323 | "pueblo", 324 | "newton", 325 | "melbourne", 326 | "bend", 327 | "paris", 328 | "centerville", 329 | "roseville", 330 | "chester", 331 | "katy", 332 | "martinsville", 333 | "germantown", 334 | "green bay", 335 | "mooresville", 336 | "bellingham", 337 | "grand haven", 338 | "belmont", 339 | "clayton", 340 | "west palm beach", 341 | "kissimmee", 342 | "lake charles", 343 | "conway", 344 | "dublin", 345 | "fishers", 346 | "winston-salem", 347 | "hampton", 348 | "irving", 349 | "clearwater", 350 | "ashtabula", 351 | "rockville", 352 | "kokomo", 353 | "new orleans", 354 | "monticello", 355 | "great falls", 356 | "erie", 357 | "thomasville", 358 | "lawrence", 359 | "janesville", 360 | "santa fe", 361 | "missoula", 362 | "cumming", 363 | "naperville", 364 | "burbank", 365 | "sioux falls", 366 | "frederick", 367 | "overland park", 368 | "renton", 369 | "lubbock", 370 | "brentwood", 371 | "gresham", 372 | "trenton", 373 | "abilene", 374 | "jamestown", 375 | "liberty", 376 | "delaware", 377 | "allentown", 378 | "cypress", 379 | "port charlotte", 380 | "honolulu", 381 | "watertown", 382 | "chesapeake", 383 | "federal way", 384 | "palm bay", 385 | "high point", 386 | "amarillo", 387 | "jenison", 388 | "alpharetta", 389 | "macon", 390 | "midlothian", 391 | "lehigh acres", 392 | "westfield", 393 | "avon", 394 | "boise", 395 | "loveland", 396 | "port orchard", 397 | "hollywood", 398 | "redmond", 399 | "mckinney", 400 | "greensburg", 401 | "lawrenceburg", 402 | "goshen", 403 | "elkton", 404 | "hermitage", 405 | "palmdale", 406 | "round rock", 407 | "lagrange", 408 | "norman", 409 | "cookeville", 410 | "belleville", 411 | "modesto", 412 | "magnolia", 413 | "morgantown", 414 | "amherst", 415 | "newport beach", 416 | "san marcos", 417 | "fountain valley", 418 | "fairfax", 419 | "panama city", 420 | "elyria", 421 | "bridgeport", 422 | "charlottesville", 423 | "owensboro", 424 | "boca raton", 425 | "warsaw", 426 | "shelby", 427 | "deltona", 428 | "woodbridge", 429 | "milwaukie", 430 | "wayne", 431 | "williamsburg", 432 | "cary", 433 | "harrison", 434 | "stafford", 435 | "benton", 436 | "waco", 437 | "mcminnville", 438 | "sterling", 439 | "gaithersburg", 440 | "bremerton", 441 | "pekin", 442 | "urbana", 443 | "kingston", 444 | "woodbury", 445 | "west lafayette", 446 | "buena park", 447 | "graham", 448 | "elizabethtown", 449 | "shelton", 450 | "jefferson", 451 | "saginaw", 452 | "rock hill", 453 | "laguna niguel", 454 | "grand junction", 455 | "mesquite", 456 | "bossier city", 457 | "laurel", 458 | "apple valley", 459 | "hudsonville", 460 | "camden", 461 | "joliet", 462 | "reno", 463 | "jonesboro", 464 | "norfolk", 465 | "richardson", 466 | "geneva", 467 | "zanesville", 468 | "sunnyvale", 469 | "whitehall", 470 | "santa monica", 471 | "westerville", 472 | "ravenna", 473 | "butler", 474 | "sullivan", 475 | "staten island", 476 | "las cruces", 477 | "findlay", 478 | "brighton", 479 | "lewisburg", 480 | "new haven", 481 | "moline", 482 | "st. petersburg", 483 | "", 484 | "sherman oaks", 485 | "mount pleasant", 486 | "van nuys", 487 | "batavia", 488 | "edmond", 489 | "kettering", 490 | "gallatin", 491 | "yorba linda", 492 | "lynchburg", 493 | "portsmouth", 494 | "chesterfield", 495 | "west monroe", 496 | "council bluffs", 497 | "xenia", 498 | "san pedro", 499 | "escondido", 500 | "port huron", 501 | "st paul", 502 | "bryan", 503 | "jasper", 504 | "carlsbad", 505 | "hanover", 506 | "corvallis", 507 | "olathe", 508 | "flushing", 509 | "albion", 510 | "redondo beach", 511 | "mishawaka", 512 | "simpsonville", 513 | "salt lake city", 514 | "chula vista", 515 | "richland", 516 | "oregon city", 517 | "acworth", 518 | "seymour", 519 | "warner robins", 520 | "carlisle", 521 | "spanaway", 522 | "lake city", 523 | "astoria", 524 | "manassas", 525 | "lawton", 526 | "santa cruz", 527 | "new albany", 528 | "sheboygan", 529 | "waynesboro", 530 | "glasgow", 531 | "bear", 532 | "coon rapids", 533 | "brazil", 534 | "tigard", 535 | "odessa", 536 | "placentia", 537 | "weatherford", 538 | "wellington", 539 | "jeffersonville", 540 | "goodlettsville", 541 | "spencer", 542 | "waterloo", 543 | "muscatine", 544 | "grand prairie", 545 | "stillwater", 546 | "ada", 547 | "spartanburg", 548 | "myrtle beach", 549 | "hixson", 550 | "conroe", 551 | "yuma", 552 | "killeen", 553 | "perry", 554 | "vista", 555 | "pittsfield", 556 | "east peoria", 557 | "sheridan", 558 | "broken arrow", 559 | "worcester", 560 | "mason", 561 | "hammond", 562 | "tiffin", 563 | "hartford", 564 | "temple", 565 | "powell", 566 | "apopka", 567 | "freeport", 568 | "kennesaw", 569 | "lodi", 570 | "hagerstown", 571 | "matthews", 572 | "sidney", 573 | "surprise", 574 | "maryville", 575 | "centralia", 576 | "grove city", 577 | "west allis", 578 | "fort lauderdale", 579 | "union city", 580 | "london", 581 | "coldwater", 582 | "valparaiso", 583 | "waterford", 584 | "paducah", 585 | "ann arbor", 586 | "hutchinson", 587 | "caledonia", 588 | "arcadia", 589 | "spring lake", 590 | "statesville", 591 | "kingsport", 592 | "falls church", 593 | "san bernardino", 594 | "anchorage", 595 | "orange park", 596 | "hot springs", 597 | "berwyn", 598 | "bethesda", 599 | "petaluma", 600 | "san clemente", 601 | "ames", 602 | "el cajon", 603 | "lewiston", 604 | "greer", 605 | "somerville", 606 | "parker", 607 | "lacey", 608 | "lewisville", 609 | "ventura", 610 | "andover", 611 | "fairview", 612 | "aliso viejo", 613 | "fontana", 614 | "kernersville", 615 | "altoona", 616 | "eagan", 617 | "largo", 618 | "fond du lac", 619 | "windsor", 620 | "livingston", 621 | "west bend", 622 | "lumberton", 623 | "brookfield", 624 | "petersburg", 625 | "new port richey", 626 | "brownsville", 627 | "brownsburg", 628 | "rock island", 629 | "shawnee", 630 | "waverly", 631 | "asheboro", 632 | "uniontown", 633 | "youngstown", 634 | "grants pass", 635 | "lockport", 636 | "berea", 637 | "pottstown", 638 | "ontario", 639 | "vidor", 640 | "easley", 641 | "coatesville", 642 | "hickory", 643 | "ephrata", 644 | "elk grove", 645 | "russellville", 646 | "carson", 647 | "douglasville", 648 | "lufkin", 649 | "prescott", 650 | "brea", 651 | "humble", 652 | "chapel hill", 653 | "north hollywood", 654 | "mt. pleasant", 655 | "fort collins", 656 | "beavercreek", 657 | "union", 658 | "eden", 659 | "new london", 660 | "cottage grove", 661 | "lincolnton", 662 | "boynton beach", 663 | "fenton", 664 | "arvada", 665 | "martinez", 666 | "aberdeen", 667 | "st louis", 668 | "defiance", 669 | "stratford", 670 | "clovis", 671 | "la habra", 672 | "visalia", 673 | "dalton", 674 | "miamisburg", 675 | "st. charles", 676 | "deland", 677 | "jersey city", 678 | "stone mountain", 679 | "niles", 680 | "downingtown", 681 | "eureka", 682 | "cuyahoga falls", 683 | "stanton", 684 | "berkeley", 685 | "nicholasville", 686 | "beloit", 687 | "coral springs", 688 | "hayward", 689 | "bloomfield", 690 | "homestead", 691 | "weston", 692 | "annapolis", 693 | "burleson", 694 | "frisco", 695 | "venice", 696 | "ringgold", 697 | "newport news", 698 | "aloha", 699 | "sherman", 700 | "winter haven", 701 | "carthage", 702 | "slidell", 703 | "bothell", 704 | "mount airy", 705 | "phoenixville", 706 | "belton", 707 | "bartlett", 708 | "galesburg", 709 | "dickson", 710 | "palmyra", 711 | "blaine", 712 | "simi valley", 713 | "west des moines", 714 | "mcdonough", 715 | "oshkosh", 716 | "cedar springs", 717 | "champaign", 718 | "pulaski", 719 | "maple grove", 720 | "allendale", 721 | "queen creek", 722 | "ft. myers", 723 | "valrico", 724 | "pearland", 725 | "parma", 726 | "maplewood", 727 | "baytown", 728 | "easton", 729 | "oregon", 730 | "lynnwood", 731 | "webster", 732 | "highland", 733 | "merced", 734 | "pomona", 735 | "old hickory", 736 | "upland", 737 | "peru", 738 | "boone", 739 | "hamburg", 740 | "reidsville", 741 | "piqua", 742 | "moreno valley", 743 | "cordova", 744 | "riverview", 745 | "lake worth", 746 | "grafton", 747 | "rossville", 748 | "texarkana", 749 | "bethlehem", 750 | "hesperia", 751 | "palm coast", 752 | "rome", 753 | "wheeling", 754 | "granbury", 755 | "dubuque", 756 | "silsbee", 757 | "kennewick", 758 | "sun prairie", 759 | "milan", 760 | "columbia city", 761 | "crawfordsville", 762 | "mechanicsburg", 763 | "centennial", 764 | "bettendorf", 765 | "taylorsville", 766 | "port angeles", 767 | "utica", 768 | "beaufort", 769 | "johnson city", 770 | "orrville", 771 | "victoria", 772 | "valdosta", 773 | "maple valley", 774 | "rancho santa margarita", 775 | "bowie", 776 | "cocoa", 777 | "punta gorda", 778 | "stockbridge", 779 | "keller", 780 | "comstock park", 781 | "trinity", 782 | "moore", 783 | "ionia", 784 | "oak harbor", 785 | "mechanicsville", 786 | "collinsville", 787 | "north las vegas", 788 | "schenectady", 789 | "garden city", 790 | "morton", 791 | "wadsworth", 792 | "burton", 793 | "providence", 794 | "newnan", 795 | "indpls", 796 | "laguna hills", 797 | "malvern", 798 | "north fort myers", 799 | "martinsburg", 800 | "morristown", 801 | "plant city", 802 | "allen", 803 | "huron", 804 | "east lansing", 805 | "florissant", 806 | "longwood", 807 | "syracuse", 808 | "massillon", 809 | "cedar park", 810 | "santa barbara", 811 | "zeeland", 812 | "phila", 813 | "metairie", 814 | "euless", 815 | "sherwood", 816 | "saint charles", 817 | "salina", 818 | "lake oswego", 819 | "middleburg", 820 | "lorain", 821 | "bay city", 822 | "smithville", 823 | "linton", 824 | "college station", 825 | "northridge", 826 | "woodland", 827 | "altamonte springs", 828 | "bolingbrook", 829 | "keizer", 830 | "cumberland", 831 | "crossville", 832 | "williamstown", 833 | "conyers", 834 | "boonville", 835 | "oak park", 836 | "cadillac", 837 | "saint petersburg", 838 | "claremont", 839 | "snellville", 840 | "laredo", 841 | "new braunfels", 842 | "kirkland", 843 | "hurst", 844 | "pendleton", 845 | "linden", 846 | "staunton", 847 | "nampa", 848 | "gulfport", 849 | "salinas", 850 | "west covina", 851 | "flagstaff", 852 | "sugar land", 853 | "avondale", 854 | "moses lake", 855 | "elizabeth", 856 | "brooksville", 857 | "kingman", 858 | "oakdale", 859 | "mt. vernon", 860 | "brookville", 861 | "ironton", 862 | "fairborn", 863 | "perrysburg", 864 | "delray beach", 865 | "oxnard", 866 | "derby", 867 | "woodland hills", 868 | "santa clara", 869 | "normal", 870 | "gardena", 871 | "temecula", 872 | "vincennes", 873 | "fairmont", 874 | "san angelo", 875 | "forest grove", 876 | "klamath falls", 877 | "ottawa", 878 | "byron center", 879 | "waynesville", 880 | "norcross", 881 | "nashua", 882 | "fort smith", 883 | "nederland", 884 | "vienna", 885 | "oviedo", 886 | "chatsworth", 887 | "clifton", 888 | "helena", 889 | "hilliard", 890 | "ellensburg", 891 | "montrose", 892 | "pineville", 893 | "deridder", 894 | "mountain view", 895 | "cherry hill", 896 | "tinley park", 897 | "elkhorn", 898 | "davie", 899 | "gladstone", 900 | "port orange", 901 | "hawthorne", 902 | "plantation", 903 | "big rapids", 904 | "versailles" }; 905 | } 906 | 907 | public string Generate() 908 | { 909 | return citynames[random.Next(0, citynames.Count)]; 910 | } 911 | } 912 | } 913 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/AmericanPhoneGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class AmericanPhoneGenerator:IGenerator 8 | { 9 | Random random; 10 | 11 | public AmericanPhoneGenerator() 12 | { 13 | random = RandomSingleton.Instance.Random; 14 | } 15 | 16 | public string Generate() 17 | { 18 | StringBuilder sb = new StringBuilder(); 19 | sb.Append("("); 20 | int areacodefirstpart = (int)random.Next(2, 9); 21 | sb.Append(areacodefirstpart.ToString()); 22 | int areacode = (int)random.Next(0, 99); 23 | if (areacode < 10) 24 | { 25 | areacode += 10; 26 | } 27 | sb.Append(areacode.ToString()); 28 | sb.Append(")"); 29 | int prefixfirstpart = (int)random.Next(2, 9); 30 | sb.Append(prefixfirstpart.ToString()); 31 | int prefix = (int)random.Next(0, 99); 32 | if (prefix < 10) 33 | { 34 | prefix += 10; 35 | } 36 | sb.Append(prefix.ToString()); 37 | sb.Append("-"); 38 | int suffix = random.Next(0000, 9999); 39 | if (suffix < 1000) 40 | { 41 | suffix = suffix + 1000; 42 | } 43 | sb.Append(suffix.ToString()); 44 | return sb.ToString(); 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/AmericanPostalCodeGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class AmericanPostalCodeGenerator:IGenerator 7 | { 8 | Random random; 9 | public int PercentageWithPlusFour { get; private set; } 10 | 11 | public AmericanPostalCodeGenerator(int percentageWithPlusFour) 12 | { 13 | PercentageWithPlusFour = percentageWithPlusFour; 14 | 15 | random = RandomSingleton.Instance.Random; 16 | } 17 | 18 | public string Generate() 19 | { 20 | string plusFour = String.Empty; 21 | 22 | if (PercentageWithPlusFour > 0 && random.Next(0, 100) % (100 / PercentageWithPlusFour) == 0) 23 | { 24 | plusFour = String.Format("-{0:0000}", random.Next(1, 9999)); 25 | } 26 | 27 | return String.Format("{0:00000}{1}", 28 | random.Next(501, 99950), 29 | plusFour).ToString(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/AmericanStateGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class AmericanStateGenerator : IGenerator 8 | { 9 | private readonly Random random; 10 | private IList states = new List(); 11 | 12 | public AmericanStateGenerator() 13 | { 14 | random = RandomSingleton.Instance.Random; 15 | LoadStates(); 16 | } 17 | 18 | #region IGenerator Members 19 | 20 | public string Generate() 21 | { 22 | return states[random.Next(0, states.Count)]; 23 | } 24 | 25 | #endregion 26 | 27 | private void LoadStates() 28 | { 29 | states = new List 30 | { 31 | "AK", 32 | "AL", 33 | "AP", 34 | "AR", 35 | "AS", 36 | "AZ", 37 | "CA", 38 | "CO", 39 | "CT", 40 | "DC", 41 | "DE", 42 | "FL", 43 | "FM", 44 | "GA", 45 | "GU", 46 | "HI", 47 | "IA", 48 | "ID", 49 | "IL", 50 | "IN", 51 | "KS", 52 | "KY", 53 | "LA", 54 | "MA", 55 | "MD", 56 | "ME", 57 | "MH", 58 | "MI", 59 | "MN", 60 | "MO", 61 | "MP", 62 | "MS", 63 | "MT", 64 | "NC", 65 | "ND", 66 | "NE", 67 | "NH", 68 | "NJ", 69 | "NM", 70 | "NV", 71 | "NY", 72 | "OH", 73 | "OK", 74 | "OR", 75 | "PA", 76 | "PR", 77 | "PW", 78 | "RI", 79 | "SC", 80 | "SD", 81 | "TN", 82 | "TX", 83 | "UT", 84 | "VA", 85 | "VI", 86 | "VT", 87 | "WA", 88 | "WV", 89 | "WI", 90 | "WY" 91 | }; 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/ArrayGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class ArrayGenerator : ListGenerator 8 | { 9 | public ArrayGenerator(int length, IGenerator elementGenerator = null) : base(length, elementGenerator) 10 | { 11 | } 12 | 13 | public override IList Generate() 14 | { 15 | return base.Generate().ToArray(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/BooleanGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class BooleanGenerator : IGenerator 7 | { 8 | private readonly Random random; 9 | 10 | public BooleanGenerator() 11 | { 12 | random = RandomSingleton.Instance.Random; 13 | } 14 | 15 | #region IGenerator Members 16 | 17 | public bool Generate() 18 | { 19 | return Convert.ToBoolean(random.Next(0, 2)); 20 | } 21 | 22 | #endregion 23 | } 24 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/ByteArrayGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class ByteArrayGenerator : IGenerator 7 | { 8 | Random random; 9 | public int Length { get; set; } 10 | 11 | public ByteArrayGenerator() 12 | : this(8) 13 | { 14 | 15 | } 16 | 17 | public ByteArrayGenerator(int length) 18 | { 19 | random = RandomSingleton.Instance.Random; 20 | Length = length; 21 | } 22 | 23 | #region IGenerator Members 24 | 25 | public byte[] Generate() 26 | { 27 | byte[] toReturn = new byte[Length]; 28 | 29 | random.NextBytes(toReturn); 30 | 31 | return toReturn; 32 | } 33 | 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/CCVGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class CCVGenerator:IGenerator 7 | { 8 | Random random; 9 | public string CCVType { get; set; } 10 | public CCVGenerator(string ccvtype) 11 | { 12 | random = RandomSingleton.Instance.Random; 13 | CCVType = ccvtype; 14 | } 15 | 16 | public string Generate() 17 | { 18 | int ccv = random.Next(0, 999); 19 | if (ccv < 100) 20 | { 21 | ccv += 100; 22 | } 23 | return ccv.ToString(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/CompanyNameGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class CompanyNameGenerator:IGenerator 8 | { 9 | Random random; 10 | IList companynames = new List(); 11 | 12 | public CompanyNameGenerator() 13 | { 14 | random = RandomSingleton.Instance.Random; 15 | LoadNames(); 16 | } 17 | 18 | public string Generate() 19 | { 20 | return companynames[random.Next(0, companynames.Count)]; 21 | } 22 | 23 | private void LoadNames() 24 | { 25 | companynames = new List { 26 | "Acme, inc.", 27 | "Widget Corp", 28 | "123 Warehousing", 29 | "Demo Company", 30 | "Smith and Co.", 31 | "Foo Bars", 32 | "ABC Telecom", 33 | "Fake Brothers", 34 | "QWERTY Logistics", 35 | "Demo, inc.", 36 | "Sample Company", 37 | "Sample, inc", 38 | "Acme Corp", 39 | "Allied Biscuit", 40 | "Ankh-Sto Associates", 41 | "Extensive Enterprise", 42 | "Galaxy Corp", 43 | "Globo-Chem", 44 | "Mr. Sparkle", 45 | "Globex Corporation", 46 | "LexCorp", 47 | "LuthorCorp", 48 | "North Central Positronics", 49 | "Omni Consimer Products", 50 | "Praxis Corporation", 51 | "Sombra Corporation", 52 | "Sto Plains Holdings", 53 | "Tessier-Ashpool", 54 | "Wayne Enterprises", 55 | "Wentworth Industries", 56 | "ZiffCorp", 57 | "Bluth Company", 58 | "Strickland Propane", 59 | "Thatherton Fuels", 60 | "Three Waters", 61 | "Water and Power", 62 | "Western Gas & Electric", 63 | "Mammoth Pictures", 64 | "Mooby Corp", 65 | "Gringotts", 66 | "Thrift Bank", 67 | "Flowers By Irene", 68 | "The Businessmens Club", 69 | "Osato Chemicals", 70 | "Transworld Consortium", 71 | "Universal Export", 72 | "United Fried Chicken", 73 | "Virtucon", 74 | "Kumatsu Motors", 75 | "Keedsler Motors", 76 | "Powell Motors", 77 | "Industrial Automation", 78 | "Sirius Cybernetics Corporation", 79 | "U.S. Robotics and Mechanical Men", 80 | "Colonial Movers", 81 | "Corellian Engineering Corporation", 82 | "Incom Corporation", 83 | "General Products", 84 | "Leeding Engines Ltd.", 85 | "Blammo", 86 | "Input, Inc.", 87 | "Mainway Toys", 88 | "Videlectrix", 89 | "Zevo Toys", 90 | "Ajax", 91 | "Axis Chemical Co.", 92 | "Barrytron", 93 | "Carrys Candles", 94 | "Cogswell Cogs", 95 | "Spacely Sprockets", 96 | "General Forge and Foundry", 97 | "Duff Brewing Company", 98 | "Dunder Mifflin", 99 | "General Services Corporation", 100 | "Monarch Playing Card Co.", 101 | "Krustyco", 102 | "Initech", 103 | "Roboto Industries", 104 | "Primatech", 105 | "Sonky Rubber Goods", 106 | "St. Anky Beer", 107 | "Stay Puft Corporation", 108 | "Vandelay Industries", 109 | "Wernham Hogg", 110 | "Gadgetron", 111 | "Burleigh and Stronginthearm", 112 | "BLAND Corporation", 113 | "Nordyne Defense Dynamics", 114 | "Petrox Oil Company", 115 | "Roxxon", 116 | "McMahon and Tate", 117 | "Sixty Second Avenue", 118 | "Charles Townsend Agency", 119 | "Spade and Archer", 120 | "Megadodo Publications", 121 | "Rouster and Sideways", 122 | "C.H. Lavatory and Sons", 123 | "Globo Gym American Corp", 124 | "The New Firm", 125 | "SpringShield", 126 | "Compuglobalhypermeganet", 127 | "Data Systems", 128 | "Gizmonic Institute", 129 | "Initrode", 130 | "Taggart Transcontinental", 131 | "Atlantic Northern", 132 | "Niagular", 133 | "Plow King", 134 | "Big Kahuna Burger", 135 | "Big T Burgers and Fries", 136 | "Chez Quis", 137 | "Chotchkies", 138 | "The Frying Dutchman", 139 | "Klimpys", 140 | "The Krusty Krab", 141 | "Monks Diner", 142 | "Milliways", 143 | "Minuteman Cafe", 144 | "Taco Grande", 145 | "Tip Top Cafe", 146 | "Moes Tavern", 147 | "Central Perk", 148 | "Chasers" 149 | }; 150 | } 151 | 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/CountryCodeGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class CountryCodeGenerator : IGenerator 7 | { 8 | 9 | private IList countrycodes = new List(); 10 | 11 | public CountryCodeGenerator() 12 | { 13 | 14 | LoadCountryCodes(); 15 | } 16 | 17 | public string Generate() 18 | { 19 | return new FromListGetSingleGenerator(countrycodes).Generate(); 20 | } 21 | 22 | private void LoadCountryCodes() 23 | { 24 | countrycodes = new List() { 25 | "AD", 26 | "AE", 27 | "AG", 28 | "AI", 29 | "AL", 30 | "AN", 31 | "AP", 32 | "AR", 33 | "AS", 34 | "AS", 35 | "AT", 36 | "AU", 37 | "AW", 38 | "BB", 39 | "BC", 40 | "BD", 41 | "BE", 42 | "BF", 43 | "BG", 44 | "BH", 45 | "BI", 46 | "BJ", 47 | "BL", 48 | "BM", 49 | "BN", 50 | "BO", 51 | "BR", 52 | "BW", 53 | "BY", 54 | "BZ", 55 | "CA", 56 | "CB", 57 | "CC", 58 | "CE", 59 | "CF", 60 | "CG", 61 | "CH", 62 | "CI", 63 | "CK", 64 | "CL", 65 | "CM", 66 | "CN", 67 | "CO", 68 | "CR", 69 | "CV", 70 | "CX", 71 | "CY", 72 | "CZ", 73 | "DE", 74 | "DJ", 75 | "DK", 76 | "DM", 77 | "DO", 78 | "DZ", 79 | "EC", 80 | "EE", 81 | "EG", 82 | "EN", 83 | "ER", 84 | "ES", 85 | "ET", 86 | "EU", 87 | "FI", 88 | "FJ", 89 | "FM", 90 | "FO", 91 | "FR", 92 | "GA", 93 | "GB", 94 | "GD", 95 | "GF", 96 | "GH", 97 | "GI", 98 | "GL", 99 | "GM", 100 | "GN", 101 | "GP", 102 | "GQ", 103 | "GR", 104 | "GT", 105 | "GU", 106 | "GW", 107 | "GY", 108 | "HK", 109 | "HN", 110 | "HO", 111 | "HR", 112 | "HT", 113 | "HU", 114 | "ID", 115 | "IE", 116 | "IL", 117 | "IN", 118 | "IQ", 119 | "IR", 120 | "IS", 121 | "IT", 122 | "JM", 123 | "JO", 124 | "JP", 125 | "KE", 126 | "KG", 127 | "KH", 128 | "KI", 129 | "KN", 130 | "KO", 131 | "KR", 132 | "KW", 133 | "KY", 134 | "KZ", 135 | "LA", 136 | "LB", 137 | "LC", 138 | "LI", 139 | "LK", 140 | "LR", 141 | "LS", 142 | "LT", 143 | "LU", 144 | "LV", 145 | "MA", 146 | "MB", 147 | "MC", 148 | "ME", 149 | "MG", 150 | "MH", 151 | "MK", 152 | "ML", 153 | "MM", 154 | "MO", 155 | "MP", 156 | "MQ", 157 | "MR", 158 | "MS", 159 | "MT", 160 | "MU", 161 | "MV", 162 | "MW", 163 | "MX", 164 | "MY", 165 | "MZ", 166 | "NA", 167 | "NB", 168 | "NC", 169 | "NE", 170 | "NF", 171 | "NG", 172 | "NI", 173 | "NL", 174 | "NN", 175 | "NO", 176 | "NP", 177 | "NT", 178 | "NU", 179 | "NV", 180 | "NZ", 181 | "OM", 182 | "PA", 183 | "PE", 184 | "PF", 185 | "PG", 186 | "PH", 187 | "PK", 188 | "PL", 189 | "PO", 190 | "PR", 191 | "PT", 192 | "PW", 193 | "PY", 194 | "QA", 195 | "RE", 196 | "RO", 197 | "RT", 198 | "RU", 199 | "RW", 200 | "SA", 201 | "SB", 202 | "SC", 203 | "SD", 204 | "SE", 205 | "SF", 206 | "SG", 207 | "SI", 208 | "SK", 209 | "SL", 210 | "SN", 211 | "SP", 212 | "SR", 213 | "SS", 214 | "SV", 215 | "SW", 216 | "SX", 217 | "SY", 218 | "SZ", 219 | "TA", 220 | "TB", 221 | "TC", 222 | "TD", 223 | "TG", 224 | "TH", 225 | "TI", 226 | "TJ", 227 | "TL", 228 | "TN", 229 | "TO", 230 | "TR", 231 | "TT", 232 | "TU", 233 | "TV", 234 | "TW", 235 | "TZ", 236 | "UA", 237 | "UG", 238 | "UI", 239 | "US", 240 | "UV", 241 | "UY", 242 | "UZ", 243 | "VC", 244 | "VE", 245 | "VG", 246 | "VI", 247 | "VL", 248 | "VN", 249 | "VR", 250 | "VU", 251 | "WF", 252 | "WK", 253 | "WL", 254 | "WS", 255 | "YA", 256 | "YE", 257 | "ZA", 258 | "ZM", 259 | "ZR", 260 | "ZW"}; 261 | } 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/CreditCardNumberGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class CreditCardNumberGenerator : IGenerator 8 | { 9 | public int Length { get; set; } 10 | private Random random; 11 | 12 | public CreditCardNumberGenerator() 13 | : this(13) 14 | { 15 | 16 | } 17 | public CreditCardNumberGenerator(int length) 18 | { 19 | random = RandomSingleton.Instance.Random; 20 | Length = length; 21 | } 22 | 23 | #region IGenerator Members 24 | 25 | public string Generate() 26 | { 27 | StringBuilder toReturn = new StringBuilder(); 28 | 29 | // Accumulator for the check digit calculation 30 | int accumulator = 0; 31 | 32 | // Counter to use with mod 2 to determine if the digit should be * by 2 when accumulating. 33 | int counter = 0; 34 | 35 | for (int i = 0; i < Length - 1; i++) 36 | { 37 | counter++; 38 | int digit = random.Next(0, 9); 39 | 40 | if (counter % 2 == 1) 41 | { 42 | accumulator += digit * 2; 43 | } 44 | else 45 | { 46 | accumulator += digit; 47 | } 48 | 49 | toReturn.Append(digit); 50 | } 51 | 52 | // Do the check digit part... 53 | toReturn.Append(9 - (accumulator % 10)); 54 | return toReturn.ToString(); 55 | } 56 | 57 | #endregion 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/CreditCardTypeGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class CreditCardTypeGenerator:IGenerator 8 | { 9 | 10 | public string Generate() 11 | { 12 | return 13 | new FromListGetSingleGenerator(new List 14 | { 15 | "MasterCard", 16 | "Visa", 17 | "Discover", 18 | "American Express" 19 | }) 20 | .Generate(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/CulturesGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public sealed class CulturesGenerator : IGenerator 8 | { 9 | readonly Func _propertyGetter; 10 | 11 | readonly Random _random = RandomSingleton.Instance.Random; 12 | 13 | public CulturesGenerator(Func propertyGetter) 14 | { 15 | _propertyGetter = propertyGetter; 16 | } 17 | 18 | public TProperty Generate() 19 | { 20 | var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); 21 | 22 | var next = _random.Next(0, cultures.Length - 1); 23 | 24 | CultureInfo culture = cultures[next]; 25 | 26 | return _propertyGetter(culture); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/DateTimeGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class DateTimeGenerator:IGenerator 7 | { 8 | Random random; 9 | public DateTime MinimumValue { get; private set; } 10 | public DateTime MaximumValue { get; private set; } 11 | 12 | public DateTimeGenerator() 13 | : this(DateTime.Now.AddYears(-10), DateTime.Now.AddYears(10)) 14 | { } 15 | 16 | 17 | public DateTimeGenerator(DateTime minimumValue, DateTime maximumValue) 18 | { 19 | MinimumValue=minimumValue; 20 | MaximumValue=maximumValue; 21 | 22 | random=RandomSingleton.Instance.Random; 23 | } 24 | 25 | public DateTime Generate() 26 | { 27 | TimeSpan timeSpan = MaximumValue - MinimumValue; 28 | int dayOffset = random.Next(0, timeSpan.Days); 29 | return MinimumValue.Date.AddDays(dayOffset) + new TimeSpan(random.Next(0, 24), random.Next(0, 59), random.Next(0, 59)); 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/DefaultGenerator.cs: -------------------------------------------------------------------------------- 1 | using Foundation.ObjectHydrator.Interfaces; 2 | 3 | namespace Foundation.ObjectHydrator.Generators 4 | { 5 | public class DefaultGenerator : IGenerator 6 | { 7 | public T DefaultValue { get; private set; } 8 | 9 | public DefaultGenerator(T defaultValue) 10 | { 11 | DefaultValue = defaultValue; 12 | } 13 | 14 | public T Generate() 15 | { 16 | return DefaultValue; 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/DoubleGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class DoubleGenerator:IGenerator 7 | { 8 | Random random; 9 | 10 | public double MinimumValue { get; set; } 11 | public double MaximumValue { get; set; } 12 | public int DecimalPlaces { get; set; } 13 | 14 | public DoubleGenerator() 15 | : this(0.0, 100) 16 | { } 17 | 18 | public DoubleGenerator(int decimalPlaces):this(0.0,100.00,decimalPlaces) 19 | { 20 | 21 | } 22 | 23 | public DoubleGenerator(double minimumValue, double maximumValue) 24 | : this(minimumValue, maximumValue, 2) 25 | { } 26 | 27 | 28 | public DoubleGenerator(double minimumValue, double maximumValue, int decimalPlaces) 29 | { 30 | if (minimumValue > maximumValue) 31 | { 32 | throw new ArgumentOutOfRangeException("minimumValue", minimumValue, "minimumValue must be <= maximumValue"); 33 | } 34 | 35 | if (decimalPlaces > 5) 36 | { 37 | throw new ArgumentOutOfRangeException("decimalPlaces", decimalPlaces, "decimalPlaces must be <=5;"); 38 | } 39 | 40 | MinimumValue = minimumValue; 41 | MaximumValue = maximumValue; 42 | DecimalPlaces = decimalPlaces; 43 | 44 | random = RandomSingleton.Instance.Random; 45 | } 46 | 47 | public double Generate() 48 | { 49 | double toReturn; 50 | double decimalPart; 51 | 52 | // The offset adjustment to get down to an Int minimum value 53 | double offset = MinimumValue - Math.Floor(MinimumValue); 54 | double adjustedMinimum = MinimumValue - offset; 55 | double adjustedMaximum = MaximumValue - offset; 56 | 57 | toReturn = random.Next((int)adjustedMinimum, (int)adjustedMaximum); 58 | decimalPart = random.NextDouble(); 59 | decimalPart *= Math.Pow(10, DecimalPlaces); 60 | decimalPart = (int)decimalPart; 61 | 62 | toReturn += decimalPart / Math.Pow(10, DecimalPlaces); 63 | 64 | // Now, add back the offset 65 | toReturn += offset; 66 | 67 | return toReturn; 68 | } 69 | 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/EmailAddressGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class EmailAddressGenerator:IGenerator 7 | { 8 | Random random; 9 | 10 | public EmailAddressGenerator() 11 | { 12 | random = RandomSingleton.Instance.Random; 13 | } 14 | 15 | private string GetPrefix(IGenerator fng, IGenerator lng) 16 | { 17 | int prefixtype = random.Next(0, 1); 18 | string prefix; 19 | if (prefixtype == 0) 20 | { 21 | prefix = String.Format("{0}_{1}", (string)fng.Generate(), (string)lng.Generate()); 22 | } 23 | else 24 | { 25 | prefix = (string)fng.Generate(); 26 | } 27 | return prefix; 28 | } 29 | private static string GetBizname(IGenerator cng) 30 | { 31 | string bizname = (string)cng.Generate(); 32 | bizname = bizname.Replace(".", ""); 33 | bizname = bizname.Replace(" ", ""); 34 | bizname = bizname.Replace(",", ""); 35 | return bizname; 36 | } 37 | public string Generate() 38 | { 39 | 40 | IGenerator fng = new FirstNameGenerator(); 41 | IGenerator lng = new LastNameGenerator(); 42 | IGenerator cng = new CompanyNameGenerator(); 43 | 44 | string prefix = GetPrefix(fng, lng); 45 | string bizname = GetBizname(cng); 46 | 47 | string[] suffix = new string[4] { ".com", ".net", ".org", ".info" }; 48 | int num = random.Next(0, suffix.Length - 1); 49 | string domaintype = suffix[num]; 50 | 51 | return String.Format("{0}@{1}{2}", prefix, bizname, domaintype); 52 | 53 | 54 | } 55 | 56 | 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/EnumGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class EnumGenerator:IGenerator 7 | { 8 | Random random; 9 | Array EnumValues; 10 | 11 | public EnumGenerator(Array enumValues) 12 | { 13 | EnumValues = enumValues; 14 | random = RandomSingleton.Instance.Random; 15 | 16 | } 17 | 18 | public object Generate() 19 | { 20 | return EnumValues.GetValue(random.Next(0, EnumValues.Length - 1)); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/FromListGenerator.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Foundation.ObjectHydrator.Interfaces; 6 | 7 | 8 | 9 | 10 | namespace Foundation.ObjectHydrator.Generators 11 | { 12 | public class FromListGenerator : IGenerator 13 | { 14 | readonly Random random; 15 | IEnumerable list = new List(); 16 | public FromListGenerator(IEnumerable list) 17 | { 18 | random = RandomSingleton.Instance.Random; 19 | this.list = list; 20 | } 21 | 22 | public T Generate() 23 | { 24 | return list.ElementAt(random.Next(0, list.Count())); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/FromListGetListGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class FromListGetListGenerator:IGenerator> 8 | { 9 | private readonly int listLength; 10 | public IEnumerable list = new List(); 11 | private IList newList = new List(); 12 | public FromListGetListGenerator(IEnumerable list, int count) 13 | { 14 | this.list = list; 15 | listLength = count; 16 | } 17 | 18 | public IList Generate() 19 | { 20 | for (int i = 0; i < listLength; i++) 21 | { 22 | if (i < list.Count()) 23 | { 24 | newList.Add(list.ElementAt(i)); 25 | } 26 | } 27 | return newList; 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/FromListGetSingleGenerator.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Foundation.ObjectHydrator.Interfaces; 6 | 7 | 8 | 9 | 10 | namespace Foundation.ObjectHydrator.Generators 11 | { 12 | public class FromListGetSingleGenerator : IGenerator 13 | { 14 | readonly Random random; 15 | IEnumerable list = new List(); 16 | public FromListGetSingleGenerator(IEnumerable list) 17 | { 18 | random = RandomSingleton.Instance.Random; 19 | this.list = list; 20 | } 21 | 22 | public T Generate() 23 | { 24 | return list.ElementAt(random.Next(0, list.Count())); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/GenderGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class GenderGenerator : IGenerator 7 | { 8 | 9 | 10 | 11 | public string Generate() 12 | { 13 | return ((IGenerator)new FromListGetSingleGenerator(new List { "Male", "Female" })).Generate(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/Generator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | using System.Reflection; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class Generator:IGenerator 8 | { 9 | private readonly PropertyInfo _info; 10 | 11 | public Generator(PropertyInfo info) 12 | { 13 | _info = info; 14 | } 15 | #region Implementation of IGenerator 16 | 17 | public object Generate() 18 | { 19 | if (_info.PropertyType.IsArray) 20 | { 21 | return Array.CreateInstance(_info.PropertyType.GetElementType(), 0); 22 | } 23 | 24 | return Activator.CreateInstance(_info.PropertyType); 25 | } 26 | 27 | #endregion 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/GuidGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class GuidGenerator : IGenerator 7 | { 8 | #region IGenerator Members 9 | 10 | public Guid Generate() 11 | { 12 | return Guid.NewGuid(); 13 | } 14 | 15 | #endregion 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/IPAddressGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class IPAddressGenerator:IGenerator 8 | { 9 | Random random; 10 | 11 | public IPAddressGenerator() 12 | { 13 | random = RandomSingleton.Instance.Random; 14 | } 15 | 16 | public string Generate() 17 | { 18 | StringBuilder sb = new StringBuilder(); 19 | sb.Append(random.Next(1, 255)); 20 | sb.Append("."); 21 | 22 | sb.Append(random.Next(0, 255)); 23 | sb.Append("."); 24 | 25 | sb.Append(random.Next(0, 255)); 26 | sb.Append("."); 27 | 28 | sb.Append(random.Next(0, 255)); 29 | return sb.ToString(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/IntegerGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class IntegerGenerator:IGenerator 7 | { 8 | Random random; 9 | 10 | public int MinimumValue { get; set; } 11 | public int MaximumValue { get; set; } 12 | 13 | public IntegerGenerator() 14 | : this(0, 100) 15 | { } 16 | 17 | public IntegerGenerator(int minimumValue, int maximumValue) 18 | { 19 | MinimumValue = minimumValue; 20 | MaximumValue = maximumValue; 21 | 22 | random = RandomSingleton.Instance.Random; 23 | } 24 | 25 | public int Generate() 26 | { 27 | return random.Next(MinimumValue, MaximumValue + 1); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/ListGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class ListGenerator:IGenerator> 7 | { 8 | private readonly int listLength; 9 | private readonly IGenerator elementGenerator; 10 | 11 | public ListGenerator(int length, IGenerator elementGenerator = null) 12 | { 13 | this.elementGenerator = elementGenerator ?? new TypeGenerator(); 14 | listLength = length; 15 | } 16 | 17 | #region IGenerator> Members 18 | 19 | public virtual IList Generate() 20 | { 21 | IList list = new List(); 22 | for (int i = 0; i < listLength; i++) 23 | { 24 | list.Add(elementGenerator.Generate()); 25 | } 26 | return list; 27 | } 28 | 29 | #endregion 30 | 31 | public static ListGenerator RandomLength() 32 | { 33 | return RandomLength(1, 10); 34 | } 35 | 36 | public static ListGenerator RandomLength(int minimumValue, int maximumValue) 37 | { 38 | return new ListGenerator(RandomSingleton.Instance.Random.Next(minimumValue, maximumValue)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/NullGenerator.cs: -------------------------------------------------------------------------------- 1 | using Foundation.ObjectHydrator.Interfaces; 2 | 3 | namespace Foundation.ObjectHydrator.Generators 4 | { 5 | public class NullGenerator:IGenerator 6 | { 7 | public object Generate() 8 | { 9 | return null; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/PasswordGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class PasswordGenerator:IGenerator 7 | { 8 | private char[] legalchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()".ToCharArray(); 9 | int length; 10 | 11 | public PasswordGenerator() 12 | : this(10) 13 | { } 14 | 15 | public PasswordGenerator(int pwlength) 16 | { 17 | length = pwlength; 18 | } 19 | 20 | public string Generate() 21 | { 22 | StringBuilder sb = new StringBuilder(); 23 | for (int i = 0; i < length; i++) 24 | { 25 | sb.Append(legalchars[RandomSingleton.Instance.Random.Next(0, legalchars.Length - 1)]); 26 | } 27 | return sb.ToString(); 28 | } 29 | 30 | 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/TextGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | 4 | namespace Foundation.ObjectHydrator.Generators 5 | { 6 | public class TextGenerator:IGenerator 7 | { 8 | static string sampleText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean non enim felis. Donec et leo vel lacus fermentum luctus ut in metus. Vivamus sagittis lacus vel mi sagittis sit amet molestie eros faucibus. Maecenas diam metus, scelerisque sed imperdiet nec, dignissim in dui. Aliquam erat volutpat. Maecenas malesuada gravida leo ac porttitor. Aliquam sed purus sit amet nisl ultrices accumsan at non ante. Duis lobortis, leo et viverra vestibulum, eros metus imperdiet justo, vel feugiat mi metus suscipit enim. Donec sed dui mi, vehicula malesuada leo. In pellentesque velit et diam aliquam vel facilisis metus faucibus. Curabitur a ipsum nulla. Suspendisse vel mi vel lacus fermentum rhoncus eget vestibulum ante. Morbi dictum sem id dui vulputate bibendum. Fusce quis faucibus leo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse at malesuada mi."; 9 | Random random; 10 | 11 | private int _Length; 12 | public int Length 13 | { 14 | get { return _Length; } 15 | set { _Length = value > sampleText.Length ? sampleText.Length : value; } 16 | } 17 | 18 | public TextGenerator() 19 | : this(25) 20 | { 21 | 22 | } 23 | 24 | public TextGenerator(int length) 25 | { 26 | Length = length; 27 | random = RandomSingleton.Instance.Random; 28 | } 29 | 30 | #region IGenerator Members 31 | 32 | public string Generate() 33 | { 34 | return sampleText.Substring(0, random.Next(1, Length - 1)).Trim(); 35 | } 36 | 37 | #endregion 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/TrackingNumberGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class TrackingNumberGenerator:IGenerator 8 | { 9 | Random random; 10 | public string Carrier {get;set;} 11 | 12 | public TrackingNumberGenerator(string carrier) 13 | { 14 | random = RandomSingleton.Instance.Random; 15 | Carrier = carrier; 16 | } 17 | 18 | public string Generate() 19 | { 20 | StringBuilder sb = new StringBuilder(); 21 | char[] chararray = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray(); 22 | int sizeofcharray=chararray.Length-1; 23 | switch (Carrier.ToLower()) 24 | { 25 | 26 | default: 27 | case "ups": 28 | sb.Append("1Z"); 29 | for (int i = 0; i < 18; i++) 30 | { 31 | sb.Append(chararray[random.Next(0, sizeofcharray)]); 32 | } 33 | break; 34 | case "fedex": 35 | sb.Append("4"); 36 | for (int i = 0; i < 14; i++) 37 | { 38 | sb.Append(random.Next(0, 9)); 39 | } 40 | break; 41 | case "usps": 42 | sb.Append("91"); 43 | for (int i = 0; i < 20; i++) 44 | { 45 | sb.Append(random.Next(0, 9)); 46 | } 47 | break; 48 | } 49 | return sb.ToString(); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/TypeGenerator.cs: -------------------------------------------------------------------------------- 1 | using Foundation.ObjectHydrator.Interfaces; 2 | 3 | namespace Foundation.ObjectHydrator.Generators 4 | { 5 | public class TypeGenerator:IGenerator 6 | { 7 | public T Generate() 8 | { 9 | return new Hydrator().GetSingle(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/TypeListGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | using System.Collections.Generic; 5 | 6 | namespace Foundation.ObjectHydrator.Generators 7 | { 8 | public class TypeListGenerator : IGenerator 9 | { 10 | private readonly Type typeOfEntity; 11 | 12 | public TypeListGenerator(Type childObjectType, object[] parameters) 13 | { 14 | typeOfEntity = childObjectType; 15 | Parameters = parameters; 16 | } 17 | 18 | public Object ChildObject { get; private set; } 19 | public object[] Parameters { get; private set; } 20 | 21 | #region IGenerator Members 22 | 23 | public object Generate() 24 | { 25 | Object instance = Activator.CreateInstance(typeOfEntity); 26 | 27 | //this string scares me. 28 | Type hydratorType = Type.GetType("Foundation.ObjectHydrator.Hydrator`1").MakeGenericType(typeOfEntity); 29 | 30 | Object theHydrator = Activator.CreateInstance(hydratorType); 31 | 32 | MethodInfo methodInfo; 33 | if (Parameters.Length > 0) 34 | { 35 | methodInfo = hydratorType.GetMethod("GetFixedLengthList"); 36 | } 37 | else 38 | { 39 | methodInfo = hydratorType.GetMethod("GetList"); 40 | } 41 | 42 | try 43 | { 44 | instance = methodInfo.Invoke(theHydrator, Parameters); 45 | } 46 | catch (Exception ex) 47 | { 48 | throw ex; 49 | } 50 | 51 | return instance; 52 | } 53 | 54 | #endregion 55 | } 56 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/UnitedKingdomCountyGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class UnitedKingdomCountyGenerator : IGenerator 8 | { 9 | private readonly Random _random; 10 | private IList _countyNames = new List(); 11 | 12 | public UnitedKingdomCountyGenerator() 13 | { 14 | _random = RandomSingleton.Instance.Random; 15 | LoadCountyNames(); 16 | } 17 | 18 | private void LoadCountyNames() 19 | { 20 | _countyNames = new List() 21 | { 22 | "London", 23 | "Bedfordshire", 24 | "Buckinghamshire", 25 | "Cambridgeshire", 26 | "Cheshire", 27 | "Cornwall and Isles of Scilly", 28 | "Cumbria", 29 | "Derbyshire", 30 | "Devon", 31 | "Dorset", 32 | "Durham", 33 | "East Sussex", 34 | "Essex", 35 | "Gloucestershire", 36 | "Greater London", 37 | "Greater Manchester", 38 | "Hampshire", 39 | "Hertfordshire", 40 | "Kent", 41 | "Lancashire", 42 | "Leicestershire", 43 | "Lincolnshire", 44 | "Merseyside", 45 | "Norfolk", 46 | "North Yorkshire", 47 | "Northamptonshire", 48 | "Northumberland", 49 | "Nottinghamshire", 50 | "Oxfordshire", 51 | "Shropshire", 52 | "Somerset", 53 | "South Yorkshire", 54 | "Staffordshire", 55 | "Suffolk", 56 | "Surrey", 57 | "Tyne and Wear", 58 | "Warwickshire", 59 | "West Midlands", 60 | "West Sussex", 61 | "West Yorkshire", 62 | "Wiltshire", 63 | "Worcestershire", 64 | "Flintshire", 65 | "Glamorgan", 66 | "Merionethshire", 67 | "Monmouthshire", 68 | "Montgomeryshire", 69 | "Pembrokeshire", 70 | "Radnorshire", 71 | "Anglesey", 72 | "Breconshire", 73 | "Caernarvonshire", 74 | "Cardiganshire", 75 | "Carmarthenshire", 76 | "Denbighshire", 77 | "Kirkcudbrightshire", 78 | "Lanarkshire", 79 | "Midlothian", 80 | "Moray", 81 | "Nairnshire", 82 | "Orkney", 83 | "Peebleshire", 84 | "Perthshire", 85 | "Renfrewshire", 86 | "Ross & Cromarty", 87 | "Roxburghshire", 88 | "Selkirkshire", 89 | "Shetland", 90 | "Stirlingshire", 91 | "Sutherland", 92 | "West Lothian", 93 | "Wigtownshire", 94 | "Aberdeenshire", 95 | "Angus", 96 | "Argyll", 97 | "Ayrshire", 98 | "Banffshire", 99 | "Berwickshire", 100 | "Bute", 101 | "Caithness", 102 | "Clackmannanshire", 103 | "Dumfriesshire", 104 | "Dumbartonshire", 105 | "East Lothian", 106 | "Fife", 107 | "Inverness", 108 | "Kincardineshire", 109 | "Kinross-shire" 110 | }; 111 | } 112 | 113 | public string Generate() 114 | { 115 | return _countyNames[_random.Next(0, _countyNames.Count)]; 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/UnitedKingdomNationalInsuranceGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Foundation.ObjectHydrator.Interfaces; 5 | 6 | namespace Foundation.ObjectHydrator.Generators 7 | { 8 | /// 9 | /// Attempts to generate a unique value that conforms to the UK National Insurance number specification 10 | /// 11 | public class UnitedKingdomNationalInsuranceGenerator : IGenerator 12 | { 13 | private readonly Random _random; 14 | 15 | private static readonly List UsedValues = new List(); 16 | private static readonly char[] ValidPrefixChars = new char[] { 'A', 'B', 'C', 'E', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'W', 'X', 'Y', 'Z' }; 17 | private static readonly string[] InvalidPrefixes = new string[] { "BG", "GB", "NK", "KN", "TN", "NT", "ZZ", "OO", "CR", "FY", "MW", "NC", "PP", "PY", "PZ", "MA", "JY", "GY" }; 18 | private static readonly char[] InvalidPrefixSecondChars = new char[] { 'O' }; 19 | private static readonly char[] ValidSuffixChars = new char[] { 'A', 'B', 'C', 'D' }; 20 | 21 | 22 | public UnitedKingdomNationalInsuranceGenerator() 23 | { 24 | _random = RandomSingleton.Instance.Random; 25 | } 26 | 27 | public string Generate() 28 | { 29 | const int maxAttempts = 10000; 30 | var attempt = 0; 31 | 32 | string candidate; 33 | do 34 | { 35 | candidate = GetValue(); 36 | } while (UsedValues.Contains(candidate) && ++attempt < maxAttempts); 37 | 38 | UsedValues.Add(candidate); 39 | return candidate; 40 | } 41 | 42 | private string GetValue() 43 | { 44 | string validPrefix = GetValidPrefix(); 45 | string str = SequenceOfDigits(6); 46 | char chr = ValidSuffixCharacter(); 47 | return string.Format("{0}{1}{2}", new object[] { validPrefix, str, chr }); 48 | } 49 | 50 | private string SequenceOfDigits(int length) 51 | { 52 | var result = new char[length]; 53 | 54 | for (int i = 0; i < length; i++) 55 | { 56 | var val = _random.Next(0, 10); 57 | result[i] = val.ToString()[0]; 58 | } 59 | 60 | return new string(result); 61 | } 62 | 63 | private string GetValidPrefix() 64 | { 65 | string str; 66 | do 67 | { 68 | str = new string(new char[] 69 | { 70 | ValidPrefixFirstCharacter(), 71 | ValidPrefixSecondCharacter() 72 | }); 73 | } while (InvalidPrefixes.Contains(str)); 74 | 75 | return str; 76 | 77 | } 78 | private char ValidPrefixFirstCharacter() 79 | { 80 | return AnyElement(ValidPrefixChars); 81 | } 82 | 83 | private char ValidPrefixSecondCharacter() 84 | { 85 | char chr; 86 | do 87 | { 88 | chr = AnyElement(ValidPrefixChars); 89 | } 90 | while (InvalidPrefixSecondChars.Contains(chr)); 91 | return chr; 92 | } 93 | 94 | private T AnyElement(IReadOnlyCollection list) 95 | { 96 | var max = list.Count; 97 | if (max < 0) 98 | { 99 | return default(T); 100 | } 101 | 102 | var idx = _random.Next(0, max); 103 | return list.ElementAt(idx); 104 | } 105 | 106 | private char ValidSuffixCharacter() 107 | { 108 | return AnyElement(ValidSuffixChars); 109 | } 110 | 111 | } 112 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/UnitedKingdomPhoneNumberGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | /// 8 | /// Generates a telephone number in the format used in the UK 9 | /// 10 | public class UnitedKingdomPhoneNumberGenerator : IGenerator 11 | { 12 | private readonly string _ndcPrefix; 13 | private readonly Random _random = RandomSingleton.Instance.Random; 14 | 15 | /// 16 | /// Creates an instance of 17 | /// See this formatting guide 18 | /// 19 | /// 20 | /// The first non-zero part of the area code. 21 | ///
    22 | ///
  • 1 0r 2 = Landline (geographic)
  • 23 | ///
  • 3 = Landline (non-geographic)
  • 24 | ///
  • 5 = Corporate and VOIP
  • 25 | ///
  • 7 = Mobiles
  • 26 | ///
  • 8 = special rate numbers
  • 27 | ///
  • 9 = premium rate numbers
  • 28 | ///
29 | /// 30 | /// 31 | public UnitedKingdomPhoneNumberGenerator(string ndcPrefix) 32 | { 33 | _ndcPrefix = ndcPrefix ?? "1"; 34 | } 35 | 36 | public string Generate() 37 | { 38 | // create an 11 character phone number 39 | // 01234 567 890 40 | var stringBuilder = new StringBuilder(); 41 | 42 | // area code (National Destination Code) 43 | stringBuilder.Append("0"); 44 | stringBuilder.Append(_ndcPrefix); 45 | for (int i = 0; i < 3; i++) 46 | { 47 | int val = this._random.Next(1, 9); 48 | stringBuilder.Append(val); 49 | } 50 | 51 | stringBuilder.Append(" "); 52 | //Subscriber number 53 | for (int i = 0; i < 6; i++) 54 | { 55 | int val = this._random.Next(0, 9); 56 | stringBuilder.Append(val); 57 | 58 | if ((i == 2) && ShouldAddSeparator()) 59 | { 60 | // add a space in the middle for nice formatting 61 | stringBuilder.Append(" "); 62 | } 63 | } 64 | 65 | return stringBuilder.ToString(); 66 | } 67 | 68 | private bool ShouldAddSeparator() 69 | { 70 | // randomly omit the formatting separator 71 | return _random.Next(0, 10) % 3 != 0; 72 | } 73 | } 74 | 75 | public class UnitedKingdomMobileGenerator : UnitedKingdomPhoneNumberGenerator 76 | { 77 | public UnitedKingdomMobileGenerator():base("7") { } 78 | } 79 | 80 | public class UnitedKingdomLandlineGenerator : UnitedKingdomPhoneNumberGenerator 81 | { 82 | public UnitedKingdomLandlineGenerator() : base("1") { } 83 | } 84 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Generators/WebsiteGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator.Generators 6 | { 7 | public class WebsiteGenerator:IGenerator 8 | { 9 | Random random; 10 | 11 | public WebsiteGenerator() 12 | { 13 | random = RandomSingleton.Instance.Random; 14 | } 15 | 16 | public string Generate() 17 | { 18 | StringBuilder sb = new StringBuilder(); 19 | sb.Append("http://www."); 20 | IGenerator companyname = new CompanyNameGenerator(); 21 | string bizname = (string)companyname.Generate(); 22 | bizname = bizname.Replace(".", ""); 23 | bizname = bizname.Replace(" ", ""); 24 | bizname = bizname.Replace(",", ""); 25 | sb.Append(bizname); 26 | string[] suffix = new string[4] { ".com", ".net", ".org", ".info" }; 27 | int num = random.Next(0, suffix.Length - 1); 28 | sb.Append(suffix[num]); 29 | return sb.ToString().ToLower(); 30 | 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Interfaces/IGenerator.cs: -------------------------------------------------------------------------------- 1 | namespace Foundation.ObjectHydrator.Interfaces 2 | { 3 | public interface IGenerator 4 | { 5 | object Generate(); 6 | } 7 | 8 | public interface IGenerator 9 | { 10 | T Generate(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Interfaces/IMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Foundation.ObjectHydrator.Interfaces 5 | { 6 | public interface IMap 7 | { 8 | Type Type { get; } 9 | bool Match(PropertyInfo info); 10 | IMapping Mapping(PropertyInfo info); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Interfaces/IMapping.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Foundation.ObjectHydrator 4 | { 5 | public interface IMapping 6 | { 7 | string PropertyName { get; } 8 | PropertyInfo PropertyInfo { get; } 9 | object Generate(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Map.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator.Interfaces; 3 | using Foundation.ObjectHydrator.Generators; 4 | using System.Reflection; 5 | 6 | namespace Foundation.ObjectHydrator 7 | { 8 | public class Map:IMap 9 | { 10 | private Func _func; 11 | private IGenerator _generator; 12 | 13 | public Map() 14 | { 15 | _func = info => info.CanWrite; 16 | } 17 | 18 | Type IMap.Type 19 | { 20 | get 21 | { 22 | return typeof(T); 23 | } 24 | } 25 | 26 | bool IMap.Match(PropertyInfo info) 27 | { 28 | return _func(info); 29 | } 30 | 31 | IMapping IMap.Mapping(PropertyInfo info) 32 | { 33 | return new Mapping(info, _generator); 34 | } 35 | 36 | public Map Matching(Func func) 37 | { 38 | _func = func; 39 | return this; 40 | } 41 | 42 | public Map Using(IGenerator generator) 43 | { 44 | _generator = generator; 45 | return this; 46 | } 47 | 48 | public Map Using(T defaultValue) 49 | { 50 | _generator = new DefaultGenerator(defaultValue); 51 | return this; 52 | } 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Mapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Foundation.ObjectHydrator.Interfaces; 4 | 5 | namespace Foundation.ObjectHydrator 6 | { 7 | public class Mapping:IMapping 8 | { 9 | public Mapping(PropertyInfo propertyInfo, IGenerator generator) 10 | { 11 | PropertyName = propertyInfo.Name; 12 | PropertyInfo = propertyInfo; 13 | object[] a = propertyInfo.GetCustomAttributes(false); 14 | foreach (var item in a) 15 | { 16 | try 17 | { 18 | System.Attribute attr = (System.Attribute)item; 19 | //TODO: Refactor this out to be more flexible and support more annotations 20 | if (attr.GetType()==typeof(System.ComponentModel.DataAnnotations.StringLengthAttribute)) 21 | { 22 | System.ComponentModel.DataAnnotations.StringLengthAttribute sla = (System.ComponentModel.DataAnnotations.StringLengthAttribute)attr; 23 | if (generator.GetType()==typeof(Generators.TextGenerator)) 24 | { 25 | generator = (IGenerator)new Generators.TextGenerator(sla.MaximumLength); 26 | } 27 | } 28 | } 29 | catch (Exception) 30 | { 31 | 32 | throw; 33 | } 34 | } 35 | Generator = generator; 36 | } 37 | 38 | public string PropertyName { get; private set; } 39 | public PropertyInfo PropertyInfo { get; private set; } 40 | public IGenerator Generator { get; private set; } 41 | 42 | public object Generate() 43 | { 44 | return Generator.Generate(); 45 | } 46 | } 47 | 48 | public class Mapping : IMapping 49 | { 50 | public Mapping(PropertyInfo propertyInfo, IGenerator generator) 51 | { 52 | PropertyName = propertyInfo.Name; 53 | PropertyInfo = propertyInfo; 54 | Generator = generator; 55 | } 56 | 57 | public string PropertyName { get; private set; } 58 | public PropertyInfo PropertyInfo { get; private set; } 59 | public IGenerator Generator { get; private set; } 60 | 61 | public object Generate() 62 | { 63 | return Generator.Generate(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Foundation.ObjectHydrator")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Foundation.ObjectHydrator")] 12 | [assembly: AssemblyCopyright("Copyright © 2009")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("688a0d31-a745-4722-95fb-1eb94964b042")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.3.0.0")] 35 | [assembly: AssemblyFileVersion("1.3.0.0")] 36 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/RandomSingleton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Foundation.ObjectHydrator 4 | { 5 | public sealed class RandomSingleton 6 | { 7 | private static readonly object SyncRoot = new Object(); 8 | private static volatile RandomSingleton instance; 9 | 10 | public Random Random { get; private set; } 11 | 12 | private RandomSingleton() 13 | { 14 | Random = new Random(); 15 | } 16 | 17 | public static RandomSingleton Instance 18 | { 19 | get 20 | { 21 | if (instance == null) 22 | { 23 | lock (SyncRoot) 24 | { 25 | if (instance == null) 26 | instance = new RandomSingleton(); 27 | } 28 | } 29 | 30 | return instance; 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/Readme.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

9 | Object Hydrator

10 |

11 | Version 0.6
12 | 10/28/2009

13 |

14 | Introduction:
15 | Object Hydrator is a tool to ease the "Model First" development style and 16 | testing scenarios, by generating objects with pre-filled data.  Doing so 17 | allows you the freedom of working in your application with 'realistic' data at 18 | the same time giving you the flexibility to make changes to your model on the 19 | fly.

20 |

21 | Using convention over configuration, Object Hydrator will pick an appropriate 22 | data type based on the type in the model and/or the name of the property and 23 | generate the data for you automatically.  With a fluent interface you can 24 | override these conventions easily and smoothly.

25 |

26 | A very simple example is as follows:
27 | Given this class

28 |

29 | public class Customer
30 | {
31 |     public string FirstName {get;set;}
32 | }
33 |
34 | You can populate an instance of this class with a random real-world first name 35 | by first creating an instance of the Hydrator like so...
36 |
37 | Hydrator<Customer> hydrator=new Hydrator<Customer>();
38 |
39 | And then call the GetSingle method assigning it to a new customer object like 40 | this....
41 |
42 | Customer mynewcustomer=hydrator.GetSingle();

43 |

44 | You can also inject your own generators at instantiation time, as long as the implement the IGenerator interface. See Hydrator_InjectedGenerator_Test.cs 45 |

46 |

47 | For more detailed examples please see the unit tests in 48 | Hydrator_SimpleCustomerTests.cs or the SampleWebApplication

49 |

50 | Please see 51 | http://objecthydrator.codeplex.com for samples and documentation.

52 |

53 | Special Thanks for his excellent code to:
54 | Scott Monnig

55 | 56 | 57 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/_CreateNewNuGetPackage/Config.ps1: -------------------------------------------------------------------------------- 1 | #========================================================== 2 | # Edit the variable values below to configure how your .nupkg file is packed (i.e. created) and pushed (i.e. uploaded) to the NuGet gallery. 3 | # 4 | # If you have modified this script: 5 | # - if you uninstall the "Create New NuGet Package From Project After Each Build" package, this file may not be removed automatically; you may need to manually delete it. 6 | # - if you update the "Create New NuGet Package From Project After Each Build" package, this file may not be updated unless you specify it to be overwritten, either by 7 | # confirming the overwrite if prompted, or by providing the "-FileConflictAction Overwrite" parameter when installing from the command line. 8 | # If you overwrite this file then your custom changes will be lost, and you will need to manually reapply your changes. 9 | # If you are not using source control, I recommend backing up this file before updating the package so you can see what changes you had made to it. 10 | #========================================================== 11 | 12 | #------------------------------------------------ 13 | # Pack parameters used to create the .nupkg file. 14 | #------------------------------------------------ 15 | 16 | # Specify the Version Number to use for the NuGet package. If not specified, the version number of the assembly being packed will be used. 17 | # NuGet version number guidance: https://docs.nuget.org/docs/reference/versioning and the Semantic Versioning spec: http://semver.org/ 18 | # e.g. "" (use assembly's version), "1.2.3" (stable version), "1.2.3-alpha" (prerelease version). 19 | $versionNumber = "1.3.0" 20 | 21 | # Specify any Release Notes for this package. 22 | # These will only be included in the package if you have a .nuspec file for the project in the same directory as the project file. 23 | $releaseNotes = "" 24 | 25 | # Specify a specific Configuration and/or Platform to only create a NuGet package when building the project with this Configuration and/or Platform. 26 | # e.g. $configuration = "Release" 27 | # $platform = "AnyCPU" 28 | $configuration = "" 29 | $platform = "" 30 | 31 | # Specify any NuGet Pack Properties to pass to MsBuild. 32 | # e.g. $packProperties = "TargetFrameworkVersion=v3.5;Optimize=true" 33 | # Do not specify the "Configuration" or "Platform" here; use the $configuration and $platform variables above. 34 | # MsBuild Properties that can be specified: http://msdn.microsoft.com/en-us/library/vstudio/bb629394.aspx 35 | $packProperties = "" 36 | 37 | # Specify any NuGet Pack options to pass to nuget.exe. 38 | # e.g. $packOptions = "-Symbols" 39 | # e.g. $packOptions = "-IncludeReferencedProjects -Symbols" 40 | # Do not specify a "-Version" (use $versionNumber above), "-OutputDirectory", or "-NonInteractive", as these are already provided. 41 | # Do not specify any "-Properties" here; instead use the $packProperties variable above. 42 | # Do not specify "-Build", as this may result in an infinite build loop. 43 | # NuGet Pack options that can be specified: http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command_Options 44 | # Use "-Symbols" to also create a symbols package. When pushing your package, the symbols package will automatically be detected and pushed as well: https://www.symbolsource.org/Public/Wiki/Publishing 45 | $packOptions = "" 46 | 47 | # Specify $true if the generated .nupkg file should be renamed to include the Configuration and Platform that was used to build the project, $false if not. 48 | # e.g. If $true, MyProject.1.1.5.6.nupkg might be renamed to MyProject.1.1.5.6.Debug.AnyCPU.nupkg 49 | # e.g. If $true, MyProject.1.1.5.6-beta1.nupkg might re renamed to MyProject.1.1.5.6-beta1.Release.x86.nupkg 50 | $appendConfigurationAndPlatformToNuGetPackageFileName = $true 51 | 52 | 53 | #------------------------------------------------ 54 | # Push parameters used to upload the .nupkg file to the NuGet gallery. 55 | #------------------------------------------------ 56 | 57 | # The NuGet gallery to upload to. If not provided, the DefaultPushSource in your NuGet.config file is used (typically nuget.org). 58 | $sourceToUploadTo = "" 59 | 60 | # The API Key to use to upload the package to the gallery. If not provided and a system-level one does not exist for the specified Source, you will be prompted for it. 61 | $apiKey = "" 62 | 63 | # Specify any NuGet Push options to pass to nuget.exe. 64 | # e.g. $pushOptions = "-Timeout 120" 65 | # Do not specify the "-Source" or "-ApiKey" here; use the variables above. 66 | # NuGet Push options that can be specified: http://docs.nuget.org/docs/reference/command-line-reference#Push_Command_Options 67 | $pushOptions = "" 68 | -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/_CreateNewNuGetPackage/DoNotModify/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrintsCharming/ObjectHydrator/bfe5f4cc59675c110916dda70e11068f68808eb5/Foundation.ObjectHydrator/_CreateNewNuGetPackage/DoNotModify/NuGet.exe -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/_CreateNewNuGetPackage/DoNotModify/UploadNuGetPackage.ps1: -------------------------------------------------------------------------------- 1 | #========================================================== 2 | # DO NOT EDIT THIS FILE. 3 | # If you want to configure how your package is uploaded, modify the Config.ps1 file. 4 | # To run this script from inside Visual Studio, right-click on the "RunMeToUploadNuGetPackage.cmd" file and choose "Run". 5 | #========================================================== 6 | 7 | # Turn on Strict Mode to help catch syntax-related errors. 8 | # This must come after a script's/function's param section. 9 | # Forces a function to be the first non-comment code to appear in a PowerShell Module. 10 | Set-StrictMode -Version Latest 11 | 12 | # PowerShell v2.0 compatible version of [string]::IsNullOrWhitespace. 13 | function Test-StringIsNullOrWhitespace([string]$string) 14 | { 15 | if ($string -ne $null) { $string = $string.Trim() } 16 | return [string]::IsNullOrEmpty($string) 17 | } 18 | 19 | # Get the directory that this script is in. 20 | $THIS_SCRIPTS_DIRECTORY_PATH = Split-Path $script:MyInvocation.MyCommand.Path 21 | 22 | # Get the path to the Config file and dot source it into this script. 23 | # The variables below should be defined in the Config file, but if they aren't we initialize them with default values. 24 | $CONFIG_FILE_PATH = Join-Path -Path (Split-Path -Path $THIS_SCRIPTS_DIRECTORY_PATH -Parent) -ChildPath 'Config.ps1' 25 | if (Test-Path -Path $CONFIG_FILE_PATH) { . $CONFIG_FILE_PATH } 26 | else { Write-Warning "Could not find Config file at '$CONFIG_FILE_PATH'. Default values will be used instead." } 27 | 28 | # The NuGet gallery to upload to. If not provided, the DefaultPushSource in your NuGet.config file is used (typically nuget.org). 29 | if (!(Test-Path Variable:Private:sourceToUploadTo) -or (Test-StringIsNullOrWhitespace $sourceToUploadTo)) { $sourceToUploadTo = ""; Write-Output "Using default Source To Upload To value." } 30 | else { Write-Output "Using user-specified Source To Update To value '$sourceToUploadTo'." } 31 | 32 | # The API Key to use to upload the package to the gallery. If not provided and a system-level one does not exist for the specified Source, you will be prompted for it. 33 | if (!(Test-Path Variable:Private:apiKey) -or (Test-StringIsNullOrWhitespace $apiKey)) { $apiKey = ""; Write-Output "Using default API Key value." } 34 | else { Write-Output "Using user-specified API Key value [value not shown here for security purposes]." } 35 | 36 | # Specify any NuGet Push options to pass to nuget.exe. 37 | # Do not specify the "-Source" or "-ApiKey" here; use the variables above. 38 | if (!(Test-Path Variable:Private:pushOptions) -or (Test-StringIsNullOrWhitespace $pushOptions)) { $pushOptions = ""; Write-Output "Using default Push Options value." } 39 | else { Write-Output "Using user-specified Push Options value '$pushOptions'." } 40 | 41 | # Add the Source and ApiKey to the Push Options if there were provided. 42 | if (!(Test-StringIsNullOrWhitespace $sourceToUploadTo)) { $pushOptions += " -Source ""$sourceToUploadTo"" " } 43 | if (!(Test-StringIsNullOrWhitespace $apiKey)) { $pushOptions += " -ApiKey ""$apiKey"" " } 44 | 45 | # Upload the new NuGet package. 46 | & "$THIS_SCRIPTS_DIRECTORY_PATH\New-NuGetPackage.ps1" -PushOptions "$pushOptions" -Verbose -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/_CreateNewNuGetPackage/RunMeToUploadNuGetPackage.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM === DO NOT EDIT THIS FILE === 3 | REM Run this script to upload a NuGet package to the NuGet gallery. 4 | REM When you run this script it will prompt you for a NuGet package file (.nupkg) and then upload it to the NuGet gallery. 5 | REM The project's .nupkg file should be in the same directory as the project's .dll/.exe file (typically bin\Debug or bin\Release). 6 | REM You may edit the Config.ps1 file to adjust the settings used to upload the package to the NuGet gallery. 7 | REM To run this script from within Visual Studio, right-click on this file from the Solution Explorer and choose Run. 8 | SET THIS_SCRIPTS_DIRECTORY=%~dp0 9 | PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%THIS_SCRIPTS_DIRECTORY%DoNotModify\UploadNuGetPackage.ps1'" -------------------------------------------------------------------------------- /Foundation.ObjectHydrator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Foundation.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Foundation.ObjectHydrator", "Foundation.ObjectHydrator\Foundation.ObjectHydrator.csproj", "{8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Foundation.ObjectHydrator.Tests", "Foundation.ObjectHydrator.Tests\Foundation.ObjectHydrator.Tests.csproj", "{44E61D49-4DA0-448C-928E-2907951DD381}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApplication", "SampleWebApplication\SampleWebApplication.csproj", "{D43EF567-08DE-479D-9D03-1820595911CF}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{9DD54A53-8184-44B1-AF98-0FEAC42B6EA1}" 13 | ProjectSection(SolutionItems) = preProject 14 | .nuget\packages.config = .nuget\packages.config 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {44E61D49-4DA0-448C-928E-2907951DD381}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {44E61D49-4DA0-448C-928E-2907951DD381}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {44E61D49-4DA0-448C-928E-2907951DD381}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {44E61D49-4DA0-448C-928E-2907951DD381}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {D43EF567-08DE-479D-9D03-1820595911CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {D43EF567-08DE-479D-9D03-1820595911CF}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {D43EF567-08DE-479D-9D03-1820595911CF}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {D43EF567-08DE-479D-9D03-1820595911CF}.Release|Any CPU.Build.0 = Release|Any CPU 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | GlobalSection(SubversionScc) = preSolution 40 | Svn-Managed = True 41 | Manager = AnkhSVN - Subversion Support for Visual Studio 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /Packages.dgml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ObjectHydrator 2 | ============== 3 | 4 | This project allows you to pass custom POCO's to it, and have it return an instance of the class populated with randomly generated but real-world looking data. This random data can be overridden by convention. 5 | 6 | **Basic syntax looks like this:** 7 | 8 | ```csharp 9 | Hydrator _customerHydrator = new Hydrator(); 10 | Customer customer = _customerHydrator.GetSingle(); 11 | List customerlist=_customerHydrator.GetList(20); 12 | ``` 13 | 14 | **Advanced syntax looks like:** 15 | 16 | ```csharp 17 | Hydrator _customerHydrator = new Hydrator() 18 | .WithInteger(x => x.CustomerAge, 1, 100) 19 | .WithAmericanPhone(x=>x.CustomerPhone); 20 | ``` 21 | 22 | **A custom generator looks like:** 23 | 24 | ```csharp 25 | public class FullNameGenerator : IGenerator 26 | { 27 | static readonly IGenerator FirstNameGen = new FirstNameGenerator(); 28 | static readonly IGenerator LastNameGen = new LastNameGenerator(); 29 | 30 | public string Generate() 31 | { 32 | return FirstNameGen.Generate() + " " + LastNameGen.Generate(); 33 | } 34 | } 35 | ``` 36 | 37 | Use a custom generator like this: 38 | 39 | ```csharp 40 | Hydrator _customerHydrator = new Hydrator() 41 | .With(x => x.FullName, new FullNameGenerator()); 42 | ``` 43 | 44 | ## Changes 45 | 46 | Version 1.3.0 47 | * Added 3 new generators UnitedKingdomPhoneNumberGenerator, UnitedKingdomInsuranceNumberGenerator, and CulturesGenerator thanks to rikrak and ushenkodmitry 48 | * "Do" method to allow a property to be set from the generated values in other properties, thanks to rikrak 49 | * Fixed randomization method which was excluding the last possible, thanks to rikrak and ushenkodmitry 50 | 51 | Version 1.1.0 52 | * Added the ability to respect the StringLength property attribute from System.ComponentModel.DataAnnotations (more annotations are welcome and likely) 53 | 54 | Version 1.0.0 55 | 56 | * Added the ability to inject Generators at instantiation time. Which looks like this: 57 | `var hydrator = new Hydrator
().WithCustomGenerator(x=>x.State, new InjectedGenerator());` 58 | 59 | Version 0.7.0 60 | 61 | * Added new generators: UnitedKingdomCityGenerator, UnitedKingdomCountyGenerator, UnitedKingdomPostcodeGenerator, AlphaNumericGenerator. 62 | 63 | ## NuGet [#objecthydrator](http://www.nuget.org/packages/objecthydrator/) 64 | 65 | Install-Package objecthydrator 66 | 67 | This version is for Visual Studio 2010 .Net 4. I'll switch to a newer version and use 2013 if there is interest. 68 | 69 | ## Summary 70 | 71 | So basically, you create a class and invoke the Hydrator object with that class type. Then call the `GetSingle` or `GetList` functions and you are returned an instance of the object populated with realistic data. The idea behind it is to use it to replace a database call to use in your UI. 72 | 73 | ## Generators 74 | 75 | Presently the generators are pretty simple and can generate limited values, they include: 76 | 77 | Generator | Description | Notes 78 | ----------|-------------|-------- 79 | FirstName | Returns a random english First Name 80 | LastName | Return a random english Last Name 81 | DateTimeGenerator | Returns a random Date within a given range. 82 | AmericanPhone | Returns a randon American Phone Number 83 | AmericanAddress | Returns a random American Address (street part) 84 | AmericanCity | Returns a random American City 85 | AmericanPostalCode | Returns a random Postal Code (including optional +4 component) 86 | Integer Generator | Returns an int within a range 87 | Enum Generator | Define the enum and it will return the string value of a random one 88 | Boolean Generator | Returns a random boolean 89 | AmericanState | Returns a random US abbreviation 90 | EmailAddress | Returns a random email address | Thanks ScottMonnig! 91 | Business Name Generator | Returns a random 3 part business name 92 | URL Generator | Returns random URL based on BusinessName Generator 93 | IPAddress Generator | Returns a random ip address 94 | TextGenerator | Random Greek Text 95 | CountryCode | Random Country Code 96 | ByteArray Generator | Returns an array of random bytes 97 | GUID Generator | Returns a new GUID 98 | TypeGenerator | Return a hydrated object of Type 99 | TypeListGenerator | Return a list of objects 100 | PasswordGenerator | Returns a string of random pw characters with length parameter 101 | UnitedKingdomCityGenerator | Returns a UK City | Thanks to fuzzy-afterlife 102 | UnitedKingdomCountyGenerator | Returns a UK County | Thanks to fuzzy-afterlife 103 | UnitedKingdomPostcodeGenerator | Returns a UK Post Code | Thanks to fuzzy-afterlife 104 | UnitedKingdomPhoneNumberGenerator | Returns a UK Phone | Thanks to rikrak 105 | UnitedKingdomInsuranceNumberGenerator | Returns a UK Ins Number | Thanks to rikrak 106 | AlphaNumericGenerator | Returns an string with alpha chars of n length | Thanks to fuzzy-afterlife 107 | CulturesGenerator | Returns a Culture Info property | Thanks to ushenkodmitry 108 | 109 | All values can be overridden so you can do things like fake search results etc... 110 | -------------------------------------------------------------------------------- /SampleWebApplication/AddCustomer.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddCustomer.aspx.cs" Inherits="SampleWebApplication.AddCustomer" %> 2 | 3 | <%@ Register src="Menu.ascx" tagname="Menu" tagprefix="uc1" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | First Name 17 |
18 | Last Name 19 |
20 | Street Address 21 |
22 | City 23 |
24 | State 25 |
26 | Zip 27 |
28 | 29 | 30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /SampleWebApplication/AddCustomer.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Foundation.ObjectHydrator; 3 | 4 | namespace SampleWebApplication 5 | { 6 | public partial class AddCustomer : System.Web.UI.Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | if (!IsPostBack) 11 | { 12 | Hydrator hydrator = new Hydrator(); 13 | Customer startwithme = hydrator.GetSingle(); 14 | txtFirstName.Text = startwithme.FirstName; 15 | txtLastName.Text = startwithme.LastName; 16 | txtStreetAddress.Text = startwithme.StreetAddress; 17 | txtCity.Text = startwithme.City; 18 | txtState.Text = startwithme.State; 19 | txtZip.Text = startwithme.Zip; 20 | } 21 | } 22 | 23 | protected void Button1_Click(object sender, EventArgs e) 24 | { 25 | 26 | //Normally I wouldn't put code like this here 27 | //But I'm just doing this for simplicity 28 | //Ryan 29 | Hydrator hydrator = new Hydrator() 30 | .With(x=>x.FirstName, txtFirstName.Text) 31 | .With(x => x.LastName, txtLastName.Text) 32 | .With(x=>x.StreetAddress,txtStreetAddress.Text) 33 | .With(x=>x.City,txtCity.Text) 34 | .With(x=>x.State,txtState.Text) 35 | .With(x=>x.Zip,txtZip.Text); 36 | 37 | Customer savethis = hydrator.GetSingle(); 38 | 39 | CustomerRepository cr = new CustomerRepository(); 40 | cr.SaveCustomer(savethis); 41 | Response.Redirect("/"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SampleWebApplication/AddCustomer.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4016 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SampleWebApplication { 12 | 13 | 14 | public partial class AddCustomer { 15 | 16 | /// 17 | /// form1 control. 18 | /// 19 | /// 20 | /// Auto-generated field. 21 | /// To modify move field declaration from designer file to code-behind file. 22 | /// 23 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 24 | 25 | /// 26 | /// Menu1 control. 27 | /// 28 | /// 29 | /// Auto-generated field. 30 | /// To modify move field declaration from designer file to code-behind file. 31 | /// 32 | protected global::SampleWebApplication.Menu Menu1; 33 | 34 | /// 35 | /// txtFirstName control. 36 | /// 37 | /// 38 | /// Auto-generated field. 39 | /// To modify move field declaration from designer file to code-behind file. 40 | /// 41 | protected global::System.Web.UI.WebControls.TextBox txtFirstName; 42 | 43 | /// 44 | /// txtLastName control. 45 | /// 46 | /// 47 | /// Auto-generated field. 48 | /// To modify move field declaration from designer file to code-behind file. 49 | /// 50 | protected global::System.Web.UI.WebControls.TextBox txtLastName; 51 | 52 | /// 53 | /// txtStreetAddress control. 54 | /// 55 | /// 56 | /// Auto-generated field. 57 | /// To modify move field declaration from designer file to code-behind file. 58 | /// 59 | protected global::System.Web.UI.WebControls.TextBox txtStreetAddress; 60 | 61 | /// 62 | /// txtCity control. 63 | /// 64 | /// 65 | /// Auto-generated field. 66 | /// To modify move field declaration from designer file to code-behind file. 67 | /// 68 | protected global::System.Web.UI.WebControls.TextBox txtCity; 69 | 70 | /// 71 | /// txtState control. 72 | /// 73 | /// 74 | /// Auto-generated field. 75 | /// To modify move field declaration from designer file to code-behind file. 76 | /// 77 | protected global::System.Web.UI.WebControls.TextBox txtState; 78 | 79 | /// 80 | /// txtZip control. 81 | /// 82 | /// 83 | /// Auto-generated field. 84 | /// To modify move field declaration from designer file to code-behind file. 85 | /// 86 | protected global::System.Web.UI.WebControls.TextBox txtZip; 87 | 88 | /// 89 | /// Button1 control. 90 | /// 91 | /// 92 | /// Auto-generated field. 93 | /// To modify move field declaration from designer file to code-behind file. 94 | /// 95 | protected global::System.Web.UI.WebControls.Button Button1; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /SampleWebApplication/Company.cs: -------------------------------------------------------------------------------- 1 | namespace SampleWebApplication 2 | { 3 | public class Company 4 | { 5 | private int _companyID; 6 | public int CompanyID 7 | { 8 | get { return _companyID; } 9 | set 10 | { 11 | _companyID = value; 12 | } 13 | } 14 | 15 | private string _companyName; 16 | public string CompanyName 17 | { 18 | get { return _companyName; } 19 | set 20 | { 21 | _companyName = value; 22 | } 23 | } 24 | 25 | private string _addressLine; 26 | public string AddressLine 27 | { 28 | get { return _addressLine; } 29 | set 30 | { 31 | _addressLine = value; 32 | } 33 | } 34 | 35 | private string _city; 36 | public string City 37 | { 38 | get { return _city; } 39 | set 40 | { 41 | _city = value; 42 | } 43 | } 44 | 45 | private string _state; 46 | public string State 47 | { 48 | get { return _state; } 49 | set 50 | { 51 | _state = value; 52 | } 53 | } 54 | 55 | private string _zip; 56 | public string Zip 57 | { 58 | get { return _zip; } 59 | set 60 | { 61 | _zip = value; 62 | } 63 | } 64 | 65 | private string _homepage; 66 | public string Homepage 67 | { 68 | get { return _homepage; } 69 | set 70 | { 71 | _homepage = value; 72 | } 73 | } 74 | 75 | public override string ToString() 76 | { 77 | return CompanyName; 78 | } 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /SampleWebApplication/Customer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SampleWebApplication 4 | { 5 | public class Customer 6 | { 7 | private string _firstName; 8 | public string FirstName 9 | { 10 | get { return _firstName; } 11 | set 12 | { 13 | _firstName = value; 14 | } 15 | } 16 | 17 | private string _lastName; 18 | public string LastName 19 | { 20 | get { return _lastName; } 21 | set 22 | { 23 | _lastName = value; 24 | } 25 | } 26 | 27 | private string _streetAddress; 28 | public string StreetAddress 29 | { 30 | get { return _streetAddress; } 31 | set 32 | { 33 | _streetAddress = value; 34 | } 35 | } 36 | 37 | private string _city; 38 | public string City 39 | { 40 | get { return _city; } 41 | set 42 | { 43 | _city = value; 44 | } 45 | } 46 | 47 | private string _state; 48 | public string State 49 | { 50 | get { return _state; } 51 | set 52 | { 53 | _state = value; 54 | } 55 | } 56 | 57 | private string _zip; 58 | public string Zip 59 | { 60 | get { return _zip; } 61 | set 62 | { 63 | _zip = value; 64 | } 65 | } 66 | 67 | private Company _company; 68 | public Company Company { get; set; } 69 | 70 | private IList _companies; 71 | public IList Companies {get;set;} 72 | 73 | 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /SampleWebApplication/CustomerFakeLookup.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerFakeLookup.aspx.cs" Inherits="SampleWebApplication.CustomerFakeLookup" %> 2 | 3 | <%@ Register src="Menu.ascx" tagname="Menu" tagprefix="uc1" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | Search for a customer by last name (returns a 'faked' list for purposes of testing)
17 | 18 | 19 |
20 | 21 | 22 | 23 |
24 | 25 |
26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /SampleWebApplication/CustomerFakeLookup.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Foundation.ObjectHydrator.Generators; 4 | 5 | 6 | namespace SampleWebApplication 7 | { 8 | public partial class CustomerFakeLookup : System.Web.UI.Page 9 | { 10 | protected void Page_Load(object sender, EventArgs e) 11 | { 12 | 13 | } 14 | 15 | protected void Button1_Click(object sender, EventArgs e) 16 | { 17 | Foundation.ObjectHydrator.Hydrator hydrator = new Foundation.ObjectHydrator.Hydrator() 18 | .With(x => x.Company, new FromListGetSingleGenerator((IList)Application["companies"])) 19 | .With(x => x.LastName, txtLastName.Text); 20 | GridView1.DataSource = hydrator.GetList(30); 21 | GridView1.DataBind(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SampleWebApplication/CustomerFakeLookup.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4016 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SampleWebApplication { 12 | 13 | 14 | public partial class CustomerFakeLookup { 15 | 16 | /// 17 | /// form1 control. 18 | /// 19 | /// 20 | /// Auto-generated field. 21 | /// To modify move field declaration from designer file to code-behind file. 22 | /// 23 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 24 | 25 | /// 26 | /// Menu1 control. 27 | /// 28 | /// 29 | /// Auto-generated field. 30 | /// To modify move field declaration from designer file to code-behind file. 31 | /// 32 | protected global::SampleWebApplication.Menu Menu1; 33 | 34 | /// 35 | /// txtLastName control. 36 | /// 37 | /// 38 | /// Auto-generated field. 39 | /// To modify move field declaration from designer file to code-behind file. 40 | /// 41 | protected global::System.Web.UI.WebControls.TextBox txtLastName; 42 | 43 | /// 44 | /// Button1 control. 45 | /// 46 | /// 47 | /// Auto-generated field. 48 | /// To modify move field declaration from designer file to code-behind file. 49 | /// 50 | protected global::System.Web.UI.WebControls.Button Button1; 51 | 52 | /// 53 | /// GridView1 control. 54 | /// 55 | /// 56 | /// Auto-generated field. 57 | /// To modify move field declaration from designer file to code-behind file. 58 | /// 59 | protected global::System.Web.UI.WebControls.GridView GridView1; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SampleWebApplication/CustomerRealLookUp.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomerRealLookUp.aspx.cs" Inherits="SampleWebApplication.CustomerRealLookUp" %> 2 | 3 | <%@ Register src="Menu.ascx" tagname="Menu" tagprefix="uc1" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | Search by last name:
17 | 18 | 19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /SampleWebApplication/CustomerRealLookUp.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SampleWebApplication 4 | { 5 | public partial class CustomerRealLookUp : System.Web.UI.Page 6 | { 7 | protected void Page_Load(object sender, EventArgs e) 8 | { 9 | 10 | } 11 | 12 | protected void Search_Click(object sender, EventArgs e) 13 | { 14 | CustomerRepository custrepos = new CustomerRepository(); 15 | GridView1.DataSource = custrepos.RealSearchByLastName(txtLastName.Text); 16 | GridView1.DataBind(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SampleWebApplication/CustomerRealLookUp.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4016 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SampleWebApplication { 12 | 13 | 14 | public partial class CustomerRealLookUp { 15 | 16 | /// 17 | /// form1 control. 18 | /// 19 | /// 20 | /// Auto-generated field. 21 | /// To modify move field declaration from designer file to code-behind file. 22 | /// 23 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 24 | 25 | /// 26 | /// Menu1 control. 27 | /// 28 | /// 29 | /// Auto-generated field. 30 | /// To modify move field declaration from designer file to code-behind file. 31 | /// 32 | protected global::SampleWebApplication.Menu Menu1; 33 | 34 | /// 35 | /// txtLastName control. 36 | /// 37 | /// 38 | /// Auto-generated field. 39 | /// To modify move field declaration from designer file to code-behind file. 40 | /// 41 | protected global::System.Web.UI.WebControls.TextBox txtLastName; 42 | 43 | /// 44 | /// Search control. 45 | /// 46 | /// 47 | /// Auto-generated field. 48 | /// To modify move field declaration from designer file to code-behind file. 49 | /// 50 | protected global::System.Web.UI.WebControls.Button Search; 51 | 52 | /// 53 | /// GridView1 control. 54 | /// 55 | /// 56 | /// Auto-generated field. 57 | /// To modify move field declaration from designer file to code-behind file. 58 | /// 59 | protected global::System.Web.UI.WebControls.GridView GridView1; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SampleWebApplication/CustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Web; 4 | 5 | namespace SampleWebApplication 6 | { 7 | public class CustomerRepository 8 | { 9 | public IEnumerable GetAllCustomers() 10 | { 11 | IList customers = (IList)HttpContext.Current.Application["customers"]; 12 | var custlist = from p in customers orderby p.LastName select p; 13 | return custlist; 14 | } 15 | 16 | public IEnumerable RealSearchByLastName(string searchbylastname) 17 | { 18 | IList customers = (IList)HttpContext.Current.Application["customers"]; 19 | var custlist = from p in customers where p.LastName.ToLower().Contains(searchbylastname.ToLower()) orderby p.FirstName select p; 20 | return custlist; 21 | } 22 | 23 | public void SaveCustomer(Customer saveme) 24 | { 25 | IList customers = (IList)HttpContext.Current.Application["customers"]; 26 | customers.Add(saveme); 27 | HttpContext.Current.Application.Lock(); 28 | HttpContext.Current.Application["customers"] = customers; 29 | HttpContext.Current.Application.UnLock(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SampleWebApplication/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SampleWebApplication._Default" %> 2 | 3 | <%@ Register src="Menu.ascx" tagname="Menu" tagprefix="uc1" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 20 |
21 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /SampleWebApplication/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SampleWebApplication 4 | { 5 | public partial class _Default : System.Web.UI.Page 6 | { 7 | protected void Page_Load(object sender, EventArgs e) 8 | { 9 | 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SampleWebApplication/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4016 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SampleWebApplication { 12 | 13 | 14 | public partial class _Default { 15 | 16 | /// 17 | /// form1 control. 18 | /// 19 | /// 20 | /// Auto-generated field. 21 | /// To modify move field declaration from designer file to code-behind file. 22 | /// 23 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 24 | 25 | /// 26 | /// Menu1 control. 27 | /// 28 | /// 29 | /// Auto-generated field. 30 | /// To modify move field declaration from designer file to code-behind file. 31 | /// 32 | protected global::SampleWebApplication.Menu Menu1; 33 | 34 | /// 35 | /// ObjectDataSource1 control. 36 | /// 37 | /// 38 | /// Auto-generated field. 39 | /// To modify move field declaration from designer file to code-behind file. 40 | /// 41 | protected global::System.Web.UI.WebControls.ObjectDataSource ObjectDataSource1; 42 | 43 | /// 44 | /// GridView1 control. 45 | /// 46 | /// 47 | /// Auto-generated field. 48 | /// To modify move field declaration from designer file to code-behind file. 49 | /// 50 | protected global::System.Web.UI.WebControls.GridView GridView1; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /SampleWebApplication/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="SampleWebApplication.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /SampleWebApplication/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Foundation.ObjectHydrator; 4 | 5 | using Foundation.ObjectHydrator.Generators; 6 | 7 | namespace SampleWebApplication 8 | { 9 | public class Global : System.Web.HttpApplication 10 | { 11 | 12 | protected void Application_Start(object sender, EventArgs e) 13 | { 14 | //Create a list of companies and tuck them away for later use 15 | Hydrator hydrator2=new Hydrator(); 16 | IList comps = hydrator2.GetList(10); 17 | Application["companies"] = comps; 18 | 19 | //Create our customer database using one of the companies created above as the Company property of the customer. 20 | //Whoa. 21 | int listSize = 4; 22 | var args = new object[] { listSize }; 23 | //Hydrator hydrator = new Hydrator() 24 | 25 | // .FromList("Company", System.Linq.Enumerable.Cast((IList)Application["companies"])) 26 | // .WithChildEntityList("Companies",typeof(Company),args); 27 | Hydrator hydrator = new Hydrator() 28 | .With(x => x.Company, new FromListGetSingleGenerator((IList)Application["companies"])) 29 | .With(x => x.Companies, new ListGenerator(listSize)); 30 | Application["customers"] = hydrator.GetList(50); 31 | 32 | 33 | 34 | 35 | } 36 | 37 | protected void Session_Start(object sender, EventArgs e) 38 | { 39 | 40 | } 41 | 42 | protected void Application_BeginRequest(object sender, EventArgs e) 43 | { 44 | 45 | } 46 | 47 | protected void Application_AuthenticateRequest(object sender, EventArgs e) 48 | { 49 | 50 | } 51 | 52 | protected void Application_Error(object sender, EventArgs e) 53 | { 54 | 55 | } 56 | 57 | protected void Session_End(object sender, EventArgs e) 58 | { 59 | 60 | } 61 | 62 | protected void Application_End(object sender, EventArgs e) 63 | { 64 | 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /SampleWebApplication/Menu.ascx: -------------------------------------------------------------------------------- 1 | <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Menu.ascx.cs" Inherits="SampleWebApplication.Menu" %> 2 |

3 | Home | 4 | Add A Customer | 5 | Search for a customer ('real') 6 | Search for a customer ('fake')

7 | -------------------------------------------------------------------------------- /SampleWebApplication/Menu.ascx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SampleWebApplication 4 | { 5 | public partial class Menu : System.Web.UI.UserControl 6 | { 7 | protected void Page_Load(object sender, EventArgs e) 8 | { 9 | 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /SampleWebApplication/Menu.ascx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4016 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SampleWebApplication { 12 | 13 | 14 | public partial class Menu { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SampleWebApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("SampleWebApplication")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("SampleWebApplication")] 12 | [assembly: AssemblyCopyright("Copyright © 2009")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | [assembly: AssemblyVersion("1.0.0.0")] 34 | [assembly: AssemblyFileVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /SampleWebApplication/SampleWebApplication.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 9.0.30729 8 | 2.0 9 | {D43EF567-08DE-479D-9D03-1820595911CF} 10 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 11 | Library 12 | Properties 13 | SampleWebApplication 14 | SampleWebApplication 15 | v4.5 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 3.5 27 | 28 | false 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | true 38 | full 39 | false 40 | bin\ 41 | DEBUG;TRACE 42 | prompt 43 | 4 44 | AllRules.ruleset 45 | false 46 | 47 | 48 | pdbonly 49 | true 50 | bin\ 51 | TRACE 52 | prompt 53 | 4 54 | AllRules.ruleset 55 | false 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | AddCustomer.aspx 86 | ASPXCodeBehind 87 | 88 | 89 | AddCustomer.aspx 90 | 91 | 92 | 93 | 94 | CustomerFakeLookup.aspx 95 | ASPXCodeBehind 96 | 97 | 98 | CustomerFakeLookup.aspx 99 | 100 | 101 | CustomerRealLookUp.aspx 102 | ASPXCodeBehind 103 | 104 | 105 | CustomerRealLookUp.aspx 106 | 107 | 108 | 109 | ASPXCodeBehind 110 | Default.aspx 111 | 112 | 113 | Default.aspx 114 | 115 | 116 | Global.asax 117 | 118 | 119 | Menu.ascx 120 | ASPXCodeBehind 121 | 122 | 123 | Menu.ascx 124 | 125 | 126 | 127 | 128 | 129 | {8B60029E-DC22-4019-8AD6-E6A6A0CAEBFA} 130 | Foundation.ObjectHydrator 131 | 132 | 133 | 134 | 135 | 136 | 137 | 10.0 138 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 139 | 140 | 141 | 142 | 143 | 150 | 151 | 152 | 153 | 154 | False 155 | True 156 | 3462 157 | / 158 | 159 | 160 | False 161 | False 162 | 163 | 164 | False 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /SampleWebApplication/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 13 | 14 | 20 | 21 | 26 | 27 | 39 | 40 | 41 | 45 | --------------------------------------------------------------------------------