static public TagDataNode CreateFromTag(TagNode tag) { if (tag == null || !_tagRegistry.ContainsKey(tag.GetTagType())) { return(null); } return(Activator.CreateInstance(_tagRegistry[tag.GetTagType()], tag) as TagDataNode); }
public static string Serialize(TagNode tag, int level) { StringBuilder str = new StringBuilder(); if (tag.GetTagType() == TagType.TAG_COMPOUND) { SerializeCompound(tag as TagNodeCompound, str, level); } else if (tag.GetTagType() == TagType.TAG_LIST) { SerializeList(tag as TagNodeList, str, level); } else { SerializeScaler(tag, str); } return str.ToString(); }
public static string GetTagNodeText(TagNode tag) { if (tag == null) return null; switch (tag.GetTagType()) { case TagType.TAG_BYTE: case TagType.TAG_SHORT: case TagType.TAG_INT: case TagType.TAG_LONG: case TagType.TAG_FLOAT: case TagType.TAG_DOUBLE: case TagType.TAG_STRING: return tag.ToString(); case TagType.TAG_BYTE_ARRAY: return tag.ToTagByteArray().Length + " bytes"; case TagType.TAG_LIST: return tag.ToTagList().Count + " entries"; case TagType.TAG_COMPOUND: return tag.ToTagCompound().Count + " entries"; } return null; }
public bool AppendTag (TagNode tag) { if (_tag.ValueType != tag.GetTagType()) return false; _tag.Add(tag); SetModified(); return true; }
public bool AppendTag(TagNode tag) { if (_tag.ValueType != tag.GetTagType()) { return(false); } _tag.Add(tag); SetModified(); return(true); }
public bool InsertTag (TagNode tag, int index) { if (index < 0 || index > _tag.Count) return false; if (_tag.ValueType != tag.GetTagType()) return false; _tag.Insert(index, tag); SetModified(); return true; }
public EditValue(TagNode tag) { InitializeComponent(); _tag = tag; if (tag == null) { DialogResult = DialogResult.Abort; Close(); return; } switch(_tag.GetTagType()) { case TagType.TAG_DOUBLE: textBox1.Minimum = decimal.MinValue; textBox1.Maximum = decimal.MaxValue; hasDecimal = true; textBox1.Value = (decimal)_tag.ToTagDouble().Data; break; case TagType.TAG_FLOAT: textBox1.Minimum = decimal.MinValue; textBox1.Maximum = decimal.MaxValue; hasDecimal = true; textBox1.Value = (decimal)_tag.ToTagFloat().Data; break; case TagType.TAG_SHORT: textBox1.Minimum = Int16.MinValue; textBox1.Maximum = Int16.MaxValue; hasDecimal = false; textBox1.Value = (decimal)_tag.ToTagShort().Data; break; case TagType.TAG_INT: textBox1.Minimum = Int32.MinValue; textBox1.Maximum = Int32.MaxValue; hasDecimal = false; textBox1.Value = (decimal)_tag.ToTagInt().Data; break; case TagType.TAG_LONG: textBox1.Minimum = Int64.MinValue; textBox1.Maximum = Int64.MaxValue; hasDecimal = false; textBox1.Value = (decimal)_tag.ToTagLong().Data; break; case TagType.TAG_BYTE: textBox1.Minimum = byte.MinValue; textBox1.Maximum = byte.MaxValue; hasDecimal = false; textBox1.Value = (decimal)_tag.ToTagByte().Data; break; } }
private bool ValidateValueInput() { try { switch (_tag.GetTagType()) { case TagType.TAG_BYTE: _tag.ToTagByte().Data = unchecked ((byte)sbyte.Parse(textBox1.Text)); break; case TagType.TAG_SHORT: _tag.ToTagShort().Data = short.Parse(textBox1.Text); break; case TagType.TAG_INT: _tag.ToTagInt().Data = int.Parse(textBox1.Text); break; case TagType.TAG_LONG: _tag.ToTagLong().Data = long.Parse(textBox1.Text); break; case TagType.TAG_FLOAT: _tag.ToTagFloat().Data = float.Parse(textBox1.Text); break; case TagType.TAG_DOUBLE: _tag.ToTagDouble().Data = double.Parse(textBox1.Text); break; case TagType.TAG_STRING: _tag.ToTagString().Data = textBox1.Text; break; } } catch (FormatException) { MessageBox.Show("The value is formatted incorrectly for the given type."); return(false); } catch (OverflowException) { MessageBox.Show("The value is outside the acceptable range for the given type."); return(false); } catch { return(false); } return(true); }
private bool ValidateValueInput() { try { switch (_tag.GetTagType()) { case TagType.TAG_BYTE: _tag.ToTagByte().Data = unchecked ((byte)sbyte.Parse(textBox1.Text)); break; case TagType.TAG_SHORT: _tag.ToTagShort().Data = short.Parse(textBox1.Text); break; case TagType.TAG_INT: _tag.ToTagInt().Data = int.Parse(textBox1.Text); break; case TagType.TAG_LONG: _tag.ToTagLong().Data = long.Parse(textBox1.Text); break; case TagType.TAG_FLOAT: _tag.ToTagFloat().Data = float.Parse(textBox1.Text); break; case TagType.TAG_DOUBLE: _tag.ToTagDouble().Data = double.Parse(textBox1.Text); break; case TagType.TAG_STRING: _tag.ToTagString().Data = textBox1.Text; break; } } catch (FormatException) { MessageBox.Show("指定された値の型が合っていません。。"); return(false); } catch (OverflowException) { MessageBox.Show("指定された値が大きすぎです。オーバーフローします。", "エラー"); return(false); } catch { return(false); } return(true); }
private bool ValidateValueInput() { try { switch (_tag.GetTagType()) { case TagType.TAG_BYTE: _tag.ToTagByte().Data = unchecked ((byte)sbyte.Parse(_valueField.StringValue)); break; case TagType.TAG_SHORT: _tag.ToTagShort().Data = short.Parse(_valueField.StringValue); break; case TagType.TAG_INT: _tag.ToTagInt().Data = int.Parse(_valueField.StringValue); break; case TagType.TAG_LONG: _tag.ToTagLong().Data = long.Parse(_valueField.StringValue); break; case TagType.TAG_FLOAT: _tag.ToTagFloat().Data = float.Parse(_valueField.StringValue); break; case TagType.TAG_DOUBLE: _tag.ToTagDouble().Data = double.Parse(_valueField.StringValue); break; case TagType.TAG_STRING: _tag.ToTagString().Data = _valueField.StringValue; break; } } catch (FormatException) { NSAlert.WithMessage("Invalid Format", "OK", null, null, "The value is formatted incorrectly for the given type.").RunModal(); return(false); } catch (OverflowException) { NSAlert.WithMessage("Invalid Range", "OK", null, null, "The value is outside the acceptable range for the given type.").RunModal(); return(false); } catch { return(false); } return(true); }
public bool AppendTag(TagNode tag) { if (tag == null || !CanCreateTag(tag.GetTagType())) return false; _container.InsertTag(tag, _container.TagCount); IsDataModified = true; if (IsExpanded) { TagDataNode node = TagDataNode.CreateFromTag(tag); if (node != null) Nodes.Add(node); } return true; }
public bool InsertTag(TagNode tag, int index) { if (index < 0 || index > _tag.Count) { return(false); } if (_tag.ValueType != tag.GetTagType()) { return(false); } _tag.Insert(index, tag); SetModified(); return(true); }
public bool AppendTag(TagNode tag) { if (tag == null || !CanCreateTag(tag.GetTagType())) { return(false); } _container.InsertTag(tag, _container.TagCount); IsDataModified = true; if (IsExpanded) { TagDataNode node = TagDataNode.CreateFromTag(tag); if (node != null) { Nodes.Add(node); } } return(true); }
private static void SerializeScaler(TagNode tag, StringBuilder str) { switch (tag.GetTagType()) { case TagType.TAG_STRING: str.Append("\"" + tag.ToTagString().Data + "\""); break; case TagType.TAG_BYTE: str.Append(tag.ToTagByte().Data); break; case TagType.TAG_SHORT: str.Append(tag.ToTagShort().Data); break; case TagType.TAG_INT: str.Append(tag.ToTagInt().Data); break; case TagType.TAG_LONG: str.Append(tag.ToTagLong().Data); break; case TagType.TAG_FLOAT: str.Append(tag.ToTagFloat().Data); break; case TagType.TAG_DOUBLE: str.Append(tag.ToTagDouble().Data); break; case TagType.TAG_BYTE_ARRAY: str.Append(Convert.ToBase64String(tag.ToTagByteArray().Data)); /*if (tag.ToTagByteArray().Length == (16 * 16 * 128 / 2)) { str.Append(Base16.Encode(tag.ToTagByteArray().Data, 1)); } else { str.Append(Base16.Encode(tag.ToTagByteArray().Data, 2)); }*/ break; } }
static TreeNode NodeFromTag(TagNode tag, int descriptionIndex, string name) { var text = SubstrateHelper.GetNodeText(name, tag); var node = ServerNode.InitializeTreeNode(_tagIconIndex[tag.GetTagType()], text, tag); if (tag.GetTagType() == TagType.TAG_LIST) { PopulateNodeFromTag(node, descriptionIndex, tag.ToTagList()); } else if (tag.GetTagType() == TagType.TAG_COMPOUND) { PopulateNodeFromTag(node, descriptionIndex, tag.ToTagCompound()); } return node; }
public override bool Matches(TagCompoundDataNode container, List <TagDataNode> matchedNodes) { TagDataNode childNode = GetChild(container, Name); TagNode tag = container.NamedTagContainer.GetTagNode(Name); if (tag == null) { return(false); } try { switch (tag.GetTagType()) { case TagType.TAG_BYTE: case TagType.TAG_INT: case TagType.TAG_LONG: case TagType.TAG_SHORT: switch (Operator) { case WildcardOperator.Equals: if (long.Parse(Value) != tag.ToTagLong()) { return(false); } break; case WildcardOperator.NotEquals: if (long.Parse(Value) == tag.ToTagLong()) { return(false); } break; } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); case TagType.TAG_FLOAT: case TagType.TAG_DOUBLE: switch (Operator) { case WildcardOperator.Equals: if (double.Parse(Value) != tag.ToTagDouble()) { return(false); } break; case WildcardOperator.NotEquals: if (double.Parse(Value) == tag.ToTagDouble()) { return(false); } break; } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); case TagType.TAG_STRING: switch (Operator) { case WildcardOperator.Equals: if (Value != tag.ToTagString().Data) { return(false); } break; case WildcardOperator.NotEquals: if (Value == tag.ToTagString().Data) { return(false); } break; } if (!matchedNodes.Contains(childNode)) { matchedNodes.Add(childNode); } return(true); } } catch { } return(false); }
static public TagDataNode CreateFromTag (TagNode tag) { if (tag == null || !_tagRegistry.ContainsKey(tag.GetTagType())) return null; return Activator.CreateInstance(_tagRegistry[tag.GetTagType()], tag) as TagDataNode; }