GeneratorMapping GetDefaultGenerator(Member property) { var generatorMapping = new GeneratorMapping(); var defaultGenerator = new GeneratorBuilder(generatorMapping, property.PropertyType, Layer.Defaults); if (property.PropertyType == typeof(Guid)) defaultGenerator.GuidComb(); else if (identityCompatibleTypes.Contains(property.PropertyType)) defaultGenerator.Identity(); else defaultGenerator.Assigned(); return generatorMapping; }
private GeneratorMapping GetDefaultGenerator(Member property) { var generatorMapping = new GeneratorMapping(); var defaultGenerator = new GeneratorBuilder(generatorMapping, property.PropertyType); if (property.PropertyType == typeof(Guid)) defaultGenerator.GuidComb(); else if (property.PropertyType == typeof(int) || property.PropertyType == typeof(long)) defaultGenerator.Identity(); else defaultGenerator.Assigned(); return generatorMapping; }
GeneratorMapping GetDefaultGenerator(Member property) { var generatorMapping = new GeneratorMapping(); var defaultGenerator = new GeneratorBuilder(generatorMapping, property.PropertyType, Layer.Defaults); if (property.PropertyType == typeof(Guid)) { defaultGenerator.GuidComb(); } else if (identityCompatibleTypes.Contains(property.PropertyType)) { defaultGenerator.Identity(); } else { defaultGenerator.Assigned(); } return(generatorMapping); }
private GeneratorMapping GetDefaultGenerator(Member property) { var generatorMapping = new GeneratorMapping(); var defaultGenerator = new GeneratorBuilder(generatorMapping, property.PropertyType); if (property.PropertyType == typeof(Guid)) { defaultGenerator.GuidComb(); } else if (property.PropertyType == typeof(int) || property.PropertyType == typeof(long)) { defaultGenerator.Identity(); } else { defaultGenerator.Assigned(); } return(generatorMapping); }
private static void GenerateConfigDriveDisk(string configDriveIsoPath, string hostname, JObject userData) { try { GeneratorBuilder.Init() .NoCloud(new NoCloudConfigDriveMetaData(hostname)) .SwapFile() .UserData(userData) .Processing() .Image().ImageFile(configDriveIsoPath) .Generate(); } catch (Exception ex) { return; } return; }
public void WrongConstructorArgumentType() { Assert.ThrowsException <ArgumentException>(() => GeneratorBuilder.BuildGenerator(typeof(WrongConstructorArgumentTypeClass), 20)); }
public void WrongType() { Assert.ThrowsException <ArgumentException>(() => GeneratorBuilder.BuildGenerator(typeof(int))); }
public GeneratorInstance(GeneratorMapping mapping, Type type) : base(mapping) { this.mapping = mapping; builder = new GeneratorBuilder(mapping, type); }
private void SetDefaultGenerator() { var generatorMapping = new GeneratorMapping(); var defaultGenerator = new GeneratorBuilder(generatorMapping, property.PropertyType); if (property.PropertyType == typeof(Guid)) defaultGenerator.GuidComb(); else if (property.PropertyType == typeof(int) || property.PropertyType == typeof(long)) defaultGenerator.Identity(); else defaultGenerator.Assigned(); attributes.SetDefault(x => x.Generator, generatorMapping); }
private static int RunNoCloudAndReturnExitCode(NoCloudOptions opts) { try { var noCloudBuilder = GeneratorBuilder.Init() .NoCloud(new NoCloudConfigDriveMetaData(opts.Hostname)); if (!opts.NoSwapFile) { noCloudBuilder.SwapFile(); } if (!string.IsNullOrWhiteSpace(opts.Proxy)) { noCloudBuilder.ProxySettings(new ConfigDriveProxySettings(opts.Proxy) { NoProxy = opts.NoProxy }); } if (!string.IsNullOrWhiteSpace(opts.UserData)) { noCloudBuilder.UserData(ReadJsonFile(opts.UserData)); } if (!string.IsNullOrWhiteSpace(opts.NetworkData)) { noCloudBuilder.NetworkData(ReadJsonFile(opts.NetworkData)); } if (!string.IsNullOrWhiteSpace(opts.Content)) { noCloudBuilder.Content(opts.Content); } var processingBuilder = noCloudBuilder.Processing(); if (!string.IsNullOrWhiteSpace(opts.ImagePath)) { processingBuilder.Image().ImageFile(opts.ImagePath); } else { processingBuilder.Callback(result => { Console.WriteLine(result.MediaName); foreach (var resultFile in result.Files) { using (var reader = new StreamReader(resultFile.Content, Encoding.UTF8)) { reader.BaseStream.Seek(0, SeekOrigin.Begin); Console.WriteLine(reader.ReadToEnd()); } } }); } processingBuilder.Generate(); return(0); } catch (Exception ex) { Console.WriteLine(ex.Message); return(-1); } }
private static GeneratorMapping GetDefaultGenerator(Member property) { var generatorMapping = new GeneratorMapping(); var defaultGenerator = new GeneratorBuilder(generatorMapping, property.PropertyType, Layer.Defaults); if (property.PropertyType == typeof (Guid)) { defaultGenerator.GuidComb(); } else if (property.PropertyType == typeof (int) || property.PropertyType == typeof (long)) { defaultGenerator.Identity(); } else { defaultGenerator.Assigned(); } return generatorMapping; }
public GeneratorInstance(GeneratorMapping mapping, Type type) : base(mapping) { builder = new GeneratorBuilder(mapping, type, Layer.Conventions); }