static void ConfigureByStObjConstruct(IActivityMonitor monitor, IStObjMutableItem o, SqlDatabase db)
            {
                var fromAbove = o.ConstructParametersAboveRoot;

                Debug.Assert(fromAbove != null, "Since we are on the root of the specializations path.");
                fromAbove.Should().NotBeEmpty().And.HaveCount(1, "We have only one base class with a StObjConstruct method.");
                var(t, parameters) = fromAbove.Single();
                t.Should().Be(typeof(SqlDatabase));

                if (parameters.Count != 3 ||
                    parameters[0].Name != "connectionString" ||
                    parameters[0].Type != typeof(string) ||
                    parameters[1].Name != "hasCKCore" ||
                    parameters[1].Type != typeof(bool) ||
                    parameters[2].Name != "useSnapshotIsolation" ||
                    parameters[2].Type != typeof(bool))
                {
                    throw new CKException("Expected SqlDatabase.StObjContruct(string connectionString, bool hasCKCore, bool useSnapshotIsolation)");
                }
                if (db.IsDefaultDatabase)
                {
                    parameters[0].SetParameterValue("The default connection string.");
                }
                else if (db.Name == "histo")
                {
                    parameters[0].SetParameterValue("The histo connection string.");
                    parameters[1].SetParameterValue(true);
                    parameters[2].SetParameterValue(true);
                }
                else
                {
                    monitor.Warn($"Unable to find configuration for Database named '{db.Name}' of type {db.GetType()}. Its ConnectionString will be null.");
                }
            }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     if (o.ClassType == typeof(C1))
     {
         o.SetAmbientPropertyConfiguration(monitor, "Ambient", typeof(TypeToMap), StObjRequirementBehavior.ErrorIfNotStObj);
     }
 }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     if (o.ClassType == typeof(BaseObjectAmbient))
     {
         o.SetAmbientPropertyValue(monitor, "OneStringValue", "Pouf", "ConfiguratorOneStringValueSetToPouf");
     }
 }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     if (o.ClassType == typeof(A))
     {
         o.SetStObjPropertyValue(monitor, "StObjPower", "This is the A property.");
     }
     if (o.ClassType == typeof(ASpec))
     {
         o.SetStObjPropertyValue(monitor, "StObjPower", "ASpec level property.");
     }
 }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     if (o.ClassType == typeof(SimpleObjectDirect))
     {
         o.SetDirectPropertyValue(monitor, "OneIntValue", 42, "ConfiguratorOneIntValueSetTo42");
     }
     if (o.ClassType == typeof(SimpleObjectAmbient))
     {
         o.SetAmbientPropertyValue(monitor, "OneIntValue", 42, "ConfiguratorOneIntValueSetTo42");
     }
 }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     if (o.InitialObject is SqlDatabase db && o.Generalization == null)
     {
         if (_mode == "UseStObjConstruct")
         {
             ConfigureByStObjConstruct(monitor, o, db);
         }
         else if (_mode == "UseSetDirectProperty")
         {
             ConfigureByDirectSetProperties(monitor, o, db);
         }
     }
 }
 // This is NOT how it works in CK.SqlServer.Setup.Engine: StObjConstruct is used.
 static void ConfigureByDirectSetProperties(IActivityMonitor monitor, IStObjMutableItem o, SqlDatabase db)
 {
     if (db.IsDefaultDatabase)
     {
         o.SetDirectPropertyValue(monitor, nameof(SqlDatabase.ConnectionString), "The default connection string.", sourceDescription: "By configurator.");
     }
     else if (db.Name == "histo")
     {
         o.SetDirectPropertyValue(monitor, nameof(SqlDatabase.ConnectionString), "The histo connection string.", sourceDescription: "By configurator.");
         o.SetDirectPropertyValue(monitor, nameof(SqlDatabase.HasCKCore), true, sourceDescription: "By configurator.");
         o.SetDirectPropertyValue(monitor, nameof(SqlDatabase.UseSnapshotIsolation), true, sourceDescription: "By configurator.");
     }
     else
     {
         monitor.Warn($"Unable to find configuration for Database named '{db.Name}' of type {db.GetType()}. Its ConnectionString will be null.");
     }
 }
Ejemplo n.º 8
0
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     if (o.ClassType == typeof(SimpleContainer))
     {
         o.SetStObjPropertyValue(monitor, "SchmurtzProp", new SchmurtzProperty("Root"));
     }
     if (o.ClassType == typeof(SpecializedContainer))
     {
         o.SetStObjPropertyValue(monitor, "SchmurtzProp", new SchmurtzProperty("SpecializedContainer specializes Root"));
     }
     if (o.ClassType == typeof(BaseObject))
     {
         o.SetStObjPropertyValue(monitor, "SchmurtzProp", new SchmurtzProperty("BaseObject belongs to SpecializedContainer"));
     }
     if (o.ClassType == typeof(SpecializedObject))
     {
         o.SetStObjPropertyValue(monitor, "SchmurtzProp", new SchmurtzProperty("Finally: SpecializedObject inherits from BaseObject"));
     }
     if (o.ClassType == typeof(SpecializedObjectWithExplicitContainer))
     {
         o.SetStObjPropertyValue(monitor, "SchmurtzProp", new SchmurtzProperty("SpecializedObjectWithExplicitContainer inherits from BaseObject BUT is directly associated to SpecializedContainer"));
     }
 }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     o.SetAmbientPropertyValue(monitor, PropertyName, PropertyValue, sourceDescription: "AmbientPropertySetAttribute");
 }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     o.SetDirectPropertyValue(monitor, PropertyName, PropertyValue, "DirectPropertySetAttribute");
 }
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     _conf?.Invoke(o);
 }
Ejemplo n.º 12
0
 public void Configure(IActivityMonitor monitor, IStObjMutableItem o)
 {
     o.SetStObjPropertyValue(monitor, PropertyName, PropertyValue);
 }