public bool SerializeTo(ViBlur blur, System.Xml.XmlWriter writer) { if (this.Type != null) { writer.WriteStartElement(ViConnType.TAG); { writer.WriteAttributeString(blur, "name", this.Name); writer.WriteAttributeString("connectable", this.Connectable.ToString()); writer.WriteAttributeString("fast", this.Fast.ToString()); writer.WriteAttributeString("attributes", this.Attributes.ToString()); writer.WriteAttributeString("defaultValue", this.DefaultValue); //DataType if (this.Type != null) { writer.WriteStartElement("dataType"); { writer.WriteString(this.Type.Name); } writer.WriteEndElement(); } } writer.WriteEndElement(); } return(true); }
public bool SerializeTo(ViBlur blur, XmlWriter writer) { writer.WriteStartElement("contentHeader"); { writer.WriteAttributeString("name", this.Name); writer.WriteAttributeString("version", this.Version); writer.WriteAttributeString("modificationDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); writer.WriteAttributeString("organization", this.Organization); writer.WriteAttributeString("author", this.Author); writer.WriteAttributeString("language", this.Language); writer.WriteStartElement("comment"); { writer.WriteString(this.Comment); } writer.WriteEndElement(); writer.WriteStartElement("coordinateInfo"); { } writer.WriteEndElement(); } writer.WriteEndElement(); return(true); }
public bool DeserializeFrom(ViBlur blur, XmlReader reader) { this.Name = reader.GetAttribute("name"); this.Version = reader.GetAttribute("version"); string modifyTime = reader.GetAttribute("modificationDateTime"); this.Organization = reader.GetAttribute("organization"); this.Author = reader.GetAttribute("author"); this.Language = reader.GetAttribute("language"); if (!string.IsNullOrEmpty(modifyTime)) { try { this.ModificationDateTime = DateTime.Parse(modifyTime); } catch (Exception) { this.ModificationDateTime = DateTime.Now; } } if (reader.IsEmptyElement) { return(true); } while (!reader.EOF) { if (!reader.Read()) { break; } if (reader.NodeType == XmlNodeType.Whitespace) { continue; } if (reader.NodeType == XmlNodeType.Element) { if (string.Compare(reader.Name, "comment", true) == 0) { if (!reader.Read()) { return(false); } this.Comment = reader.Value; } else if (string.Compare(reader.Name, "coordinateInfo", true) == 0) { } } else if (reader.NodeType == XmlNodeType.EndElement) { if (string.Compare(reader.Name, "contentHeader", true) == 0) { return(true); } } } return(false); }
public bool SerializeTo(ViBlur blur, System.Xml.XmlWriter writer) { writer.WriteStartElement(ViFirmBlockType.TAG); { writer.WriteAttributeString(blur, "name", this.Name); writer.WriteAttributeString("category", this.Category); writer.WriteAttributeString("mode", this.ModesDecl); //dataType if (this.Type != null) { writer.WriteStartElement("dataType"); { writer.WriteAttributeString("typeName", this.Type.Name); writer.WriteAttributeString("typeShortName", this.Type.ShortName); } writer.WriteEndElement(); } //InputConnectors writer.WriteStartElement("inputVars"); if (this.InputConnectors != null && this.InputConnectors.Count > 0) { foreach (ViConnType item in this.InputConnectors) { item.SerializeTo(blur, writer); } } writer.WriteEndElement(); //OutputConnectors writer.WriteStartElement("outputVars"); if (this.OutputConnectors != null && this.OutputConnectors.Count > 0) { foreach (ViConnType item in this.OutputConnectors) { item.SerializeTo(blur, writer); } } writer.WriteEndElement(); //InOutputConnectorCount if (this.InOutConnectorCount > 0) { writer.WriteStartElement("inOutVars"); { writer.WriteAttributeString("count", this.InOutConnectorCount.ToString()); } writer.WriteEndElement(); } } writer.WriteEndElement(); return(true); }
/// <summary> /// 对字符串进行去混淆(解码)。 /// </summary> public static string Decode(ViBlur blur, string str) { if (blur == Disable) { return(str); } if (blur == NoBlur) { return(str); } return(blur.Decode(str)); }
/// <summary> /// 从混淆的 Xml Value 值中,解码出混淆之前的字符串的辅助函数。 /// </summary> public static bool ReadValue(this System.Xml.XmlReader This, ViBlur blur, out string value) { if (This.Read()) { value = This.Value.BlurDecode(blur); return(true); } else { value = null; return(false); } }
/// <summary> /// 得到指定种子的混淆用助手用对象。如果指定种子为空字符串,则返回 baseBlur;如果 baseBlur 还为空,则返回 NoBlur。 /// </summary> public static ViBlur GetBlur(ViBlur baseBlur, string key) { if (baseBlur == null) { return(null); } if (string.IsNullOrEmpty(key)) { return(baseBlur ?? NoBlur); } return(new ViBlur(key)); }
public bool DeserializeFrom(ViBlur blur, XmlReader reader) { this.CompanyName = reader.GetAttribute("companyName"); this.CompanyURL = reader.GetAttribute("companyURL"); this.ProductName = reader.GetAttribute("productName"); this.ProductVersion = reader.GetAttribute("productVersion"); this.ProductRelease = reader.GetAttribute("productRelease"); string createTime = reader.GetAttribute("creationDateTime"); this.ContentDescription = reader.GetAttribute("contentDescription"); if (!string.IsNullOrEmpty(createTime)) { try { this.CreationDateTime = DateTime.Parse(createTime); } catch (Exception) { this.CreationDateTime = DateTime.Now; } } // 空标签退出,否则读取子标签 if (reader.IsEmptyElement) { return(true); } while (!reader.EOF) { if (!reader.Read()) { break; } if (reader.NodeType == XmlNodeType.Whitespace) { continue; } if (reader.NodeType == XmlNodeType.Element) { } else if (reader.NodeType == XmlNodeType.EndElement) { if (string.Compare(reader.Name, "fileHeader", true) == 0) { return(true); } } } return(false); }
public bool SerializeTo(ViBlur blur, System.Xml.XmlWriter writer) { writer.WriteStartElement("fileHeader"); { if (this.CompanyName != null) { writer.WriteAttributeString("companyName", this.CompanyName); } if (this.CompanyURL != null) { writer.WriteAttributeString("companyURL", this.CompanyURL); } if (this.ProductName != null) { writer.WriteAttributeString("productName", this.ProductName); } if (this.ProductVersion != null) { writer.WriteAttributeString("productVersion", this.ProductVersion); } if (this.ProductRelease != null) { writer.WriteAttributeString("productRelease", this.ProductRelease); } if (this.CreationDateTime != null) { writer.WriteAttributeString("creationDateTime", this.CreationDateTime.ToString("yyyy-MM-dd HH:mm:ss")); } if (this.ContentDescription != null) { writer.WriteAttributeString("contentDescription", this.ContentDescription); } } writer.WriteEndElement(); return(true); }
public static string BlurDecode(this string This, ViBlur blur) { return(ViBlur.Encode(blur, This)); }
/// <summary> /// 从混淆的 Xml Attribute 值中,解码出混淆之前的字符串的辅助函数。 /// </summary> public static string GetAttribute(this System.Xml.XmlReader This, ViBlur blur, string name) { return(This.GetAttribute(name).BlurDecode(blur)); }
/// <summary> /// 将混淆后的字符串值,写入 Xml Attribute 的辅助函数。 /// </summary> public static void WriteAttributeString(this System.Xml.XmlWriter This, ViBlur blur, string localName, string value) { This.WriteAttributeString(localName, value.BlurEncode(blur)); }
/// <summary> /// 将混淆后的字符串值,写入 Xml Value 的辅助函数。 /// </summary> public static void WriteValue(this System.Xml.XmlWriter This, ViBlur blur, string value) { This.WriteValue(value.BlurEncode(blur)); }
public bool DeserializeFrom(ViBlur blur, System.Xml.XmlReader reader) { this.Name = reader.GetAttribute(blur, "name"); string category = reader.GetAttribute("category"); if (!string.IsNullOrEmpty(category)) { this.Category = category; } string mode = reader.GetAttribute("mode"); if (!string.IsNullOrEmpty(mode)) { this.ModesDecl = mode; } if (reader.IsEmptyElement) { return(true); } int stage = 0x00; // 0x00: 未开始 // 0x01: 开始 INPUT // 0x02: 开始 OUTPUT // 0x03: 开始 IN_OUT while (!reader.EOF) { if (!reader.Read()) { break; } if (reader.NodeType == System.Xml.XmlNodeType.Whitespace) { continue; } if (reader.NodeType == System.Xml.XmlNodeType.Element) { if (string.Compare(reader.Name, "dataType", true) == 0) { string typeName = reader.GetAttribute("typeName"); string typeShortName = reader.GetAttribute("typeShortName"); ViDataType dataType = new ViDataType(typeName, typeShortName); this.Type = dataType; } else if (string.Compare(reader.Name, "inputVars", true) == 0) { this.InputConnectors.Clear(); stage = 0x01; } else if (string.Compare(reader.Name, "outputVars", true) == 0) { this.OutputConnectors.Clear(); stage = 0x02; } else if (string.Compare(reader.Name, "inOutVars", true) == 0) { string count = reader.GetAttribute("count"); if (!string.IsNullOrEmpty(count)) { this.InOutConnectorCount = int.Parse(count); } } else if (string.Compare(reader.Name, ViConnType.TAG, true) == 0) { ViConnType connType = new ViConnType(null, null); if (!connType.DeserializeFrom(blur, reader)) { return(false); } if (stage == 0x01) { this.InputConnectors.Add(connType); } else if (stage == 0x02) { this.OutputConnectors.Add(connType); } } } else if (reader.NodeType == System.Xml.XmlNodeType.EndElement) { if (string.Compare(reader.Name, ViFirmBlockType.TAG, true) == 0) { return(true); } } } return(false); }
public bool DeserializeFrom(ViBlur blur, System.Xml.XmlReader reader) { string name = reader.GetAttribute(blur, "name"); string connectable = reader.GetAttribute("connectable"); string fast = reader.GetAttribute("fast"); string attributes = reader.GetAttribute("attributes"); string defaultValue = reader.GetAttribute("defaultValue"); string connected = reader.GetAttribute("connected"); //Name if (!string.IsNullOrEmpty(name)) { this.Name = name; } //Connectable if (!string.IsNullOrEmpty(connectable)) { this.Connectable = bool.Parse(connectable); } //Fast if (!string.IsNullOrEmpty(fast)) { this.Fast = bool.Parse(fast); } //Attributes if (!string.IsNullOrEmpty(attributes)) { if (string.Compare(attributes, ViConnAttributes.F_EDGE.ToString(), true) == 0) { this.Attributes = ViConnAttributes.F_EDGE; } else if (string.Compare(attributes, ViConnAttributes.R_EDGE.ToString(), true) == 0) { this.Attributes = ViConnAttributes.R_EDGE; } else { this.Attributes = ViConnAttributes.None; } } if (!string.IsNullOrEmpty(defaultValue)) { this.DefaultValue = defaultValue; } while (!reader.EOF) { if (!reader.Read()) { break; } if (reader.NodeType == System.Xml.XmlNodeType.Whitespace) { continue; } if (reader.NodeType == System.Xml.XmlNodeType.Element) { if (string.Compare(reader.Name, "dataType", true) == 0) { string typeName = reader.GetAttribute("typeName"); //读取Value if (!reader.IsEmptyElement && string.IsNullOrEmpty(typeName)) { if (!reader.Read()) { break; } typeName = reader.Value; } ViDataType dataType = ViDataType.GetDataType(typeName); this.Type = dataType; } } else if (reader.NodeType == System.Xml.XmlNodeType.EndElement) { if (string.Compare(reader.Name, ViConnType.TAG, true) == 0) { return(true); } } } return(false); }