Esempio n. 1
0
        public void ApplyAllProperties(object target, PropFilter filter, APPLYDIRECTION direction)
        {
            System.Reflection.PropertyInfo[] props = this.GetType().GetProperties();
            foreach (var p in props)
            {
                if (p.CanWrite)
                {
                    string fullpropname = p.Name;
                    int    index        = fullpropname.IndexOf("_");
                    if (index < 0)
                    {
                        throw new System.ArgumentException("invalid Property name");
                    }
                    string        propType = fullpropname.Substring(0, index);
                    string        propname = fullpropname.Substring(index + 1);
                    List <String> path     = new List <String>();
                    path.Add(propname);


                    if ((target is Form) && (propType == "Form"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }

                    if ((target is YDigitalDisplay) && (propType == "display"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }


                    if ((target is YAngularGauge) && (propType == "AngularGauge"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }

                    if ((target is YSolidGauge) && (propType == "SolidGauge"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }

                    if ((target is YGraph) && (propType == "Graph"))
                    {
                        ApplyProperties(this, target, fullpropname, p.GetValue(this, null), path, direction);
                    }
                }
            }
        }
Esempio n. 2
0
        public void ApplyProperties(object rootSource, object rootTarget, string fullpropname, object sourceValue, List <String> path, APPLYDIRECTION direction)
        {
            if (sourceValue is AlarmSection)
            {
                return;                         // dirty hack: alarms are no handled through reflexion
            }
            if ((sourceValue is GenericProperties.BordersMode) && constants.MonoRunning)
            {
                return; // dirty hack: borders not supported in mono
            }
            if (!IsStructured(sourceValue))
            {
                if (direction == APPLYDIRECTION.SETTINGS_TO_TARGET)
                {
                    copyProperty_STT(rootTarget, this, fullpropname, path);
                }
                else
                {
                    copyProperty_SFT(rootTarget, this, fullpropname, path);
                }
            }
            else
            {
                // map all target's user data to its mirrored source
                List <String> path2 = new List <String>(path);
                path2.Add("");
                object       target = getObjectFromPath(rootTarget, path2);
                PropertyInfo info   = target.GetType().GetProperty("userData");
                if (info != null)
                {
                    info.SetValue(target, sourceValue, null);
                }



                foreach (PropertyInfo p  in sourceValue.GetType().GetProperties())
                {
                    if (p.CanWrite)
                    {
                        path.Add(p.Name);
                        ApplyProperties(rootSource, rootTarget, fullpropname, p.GetValue(sourceValue, null), path, direction);
                        path.RemoveAt(path.Count - 1);
                    }
                }
            }
        }