예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModel"/> class.
        /// </summary>
        /// <param name="viewConfiguration">The name of this view.</param>
        /// <param name="viewElement">The configuration element of the view template this class handles.</param>
        public ViewModel(ViewConfiguration viewConfiguration, XmlElement viewElement)
            : this(viewConfiguration)
        {
            Contract.Requires<ArgumentException>(viewElement != null);

            this.ConfigNode = (XmlElement) viewElement.CloneNode(true);

            var config = context.ProjectConfiguration;
            var currentPath = context.Request.Path;

            var matchingLibs = new List<ResourceLibraryInfo>(
                config.ResourceLibraries.Values.Where(l => l.MatchesPath(currentPath)));

            foreach (ResourceLibraryInfo library in matchingLibs)
            {
                foreach (string libraryRef in library.LibraryDependencies)
                {
                    if (!config.ResourceLibraries.ContainsKey(libraryRef))
                    {
                        log.ErrorFormat("Library '{0}' is referencing a non-existing library '{1}'.", library.Name, libraryRef);
                        continue;
                    }

                    ResourceLibraryInfo referenced = config.ResourceLibraries[libraryRef];
                    autoResources.AddRange(referenced.Resources);
                }

                autoResources.AddRange(library.Resources);
            }

            this.AddViewResources(autoResources);
        }
        /// <summary>
        /// 建立可更新的「組態記錄」。
        /// </summary>
        /// <param name="data">組態的  Xml 資料。</param>
        public ConfigurationRecord(string name, XmlElement data)
        {
            if (data == null)
                throw new ArgumentException("組態的 Xml 資料不可以是 Null。");

            Namespace = name;
            EditAction = 2;//修改
            BaseData = null; //舊的格式的話,保持此資料是 Null。

            if (data.LocalName != RootName)
                PreviousData = data.CloneNode(true) as XmlElement;
            else
                BaseData = new AutoDictionary(data.SelectNodes(RecordName), "Name", false);
        }
예제 #3
0
        public NewEnemyWindow(XmlElement templateEnemy, Editor editor)
        {
            parentEditor = editor;
            try
            {
                NewEnemyElement = (XmlElement)templateEnemy.CloneNode(true);
                templateEnemy.ParentNode.AppendChild(NewEnemyElement);
                Eject = true;
                parentDoc = NewEnemyElement.OwnerDocument;


            }
            catch
            {
                Console.Out.WriteLine("Failed to receive an xmlelement");
            }
            InitializeComponent();


        }
예제 #4
0
		public DotNetProject (string languageName, ProjectCreateInformation projectCreateInfo, XmlElement projectOptions) : this(languageName)
		{
			if ((projectOptions != null) && (projectOptions.Attributes ["Target"] != null))
				CompileTarget = (CompileTarget)Enum.Parse (typeof(CompileTarget), projectOptions.Attributes ["Target"].Value);
			else if (IsLibraryBasedProjectType)
				CompileTarget = CompileTarget.Library;

			if (this.LanguageBinding != null) {
				LanguageParameters = languageBinding.CreateProjectParameters (projectOptions);
				
				bool externalConsole = false;

				string platform = null;
				if (projectOptions != null) {
					projectOptions.SetAttribute ("DefineDebug", "True");
					if (!projectOptions.HasAttribute ("Platform")) {
						// Clone the element since we are going to change it
						platform = GetDefaultTargetPlatform (projectCreateInfo);
						projectOptions = (XmlElement)projectOptions.CloneNode (true);
						projectOptions.SetAttribute ("Platform", platform);
					} else
						platform = projectOptions.GetAttribute ("Platform");
					if (projectOptions.GetAttribute ("ExternalConsole") == "True")
						externalConsole = true;
				}
				string platformSuffix = string.IsNullOrEmpty (platform) ? string.Empty : "|" + platform;
				DotNetProjectConfiguration configDebug = CreateConfiguration ("Debug" + platformSuffix) as DotNetProjectConfiguration;
				configDebug.CompilationParameters = languageBinding.CreateCompilationParameters (projectOptions);
				configDebug.DebugMode = true;
				configDebug.ExternalConsole = externalConsole;
				configDebug.PauseConsoleOutput = externalConsole;
				Configurations.Add (configDebug);

				DotNetProjectConfiguration configRelease = CreateConfiguration ("Release" + platformSuffix) as DotNetProjectConfiguration;
				
				if (projectOptions != null) {
					XmlElement releaseProjectOptions = (XmlElement)projectOptions.CloneNode (true);
					releaseProjectOptions.SetAttribute ("Release", "True");
					configRelease.CompilationParameters = languageBinding.CreateCompilationParameters (releaseProjectOptions);
				} else {
					configRelease.CompilationParameters = languageBinding.CreateCompilationParameters (null);
				}
				
				configRelease.CompilationParameters.RemoveDefineSymbol ("DEBUG");
				configRelease.DebugMode = false;
				configRelease.ExternalConsole = externalConsole;
				configRelease.PauseConsoleOutput = externalConsole;
				Configurations.Add (configRelease);
			}

			if ((projectOptions != null) && (projectOptions.Attributes["TargetFrameworkVersion"] != null))
				newProjectTargetFrameworkId = TargetFrameworkMoniker.Parse (projectOptions.Attributes["TargetFrameworkVersion"].Value);

			string binPath;
			if (projectCreateInfo != null) {
				Name = projectCreateInfo.ProjectName;
				binPath = projectCreateInfo.BinPath;
				defaultNamespace = SanitisePotentialNamespace (projectCreateInfo.ProjectName);
			} else {
				binPath = ".";
			}

			foreach (DotNetProjectConfiguration dotNetProjectConfig in Configurations) {
				dotNetProjectConfig.OutputDirectory = Path.Combine (binPath, dotNetProjectConfig.Name);

				if ((projectOptions != null) && (projectOptions.Attributes["PauseConsoleOutput"] != null))
					dotNetProjectConfig.PauseConsoleOutput = Boolean.Parse (projectOptions.Attributes["PauseConsoleOutput"].Value);

				if (projectCreateInfo != null)
					dotNetProjectConfig.OutputAssembly = projectCreateInfo.ProjectName;
			}
		}
예제 #5
0
 private static byte[] CalculateC14nByteRange(XmlElement element, XmlDocument doc) {
     XmlElement cloneElement = (XmlElement)element.CloneNode(true);
     NormalizeNamespaces(element.CreateNavigator(), cloneElement.CreateNavigator());
     XmlDocument elememntDoc = new XmlDocument(doc.NameTable);
     elememntDoc.LoadXml(cloneElement.OuterXml);
     XmlDsigC14NTransform c14nTransform = new XmlDsigC14NTransform();
     c14nTransform.LoadInput(elememntDoc);
     return ((MemoryStream)c14nTransform.GetOutput()).ToArray();
 }
예제 #6
0
        private static XmlElement GenerateCustomReference(XmlDocument doc, XmlElement signedElement, String uri, String type, String id) {

            XmlElement reference = doc.CreateElement("Reference", SecurityConstants.XMLDSIG_URI);
            if (uri == null)
                uri = string.Empty;
            reference.SetAttribute("URI", uri);
            if(type != null)
                reference.SetAttribute("Type", type);
            if(id != null)
                reference.SetAttribute("Id", id);
            XmlElement xpathSelect = (XmlElement)signedElement.CloneNode(true);
            XPathNavigator xpathSelectNavigator = xpathSelect.CreateNavigator();
            NormalizeNamespaces(doc.DocumentElement.CreateNavigator(), xpathSelectNavigator);
            xpathSelectNavigator.CreateAttribute("xmlns", "xades", SecurityConstants.XMLNS_URI, SecurityConstants.XADES_132_URI);
            xpathSelectNavigator.CreateAttribute("xmlns", "", SecurityConstants.XMLNS_URI, SecurityConstants.XMLDSIG_URI);
            
            XmlDocument digestDoc = new XmlDocument(doc.NameTable);
            digestDoc.LoadXml(xpathSelect.OuterXml);

            byte[] md = CalculateC14nDigest(digestDoc, new SHA1Managed());

            XmlElement digestMethod = doc.CreateElement("DigestMethod", SecurityConstants.XMLDSIG_URI);
            digestMethod.SetAttribute("Algorithm", SecurityConstants.XMLDSIG_URI_SHA1);
            reference.AppendChild(digestMethod);

            XmlElement digestValue = doc.CreateElement("DigestValue", SecurityConstants.XMLDSIG_URI);

            digestValue.AppendChild(doc.CreateTextNode(Convert.ToBase64String(md)));

            reference.AppendChild(digestValue);
            return reference;
        }
예제 #7
0
		protected override void OnInitializeFromTemplate (ProjectCreateInformation projectCreateInfo, XmlElement projectOptions)
		{
			base.OnInitializeFromTemplate (projectCreateInfo, projectOptions);

			if ((projectOptions != null) && (projectOptions.Attributes ["Target"] != null))
				CompileTarget = (CompileTarget)Enum.Parse (typeof(CompileTarget), projectOptions.Attributes ["Target"].Value);
			else if (IsLibraryBasedProjectType)
				CompileTarget = CompileTarget.Library;

			if (this.LanguageBinding != null) {

				bool externalConsole = false;

				string platform = null;
				if (!projectOptions.HasAttribute ("Platform")) {
					// Clone the element since we are going to change it
					platform = GetDefaultTargetPlatform (projectCreateInfo);
					projectOptions = (XmlElement)projectOptions.CloneNode (true);
					projectOptions.SetAttribute ("Platform", platform);
				} else
					platform = projectOptions.GetAttribute ("Platform");
				
				if (projectOptions.GetAttribute ("ExternalConsole") == "True")
					externalConsole = true;

				string platformSuffix = string.IsNullOrEmpty (platform) ? string.Empty : "|" + platform;
				DotNetProjectConfiguration configDebug = CreateConfiguration ("Debug" + platformSuffix, ConfigurationKind.Debug) as DotNetProjectConfiguration;
				DefineSymbols (configDebug.CompilationParameters, projectOptions, "DefineConstantsDebug");
				configDebug.ExternalConsole = externalConsole;
				configDebug.PauseConsoleOutput = externalConsole;
				Configurations.Add (configDebug);

				DotNetProjectConfiguration configRelease = CreateConfiguration ("Release" + platformSuffix, ConfigurationKind.Release) as DotNetProjectConfiguration;
				DefineSymbols (configRelease.CompilationParameters, projectOptions, "DefineConstantsRelease");
				configRelease.CompilationParameters.RemoveDefineSymbol ("DEBUG");
				configRelease.ExternalConsole = externalConsole;
				configRelease.PauseConsoleOutput = externalConsole;
				Configurations.Add (configRelease);
			}

			targetFramework = GetTargetFrameworkForNewProject (projectOptions, GetDefaultTargetFrameworkId ());

			string binPath;
			if (projectCreateInfo != null) {
				Name = projectCreateInfo.ProjectName;
				binPath = projectCreateInfo.BinPath;
				defaultNamespace = SanitisePotentialNamespace (projectCreateInfo.ProjectName);
			} else {
				binPath = ".";
			}

			foreach (DotNetProjectConfiguration dotNetProjectConfig in Configurations) {
				dotNetProjectConfig.OutputDirectory = Path.Combine (binPath, dotNetProjectConfig.Name);

				if ((projectOptions != null) && (projectOptions.Attributes["PauseConsoleOutput"] != null))
					dotNetProjectConfig.PauseConsoleOutput = Boolean.Parse (projectOptions.Attributes["PauseConsoleOutput"].Value);

				if (projectCreateInfo != null)
					dotNetProjectConfig.OutputAssembly = projectCreateInfo.ProjectName;
			}
		}
예제 #8
0
        // ################################################################################################################
        /// <summary>Encode RTT action elements on a string of text to turn one string to the next string.
        /// This follows the XMPP In-Band Real Time Text Specification.</summary>
        /// <param name="rtt">The rtt element object</param>
        /// <param name="before">Previous real time message</param>
        /// <param name="after">Current real time message</param>
        /// <returns>Efficiently encoded RTT fragment to send in XML "rtt" element to change "before" into "after"</returns>
        public static XmlNode EncodeRawRTT(XmlElement rtt, Message before, Message after)
        {
            if (after.CursorPos < 0) after.CursorPos = 0;
            if (after.CursorPos > after.Text.Length) after.CursorPos = after.Text.Length;

            int curPos = before.CursorPos;
            bool textChanged = (before.Text != after.Text);
            bool posChanged = (before.CursorPos != after.CursorPos);
            if (!textChanged && !posChanged) return rtt;

            #if _DEBUG_RTT_CODEC
            XmlElement lastChild = (XmlElement)rtt.LastChild;
            #endif
            if (textChanged)
            {
                // Before text and after text is different
                int leadingSame = 0;
                int trailingSame = 0;
                int i = 0;
                int j = 0;

                // Find number of characters at start that remains the same
                while ((before.Text.Length > i) && (after.Text.Length > i))
                {
                    if (before.Text[i] != after.Text[i])
                    {
                        break;
                    }
                    i++;
                    leadingSame++;
                }

                // Find number of characters at end that remains the same
                i = before.Text.Length;
                j = after.Text.Length;
                while ((i > leadingSame) && (j > leadingSame))
                {
                    i--;
                    j--;
                    if (before.Text[i] != after.Text[j])
                    {
                        break;
                    }
                    trailingSame++;
                }

                // Erase text if a deletion is detected anywhere in the string.
                int charsRemoved = before.Text.Length - trailingSame - leadingSame;
                if (charsRemoved > 0)
                {
                    int posEndOfRemovedChars = before.Text.Length - trailingSame;
                    int posStartOfRemovedChars = posEndOfRemovedChars - charsRemoved;

                    // Do <e/> ERASE TEXT action element to delete text block
                    AppendElement.EraseText(rtt, posEndOfRemovedChars, charsRemoved, before.Text.Length);
                    curPos = posStartOfRemovedChars;
                }

                // Do <t/> INSERT TEXT action element if any text insertion is detected anywhere in the string
                int charsInserted = after.Text.Length - trailingSame - leadingSame;
                string insertedText = after.Text.Substring(leadingSame, charsInserted);
                AppendElement.InsertText(rtt, insertedText, curPos, before.Text.Length);
                curPos += charsInserted;
            }

            // To assist in the optional remote cursor, do a blank <t/> INSERT TEXT action element
            if ((before.CursorPos != -1) &&
                (curPos != after.CursorPos))
            {
                AppendElement.CursorPosition(rtt, after.CursorPos);
            }

            #if _DEBUG_RTT_CODEC
            // Start of RTT encode/decode test
            int testPos = before.CursorPos;
            int interval = 0;
            XmlElement rttTest;
            if (lastChild == null)
            {
                rttTest = (XmlElement)rtt.CloneNode(true);
            }
            else
            {
                rttTest = rtt.OwnerDocument.CreateElement(RealTimeText.ROOT);
                lastChild = (XmlElement)lastChild.NextSibling;
                while (lastChild != null)
                {
                    rttTest.AppendChild(lastChild.Clone());
                    lastChild = (XmlElement)lastChild.NextSibling;
                }
            }
            string codedText = rttTest.InnerXml.ToString();
            Message msg = new Message();
            msg.Text = before.Text;
            msg.CursorPos = testPos;
            msg.CurrentKeyInterval = interval;
            msg.KeyIntervalsEnabled= false;
            DecodeRawRTT(rttTest, msg);

            Console.WriteLine("------------");
            Console.WriteLine("Before Text : " + before.Text);
            Console.WriteLine("After Text  : " + after.Text);
            Console.WriteLine("CODED Text  : " + codedText);
            Debug.Assert(after.Text == msg.Text, "*** ASSERT FAIL! RTT TEXT MISMATCH.");
            Debug.Assert(after.CursorPos == msg.CursorPos, "*** ASSERT FAIL! RTT CURSOR POS MISMATCH: " + testPos.ToString() + " vs " + after.CursorPos.ToString());
            // End of RTT encode/decode test
            #endif
            return rtt;
        }
예제 #9
0
		private string ElementToXmlString(XmlElement element)
		{
			//    TODO    My goodness ECMA is complicated (see 10.2.1).  We'll try this first.
			XmlElement copy = (XmlElement)element.CloneNode(true);
			if (prettyPrint)
			{
				BeautifyElement(copy, 0);
			}
			return ToString(copy);
		}
예제 #10
0
		private static void FixCategory(XmlElement node)
		{
			if (node.InnerText.Contains("/"))
			{
				var arr = node.InnerText.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
				node.InnerText = arr[0];
				for (var i = 1; i < arr.Length; i++)
				{
					var clone = node.CloneNode(true);
					clone.InnerText = arr[i];
					node.ParentNode.InsertBefore(clone, node);
				}
			}
		}
예제 #11
0
        public static WfpItem AddItem(string code, XmlElement xml)
        {
            lock(Items)
            {
                if (Items.ContainsKey(code))
                    throw new Exception("Windows WFP, unexpected: Rule '" + code + "' already exists");

                WfpItem item = new WfpItem();
                item.Code = code;

                List<string> layers = new List<string>();

                if (xml.GetAttribute("layer") == "all")
                {
                    layers.Add("ale_auth_recv_accept_v4");
                    layers.Add("ale_auth_recv_accept_v6");
                    layers.Add("ale_auth_connect_v4");
                    layers.Add("ale_auth_connect_v6");
                    layers.Add("ale_flow_established_v4");
                    layers.Add("ale_flow_established_v6");
                }
                else if (xml.GetAttribute("layer") == "ipv4")
                {
                    layers.Add("ale_auth_recv_accept_v4");
                    layers.Add("ale_auth_connect_v4");
                    layers.Add("ale_flow_established_v4");
                }
                else if (xml.GetAttribute("layer") == "ipv6")
                {
                    layers.Add("ale_auth_recv_accept_v6");
                    layers.Add("ale_auth_connect_v6");
                    layers.Add("ale_flow_established_v6");
                }
                else
                    layers.Add(xml.GetAttribute("layer"));

                if (xml.HasAttribute("weight") == false)
                {
                    xml.SetAttribute("weight", "1000");
                }

                foreach (string layer in layers)
                {
                    XmlElement xmlClone = xml.CloneNode(true) as XmlElement;
                    xmlClone.SetAttribute("layer", layer);
                    string xmlStr = xmlClone.OuterXml;

                    UInt64 id1 = LibPocketFirewallAddRule(xmlStr);

                    if (id1 == 0)
                    {
                        throw new Exception(MessagesFormatter.Format(Messages.WfpRuleAddFail, LibPocketFirewallGetLastError2(), xmlStr));
                    }
                    else
                    {
                        // Only used for debugging WFP issue with rules in some system
                        // Engine.Instance.Logs.Log(LogType.Verbose, Messages.Format(Messages.WfpRuleAddSuccess, xmlStr));
                        item.FirewallIds.Add(id1);
                    }
                }

                Items[item.Code] = item;

                return item;
            }
        }
예제 #12
0
        /// <summary>
        /// Gets a <see cref="FrameworkTemplate"/> based on the specified parameters.
        /// </summary>
        /// <param name="xmlElement">The xml element to get template xaml from.</param>
        /// <param name="parentObject">The <see cref="XamlObject"/> to use as source for resources and contextual information.</param>
        /// <returns>A <see cref="FrameworkTemplate"/> based on the specified parameters.</returns>
        public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject)
        {
            var nav = xmlElement.CreateNavigator();

            var ns = new Dictionary<string, string>();
            while (true)
            {
                var nsInScope = nav.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml);
                foreach (var ak in nsInScope)
                {
                    if (!ns.ContainsKey(ak.Key) && ak.Key != "")
                        ns.Add(ak.Key, ak.Value);
                }
                if (!nav.MoveToParent())
                    break;
            }

            xmlElement = (XmlElement)xmlElement.CloneNode(true);

            foreach (var dictentry in ns.ToList())
            {
                var value = dictentry.Value;
                if (value.StartsWith("clr-namespace") && !value.Contains(";assembly=")) {
                    if (!string.IsNullOrEmpty(parentObject.OwnerDocument.CurrentProjectAssemblyName)) {
                        value += ";assembly=" + parentObject.OwnerDocument.CurrentProjectAssemblyName;
                    }
                }
                xmlElement.SetAttribute("xmlns:" + dictentry.Key, value);
            }

            var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace);

            if (string.IsNullOrEmpty(keyAttrib)) {
                xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__");
            }

            var xaml = xmlElement.OuterXml;
            xaml = "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/netfx/2007/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + xaml + "</ResourceDictionary>";
            StringReader stringReader = new StringReader(xaml);
            XmlReader xmlReader = XmlReader.Create(stringReader);
            var xamlReader = new XamlXmlReader(xmlReader, parentObject.ServiceProvider.SchemaContext);

            var seti = new XamlObjectWriterSettings();

            var resourceDictionary = new ResourceDictionary();
            var obj = parentObject;
            while (obj != null)
            {
                if (obj.Instance is ResourceDictionary)
                {
                    var r = obj.Instance as ResourceDictionary;
                    foreach (var k in r.Keys)
                    {
                        if (!resourceDictionary.Contains(k))
                            resourceDictionary.Add(k, r[k]);
                    }
                }
                else if (obj.Instance is FrameworkElement)
                {
                    var r = ((FrameworkElement)obj.Instance).Resources;
                    foreach (var k in r.Keys)
                    {
                        if (!resourceDictionary.Contains(k))
                            resourceDictionary.Add(k, r[k]);
                    }
                }

                obj = obj.ParentObject;
            }

            seti.BeforePropertiesHandler = (s, e) =>
            {
                if (seti.BeforePropertiesHandler != null)
                {
                    var rr = e.Instance as ResourceDictionary;
                    rr.MergedDictionaries.Add(resourceDictionary);
                    seti.BeforePropertiesHandler = null;
                }
            };

            var writer = new XamlObjectWriter(parentObject.ServiceProvider.SchemaContext, seti);

            XamlServices.Transform(xamlReader, writer);

            var result = (ResourceDictionary)writer.Result;

            var enr = result.Keys.GetEnumerator();
            enr.MoveNext();
            var rdKey = enr.Current;

            var template = result[rdKey] as FrameworkTemplate;

            result.Remove(rdKey);
            return template;
        }
예제 #13
0
        private static XmlElement GetSpecialItemRow(XmlElement rowTemplate, OrderDetail orderItem)
        {
            XmlElement newRow = (XmlElement)rowTemplate.CloneNode(true);
            newRow.RemoveAttribute("Name");

            var tableCells = newRow.GetElementsByTagName("TableCell");

            foreach (XmlElement cell in tableCells)
            {
                var node = cell.FirstChild;

                if (cell.FirstChild == null)
                    node = cell;

                node.InnerText = node.InnerText.Replace("@Barcode", orderItem.Barcode);
                node.InnerText = node.InnerText.Replace("@ItemName", orderItem.ItemName);
                node.InnerText = node.InnerText.Replace("@Price", orderItem.Price.ToString("N0"));
                node.InnerText = node.InnerText.Replace("@MRP", orderItem.MRP.ToString("N0"));
                node.InnerText = node.InnerText.Replace("@Discount", orderItem.Discount.ToString("P"));
                node.InnerText = node.InnerText.Replace("@Quantity", orderItem.Quantity.ToString("N0"));
                node.InnerText = node.InnerText.Replace("@Amount", orderItem.LineTotal.ToString("N0"));
            }

            return newRow;
        }
예제 #14
0
        private static XmlElement GetItemRow(XmlElement rowTemplate, OrderDetail orderItem)
        {
            XmlElement newRow = (XmlElement)rowTemplate.CloneNode(true);
            newRow.RemoveAttribute("Name");

            var tableCells = newRow.GetElementsByTagName("TableCell");

            foreach (XmlElement cell in tableCells)
            {
                if (cell.HasAttribute("Name"))
                {
                    switch (cell.Attributes["Name"].Value.ToString())
                    {
                        case "Barcode":
                            cell.FirstChild.InnerText = orderItem.Barcode;
                            break;
                        case "ItemName":
                            cell.FirstChild.InnerText = orderItem.ItemName;
                            break;
                        case "MRP":
                            cell.FirstChild.InnerText = orderItem.MRP.ToString("F2");
                            break;
                        case "Price":
                            cell.FirstChild.InnerText = orderItem.Price.ToString("F2");
                            break;
                        case "Quantity":
                            cell.FirstChild.InnerText = orderItem.Quantity.ToString("N0");
                            break;
                        case "Discount":
                            cell.FirstChild.InnerText = orderItem.Discount.ToString("P");
                            break;
                        case "Amount":
                            cell.FirstChild.InnerText = orderItem.LineTotal.ToString("F2");
                            break;
                    }

                    cell.RemoveAttribute("Name");
                }
            }
            return newRow;
        }
예제 #15
0
파일: XmlDoc.cs 프로젝트: debop/NFramework
        /// <summary>
        /// 부모 노드에 원본 노드의 복사본을 추가한다.
        /// </summary>
        /// <param name="parentNode">부모 노드</param>
        /// <param name="srcNode">복사할 대상 요소</param>
        /// <returns>새로 복사해서 부모노드에 추가한 요소(<see cref="XmlElement"/>)</returns>
        public XmlElement AddElement(XmlNode parentNode, XmlElement srcNode) {
            parentNode.ShouldNotBeNull("parentNode");
            srcNode.ShouldNotBeNull("srcNode");

            if(IsDebugEnabled)
                log.Debug("XmlElement를 추가합니다... parentNode=[{0}], srcNode=[{1}]", parentNode.Name, srcNode.Name);

            var result = srcNode.CloneNode(true) as XmlElement;

            if(result != null) {
                parentNode.AppendChild(result);

                if(IsDebugEnabled)
                    log.Debug("XmlElement를 추가했습니다!!! 추가된 XmlElement=[{0}]", result);
            }

            return result;
        }