public void PropSetter_ViewManager_PropType_Number() { var methods = new[] { (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestByte(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestSByte(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestInt16(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestUInt16(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestInt32(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestUInt32(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestInt64(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestUInt64(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestSingle(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestDouble(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestDecimal(null, 0)), }; foreach (var method in methods) { foreach (var setter in PropSetter.CreateViewManagerSetters <object>(method)) { Assert.AreEqual("number", setter.PropType); } } }
public SqlCommandSet() { instance = Activator.CreateInstance(sqlCmdSetType, true); connectionSetter = (PropSetter <SqlConnection>) Delegate.CreateDelegate(typeof(PropSetter <SqlConnection>), instance, "set_Connection"); transactionSetter = (PropSetter <SqlTransaction>) Delegate.CreateDelegate(typeof(PropSetter <SqlTransaction>), instance, "set_Transaction"); commandTimeoutSetter = (PropSetter <int>) Delegate.CreateDelegate(typeof(PropSetter <int>), instance, "set_CommandTimeout"); connectionGetter = (PropGetter <SqlConnection>) Delegate.CreateDelegate(typeof(PropGetter <SqlConnection>), instance, "get_Connection"); commandGetter = (SqlCommandSet.PropGetter <System.Data.SqlClient.SqlCommand>) Delegate.CreateDelegate(typeof(SqlCommandSet.PropGetter <System.Data.SqlClient.SqlCommand>), instance, "get_BatchCommand"); doAppend = (AppendCommand)Delegate.CreateDelegate(typeof(AppendCommand), instance, "Append"); doExecuteNonQuery = (ExecuteNonQueryCommand) Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteNonQuery"); doDispose = (DisposeCommand)Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); }
public SqlClientSqlCommandSet() { instance = Activator.CreateInstance(sqlCmdSetType, true); connectionSetter = (PropSetter<SqlConnection>) Delegate.CreateDelegate(typeof(PropSetter<SqlConnection>), instance, "set_Connection"); transactionSetter = (PropSetter<SqlTransaction>) Delegate.CreateDelegate(typeof(PropSetter<SqlTransaction>), instance, "set_Transaction"); commandTimeoutSetter = (PropSetter<int>) Delegate.CreateDelegate(typeof(PropSetter<int>), instance, "set_CommandTimeout"); connectionGetter = (PropGetter<SqlConnection>) Delegate.CreateDelegate(typeof(PropGetter<SqlConnection>), instance, "get_Connection"); commandGetter = (SqlClientSqlCommandSet.PropGetter<System.Data.SqlClient.SqlCommand>) Delegate.CreateDelegate(typeof(SqlClientSqlCommandSet.PropGetter<System.Data.SqlClient.SqlCommand>), instance, "get_BatchCommand"); doAppend = (AppendCommand) Delegate.CreateDelegate(typeof(AppendCommand), instance, "Append"); doExecuteNonQuery = (ExecuteNonQueryCommand) Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteNonQuery"); doDispose = (DisposeCommand) Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); }
public void PropSetter_ViewManager_Name() { var method = (MethodInfo)ReflectionHelpers.InfoOf((Test t) => t.TestString(null, null)); var setters = PropSetter.CreateViewManagerSetters <object>(method); Assert.AreEqual(1, setters.Count()); Assert.AreEqual("TestString", setters.First().Name); }
public void PropSetter_CustomType() { var setter = PropSetter.CreateShadowNodeSetters( (MethodInfo)ReflectionHelpers.InfoOf( (TestShadowNode t) => t.TestCustom(0))).Single(); Assert.AreEqual("myInt", setter.PropType); }
public void PropSetter_ArgumentChecks() { AssertEx.Throws <ArgumentNullException>( () => PropSetter.CreateShadowNodeSetters(null).ToList(), ex => Assert.AreEqual("method", ex.ParamName)); AssertEx.Throws <ArgumentNullException>( () => PropSetter.CreateViewManagerSetters <object>(null).ToList(), ex => Assert.AreEqual("method", ex.ParamName)); }
public MySqlClientSqlCommandSet(int batchSize) { instance = Activator.CreateInstance(sqlCmdSetType, true); doInitialise = (InitialiseCommand)Delegate.CreateDelegate(typeof(InitialiseCommand), instance, "InitializeBatching"); batchSizeSetter = (PropSetter<int>)Delegate.CreateDelegate(typeof(PropSetter<int>), instance, "set_UpdateBatchSize"); doAppend = (AppendCommand)Delegate.CreateDelegate(typeof(AppendCommand), instance, "AddToBatch"); doExecuteNonQuery = (ExecuteNonQueryCommand)Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteBatch"); doDispose = (DisposeCommand)Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); Initialise(batchSize); }
public MySqlClientSqlCommandSet(int batchSize) { instance = Activator.CreateInstance(sqlCmdSetType, true); doInitialise = (InitialiseCommand)Delegate.CreateDelegate(typeof(InitialiseCommand), instance, "InitializeBatching"); batchSizeSetter = (PropSetter <int>)Delegate.CreateDelegate(typeof(PropSetter <int>), instance, "set_UpdateBatchSize"); doAppend = (AppendCommand)Delegate.CreateDelegate(typeof(AppendCommand), instance, "AddToBatch"); doExecuteNonQuery = (ExecuteNonQueryCommand)Delegate.CreateDelegate(typeof(ExecuteNonQueryCommand), instance, "ExecuteBatch"); doDispose = (DisposeCommand)Delegate.CreateDelegate(typeof(DisposeCommand), instance, "Dispose"); Initialise(batchSize); }
public void PropSetter_ViewManager_PropType_Nullable_Boolean() { var setters = PropSetter.CreateViewManagerSetters <object>( (MethodInfo)ReflectionHelpers.InfoOf( (Test t) => t.TestNullable(null, false))); foreach (var setter in setters) { Assert.AreEqual("boolean", setter.PropType); } }
public void PropSetter_ShadowNode_PropType() { var setters = PropSetter.CreateShadowNodeSetters( (MethodInfo)ReflectionHelpers.InfoOf( (TestShadowNode t) => t.TestArray(null))); foreach (var setter in setters) { Assert.AreEqual("Array", setter.PropType); } }
public void PropSetter_ViewManager_PropType_String() { var setters = PropSetter.CreateViewManagerSetters <object>( (MethodInfo)ReflectionHelpers.InfoOf( (Test t) => t.TestString(null, null))); foreach (var setter in setters) { Assert.AreEqual("String", setter.PropType); } }
public override void SaveControlSettings( Window control, string settingName, SettingsBag <TSettings> settings) { WndSettings setting = new WndSettings(); setting.Location = new Point(control.Left, control.Top); setting.Size = new Size(control.Width, control.Height); PropSetter.SetValue(settings.Settings, settingName, setting); }
public void PropSetter_DefaultValue() { var methods = new[] { (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestBoolean(null, false)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestByte(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestSByte(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestInt16(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestUInt16(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestInt32(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestUInt32(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestInt64(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestUInt64(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestSingle(null, 0)), (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestDouble(null, 0)), }; var instance = new DefaultTest(); Assert.AreEqual(default(byte), instance.TestByteValue); Assert.AreEqual(default(sbyte), instance.TestSByteValue); Assert.AreEqual(default(short), instance.TestInt16Value); Assert.AreEqual(default(ushort), instance.TestUInt16Value); Assert.AreEqual(default(int), instance.TestInt32Value); Assert.AreEqual(default(uint), instance.TestUInt32Value); Assert.AreEqual(default(long), instance.TestInt64Value); Assert.AreEqual(default(ulong), instance.TestUInt64Value); Assert.AreEqual(default(float), instance.TestSingleValue); Assert.AreEqual(default(double), instance.TestDoubleValue); Assert.AreEqual(false, instance.TestBooleanValue); var emptyMap = new JObject(); foreach (var method in methods) { var setter = PropSetter.CreateViewManagerSetters <object>(method).Single(); setter.UpdateViewManagerProp(instance, null, emptyMap); } Assert.AreEqual(byte.MaxValue, instance.TestByteValue); Assert.AreEqual(sbyte.MaxValue, instance.TestSByteValue); Assert.AreEqual(short.MaxValue, instance.TestInt16Value); Assert.AreEqual(ushort.MaxValue, instance.TestUInt16Value); Assert.AreEqual(int.MaxValue, instance.TestInt32Value); Assert.AreEqual(uint.MaxValue, instance.TestUInt32Value); Assert.AreEqual(long.MaxValue, instance.TestInt64Value); Assert.AreEqual(ulong.MaxValue, instance.TestUInt64Value); Assert.AreEqual(float.MaxValue, instance.TestSingleValue); Assert.AreEqual(double.MaxValue, instance.TestDoubleValue); Assert.AreEqual(true, instance.TestBooleanValue); }
public void PropSetter_ViewManager_Group() { var setters = PropSetter.CreateViewManagerSetters <object>( (MethodInfo)ReflectionHelpers.InfoOf( (Test t) => t.TestGroup(null, 0, null))).ToList(); Assert.AreEqual(3, setters.Count); Assert.IsNotNull(setters.FirstOrDefault(s => s.Name == "foo")); Assert.IsNotNull(setters.FirstOrDefault(s => s.Name == "bar")); Assert.IsNotNull(setters.FirstOrDefault(s => s.Name == "baz")); foreach (var setter in setters) { Assert.AreEqual("String", setter.PropType); } }
public void PropSetter_ShadowNode_Group() { var setters = PropSetter.CreateShadowNodeSetters( (MethodInfo)ReflectionHelpers.InfoOf( (TestShadowNode t) => t.TestGroup(0, null))).ToList(); Assert.AreEqual(3, setters.Count); Assert.IsNotNull(setters.FirstOrDefault(s => s.Name == "foo")); Assert.IsNotNull(setters.FirstOrDefault(s => s.Name == "bar")); Assert.IsNotNull(setters.FirstOrDefault(s => s.Name == "baz")); foreach (var setter in setters) { Assert.AreEqual("String", setter.PropType); } }
public void PropSetter_DefaultValue_Undefined() { var method = (MethodInfo)ReflectionHelpers.InfoOf((DefaultTest t) => t.TestBoolean(null, false)); var instance = new DefaultTest(); Assert.AreEqual(false, instance.TestBooleanValue); var emptyMap = new JObject { { "TestBoolean", JValue.CreateUndefined() }, }; var setter = PropSetter.CreateViewManagerSetters <object>(method).Single(); setter.UpdateViewManagerProp(instance, null, emptyMap); Assert.AreEqual(true, instance.TestBooleanValue); }
protected override void LoadControlSettings( Window control, string settingName, SettingsBag <TSettings> settings) { WndSettings setting = PropSetter.GetValue <WndSettings>(settings.Settings, settingName); //WndSettings setting = settings.GetSettingCmplx<WndSettings>(settingName, WndSettings.Empty); if (!setting.Equals(WndSettings.Empty)) { control.WindowStartupLocation = WindowStartupLocation.Manual; control.Left = setting.Location.X; control.Top = setting.Location.Y; control.Width = setting.Size.Width; control.Height = setting.Size.Height; } }
/// <summary> /// Append the specified setter to your list, making a prop setter that will set all the indicated properties. /// </summary> public void AppendProp(PropSetter props) { if (m_fHasBeenUsed) throw new ArgumentException("Cannot append to a PropSettings that has been used to make an assembled styles"); if (m_next == null) m_next = (PropSetterImpl) props; else m_next.AppendProp(props); // Put it on the end of the chain so this one happens first }
/// <summary> /// Return an AssembledStyles that has the properties of the recipient, modified as specified by /// the given setter (and any that have been appended to it). /// </summary> public AssembledStyles WithProperties(PropSetter setter) { if (setter == null) return this; // no setter, no change. return m_styleCache.GetDerivedStyle(this, setter); }
internal AssembledStyles(AssembledStyles basedOn, PropSetter setter) : this(basedOn) { var impl = (PropSetterImpl) setter; impl.SetProperty(this); }