|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace System.Web
{
public partial class Local : LocalBase
{
/// <summary>
/// An experimental class allowing to specify any object having a Text property in the target and source list.
/// Checkboxes, DropDownLists and RadioButtonLists are also supported.
/// </summary>
/// <typeparam name="T">The generic type T for the variable.</typeparam>
public class CompositeVar<T> : Var<T>
{
List<object> _targetControls { get; set; }
List<object> _sourceControls { get; set; }
public CompositeVar(string key, object targetObjects, params object[] sourceObjects)
: this(default(T), key, new List<object> { targetObjects }, sourceObjects) { }
public CompositeVar(string key, List<object> targetObjects, params object[] sourceObjects)
: this(default(T), key, targetObjects, sourceObjects) { }
public CompositeVar(T defaultValue, string key, List<object> targetObjects, params object[] sourceObjects)
: base(defaultValue, key, null, null, null, null)
{
List<Sources> sourceTypes = new List<Sources>();
if (sourceObjects != null)
{
foreach (object obj in sourceObjects)
if (obj.GetType() == typeof(Sources))
sourceTypes.Add((Sources)obj);
else
_sourceControls.Add(obj);
SourceTypes = sourceTypes.ToArray();
}
if (targetObjects != null)
{
foreach (object obj in targetObjects)
if (obj.GetType() == typeof(byte))
TargetTypes += (byte)obj;
else
_targetControls.Add(obj);
}
}
//public new T Value
//{
// get
// {
// foreach (object obj in _sourceControls)
// {
// string propertyName = (obj);
// object value = Reflection.GetPropertyValue<object>(obj, propertyName);
// if (value != null)
// return Serialization.FromJson<T>(value.ToString());
// }
// return default(T);
// }
// set
// {
// foreach (object obj in _targetControls)
// {
// string propertyName = Reflection.GetInputPropertyName(obj);
// Reflection.SetPropertyValue<string>(obj, propertyName, Serialization.ToJson<T>(value));
// }
// }
//}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.