Exemplo n.º 1
0
        private static void Import(IEnumerable <string> assets, Dictionary <Slot, Type> xamlTypes)
        {
            foreach (var asset in assets)
            {
                Slot lastSlot;
                Type xamlType;

                try
                {
                    if (!asset.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    var xaml  = Xaml.Parse(asset);
                    var slots = Slot.Parse(xaml.classFullName).ToArray();
                    lastSlot = slots.Last();

                    foreach (var xamlSlot in slots.Take(slots.Length - 1))
                    {
                        if (!xamlTypes.TryGetValue(xamlSlot, out xamlType))
                        {
                            xamlType.nested     = new Dictionary <Slot, Type>();
                            xamlTypes[xamlSlot] = xamlType;
                        }

                        xamlTypes = xamlType.nested;
                    }

                    if (!xamlTypes.TryGetValue(lastSlot, out xamlType))
                    {
                        xamlType.nested = new Dictionary <Slot, Type>();
                    }

                    xamlType.names = xaml.names;
                }
                catch (Exception exception)
                {
                    Debug.LogException(exception);
                    continue;
                }

                xamlType.asset      = asset;
                xamlTypes[lastSlot] = xamlType;
            }
        }