示例#1
0
        protected override void Apply()
        {
            bool fTokenizeParameter = false;
            SetTokenizedAttributeStorage        storage    = TransformStorage;
            List <Dictionary <string, string> > parameters = null;

            if (storage != null)
            {
                fTokenizeParameter = storage.EnableTokenizeParameters;
                if (fTokenizeParameter)
                {
                    parameters = storage.DictionaryList;
                }
            }

            foreach (XmlAttribute transformAttribute in TransformAttributes)
            {
                XmlAttribute targetAttribute = TargetNode.Attributes.GetNamedItem(transformAttribute.Name) as XmlAttribute;

                string newValue = TokenizeValue(targetAttribute, transformAttribute, fTokenizeParameter, parameters);

                if (targetAttribute != null)
                {
                    targetAttribute.Value = newValue;
                }
                else
                {
                    XmlAttribute newAttribute = (XmlAttribute)transformAttribute.Clone();
                    newAttribute.Value = newValue;
                    TargetNode.Attributes.Append(newAttribute);
                }

                Log.LogMessage(MessageType.Verbose, Resources.XMLTRANSFORMATION_TransformMessageSetAttribute, transformAttribute.Name);
            }

            if (TransformAttributes.Count > 0)
            {
                Log.LogMessage(MessageType.Verbose, Resources.XMLTRANSFORMATION_TransformMessageSetAttributes, TransformAttributes.Count);
            }
            else
            {
                Log.LogWarning(Resources.XMLTRANSFORMATION_TransformMessageNoSetAttributes);
            }
        }
示例#2
0
        protected override void Apply()
        {
            bool fTokenizeParameter = false;
            SetTokenizedAttributeStorage        transformStorage = this.TransformStorage;
            List <Dictionary <string, string> > parameters       = null;

            if (transformStorage != null)
            {
                fTokenizeParameter = transformStorage.EnableTokenizeParameters;
                if (fTokenizeParameter)
                {
                    parameters = transformStorage.DictionaryList;
                }
            }
            foreach (XmlAttribute attribute in base.TransformAttributes)
            {
                XmlAttribute namedItem = base.TargetNode.Attributes.GetNamedItem(attribute.Name) as XmlAttribute;
                string       str       = this.TokenizeValue(namedItem, attribute, fTokenizeParameter, parameters);
                if (namedItem != null)
                {
                    namedItem.Value = str;
                }
                else
                {
                    XmlAttribute node = (XmlAttribute)attribute.Clone();
                    node.Value = str;
                    base.TargetNode.Attributes.Append(node);
                }
                object[] messageArgs = new object[] { attribute.Name };
                base.Log.LogMessage(MessageType.Verbose, SR.XMLTRANSFORMATION_TransformMessageSetAttribute, messageArgs);
            }
            if (base.TransformAttributes.Count <= 0)
            {
                base.Log.LogWarning(SR.XMLTRANSFORMATION_TransformMessageNoSetAttributes, new object[0]);
            }
            else
            {
                object[] messageArgs = new object[] { base.TransformAttributes.Count };
                base.Log.LogMessage(MessageType.Verbose, SR.XMLTRANSFORMATION_TransformMessageSetAttributes, messageArgs);
            }
        }