コード例 #1
0
        public void HowTo()
        {
//<document>
            OGen.NTier.Libraries.DataLayer.DOPropertyAttribute _attribute
                = (OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)Attribute.GetCustomAttribute(
                      typeof(OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User).GetProperty("IDUser"),
                      typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute),
                      true
                      );
            Console.WriteLine(
                "name:{0};  isPK:{1};  isIdentity:{2};  DefaultValue:{3};",
                _attribute.Name,
                _attribute.IsPK,
                _attribute.IsIdentity,
                _attribute.DefaultValue,

                // many other properties available, like:
                _attribute.AditionalInfo,
                _attribute.DefaultValue,
                _attribute.ExtendedDescription,
                _attribute.ForeignKey_TableName,
                _attribute.ForeignKey_TableFieldName,
                _attribute.FriendlyName,
                _attribute.IsBoolean,
                _attribute.IsConfig_Config,
                _attribute.IsConfig_Datatype,
                _attribute.IsConfig_Name,
                _attribute.IsDateTime,
                _attribute.IsDecimal,
                _attribute.IsInteger,
                _attribute.IsListItemText,
                _attribute.IsListItemValue,
                _attribute.IsNullable,
                _attribute.IsText,
                _attribute.Size
                );
//</document>

            // the only porpuses is to keep documentation code samples updated by:
            // 1) ensure documentation code samples are compiling
            // 2) no exceptions are beeing thrown by documentation code samples
            Assert.IsTrue(
                true,
                "documentation code sample is failing"
                );
        }
コード例 #2
0
        public void HowTo()
        {
//<document>
            Type[] _types;
            System.Reflection.Assembly _assembly;


            _assembly = System.Reflection.Assembly.Load(
        #if NET_1_1
                "OGen.NTier.Kick.Libraries.DataLayer-1.1"
        #else // elif NET_2_0
                "OGen.NTier.Kick.Libraries.DataLayer-2.0"
        #endif
                );
            _types = _assembly.GetTypes();
            for (int t = 0; t < _types.Length; t++)
            {
                Type _type = (Type)_types[t];

                object[] _doclassattributes = _type.GetCustomAttributes(
                    typeof(OGen.NTier.Libraries.DataLayer.DOClassAttribute),
                    true//false
                    );
                for (int c = 0; c < _doclassattributes.Length; c++)
                {
                    if (c == 0)
                    {
                        Console.Write("{0}: ", _type.Name.PadRight(35, ' '));
                    }

                    OGen.NTier.Libraries.DataLayer.DOClassAttribute _classattribute
                        = (OGen.NTier.Libraries.DataLayer.DOClassAttribute)_doclassattributes[c];
                    Console.WriteLine(
                        "name(db): {0}; isVirtualTable: {1}; isConfig: {2};  ",
                        _classattribute.Name.PadRight(35, ' '),
                        _classattribute.IsVirtualTable ? "T" : "F",
                        _classattribute.IsConfig ? "T" : "F"
                        );
                }
            }


            _assembly = System.Reflection.Assembly.Load(
        #if NET_1_1
                "OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures-1.1"
        #else // elif NET_2_0
                "OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures-2.0"
        #endif
                );
            _types = _assembly.GetTypes();
            for (int t = 0; t < _types.Length; t++)
            {
                Type _type = (Type)_types[t];

                System.Reflection.PropertyInfo[] _properties = _type.GetProperties(
                    System.Reflection.BindingFlags.Public |
                    System.Reflection.BindingFlags.Instance
                    );
                for (int p = 0; p < _properties.Length; p++)
                {
                    if (Attribute.IsDefined(
                            _properties[p],
                            typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)
                            ))
                    {
                        Console.Write(
                            "{0}.{1}: ",
                            _type.Name.PadRight(27, ' '),
                            _properties[p].Name.PadRight(25, ' ')
                            );
                        Attribute[] _attributes = Attribute.GetCustomAttributes(
                            _properties[p],
                            typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute),
                            true
                            );
                        for (int a = 0; a < _attributes.Length; a++)
                        {
                            OGen.NTier.Libraries.DataLayer.DOPropertyAttribute _propertyattribute
                                = (OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)_attributes[a];
                            Console.WriteLine(
                                "name(db):{0}; isPK:{1}; isIdentity:{2}; isText:{3};",
                                _propertyattribute.Name.PadRight(25, ' '),
                                _propertyattribute.IsPK ? "T" : "F",
                                _propertyattribute.IsIdentity ? "T" : "F",
                                //_propertyattribute.DefaultValue,
                                _propertyattribute.IsText ? "T" : "F"
                                );
                        }
                        //Console.WriteLine();
                    }
                }
                //Console.WriteLine();
            }
//</document>

            // the only porpuses is to keep documentation code samples updated by:
            // 1) ensure documentation code samples are compiling
            // 2) no exceptions are beeing thrown by documentation code samples
            Assert.IsTrue(
                true,
                "documentation code sample is failing"
                );
        }
コード例 #3
0
        public void HowTo()
        {
//<document>
            OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User _user
                                = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User();
            _user.IDUser        = 123L;
            _user.Login         = "******";
            _user.Password      = "******";
            _user.IFApplication = 123;

            System.Reflection.PropertyInfo[] _properties
                = typeof(OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User).GetProperties(
                      System.Reflection.BindingFlags.Public |
                      System.Reflection.BindingFlags.Instance
                      );
            for (int _prop = 0; _prop < _properties.Length; _prop++)
            {
                if (Attribute.IsDefined(
                        _properties[_prop],
                        typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)
                        ))
                {
                    Console.Write(
                        "{0}: ",
                        _properties[_prop].Name
                        );
                    Attribute[] _attributes = Attribute.GetCustomAttributes(
                        _properties[_prop],
                        typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute),
                        true
                        );
                    for (int _att = 0; _att < _attributes.Length; _att++)
                    {
                        //if (_attributes[_att].GetType() == typeof(DOPropertyAttribute)) {
                        OGen.NTier.Libraries.DataLayer.DOPropertyAttribute _attribute
                            = (OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)_attributes[_att];
                        Console.Write(
                            "name:{0};  isPK:{1};  isIdentity:{2};  DefaultValue:{3};  ",
                            _attribute.Name,
                            _attribute.IsPK,
                            _attribute.IsIdentity,
                            _attribute.DefaultValue
                            );
                        //}
                    }
                    Console.Write(
                        "value: {0}; ",
                        _properties[_prop].GetValue(_user, null)
                        );
                    _properties[_prop].SetValue(
                        _user,
                        Convert.ChangeType(
                            456,
                            _properties[_prop].PropertyType
                            ),
                        null
                        );
                    Console.WriteLine(
                        "new value: {0}",
                        _properties[_prop].GetValue(_user, null)
                        );
                }
            }
//</document>

            // the only porpuses is to keep documentation code samples updated by:
            // 1) ensure documentation code samples are compiling
            // 2) no exceptions are beeing thrown by documentation code samples
            Assert.IsTrue(
                true,
                "documentation code sample is failing"
                );
        }