Beispiel #1
0
        public void Load_InstanceMembers_InsideConstructor_Loaded()
        {
            var config = new Configuration(options =>
            {
                options
                .UseJsonConverter()
                .UseInMemory(new[]
                {
                    new Setting {
                        Name = "PublicProperty", Value = "a"
                    },
                    new Setting {
                        Name = "PrivateProperty", Value = "b"
                    },
                    new Setting {
                        Name = "PublicField", Value = "c"
                    },
                    new Setting {
                        Name = "PrivateField", Value = "d"
                    },
                    new Setting {
                        Name = "PrivateReadOnlyField", Value = "e"
                    },
                    new Setting {
                        Name = "PublicReadOnlyProperty", Value = "f"
                    },
                });
            });

            var x = new InstanceClass(config);

            CollectionAssert.AreEqual(new[] { "a", "b", "c", "d", "e", "f" }, x.GetValues().ToList());
        }
Beispiel #2
0
        private void ModdingReflectionHelperReadTest()
        {
            Log("=========Reflection Read Start==========");
            InstanceClass instance = new InstanceClass();

            // get  StaticClass._static_field
            FieldInfo fi = ReflectionHelper.GetField(typeof(StaticClass), "_static_field", false);

            Log($"StaticClass._static_field is {fi.GetValue(null)}");

            // get  InstanceClass._static_field
            //first way
            fi = ReflectionHelper.GetField(typeof(InstanceClass), "_static_field", false);
            Log($"(First way)InstanceClass._static_field is {fi.GetValue(null)}");
            //second way

            /*string val = ReflectionHelper.GetAttr<InstanceClass, string>("_static_field");
             * Log($"(second way)InstanceClass._static_field is {val}");*/

            // get InstanceClass._non_static_field
            //first way
            fi = ReflectionHelper.GetField(typeof(InstanceClass), "_non_static_field");
            Log($"(First way)InstanceClass._non_static_field is {fi.GetValue(instance)}");
            //second way
            int nonstatic = ReflectionHelper.GetAttr <InstanceClass, int>(instance, "_non_static_field");

            Log($"(second way)InstanceClass._non_static_field is {nonstatic}");

            Log("=========Reflection End==========");
        }
Beispiel #3
0
        private void ModdingReflectionHelperWriteTest()
        {
            Log("=========Reflection Write Start==========");
            InstanceClass instance = new InstanceClass();

            // set  StaticClass._static_field
            FieldInfo fi = ReflectionHelper.GetField(typeof(StaticClass), "_static_field", false);

            fi.SetValue(null, "modify static field in static");
            Log($"StaticClass._static_field is {fi.GetValue(null)}"); // verify change

            // set  InstanceClass._static_field
            fi = ReflectionHelper.GetField(typeof(InstanceClass), "_static_field", false);
            fi.SetValue(null, "modify static field in instance");
            Log($"(First way)InstanceClass._static_field is {fi.GetValue(null)}"); // verify

            // set InstanceClass._non_static_field
            //first way
            fi = ReflectionHelper.GetField(typeof(InstanceClass), "_non_static_field");
            fi.SetValue(instance, 1);
            Log($"(First way)InstanceClass._non_static_field is {fi.GetValue(instance)}");
            //second way
            ReflectionHelper.SetAttr <InstanceClass, int>(instance, "_non_static_field", 2);
            int nonstatic = ReflectionHelper.GetAttr <InstanceClass, int>(instance, "_non_static_field");

            Log($"(second way)InstanceClass._non_static_field is {nonstatic}");

            Log("=========Reflection End==========");
        }
Beispiel #4
0
        private void VasiMirrorWriteTest()
        {
            Log("=========Mirror Write Start==========");
            InstanceClass instance = new InstanceClass();

            //first way : use SetField
            Mirror.SetField <InstanceClass, string>("_static_field", "modify static in instance");
            string f1 = Mirror.GetField <InstanceClass, string>("_static_field");

            Log($"InstanceClass._static_field is {f1}");

            //second way : use ref
            ref string rf1 = ref Mirror.GetFieldRef <InstanceClass, string>("_static_field");
Beispiel #5
0
        private void VasiMirrorReadTest()
        {
            Log("=========Mirror Read Start==========");
            InstanceClass instance = new InstanceClass();

            string f1 = Mirror.GetField <InstanceClass, string>("_static_field");

            Log($"InstanceClass._static_field is {f1}");

            int f2 = Mirror.GetField <InstanceClass, int>(instance, "_non_static_field");

            Log($"InstanceClass._non_static_field is {f2}");

            Log("=========Mirror End==========");
        }
Beispiel #6
0
            internal static InstanceClass GetInstanceClass()
            {
                var instance = new InstanceClass();

                if (!InitFromFile(ref instance.ViewLists, ViewListFile))
                {
                    //instance.ViewLists.Add(new ViewList("Version", 100));
                }
                if (!InitFromFile(ref instance.ViewBoxes, ViewBoxFile))
                {
                    instance.ViewBoxes.Add(new ViewBox("Author", Colors.Gray));
                    instance.ViewBoxes.Add(new ViewBox("Tags", Colors.Gray));
                    instance.ViewBoxes.Add(new ViewBox("Description", Colors.Black));
                }
                return(instance);
            }
Beispiel #7
0
 public IDatabaseInstance AddDatabase(PostgresEngineVersion databaseEngineVersion, string identification, string databaseName, string userName, string password, StorageType storageType, InstanceClass instanceClass, InstanceSize instanceSize, IVpc vpc, string securityGroupId, string securityGroupName, string parameterGroupId = null, IRole[] roles = null, double?allocatedStorageGb = 5, RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, bool deleteAutomatedBackups = false, int backupRetentionDays = 1, bool deletionProtection = false, SubnetType subnetType = SubnetType.PUBLIC, bool allowGroupAllOutbound = true, string defaultSubnetDomainSeparator = ",")
 {
     return(AwsCdkDatabaseHandler.CreateDatabase(databaseEngineVersion, identification, databaseName, userName, password, storageType,
                                                 instanceClass, instanceSize, vpc, securityGroupId, securityGroupName, parameterGroupId, roles, allocatedStorageGb, removalPolicy, deleteAutomatedBackups,
                                                 backupRetentionDays, deletionProtection, subnetType, defaultSubnetDomainSeparator));
 }
Beispiel #8
0
 public IDatabaseCluster AddDatabase(AuroraPostgresEngineVersion databaseEngineVersion, string identification, string clusterIdentifier, string instanceIdentifierBase, string databaseName, double?port, double?instances, string userName, string secretName, IVpc vpc, InstanceClass instanceClass, InstanceSize instanceSize, string securityId, string securityGroupId, string parameterGroupId = null, IRole[] roles = null, bool storageEncrypted = true, SubnetType subnetType = SubnetType.PRIVATE, string subnets = "", RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, int backupRetentionDays = 1, bool deletionProtection = false, string defaultSubnetDomainSeparator = ",")
 {
     return(AwsCdkDatabaseHandler.CreateDatabaseCluster(databaseEngineVersion, identification, clusterIdentifier,
                                                        instanceIdentifierBase, databaseName, port, instances, userName, secretName, vpc, instanceClass,
                                                        instanceSize, securityId, securityGroupId, parameterGroupId, roles, storageEncrypted, subnetType, defaultSubnetDomainSeparator, subnets, removalPolicy, backupRetentionDays));
 }
        public IDatabaseInstance CreateDatabase(DeputyBase databaseEngineVersion, string identification, string databaseName, double?port, string userName, string secretName, StorageType storageType, InstanceClass instanceClass, InstanceSize instanceSize, IVpc vpc, string securityId, string securityGroupId, string parameterGroupId = null, IRole[] roles = null, double?allocatedStorageGb = 5, RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, bool deleteAutomatedBackups = false, int backupRetentionDays = 1, bool deletionProtection = false, SubnetType subnetType = SubnetType.PRIVATE_ISOLATED, string defaultSubnetDomainSeparator = ",", string subnets = "", bool multiAZEnabled = true, bool autoMinorVersionUpgrade = false, bool?storageEncrypted = true)
        {
            BasicDatabaseInfra(vpc, secretName, securityId, securityGroupId, subnetType, defaultSubnetDomainSeparator, subnets, out var securityGroup, out var secret, out var subnetSelection);
            var engine = GetInstanceEngine(databaseEngineVersion);

            return(new DatabaseInstance(Scope, identification, new DatabaseInstanceProps
            {
                Engine = engine,
                RemovalPolicy = removalPolicy,
                DeletionProtection = deletionProtection,
                Credentials = Credentials.FromPassword(userName, secret.SecretValue),
                StorageType = storageType,
                DatabaseName = databaseName,
                Port = port,
                VpcSubnets = subnetSelection,
                Vpc = vpc,
                SecurityGroups = new[]
                {
                    securityGroup
                },
                DeleteAutomatedBackups = deleteAutomatedBackups,
                BackupRetention = Duration.Days(backupRetentionDays),
                AllocatedStorage = allocatedStorageGb,
                InstanceType = InstanceType.Of(instanceClass, instanceSize),
                ParameterGroup = CreateClusterParameterGroup(parameterGroupId, engine, roles),
                MultiAz = multiAZEnabled,
                AutoMinorVersionUpgrade = autoMinorVersionUpgrade,
                StorageEncrypted = storageEncrypted
            }));
        }
 public IDatabaseInstance AddDatabase(MysqlEngineVersion databaseEngineVersion, string identification, string databaseName, double?port, string userName, ISecret passwordSecret, StorageType storageType, InstanceClass instanceClass, InstanceSize instanceSize, IVpc vpc, ISecurityGroup securityGroup, ISubnetGroup subnetGroup, IParameterGroup parameterGroup = null, double?allocatedStorageGb = 5, RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, bool deleteAutomatedBackups = false, int backupRetentionDays = 1, bool deletionProtection = false, string[] logTypes = null, bool?storageEncrypted = null, bool?enableIamAuthentication = null, Duration enhancedMonitoringInterval = null, bool multiAZEnabled = true, bool autoMinorVersionUpgrade = false)     //NOSONAR number of params
 {
     return(HandlerResources.AwsCdkDatabaseHandler.CreateDatabase(databaseEngineVersion, identification, databaseName, port, userName, passwordSecret, storageType,
                                                                  instanceClass, instanceSize, vpc, securityGroup, subnetGroup, parameterGroup, allocatedStorageGb, removalPolicy, deleteAutomatedBackups,
                                                                  backupRetentionDays, deletionProtection, logTypes, storageEncrypted, enableIamAuthentication, enhancedMonitoringInterval, multiAZEnabled, autoMinorVersionUpgrade));
 }
        public IDatabaseInstance CreateDatabaseSqlServer(DeputyBase databaseEngineVersion, string identification, string databaseName, string userName, string password, StorageType storageType, InstanceClass instanceClass, string instanceSize, IVpc vpc, ISecurityGroup security, string securityGroupId, string parameterGroupId = null, IRole[] roles = null, double?allocatedStorageGb = 5, RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, bool deleteAutomatedBackups = false, int backupRetentionDays = 1, bool?deletionProtection = false, SubnetType subnetType = SubnetType.PRIVATE_ISOLATED, string defaultSubnetDomainSeparator = ",", string subnets = "", bool multiAZEnabled = true, bool?autoMinorVersionUpgrade = false, bool?storageEncrypted = true, string licenseOption = "LICENSE_INCLUDED", string edition = "ex")
        {
            BasicDatabaseInfraWithHardcodedPassword(vpc, subnetType, defaultSubnetDomainSeparator, subnets, out var subnetSelection);
            var engine = GetInstanceEngine(databaseEngineVersion, edition);

            return(new DatabaseInstance(Scope, identification, new DatabaseInstanceProps
            {
                Engine = engine,
                RemovalPolicy = removalPolicy,
                DeletionProtection = deletionProtection,
                Credentials = Credentials.FromPassword(userName, SecretValue.PlainText(password)),
                StorageType = storageType,
                DatabaseName = licenseOption == LicenseModel.LICENSE_INCLUDED.ToString() ? null : databaseName,
                VpcSubnets = subnetSelection,
                Vpc = vpc,
                SecurityGroups = new[]
                {
                    security
                },
                DeleteAutomatedBackups = deleteAutomatedBackups,
                BackupRetention = Duration.Days(backupRetentionDays),
                AllocatedStorage = allocatedStorageGb,
                InstanceType = InstanceType.Of(instanceClass, GetInstanceSize(instanceSize)),
                ParameterGroup = CreateClusterParameterGroup(parameterGroupId, engine, roles),
                MultiAz = multiAZEnabled,
                AutoMinorVersionUpgrade = autoMinorVersionUpgrade,
                StorageEncrypted = storageEncrypted,
                LicenseModel = GetLicenseModel(licenseOption)
            }));
        }
        public IDatabaseInstance CreateDatabase(DeputyBase databaseEngineVersion, string identification, string databaseName, double?port, string userName, ISecret passwordSecret, StorageType storageType, InstanceClass instanceClass, InstanceSize instanceSize, IVpc vpc, ISecurityGroup securityGroup, ISubnetGroup subnetGroup, IParameterGroup parameterGroup = null, double?allocatedStorageGb = 5, RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, bool deleteAutomatedBackups = false, int backupRetentionDays = 1, bool deletionProtection = false, string[] logTypes = null, bool?storageEncrypted = null, bool?enableIamAuthentication = false, Duration enhancedMonitoringInterval = null, bool multiAZEnabled = true, bool autoMinorVersionUpgrade = false)
        {
            BasicDatabaseInfra(vpc);
            var engine = GetInstanceEngine(databaseEngineVersion);

            return(new DatabaseInstance(Scope, identification, new DatabaseInstanceProps
            {
                Engine = engine,
                RemovalPolicy = removalPolicy,
                DeletionProtection = deletionProtection,
                Credentials = Credentials.FromPassword(userName, passwordSecret.SecretValue),
                StorageType = storageType,
                DatabaseName = databaseName,
                Port = port,
                SubnetGroup = subnetGroup,
                Vpc = vpc,
                SecurityGroups = new[]
                {
                    securityGroup
                },
                DeleteAutomatedBackups = deleteAutomatedBackups,
                BackupRetention = Duration.Days(backupRetentionDays),
                AllocatedStorage = allocatedStorageGb,
                InstanceType = InstanceType.Of(instanceClass, instanceSize),
                ParameterGroup = parameterGroup,
                CloudwatchLogsExports = logTypes,
                StorageEncrypted = storageEncrypted,
                IamAuthentication = enableIamAuthentication,
                MonitoringInterval = enhancedMonitoringInterval,
                MultiAz = multiAZEnabled,
                AutoMinorVersionUpgrade = autoMinorVersionUpgrade
            }));
        }
Beispiel #13
0
 void Awake()
 {
     instance         = this;
     TextAssetManager = transform.GetComponent <TextAssetManager>();
 }
Beispiel #14
0
 public static void Restore(InstanceClass ic)
 {
     ic.Value = ((IInstanceClassInternal)ic).OldValue;
 }
Beispiel #15
0
 public static void Backup(InstanceClass ic)
 {
     ((IInstanceClassInternal)ic).OldValue = ic.Value;
 }
        /// <summary>
        /// AwsCdkDatabaseHandler
        /// </summary>
        /// <param name="databaseEngineVersion"></param>
        /// <param name="identification"></param>
        /// <param name="clusterIdentifier"></param>
        /// <param name="instanceIdentifierBase"></param>
        /// <param name="databaseName"></param>
        /// <param name="port"></param>
        /// <param name="instances"></param>
        /// <param name="userName"></param>
        /// <param name="secretName"></param>
        /// <param name="vpc"></param>
        /// <param name="instanceClass"></param>
        /// <param name="instanceSize"></param>
        /// <param name="securityId"></param>
        /// <param name="securityGroupId"></param>
        /// <param name="parameterGroupId"></param>
        /// <param name="roles"></param>
        /// <param name="storageEncrypted"></param>
        /// <param name="subnetType"></param>
        /// <param name="defaultSubnetDomainSeparator"></param>
        /// <param name="subnets"></param>
        /// <param name="removalPolicy"></param>
        /// <param name="backupRetentionDays"></param>
        /// <param name="deletionProtection"></param>
        public IDatabaseCluster CreateDatabaseCluster(DeputyBase databaseEngineVersion, string identification, string clusterIdentifier, string instanceIdentifierBase, string databaseName, double?port, double?instances, string userName, string secretName, IVpc vpc, InstanceClass instanceClass, InstanceSize instanceSize, string securityId, string securityGroupId, string parameterGroupId = null, IRole[] roles = null, bool storageEncrypted = true, SubnetType subnetType = SubnetType.PRIVATE_ISOLATED, string defaultSubnetDomainSeparator = ",", string subnets = "", RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, int backupRetentionDays = 1, bool deletionProtection = false)
        {
            BasicDatabaseInfra(vpc, secretName, securityId, securityGroupId, subnetType, defaultSubnetDomainSeparator, subnets, out var securityGroup, out var secret, out var subnetSelection);
            var engine = GetClusterEngine(databaseEngineVersion);

            return(new DatabaseCluster(Scope, identification, new DatabaseClusterProps
            {
                ClusterIdentifier = clusterIdentifier,
                InstanceIdentifierBase = instanceIdentifierBase,
                Engine = engine,
                RemovalPolicy = removalPolicy,
                DeletionProtection = deletionProtection,
                Port = port,
                InstanceProps = new Amazon.CDK.AWS.RDS.InstanceProps
                {
                    InstanceType = InstanceType.Of(instanceClass, instanceSize),
                    VpcSubnets = subnetSelection,
                    Vpc = vpc,
                    SecurityGroups = new[]
                    {
                        securityGroup
                    }
                },
                StorageEncrypted = storageEncrypted,
                Instances = instances,
                Credentials = Credentials.FromPassword(userName, secret.SecretValue),
                DefaultDatabaseName = databaseName,
                ParameterGroup = CreateClusterParameterGroup(parameterGroupId, engine, roles),
                Backup = new BackupProps
                {
                    Retention = Duration.Days(backupRetentionDays)
                }
            }));
        }
 public IDatabaseInstance AddDatabase(SqlServerEngineVersion databaseEngineVersion, string identification, string databaseName, string userName, string password, StorageType storageType, InstanceClass instanceClass, string instanceSize, IVpc vpc, ISecurityGroup securityGroup, string securityGroupName, string parameterGroupId = null, IRole[] roles = null, double?allocatedStorageGb = 5, RemovalPolicy removalPolicy = RemovalPolicy.DESTROY, bool deleteAutomatedBackups = false, int backupRetentionDays = 1, bool?deletionProtection = false, SubnetType subnetType = SubnetType.PUBLIC, bool allowGroupAllOutbound = true, string defaultSubnetDomainSeparator = ",", bool multiAZEnabled = true, bool?storageEncrypted = true, string licenseOption = "LICENSE_INCLUDED", string edition = "ex", bool?autoMinorVersionUpgrade = false)     //NOSONAR number of params
 {
     return(HandlerResources.AwsCdkDatabaseHandler.CreateDatabaseSqlServer(databaseEngineVersion, identification, databaseName, userName, password, storageType,
                                                                           instanceClass, instanceSize, vpc, securityGroup, identification, parameterGroupId, roles, allocatedStorageGb, removalPolicy, deleteAutomatedBackups,
                                                                           backupRetentionDays, deletionProtection, subnetType, defaultSubnetDomainSeparator, storageEncrypted: storageEncrypted, licenseOption: licenseOption, edition: edition, autoMinorVersionUpgrade: autoMinorVersionUpgrade));
 }