상속: ImplicitModuleBase
예제 #1
0
        public static ImplicitScaleOffset ScaleOffsetFromXElement(ImplicitXmlChain chain, XElement xElement)
        {
            var sourceString = (xElement.Attribute("source") != null ? xElement.Attribute("source").Value : String.Empty);
            var scaleString  = (xElement.Attribute("scale") != null ? xElement.Attribute("scale").Value : String.Empty);
            var offsetString = (xElement.Attribute("offset") != null ? xElement.Attribute("offset").Value : String.Empty);

            ImplicitScaleOffset scaleOffset;
            ImplicitModuleBase  source;
            Double value;

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

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

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

            return(scaleOffset);
        }
        public static ImplicitScaleOffset ScaleOffsetFromXElement(ImplicitXmlChain chain, XElement xElement)
        {
            var sourceString = (xElement.Attribute("source") != null ? xElement.Attribute("source").Value : String.Empty);
            var scaleString = (xElement.Attribute("scale") != null ? xElement.Attribute("scale").Value : String.Empty);
            var offsetString = (xElement.Attribute("offset") != null ? xElement.Attribute("offset").Value : String.Empty);

            ImplicitScaleOffset scaleOffset;
            ImplicitModuleBase source;
            Double value;

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

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

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

            return scaleOffset;

        }