Ejemplo n.º 1
0
        private static bool UIFieldsMatch(MapElementPropertiesCopySettings settings, MapElement first, MapElement second)
        {
            FieldInfo[] props = settings.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (FieldInfo prop in props)
            {
                // Property set?
                if (!(bool)prop.GetValue(settings))
                {
                    continue;
                }

                foreach (Attribute attr in Attribute.GetCustomAttributes(prop))
                {
                    if (attr.GetType() != typeof(FieldDescription))
                    {
                        continue;
                    }
                    FieldDescription fd = (FieldDescription)attr;
                    if (fd.SupportsCurrentMapFormat && !string.IsNullOrEmpty(fd.Field1))
                    {
                        if (!string.IsNullOrEmpty(fd.Field2))
                        {
                            if (!UniFields.ValuesMatch(fd.Field1, fd.Field2, first, second))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!UniFields.ValuesMatch(fd.Field1, first, second))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
 protected void ApplyUIFields <T>(ICollection <T> collection, MapElementPropertiesCopySettings settings) where T : MapElement
 {
     FieldInfo[] props = settings.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
     foreach (FieldInfo prop in props)
     {
         // Property set?
         if (!(bool)prop.GetValue(settings))
         {
             continue;
         }
         foreach (Attribute attr in Attribute.GetCustomAttributes(prop))
         {
             if (attr.GetType() != typeof(FieldDescription))
             {
                 continue;
             }
             FieldDescription fd = (FieldDescription)attr;
             if (fd.SupportsCurrentMapFormat && !string.IsNullOrEmpty(fd.Field1))
             {
                 if (!string.IsNullOrEmpty(fd.Field2))
                 {
                     foreach (T me in collection)
                     {
                         Apply(me.Fields, fd.Field1, fd.Field2);
                     }
                 }
                 else
                 {
                     foreach (T me in collection)
                     {
                         Apply(me.Fields, fd.Field1);
                     }
                 }
             }
         }
     }
 }