private void Awake()
 {
     descriptionManager = FindObjectOfType <DescriptionManager>() as DescriptionManager;
     isWithinRange      = false;
     originPosition     = this.gameObject.transform.position;
     gameManager        = FindObjectOfType <GameManager>() as GameManager;
 }
#pragma warning restore CS8618 // Non-nullable field is uninitialized.

        public XElement ExportXml()
        {
            return(new XElement("Type",
                                new XAttribute("Name", Type.Name),

                                !Options.IsSetAssert(DescriptionOptions.Description, Type) ||
                                Description == null ||
                                (Assembly.IsDefault && Description == DescriptionManager.DefaultTypeDescription(Type)) ? null :
                                new XAttribute("Description", Description),

                                !Options.IsSetAssert(DescriptionOptions.PluralDescription, Type) ||
                                PluralDescription == null ||
                                (PluralDescription == NaturalLanguageTools.Pluralize(Description !, Assembly.Culture)) ? null :
                                new XAttribute("PluralDescription", PluralDescription),

                                !Options.IsSetAssert(DescriptionOptions.Gender, Type) ||
                                Gender == null ||
                                (Gender == NaturalLanguageTools.GetGender(Description !, Assembly.Culture)) ? null :
                                new XAttribute("Gender", Gender.ToString()),

                                !Options.IsSetAssert(DescriptionOptions.Members, Type) ? null :
                                (from m in GetMembers(Type)
                                 where DescriptionManager.OnShouldLocalizeMember(m)
                                 orderby m.Name
                                 let value = Members !.TryGetC(m.Name)
                                             where value != null && !(Assembly.IsDefault && (DescriptionManager.DefaultMemberDescription(m) == value))
                                             select new XElement("Member", new XAttribute("Name", m.Name), new XAttribute("Description", value)))
                                ));
        }
Exemple #3
0
        public AssemblyResultTS Sync(string assembly, string culture, string? @namespace = null)
        {
            Assembly    ass           = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly));
            CultureInfo targetCulture = CultureInfo.GetCultureInfo(culture);

            CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture);

            var cultures = TranslationLogic.CurrentCultureInfos(defaultCulture);
            Dictionary <CultureInfo, LocalizedAssembly> reference = (from ci in cultures
                                                                     let la = DescriptionManager.GetLocalizedAssembly(ass, ci)
                                                                              where la != null || ci == defaultCulture || ci == targetCulture
                                                                              select KVP.Create(ci, la ?? LocalizedAssembly.ImportXml(ass, ci, forceCreate: ci == defaultCulture || ci == targetCulture))).ToDictionary();

            var master  = reference.Extract(defaultCulture);
            var target  = reference.Extract(targetCulture);
            var changes = TranslationSynchronizer.GetAssemblyChanges(TranslationServer.Translator, target, master, reference.Values.ToList(), null, @namespace, out int totalTypes);

            return(new AssemblyResultTS
            {
                totalTypes = totalTypes,
                cultures = cultures.Select(c => c.ToCulturesTS()).ToDictionary(a => a.name),
                types = changes.Types.Select(t => t.Type.Type.ToLocalizableTypeTS().Let(localizedTypes =>
                {
                    localizedTypes.cultures = cultures.ToDictionary(c => c.Name, c => GetLocalizedType(t, c, c.Equals(targetCulture)));
                    return localizedTypes;
                })).ToDictionary(lt => lt.type),
            });
        }
Exemple #4
0
    void Start()
    {
        if (buttonIndex >= 10)      // jeśli buttony to "X" do usuwania save'ów
        {
            return;
        }

        descriptionManager = GameObject.FindWithTag("Description").GetComponent <DescriptionManager>();
        data = SaveSystem.LoadSaveData(buttonIndex);


        if (data != null)       // save exists
        {
            this.GetComponentInChildren <Text>().text += " - zajęty";
        }
        else                    // save doesn't exist
        {
            this.GetComponentInChildren <Text>().text += " - wolny";
            try
            {
                Xbutton.SetActive(false);
            }
            catch (NullReferenceException)
            {
                // jeśli Xbutton nie znaleziony, to mamy do czynienia z buttonami w scenie Save Game, które nie mają swoich Xbuttonów - jest okej ;)
            }
        }
    }
 private static ValueLineBoxOptions GetValueLineOptions(string prefix)
 {
     return(new ValueLineBoxOptions(ValueLineType.DateTime, prefix)
     {
         labelText = DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate),
         value = DateTime.Now
     });
 }
        public void ExportXml()
        {
            var doc = ToXml();

            string fileName = TranslationFileName(Assembly, Culture);

            doc.Save(fileName);

            DescriptionManager.Invalidate();
        }
Exemple #7
0
        private void InitializeControls()
        {
            _listBoxDescriptionManager = new DescriptionManager(toolTip);
            _listBoxDescriptionManager.Register(lbOrders, _ordersProcessor);
            _listBoxDescriptionManager.Register(lbPositions, _positionsProcessor);

            Text = $"{Text} - {_runner.GetType().Name} runner";
            cbSide.BindTo(new[] { OrderSide.Buy, OrderSide.Sell });
            cbType.BindTo(Enum.GetValues(typeof(OrderType)).Cast <OrderType>().ToArray());
        }
 private void Awake()
 {
     if (Instance)
     {
         Destroy(this);
     }
     else
     {
         Instance = this;
     }
 }
Exemple #9
0
 public string GetItemDescription(object item)
 {
     return(DescriptionManager.ToDescription <IPosition>(item, (position, sb) =>
     {
         if (CanExitPosition(position))
         {
             sb.AppendLine();
             sb.AppendLine(" * Double click to exit position");
         }
     }));
 }
    public static object GetCurrentValidCulture()
    {
        var ci = CultureInfo.CurrentCulture;

        while (ci != CultureInfo.InvariantCulture && !EntityAssemblies.Keys.Any(a => DescriptionManager.GetLocalizedAssembly(a, ci) != null))
        {
            ci = ci.Parent;
        }

        return(ci != CultureInfo.InvariantCulture ? ci : CultureInfo.GetCultureInfo("en"));
    }
Exemple #11
0
        public List <NamespaceSyncStats> SyncStats(string assembly, string culture)
        {
            Assembly    ass            = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly));
            CultureInfo targetCulture  = CultureInfo.GetCultureInfo(culture);
            CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture);

            var targetAssembly  = DescriptionManager.GetLocalizedAssembly(ass, targetCulture) ?? LocalizedAssembly.ImportXml(ass, targetCulture, forceCreate: true) !;
            var defaultAssembly = DescriptionManager.GetLocalizedAssembly(ass, defaultCulture) ?? LocalizedAssembly.ImportXml(ass, defaultCulture, forceCreate: true) !;

            return(TranslationSynchronizer.SyncNamespaceStats(targetAssembly, defaultAssembly));
        }
Exemple #12
0
    private IEnumerable <KeyValuePair <string, string> > GetAllTranslations(Assembly assembly, string from, string to)
    {
        var locFrom = DescriptionManager.GetLocalizedAssembly(assembly, CultureInfo.GetCultureInfo(from));
        var locTo   = DescriptionManager.GetLocalizedAssembly(assembly, CultureInfo.GetCultureInfo(to));

        if (locFrom == null || locTo == null)
        {
            return(Enumerable.Empty <KeyValuePair <string, string> >());
        }

        return((locFrom.Types.JoinDictionary(locTo.Types, (type, ft, tt) => GetAllTranslations(ft, tt))).Values.SelectMany(pairs => pairs));
    }
    private void Start()
    {
        collider           = GetComponent <SphereCollider>();
        descriptionManager = FindObjectOfType <DescriptionManager>();
        animator           = FindObjectOfType <Animator>();

        trigger = GetComponent <EventTrigger>();
        EventTrigger.Entry entry = new EventTrigger.Entry();
        entry.eventID = EventTriggerType.PointerEnter;
        entry.callback.AddListener((data) => { OnPointerEnterDelegate((PointerEventData)data); });
        trigger.triggers.Add(entry);
    }
Exemple #14
0
        static Reflector()
        {
            DescriptionManager.CleanTypeName = CleanTypeName;                               //To allow MyEntityEntity
            DescriptionManager.CleanType     = t => EnumEntity.Extract(t) ?? t.CleanType(); //To allow Lite<T>

            DescriptionManager.DefaultDescriptionOptions += DescriptionManager_IsEnumsInEntities;
            DescriptionManager.DefaultDescriptionOptions += DescriptionManager_IsQuery;
            DescriptionManager.DefaultDescriptionOptions += DescriptionManager_IsSymbolContainer;
            DescriptionManager.DefaultDescriptionOptions += DescriptionManager_IsIEntity;

            DescriptionManager.ShouldLocalizeMemeber += DescriptionManager_ShouldLocalizeMemeber;
            DescriptionManager.Invalidate();
        }
Exemple #15
0
        public string GetItemDescription(object item)
        {
            return(DescriptionManager.ToDescription <IOrder>(item, (order, sb) =>
            {
                foreach (var state in order.States)
                {
                    sb.AppendLine($"{state.Timestamp:G}: {state}");
                }

                if (!order.IsFinalState)
                {
                    sb.AppendLine();
                    sb.AppendLine(" * Double click to cancel order");
                }
            }));
        }
Exemple #16
0
        public ActionResult View(string assembly, string culture, bool searchPressed, string filter)
        {
            Assembly ass = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly));

            CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture);
            CultureInfo targetCulture  = culture == null ? null : CultureInfo.GetCultureInfo(culture);

            Dictionary <CultureInfo, LocalizedAssembly> reference = !searchPressed ? null :
                                                                    (from ci in TranslationLogic.CurrentCultureInfos(defaultCulture)
                                                                     let la = DescriptionManager.GetLocalizedAssembly(ass, ci)
                                                                              where la != null || ci == defaultCulture || ci == targetCulture
                                                                              select KVP.Create(ci, la ?? LocalizedAssembly.ImportXml(ass, ci, forceCreate: true))).ToDictionary();

            ViewBag.filter         = filter;
            ViewBag.searchPressed  = searchPressed;
            ViewBag.Assembly       = ass;
            ViewBag.DefaultCulture = defaultCulture;
            ViewBag.Culture        = targetCulture;

            return(base.View(TranslationClient.ViewPrefix.FormatWith("View"), reference));
        }
        internal static LocalizedType ImportXml(Type type, DescriptionOptions opts, LocalizedAssembly assembly, XElement x)
        {
            string?description = !opts.IsSetAssert(DescriptionOptions.Description, type) ? null :
                                 (x == null || x.Attribute("Name").Value != type.Name ? null : x.Attribute("Description")?.Value) ??
                                 (!assembly.IsDefault ? null : DescriptionManager.DefaultTypeDescription(type));

            var xMembers = x?.Elements("Member")
                           .Select(m => KeyValuePair.Create(m.Attribute("Name").Value, m.Attribute("Description").Value))
                           .Distinct(m => m.Key)
                           .ToDictionary();

            LocalizedType result = new LocalizedType
            {
                Type     = type,
                Options  = opts,
                Assembly = assembly,

                Description       = description,
                PluralDescription = !opts.IsSetAssert(DescriptionOptions.PluralDescription, type) ? null :
                                    ((x == null || x.Attribute("Name").Value != type.Name ? null : x.Attribute("PluralDescription")?.Value) ??
                                     (!assembly.IsDefault ? null : type.GetCustomAttribute <PluralDescriptionAttribute>()?.PluralDescription) ??
                                     (description == null ? null : NaturalLanguageTools.Pluralize(description, assembly.Culture))),

                Gender = !opts.IsSetAssert(DescriptionOptions.Gender, type) ? null :
                         ((x?.Attribute("Gender")?.Value.Single()) ??
                          (!assembly.IsDefault ? null : type.GetCustomAttribute <GenderAttribute>()?.Gender) ??
                          (description == null ? null : NaturalLanguageTools.GetGender(description, assembly.Culture))),

                Members = !opts.IsSetAssert(DescriptionOptions.Members, type) ? null :
                          (from m in GetMembers(type)
                           where DescriptionManager.OnShouldLocalizeMember(m)
                           let value = xMembers?.TryGetC(m.Name) ?? (!assembly.IsDefault ? null : DescriptionManager.DefaultMemberDescription(m))
                                       where value != null
                                       select KeyValuePair.Create(m.Name, value))
                          .ToDictionary()
            };

            return(result);
        }
Exemple #18
0
        private TranslatedSummaryState CalculateStatus(Assembly a, CultureInfo ci)
        {
            var fileName = LocalizedAssembly.TranslationFileName(a, ci);

            if (!System.IO.File.Exists(fileName))
            {
                return(TranslatedSummaryState.None);
            }

            var target = DescriptionManager.GetLocalizedAssembly(a, ci) !;

            CultureInfo defaultCulture = CultureInfo.GetCultureInfo(a.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture);
            var         master         = DescriptionManager.GetLocalizedAssembly(a, defaultCulture) !;

            var result = TranslationSynchronizer.GetMergeChanges(target, master, new List <LocalizedAssembly>());

            if (result.Any())
            {
                return(TranslatedSummaryState.Pending);
            }

            return(TranslatedSummaryState.Completed);
        }
Exemple #19
0
        public TranslatedSummaryState Status(Lite <RoleEntity> role)
        {
            if (!System.IO.File.Exists(FileName))
            {
                return(TranslatedSummaryState.None);
            }

            var target = DescriptionManager.GetLocalizedAssembly(Assembly, CultureInfo);

            CultureInfo defaultCulture = CultureInfo.GetCultureInfo(Assembly.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture);
            var         master         = DescriptionManager.GetLocalizedAssembly(Assembly, defaultCulture);

            var result = TranslationSynchronizer.GetMergeChanges(target, master, new List <LocalizedAssembly>());


            if (result.Any(r => role == null || TranslationLogic.GetCountNotLocalizedMemebers(role, CultureInfo, r.Type.Type) > 0))
            {
                return(TranslatedSummaryState.Pending);
            }


            return(TranslatedSummaryState.Completed);
        }
        public static DescriptionOptions GetDescriptionOptions(Type type)
        {
            var doa = type.GetCustomAttribute <DescriptionOptionsAttribute>(true);

            if (doa != null)
            {
                return(type.IsGenericTypeDefinition ? doa.Options & DescriptionOptions.Members : doa.Options);
            }

            DescriptionOptions?def = DescriptionManager.OnDefaultDescriptionOptions(type);

            if (def != null)
            {
                return(type.IsGenericTypeDefinition ? def.Value & DescriptionOptions.Members : def.Value);
            }

            if (DescriptionManager.ExternalEnums.ContainsKey(type))
            {
                return(DescriptionOptions.Members);
            }

            return(DescriptionOptions.None);
        }
Exemple #21
0
        public ActionResult Sync(string assembly, string culture, bool translatedOnly, Lite <RoleEntity> role)
        {
            Assembly    ass           = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly));
            CultureInfo targetCulture = CultureInfo.GetCultureInfo(culture);

            CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture);

            Dictionary <CultureInfo, LocalizedAssembly> reference = (from ci in TranslationLogic.CurrentCultureInfos(defaultCulture)
                                                                     let la = DescriptionManager.GetLocalizedAssembly(ass, ci)
                                                                              where la != null || ci == defaultCulture || ci == targetCulture
                                                                              select KVP.Create(ci, la ?? LocalizedAssembly.ImportXml(ass, ci, forceCreate: true))).ToDictionary();
            var master = reference.Extract(defaultCulture);

            var target = reference.Extract(targetCulture);

            DictionaryByTypeName(target); //To avoid finding duplicated types on save
            int totalTypes;
            var changes = TranslationSynchronizer.GetAssemblyChanges(TranslationClient.Translator, target, master, reference.Values.ToList(), role, null, out totalTypes);

            ViewBag.Role       = role;
            ViewBag.TotalTypes = totalTypes;
            ViewBag.Culture    = targetCulture;
            return(base.View(TranslationClient.ViewPrefix.FormatWith("Sync"), changes));
        }
 public DescriptionController(IDescriptionService description)
 {
     _descriptionManager = (DescriptionManager)description;
 }
Exemple #23
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <EmployeeEntity>()
                    {
                        View = e => new Employee()
                    },
                    new EntitySettings <TerritoryEntity>()
                    {
                        View = e => new Territory()
                    },
                    new EntitySettings <RegionEntity>()
                    {
                        View = e => new Region()
                    },

                    new EntitySettings <ProductEntity>()
                    {
                        View = e => new Product()
                    },
                    new EntitySettings <CategoryEntity>()
                    {
                        View = e => new Category(), IsViewable = true
                    },
                    new EntitySettings <SupplierEntity>()
                    {
                        View = e => new Supplier()
                    },

                    new EntitySettings <CompanyEntity>()
                    {
                        View = e => new Company()
                    },
                    new EntitySettings <PersonEntity>()
                    {
                        View = e => new Person()
                    },

                    new EntitySettings <OrderEntity>()
                    {
                        View = e => new Order()
                    },
                });


                QuerySettings.RegisterPropertyFormat((EmployeeEntity e) => e.Photo, b =>
                {
                    b.Converter = SouthwindConverters.ImageConverter;
                    return(Fluent.GetDataTemplate(() => new Image {
                        MaxHeight = 32.0, Stretch = Stretch.Uniform
                    }
                                                  .Bind(Image.SourceProperty, b)
                                                  .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear)));
                }); //Photo

                QuerySettings.RegisterPropertyFormat((CategoryEntity e) => e.Picture, b =>
                {
                    b.Converter = SouthwindConverters.EmbeddedImageConverter;
                    return(Fluent.GetDataTemplate(() => new Image {
                        MaxHeight = 32.0, Stretch = Stretch.Uniform
                    }
                                                  .Bind(Image.SourceProperty, b)
                                                  .Set(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Linear)));
                }); //Picture

                Constructor.Register(ctx => new EmployeeEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new PersonEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new CompanyEntity {
                    Address = new AddressEmbedded()
                });
                Constructor.Register(ctx => new SupplierEntity {
                    Address = new AddressEmbedded()
                });

                OperationClient.AddSettings(new List <OperationSettings>()
                {
                    new ConstructorOperationSettings <OrderEntity>(OrderOperation.Create)
                    {
                        Constructor = ctx =>
                        {
                            var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue

                            return(OperationServer.Construct(OrderOperation.Create, cust));
                        },
                    },


                    new ContextualOperationSettings <ProductEntity>(OrderOperation.CreateOrderFromProducts)
                    {
                        Click = ctx =>
                        {
                            var cust = Finder.Find <CustomerEntity>(); // could return null, but we let it continue

                            var result = OperationServer.ConstructFromMany(ctx.Entities, OrderOperation.CreateOrderFromProducts, cust);

                            Navigator.Navigate(result);
                        },
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.SaveNew)
                    {
                        IsVisible = ctx => ctx.Entity.IsNew
                    },
                    new EntityOperationSettings <OrderEntity>(OrderOperation.Save)
                    {
                        IsVisible = ctx => !ctx.Entity.IsNew
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Cancel)
                    {
                        ConfirmMessage = ctx => ((OrderEntity)ctx.Entity).State == OrderState.Shipped ? OrderMessage.CancelShippedOrder0.NiceToString(ctx.Entity) : null
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Ship)
                    {
                        Click = ctx =>
                        {
                            DateTime shipDate = DateTime.Now;
                            if (!ValueLineBox.Show(ref shipDate,
                                                   labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate),
                                                   owner: Window.GetWindow(ctx.EntityControl)))
                            {
                                return(null);
                            }

                            try
                            {
                                return(ctx.Entity.Execute(OrderOperation.Ship, shipDate));
                            }
                            catch (IntegrityCheckException e)
                            {
                                ctx.Entity.SetGraphErrors(e);
                                throw e;
                            }
                        },

                        Contextual =
                        {
                            Click                 = ctx =>
                            {
                                DateTime shipDate = DateTime.Now;
                                if (!ValueLineBox.Show(ref shipDate,
                                                       labelText: DescriptionManager.NiceName((OrderEntity o) => o.ShippedDate),
                                                       owner: Window.GetWindow(ctx.SearchControl)))
                                {
                                    return;
                                }

                                ctx.Entities.SingleEx().ExecuteLite(OrderOperation.Ship, shipDate);
                            }
                        }
                    },
                });

                //NotDefined
            }
        }
 // Use this for initialization
 void Start()
 {
     descMng = descriptionPanel.GetComponent<DescriptionManager>();
 }
Exemple #25
0
 private void Start()
 {
     Manager = GameObject.Find("DescriptionPanel").GetComponent <DescriptionManager>();
 }
Exemple #26
0
 static SemiSymbol()
 {
     DescriptionManager.DefaultDescriptionOptions += DescriptionManager_IsSymbolContainer;
     DescriptionManager.Invalidate();
 }
 private void Start()
 {
     collider           = GetComponent <SphereCollider>();
     descriptionManager = FindObjectOfType <DescriptionManager>();
 }
Exemple #28
0
        public AssemblyResultTS Retrieve(string assembly, string culture, string filter)
        {
            Assembly ass = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly));

            CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture);
            CultureInfo?targetCulture  = culture == null ? null : CultureInfo.GetCultureInfo(culture);

            var cultures = TranslationLogic.CurrentCultureInfos(defaultCulture);

            Dictionary <string, LocalizableTypeTS> types =
                (from ci in cultures
                 let la = DescriptionManager.GetLocalizedAssembly(ass, ci)
                          where la != null || ci == defaultCulture || ci == targetCulture
                          let la2 = la ?? LocalizedAssembly.ImportXml(ass, ci, forceCreate: true)
                                    from t in la2.Types.Values
                                    let lt = new LocalizedTypeTS
            {
                culture = ci.Name,
                typeDescription = new LocalizedDescriptionTS
                {
                    gender = t.Gender?.ToString(),
                    description = t.Description,
                    pluralDescription = t.PluralDescription,
                },
                members = t.Members.Select(kvp => new LocalizedMemberTS {
                    name = kvp.Key, description = kvp.Value
                }).ToDictionary(a => a.name),
            }
                 group lt by t.Type into g
                 select KVP.Create(g.Key.Name, g.Key.ToLocalizableTypeTS().Let(localizedTypes =>
            {
                localizedTypes.cultures = g.ToDictionary(a => a.culture);
                return(localizedTypes);
            })))
                .ToDictionaryEx("types");


            types.ToList().ForEach(lt => lt.Value.FixMembers(defaultCulture));

            if (filter.HasText())
            {
                var complete = types.Extract((k, v) => v.type.Contains(filter, StringComparison.InvariantCultureIgnoreCase) ||
                                             v.cultures.Values.Select(a => a.typeDescription !).Any(td =>
                                                                                                    td.description != null && td.description.Contains(filter, StringComparison.InvariantCultureIgnoreCase) ||
                                                                                                    td.pluralDescription != null && td.pluralDescription.Contains(filter, StringComparison.InvariantCultureIgnoreCase)));


                var filtered = types.Extract((k, v) =>
                {
                    var allMembers = v.cultures.Values.SelectMany(a => a.members.Keys).Distinct().ToList();

                    var filteredMembers = allMembers.Where(m => m.Contains(filter, StringComparison.InvariantCultureIgnoreCase) ||
                                                           v.cultures.Values.Any(lt => lt.members.GetOrThrow(m).description?.Contains(filter, StringComparison.InvariantCultureIgnoreCase) ?? false))
                                          .ToList();

                    if (filteredMembers.Count == 0)
                    {
                        return(false);
                    }

                    foreach (var item in v.cultures.Values)
                    {
                        item.members = item.members.Where(a => filteredMembers.Contains(a.Key)).ToDictionary();
                    }

                    return(true);
                });

                types = complete.Concat(filtered).ToDictionary();
            }

            return(new AssemblyResultTS
            {
                types = types.OrderBy(a => a.Key).ToDictionary(),
                cultures = cultures.Select(c => c.ToCulturesTS())
                           .ToDictionary(a => a.name)
            });
        }
Exemple #29
0
 // Use this for initialization
 void Start()
 {
     descMng = descriptionPanel.GetComponent <DescriptionManager>();
 }