public List<FamilySelectorViewModel> CreateFamilyViewModels(IEnumerable<ExportedDataType> exportedDTs)
        {
            var res = new List<FamilySelectorViewModel>();
            foreach (var exportedDataType in exportedDTs)
            {
                var newModel = new FamilySelectorViewModel();

                newModel.DataType = exportedDataType;
                newModel.FamilySymbolsList = new List<Tuple<FamilySymbol, string>>();

                var symbols = GetFamilySymbols(exportedDataType);

                foreach (var familySymbol in symbols)
                {
                    newModel.FamilySymbolsList.Add(new Tuple<FamilySymbol, string>(familySymbol, GetSymbolDisplayName(familySymbol)));
                }
                if (!exportedDataType.IsWireObject)
                    SetSuitableTemplateType(newModel, exportedDataType);
                else
                    SetWireTemplateType(newModel);

                SetFullyEqualSymbolAsSelectedIfExists(newModel, exportedDataType);

                //If no suitable founded than set first
                if (newModel.SelectedSymbol == null)
                    newModel.SelectedSymbol = newModel.FamilySymbolsList.FirstOrDefault();

                res.Add(newModel);
            }
            return res;
        }
 private static void SetSuitableTemplateType(FamilySelectorViewModel newModel, ExportedDataType exportedDataType)
 {
     foreach (var familySymbol in newModel.FamilySymbolsList)
     {
         var templateParam = familySymbol.Item1.get_Parameter("TemplateType");
         if (templateParam != null && templateParam.AsInteger() != 0)
         {
             if (CompareFields(exportedDataType.Fields.Where(field => field.IsTemplate), familySymbol))
             {
                 newModel.SelectedSymbol = familySymbol;
                 newModel.CreateCopy = true;
                 return;
             }
         }
     }
 }
        private void SetWireTemplateType(FamilySelectorViewModel newModel)
        {
            var wireTemplate = newModel.FamilySymbolsList.FirstOrDefault(fs => fs.Item1.Name == "WireTemplate");

            if (wireTemplate != null)
                newModel.SelectedSymbol = wireTemplate;
        }
 private static void SetFullyEqualSymbolAsSelectedIfExists(FamilySelectorViewModel newModel,
                                                           ExportedDataType exportedDataType)
 {
     foreach (var familySymbol in newModel.FamilySymbolsList.Select(fs => fs))
     {
         if (CompareFields(exportedDataType.Fields, familySymbol))
         {
             newModel.SelectedSymbol = familySymbol;
             newModel.CreateCopy = false;
             return;
         }
     }
 }