상속: ImplicitModuleBase
예제 #1
0
        public static ImplicitScaleDomain ScaleDomainFromXElement(ImplicitXmlChain chain, XElement xElement)
        {
            var sourceString = (xElement.Attribute("source") != null ? xElement.Attribute("source").Value : String.Empty);
            var xs           = (xElement.Attribute("xs") != null ? xElement.Attribute("xs").Value : String.Empty);
            var ys           = (xElement.Attribute("ys") != null ? xElement.Attribute("ys").Value : String.Empty);
            var zs           = (xElement.Attribute("zs") != null ? xElement.Attribute("zs").Value : String.Empty);
            var vs           = (xElement.Attribute("vs") != null ? xElement.Attribute("vs").Value : String.Empty);
            var us           = (xElement.Attribute("us") != null ? xElement.Attribute("us").Value : String.Empty);
            var ws           = (xElement.Attribute("ws") != null ? xElement.Attribute("ws").Value : String.Empty);

            ImplicitScaleDomain scaleDomain;
            ImplicitModuleBase  source;
            Double value;

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

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

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

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

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

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

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

            return(scaleDomain);
        }
        public static ImplicitScaleDomain ScaleDomainFromXElement(ImplicitXmlChain chain, XElement xElement)
        {
            var sourceString = (xElement.Attribute("source") != null ? xElement.Attribute("source").Value : String.Empty);
            var xs = (xElement.Attribute("xs") != null ? xElement.Attribute("xs").Value : String.Empty);
            var ys = (xElement.Attribute("ys") != null ? xElement.Attribute("ys").Value : String.Empty);
            var zs = (xElement.Attribute("zs") != null ? xElement.Attribute("zs").Value : String.Empty);
            var vs = (xElement.Attribute("vs") != null ? xElement.Attribute("vs").Value : String.Empty);
            var us = (xElement.Attribute("us") != null ? xElement.Attribute("us").Value : String.Empty);
            var ws = (xElement.Attribute("ws") != null ? xElement.Attribute("ws").Value : String.Empty);

            ImplicitScaleDomain scaleDomain;
            ImplicitModuleBase source;
            Double value;

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

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

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

            if (!String.IsNullOrEmpty(zs))
            {

                if (chain.Modules.TryGetValue(zs, out source))
                    scaleDomain.ZScale = source;
                else if (Double.TryParse(zs, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    scaleDomain.ZScale = value;
                else
                    throw new InvalidOperationException("Invalid zs value");
            }

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

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

            if (!String.IsNullOrEmpty(ws))
            {

                if (chain.Modules.TryGetValue(ws, out source))
                    scaleDomain.WScale = source;
                else if (Double.TryParse(ws, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
                    scaleDomain.WScale = value;
                else
                    throw new InvalidOperationException("Invalid ws value");
            }

            return scaleDomain;
        }