Example #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }
            var compack = value as MultiComponentPack;

            List <MultiPropertyPack> pack = new List <MultiPropertyPack>();

            if (compack.merged_components.Count == 0)
            {
                return(null);
            }

            MochaInterface.Component c = compack.merged_components[0];

            PropertyValueConverter pvc = new PropertyValueConverter();
            var pi_ret = new ObservableCollection <PropertyValueConverter.PropertyInfo>();

            pi_ret = pvc.Convert(c, null, "Component", null) as ObservableCollection <PropertyValueConverter.PropertyInfo>;

            foreach (var pi in pi_ret)
            {
                MultiPropertyPack ppack = new MultiPropertyPack();
                ppack.merged_data = pi.PropertyValue;
                MultiPropertyInfoWrapper merged_pi = new MultiPropertyInfoWrapper();
                merged_pi.merged_name        = pi.PropertyName;
                merged_pi.merged_value       = pi.PropertyValue;
                merged_pi.participating_objs = new List <object>();
                foreach (var comp in compack.merged_components)
                {
                    merged_pi.participating_objs.Add(comp);
                }

                PropertyValueConverter.PropertyInfo m_pi = new PropertyValueConverter.PropertyInfo();
                m_pi.PropertyName  = "merged_value";
                m_pi.PropertyObj   = merged_pi;
                m_pi.propertyInfo  = merged_pi.GetType().GetProperty("merged_value");
                m_pi.PropertyType  = pi.PropertyType;
                m_pi.PropertyValue = merged_pi.merged_value;

                ppack.merged_propertyinfo      = m_pi;
                ppack.participating_components = compack.merged_components;
                pack.Add(ppack);
            }
            return(pack);
        }
Example #2
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return null;
            var compack = value as MultiComponentPack;

            List<MultiPropertyPack> pack = new List<MultiPropertyPack>();

            if (compack.merged_components.Count == 0)
                return null;

            MochaInterface.Component c = compack.merged_components[0];

            PropertyValueConverter pvc = new PropertyValueConverter();
            var pi_ret = new ObservableCollection<PropertyValueConverter.PropertyInfo>();
            pi_ret = pvc.Convert(c, null, "Component", null) as ObservableCollection<PropertyValueConverter.PropertyInfo>;

            foreach (var pi in pi_ret)
            {
                MultiPropertyPack ppack = new MultiPropertyPack();
                ppack.merged_data = pi.PropertyValue;
                MultiPropertyInfoWrapper merged_pi = new MultiPropertyInfoWrapper();
                merged_pi.merged_name = pi.PropertyName;
                merged_pi.merged_value = pi.PropertyValue;
                merged_pi.participating_objs = new List<object>();
                foreach (var comp in compack.merged_components)
                    merged_pi.participating_objs.Add(comp);

                PropertyValueConverter.PropertyInfo m_pi = new PropertyValueConverter.PropertyInfo();
                m_pi.PropertyName = "merged_value";
                m_pi.PropertyObj = merged_pi;
                m_pi.propertyInfo = merged_pi.GetType().GetProperty("merged_value");
                m_pi.PropertyType = pi.PropertyType;
                m_pi.PropertyValue = merged_pi.merged_value;

                ppack.merged_propertyinfo = m_pi;
                ppack.participating_components = compack.merged_components;
                pack.Add(ppack);
            }
            return pack;
        }