コード例 #1
0
ファイル: IdentityStep.cs プロジェクト: oblivious/Oblivious
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: Converge.cs プロジェクト: phoenixyj/haipa
        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;
        }
コード例 #6
0
 public void WrongConstructorArgumentType()
 {
     Assert.ThrowsException <ArgumentException>(() => GeneratorBuilder.BuildGenerator(typeof(WrongConstructorArgumentTypeClass), 20));
 }
コード例 #7
0
 public void WrongType()
 {
     Assert.ThrowsException <ArgumentException>(() => GeneratorBuilder.BuildGenerator(typeof(int)));
 }
コード例 #8
0
 public GeneratorInstance(GeneratorMapping mapping, Type type)
     : base(mapping)
 {
     this.mapping = mapping;
     builder      = new GeneratorBuilder(mapping, type);
 }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
ファイル: IdentityStep.cs プロジェクト: umittal/MunimJi
        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;
        }
コード例 #12
0
 public GeneratorInstance(GeneratorMapping mapping, Type type)
     : base(mapping)
 {
     builder = new GeneratorBuilder(mapping, type, Layer.Conventions);
 }