protected override void InitializeFromXml()
        {
            var namespaceManager = ParameterNode.GetNameSpaceManager();

            var id = ParameterNode.SelectSingleNode("./Id", namespaceManager);

            if (id != null)
            {
                Guid testId;
                if (Guid.TryParse(id.InnerText, out testId))
                {
                    var name = ParameterNode.SelectSingleNode("./Name", namespaceManager)?.InnerText;
                    if (name == null)
                    {
                        throw new InvalidXmlException("Name element is missing", ParameterNode);
                    }

                    var valueNode = ParameterNode.SelectSingleNode("./Value", namespaceManager);
                    var value     = valueNode?.InnerText;

                    // Don't store encrypted string
                    if (Sensitive)
                    {
                        value = null;
                    }

                    Name  = name;
                    Value = value;
                }
            }
            else
            {
                throw new InvalidXmlException("Id element is missing", ParameterNode);
            }
        }
Exemple #2
0
        private Type ExtractDataType()
        {
            var dataType = ParameterNode.SelectSingleNode("./Value", ParameterNode.GetNameSpaceManager())?.Attributes?["xsi:type"]?.Value;

            switch (dataType)
            {
            case "xsd:boolean":
                return(typeof(bool));

            case "xsd:unsignedByte":
                return(typeof(byte));

            case "xsd:dateTime":
                return(typeof(DateTime));

            case "xsd:decimal":
                return(typeof(decimal));

            case "xsd:double":
                return(typeof(double));

            case "xsd:short":
                return(typeof(short));

            case "xsd:int":
                return(typeof(int));

            case "xsd:long":
                return(typeof(long));

            case "xsd:byte":
                return(typeof(sbyte));

            case "xsd:float":
                return(typeof(float));

            case "xsd:string":
                return(typeof(string));

            case "xsd:unsignedInt":
                return(typeof(uint));

            case "xsd:unsignedLong":
                return(typeof(ulong));

            default:
                return(null);
            }
        }
Exemple #3
0
        protected override void InitializeFromXml()
        {
            if (ScopeName == null)
            {
                throw new ArgumentNullException(nameof(ScopeName));
            }

            var namespaceManager = ParameterNode.GetNameSpaceManager();
            var name             = XmlHelpers.GetAttributeNode(ParameterNode, "SSIS:Name")?.Value;

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new InvalidXmlException("SSIS:Name attribute can not be null or empty", ParameterNode);
            }

            var propertiesXmlElement = ParameterNode.SelectSingleNode("./SSIS:Properties", namespaceManager) as XmlElement;

            if (propertiesXmlElement == null)
            {
                throw new InvalidXmlException("Could not find collection of parameter properties", ParameterNode);
            }

            var valueXmlElement = propertiesXmlElement.SelectSingleNode("./SSIS:Property[@SSIS:Name = \"Value\"]", namespaceManager) as XmlElement;
            var value           = valueXmlElement?.InnerText;

            Name          = $"{ScopeName}::{name}";
            Value         = value;
            ParentElement = propertiesXmlElement;
            ValueElement  = valueXmlElement;
            Sensitive     = ParentElement.SelectSingleNode("./SSIS:Property[@SSIS:Name = \"Sensitive\"]", ParentElement.GetNameSpaceManager())?.InnerText == "1";

            if (valueXmlElement == null)
            {
                ValueElement = ParentElement.GetDocument().CreateElement("SSIS:Property", XmlHelpers.Schemas.SSIS);
                ValueElement.SetAttribute("Name", XmlHelpers.Schemas.SSIS, "Value");
                if (Sensitive)
                {
                    ValueElement.SetAttribute("Sensitive", XmlHelpers.Schemas.SSIS, "1");
                }
            }
            else
            {
                ValueElement = valueXmlElement;
            }

            ParameterDataType = ExtractDataType();
        }