Inheritance: ImplicitModuleBase
コード例 #1
0
ファイル: ImplicitXmlChain.cs プロジェクト: JPMMaia/tuguiadas
        public static ImplicitTranslateDomain TranslateDomainFromXElement(ImplicitXmlChain chain, XElement xElement)
        {
            var sourceString = (xElement.Attribute("source") != null ? xElement.Attribute("source").Value : String.Empty);
            var xa           = (xElement.Attribute("xa") != null ? xElement.Attribute("xa").Value : String.Empty);
            var ya           = (xElement.Attribute("ya") != null ? xElement.Attribute("ya").Value : String.Empty);
            var za           = (xElement.Attribute("za") != null ? xElement.Attribute("za").Value : String.Empty);
            var va           = (xElement.Attribute("va") != null ? xElement.Attribute("va").Value : String.Empty);
            var ua           = (xElement.Attribute("ua") != null ? xElement.Attribute("ua").Value : String.Empty);
            var wa           = (xElement.Attribute("wa") != null ? xElement.Attribute("wa").Value : String.Empty);

            ImplicitTranslateDomain translateDomain;

            ImplicitModuleBase source;
            Double             value;

            if (!String.IsNullOrEmpty(sourceString))
            {
                if (chain.Modules.TryGetValue(sourceString, out source))
                {
                    translateDomain = new ImplicitTranslateDomain(source);
                }
                else if (Double.TryParse(sourceString, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                {
                    translateDomain = new ImplicitTranslateDomain(value);
                }
                else
                {
                    throw new InvalidOperationException("Invalid source value");
                }
            }
            else
            {
                throw new InvalidOperationException("Missing source");
            }

            if (!String.IsNullOrEmpty(xa))
            {
                if (chain.Modules.TryGetValue(xa, out source))
                {
                    translateDomain.XAxis = source;
                }
                else if (Double.TryParse(xa, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                {
                    translateDomain.XAxis = value;
                }
                else
                {
                    throw new InvalidOperationException("Invalid xa value");
                }
            }

            if (!String.IsNullOrEmpty(ya))
            {
                if (chain.Modules.TryGetValue(ya, out source))
                {
                    translateDomain.YAxis = source;
                }
                else if (Double.TryParse(ya, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                {
                    translateDomain.YAxis = value;
                }
                else
                {
                    throw new InvalidOperationException("Invalid ya value");
                }
            }

            if (!String.IsNullOrEmpty(za))
            {
                if (chain.Modules.TryGetValue(za, out source))
                {
                    translateDomain.ZAxis = source;
                }
                else if (Double.TryParse(za, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                {
                    translateDomain.ZAxis = value;
                }
                else
                {
                    throw new InvalidOperationException("Invalid za value");
                }
            }

            if (!String.IsNullOrEmpty(va))
            {
                if (chain.Modules.TryGetValue(va, out source))
                {
                    translateDomain.VAxis = source;
                }
                else if (Double.TryParse(va, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                {
                    translateDomain.VAxis = value;
                }
                else
                {
                    throw new InvalidOperationException("Invalid va value");
                }
            }

            if (!String.IsNullOrEmpty(ua))
            {
                if (chain.Modules.TryGetValue(ua, out source))
                {
                    translateDomain.UAxis = source;
                }
                else if (Double.TryParse(ua, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                {
                    translateDomain.UAxis = value;
                }
                else
                {
                    throw new InvalidOperationException("Invalid ua value");
                }
            }

            if (!String.IsNullOrEmpty(wa))
            {
                if (chain.Modules.TryGetValue(wa, out source))
                {
                    translateDomain.WAxis = source;
                }
                else if (Double.TryParse(wa, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                {
                    translateDomain.WAxis = value;
                }
                else
                {
                    throw new InvalidOperationException("Invalid wa value");
                }
            }

            return(translateDomain);
        }
コード例 #2
0
        public static ImplicitTranslateDomain TranslateDomainFromXElement(ImplicitXmlChain chain, XElement xElement)
        {
            var sourceString = (xElement.Attribute("source") != null ? xElement.Attribute("source").Value : String.Empty);
            var xa = (xElement.Attribute("xa") != null ? xElement.Attribute("xa").Value : String.Empty);
            var ya = (xElement.Attribute("ya") != null ? xElement.Attribute("ya").Value : String.Empty);
            var za = (xElement.Attribute("za") != null ? xElement.Attribute("za").Value : String.Empty);
            var va = (xElement.Attribute("va") != null ? xElement.Attribute("va").Value : String.Empty);
            var ua = (xElement.Attribute("ua") != null ? xElement.Attribute("ua").Value : String.Empty);
            var wa = (xElement.Attribute("wa") != null ? xElement.Attribute("wa").Value : String.Empty);

            ImplicitTranslateDomain translateDomain;

            ImplicitModuleBase source;
            Double value;

            if (!String.IsNullOrEmpty(sourceString))
            {
                if (chain.Modules.TryGetValue(sourceString, out source))
                    translateDomain = new ImplicitTranslateDomain(source);
                else if (Double.TryParse(sourceString, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    translateDomain = new ImplicitTranslateDomain(value);
                else
                    throw new InvalidOperationException("Invalid source value");
            }
            else
                throw new InvalidOperationException("Missing source");

            if (!String.IsNullOrEmpty(xa))
            {
                if (chain.Modules.TryGetValue(xa, out source))
                    translateDomain.XAxis = source;
                else if (Double.TryParse(xa, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    translateDomain.XAxis = value;
                else
                    throw new InvalidOperationException("Invalid xa value");
            }

            if (!String.IsNullOrEmpty(ya))
            {
                if (chain.Modules.TryGetValue(ya, out source))
                    translateDomain.YAxis = source;
                else if (Double.TryParse(ya, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    translateDomain.YAxis = value;
                else
                    throw new InvalidOperationException("Invalid ya value");
            }

            if (!String.IsNullOrEmpty(za))
            {
                if (chain.Modules.TryGetValue(za, out source))
                    translateDomain.ZAxis = source;
                else if (Double.TryParse(za, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    translateDomain.ZAxis = value;
                else
                    throw new InvalidOperationException("Invalid za value");
            }

            if (!String.IsNullOrEmpty(va))
            {
                if (chain.Modules.TryGetValue(va, out source))
                    translateDomain.VAxis = source;
                else if (Double.TryParse(va, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    translateDomain.VAxis = value;
                else
                    throw new InvalidOperationException("Invalid va value");
            }

            if (!String.IsNullOrEmpty(ua))
            {
                if (chain.Modules.TryGetValue(ua, out source))
                    translateDomain.UAxis = source;
                else if (Double.TryParse(ua, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    translateDomain.UAxis = value;
                else
                    throw new InvalidOperationException("Invalid ua value");
            }

            if (!String.IsNullOrEmpty(wa))
            {
                if (chain.Modules.TryGetValue(wa, out source))
                    translateDomain.WAxis = source;
                else if (Double.TryParse(wa, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    translateDomain.WAxis = value;
                else
                    throw new InvalidOperationException("Invalid wa value");
            }

            return translateDomain;
        }