Example #1
0
        public ObjectFormatter(Type type, CustomDict customFieldFormatters, CustomDict customTagFormatters)
        {
            var(fieldFormatters, tagFormatters) = CreateFormatters(type, customFieldFormatters, customTagFormatters);

            _fieldFormatters = fieldFormatters.ToArray();
            _fieldCount      = _fieldFormatters.Length;
            _tagFormatters   = tagFormatters.ToArray();
            _tagCount        = _tagFormatters.Length;
        }
Example #2
0
 public void ClearAllBullseyeLinesAndCalculations(CustomDict row)
 {
     foreach (GameObject child in row.GetValues())
     {
         if (child)
         {
             ClearLine(child, row.GetKey());
             ClearCalculationsText(child, row.GetKey());
         }
     }
 }
Example #3
0
    public CustomDict GetFromBullseyeList(string name)
    {
        CustomDict popObject = null;

        foreach (CustomDict child in BullseyeRef)
        {
            if (child.GetKey().name == name)
            {
                return(child);

                break;
            }
        }
        return(popObject);
    }
Example #4
0
 private GameObject IsInBullseyeListOfList(CustomDict temp, GameObject ref2)
 {
     foreach (CustomDict child in BullseyeRef)
     {
         if (child.GetKey().name == temp.GetKey().name)
         {
             foreach (GameObject subchild in child.GetValues())
             {
                 if (subchild.name == ref2.name)
                 {
                     return(subchild);
                 }
             }
         }
     }
     return(null);
 }
Example #5
0
        private static bool CheckCustomFormatters(CustomDict customFieldFormatters, CustomDict customTagFormatters, PropertyInfo property,
                                                  List <IFormatter> fieldFormatters, List <IFormatter> tagFormatters)
        {
            bool custom = false;

            if (customFieldFormatters != null && customFieldFormatters.TryGetValue((property.Name, property.PropertyType), out var cf))
            {
                fieldFormatters.Add(cf(property));
                custom = true;
            }

            if (customTagFormatters != null && customTagFormatters.TryGetValue((property.Name, property.PropertyType), out cf))
            {
                tagFormatters.Add(cf(property));
                custom = true;
            }

            return(custom);
        }
Example #6
0
    public void AddToBullseyeList(GameObject ref1, GameObject ref2)
    {
        CustomDict temp = GetBullsEyeListContains(ref1.name);

        if (temp != null)
        {
            if (!IsInBullseyeListOfList(temp, ref2))
            {
                temp.AddToList(ref2);
                SetBullList(ref1.name, temp.GetValues());
            }
        }

        else
        {
            temp = new CustomDict();
            temp.SetKey(ref1);
            temp.AddToList(ref2);
            BullseyeRef.Add(temp);
        }
        // temp.SetUniqueName(air1.name + air2.name);
        //temp.SetDisplayName(air1.name.Substring(0, 3) + " ---- " + air2.name.Substring(0, 3));
    }
Example #7
0
    public void OnClearSignClick(GameObject row)
    {
        if (row.name.Contains("bullseye"))
        {
            Debug.Log(row.name);
            CustomDict temp = refData.GetFromBullseyeList(row.name);
            Debug.Log(temp.GetKey().name);

            GetComponent <ReferenceCalculator>().ClearAllBullseyeLinesAndCalculations(temp);
            refData.RemoveFromBullseyeList(row.name);
            Destroy(BullsEyeParent.transform.Find(row.name).gameObject);
        }
        else
        {
            CustomDict temp = refData.GetFromBullseyeList(row.transform.parent.name);
            Debug.Log(row.name);
            Debug.Log(temp.GetKey());
            GameObject aircraft = refData.PopFromBullseyeSublist(row.transform.parent.name, row.name);
            GetComponent <ReferenceCalculator>().ClearLine(aircraft, temp.GetKey());
            GetComponent <ReferenceCalculator>().ClearCalculationsText(aircraft, temp.GetKey());
            if (temp.GetValues().Count <= 0)
            {
                if (bullsEyeObject)
                {
                    if (temp.GetKey().name == bullsEyeObject.name)
                    {
                        DeleteDangling();
                    }
                }

                Destroy(BullsEyeParent.transform.Find(temp.GetKey().name).gameObject);
                refData.RemoveFromBullseyeList(temp.GetKey().name);
            }
        }
        counterObj.text = refData.GetLastBullseyeListCount().ToString();
        ViewBullPanel.GetComponent <PopulateAirRef>().PopulateBull();
    }
Example #8
0
        private static (List <IFormatter> fieldFormatters, List <IFormatter> tagFormatters) CreateFormatters(Type type,
                                                                                                             CustomDict customFieldFormatters, CustomDict customTagFormatters)
        {
            var fieldFormatters = new List <IFormatter>();
            var tagFormatters   = new List <IFormatter>();

            foreach (var property in type.GetProperties().Where(p => p.CanRead))
            {
                if (CheckCustomFormatters(customFieldFormatters, customTagFormatters, property, fieldFormatters, tagFormatters))
                {
                    continue;
                }

                if (FieldFormatter.IsFieldType(property.PropertyType))
                {
                    var formatter = FieldFormatter.TryCreate(property);
                    if (formatter != null)
                    {
                        fieldFormatters.Add(formatter);
                    }
                }
                else if (TagFormatter.IsTagType(property.PropertyType))
                {
                    var tagFormatter = TagFormatter.TryCreate(property);
                    if (tagFormatter != null)
                    {
                        tagFormatters.Add(tagFormatter);
                    }
                }
            }

            return(fieldFormatters, tagFormatters);
        }