Exemple #1
0
        private static void LoadUsingNode(VisualTreeAsset vta, XElement elt, XElement child)
        {
            bool   flag = false;
            string text = null;
            string path = null;

            foreach (XAttribute current in child.Attributes())
            {
                string localName = current.Name.LocalName;
                if (localName == null)
                {
                    goto IL_99;
                }
                if (!(localName == "path"))
                {
                    if (!(localName == "alias"))
                    {
                        goto IL_99;
                    }
                    text = current.Value;
                    if (text == string.Empty)
                    {
                        UIElementsViewImporter.logger.LogError(ImportErrorType.Semantic, ImportErrorCode.UsingHasEmptyAlias, child, UIElementsViewImporter.Error.Level.Fatal, child);
                    }
                }
                else
                {
                    flag = true;
                    path = current.Value;
                }
                continue;
IL_99:
                UIElementsViewImporter.logger.LogError(ImportErrorType.Semantic, ImportErrorCode.UnknownAttribute, current.Name.LocalName, UIElementsViewImporter.Error.Level.Fatal, child);
            }
            if (!flag)
            {
                UIElementsViewImporter.logger.LogError(ImportErrorType.Semantic, ImportErrorCode.MissingPathAttributeOnUsing, null, UIElementsViewImporter.Error.Level.Fatal, elt);
            }
            else
            {
                if (string.IsNullOrEmpty(text))
                {
                    text = Path.GetFileNameWithoutExtension(path);
                }
                if (vta.AliasExists(text))
                {
                    UIElementsViewImporter.logger.LogError(ImportErrorType.Semantic, ImportErrorCode.DuplicateUsingAlias, text, UIElementsViewImporter.Error.Level.Fatal, elt);
                }
                else
                {
                    vta.RegisterUsing(text, path);
                }
            }
        }
Exemple #2
0
        private static void LoadUsingNode(VisualTreeAsset vta, XElement elt, XElement child)
        {
            bool   hasPath = false;
            string alias   = null;
            string path    = null;

            foreach (var xAttribute in child.Attributes())
            {
                switch (xAttribute.Name.LocalName)
                {
                case k_UsingPathAttr:
                    hasPath = true;
                    path    = xAttribute.Value;
                    break;

                case k_UsingAliasAttr:
                    alias = xAttribute.Value;
                    if (alias == String.Empty)
                    {
                        logger.LogError(ImportErrorType.Semantic,
                                        ImportErrorCode.UsingHasEmptyAlias,
                                        child,
                                        Error.Level.Fatal,
                                        child
                                        );
                    }
                    break;

                default:
                    logger.LogError(ImportErrorType.Semantic,
                                    ImportErrorCode.UnknownAttribute,
                                    xAttribute.Name.LocalName,
                                    Error.Level.Fatal,
                                    child
                                    );
                    break;
                }
            }

            if (!hasPath)
            {
                logger.LogError(ImportErrorType.Semantic,
                                ImportErrorCode.MissingPathAttributeOnUsing,
                                null,
                                Error.Level.Fatal,
                                elt
                                );
                return;
            }

            if (String.IsNullOrEmpty(alias))
            {
                alias = Path.GetFileNameWithoutExtension(path);
            }

            if (vta.AliasExists(alias))
            {
                logger.LogError(ImportErrorType.Semantic,
                                ImportErrorCode.DuplicateUsingAlias,
                                alias,
                                Error.Level.Fatal,
                                elt
                                );
                return;
            }

            vta.RegisterUsing(alias, path);
        }