Ejemplo n.º 1
0
        private static void ConfiSavePropertyAnalysis(Object target, PropertyInfo prop)
        {
            var configTag = TypeInfoProvider.GetConfigTag(prop);

            if (configTag != null)
            {
                Object value = TypeInfoProvider.GetValue(prop, target);
                if (configTag.IsEncrypted && value != null && prop.PropertyType == typeof(String))
                {
                    String strValue = value as String;
                    strValue = DefaultStringEncryptor.Encrypt(strValue);
                    TypeInfoProvider.SetValue(prop, target, strValue);
                    return;
                }
                if (prop.PropertyType.IsSubclassOf(typeof(ConfigBase)))
                {
                    Object valueCopy = TypeInfoProvider.CreateInstance(prop.PropertyType);
                    CopyConfigObject(value, valueCopy, prop.PropertyType);
                    TypeInfoProvider.SetValue(prop, target, valueCopy);
                    Type type          = prop.PropertyType;
                    var  propertyInfos = TypeInfoProvider.GetProperties(type);
                    foreach (var cprop in propertyInfos)
                    {
                        ConfiSavePropertyAnalysis(valueCopy, cprop);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void CopyConfigObject(Object source, Object dest, Type type)
        {
            var propertyInfos = TypeInfoProvider.GetProperties(type);

            foreach (var prop in propertyInfos)
            {
                Object value = TypeInfoProvider.GetValue(prop, source);
                TypeInfoProvider.SetValue(prop, dest, value);
            }
        }