1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
public class ClsDataBaseElement
{
private string s_User;
protected string s_Pwd;
protected string s_CheminIP;
protected string s_CheminDivers;
protected string s_DataBaseType;
protected string s_FileExtension;
protected Int32 iType;
public ClsDataBaseElement(string col)
{
}
/// <summary>
/// Constructeur de la classe des éléments d'une base des données
/// </summary>
private ClsDataBaseElement()
{
Int32 i =0;
Type MyType = typeof(ClsDataBaseElement);
PropertyInfo[] LProp = MyType.GetProperties();
foreach (PropertyInfo Pi in LProp)
{
Attribute[] atrib=Attribute.GetCustomAttributes(Pi,typeof(CpropertyRequired));// GetCustomAttributes(Pi,typeof(CpropertyRequired));
object[] Obj = Pi.GetCustomAttributes(typeof(CpropertyRequired),true);
if (Pi.IsDefined(typeof(CpropertyRequired),true))
{
object o = Activator.CreateInstance(typeof(ClsDataBaseElement),new object[]{"TEST"});
CpropertyRequired Oprop = Obj[0] as CpropertyRequired;
Oprop.Required = true;
System.Windows.Forms.MessageBox.Show(Pa.ToString());
Pi.SetValue(o,Oprop,null);
}
}
}
/*public static void InitDefaults(this object o)
{
}*/
public static ClsDataBaseElement ParseForElement()
{
ClsDataBaseElement od = new ClsDataBaseElement();
return od;
}
public string p_s_DataBaseType
{
get {return this.s_DataBaseType;}
set {this.s_DataBaseType = value;}
}
[CpropertyRequired(false)]
public string p_s_UserName
{
get {return this.s_User;}
set {this.s_User = value;}
}
[CpropertyRequired(false)]
public string p_s_Password
{
get {return this.s_Pwd;}
set {this.s_Pwd = value;}
}
[CpropertyRequired(false)]
public string p_s_CheminIp
{
get {return this.s_CheminIP;}
set {this.s_CheminIP = value;}
}
[CpropertyRequired(false)]
public string p_s_CheminDivers
{
get {return this.s_CheminDivers;}
set {this.s_CheminDivers = value;}
}
public Int32 p_i_Type
{
get {return this.iType;}
set {this.iType = value;}
}
[CpropertyRequired(false)]
public string p_s_FileExtension
{
get { return this.s_FileExtension;}
set { this.s_FileExtension = value;}
}
public string GetElementType
{
get {return this.s_DataBaseType;}
}
}
#region "Attribut de la classe"
[AttributeUsage(AttributeTargets.Property,AllowMultiple = false)]
public class CpropertyRequired : System.Attribute
{
public Boolean Required= false;
public CpropertyRequired(Boolean Asaisir)
{
this.Required = Asaisir;
}
}
#endregion |
Partager