コード例 #1
0
 private void LoadTag(ListTag tags)
 {
     foreach (Tag tag in tags.Tags)
     {
         if (tag is EndTag)
         {
             this.AddEndTag();
         }
         else if (tag is ByteTag)
         {
             ByteTag t = (ByteTag)tag;
             this.AddTag(t.Data, t.TagType);
         }
         else if (tag is ShortTag)
         {
             ShortTag t = (ShortTag)tag;
             this.AddTag(t.Data, t.TagType);
         }
         else if (tag is IntTag)
         {
             IntTag t = (IntTag)tag;
             this.AddTag(t.Data, t.TagType);
         }
         else if (tag is LongTag)
         {
             LongTag t = (LongTag)tag;
             this.AddTag(t.Data, t.TagType);
         }
         else if (tag is FloatTag)
         {
             FloatTag t = (FloatTag)tag;
             this.AddTag(t.Data, t.TagType);
         }
         else if (tag is DoubleTag)
         {
             DoubleTag t = (DoubleTag)tag;
             this.AddTag(t.Data, t.TagType);
         }
         //TODO: ByteArrayTag...
         else if (tag is StringTag)
         {
             StringTag t = (StringTag)tag;
             this.AddTag(t.Data, t.TagType);
         }
         else if (tag is ListTag)
         {
             ListTag t = (ListTag)tag;
             this.AddListInListTagHeader(t);
             this.LoadTag(t);
         }
         else if (tag is CompoundTag)
         {
             CompoundTag t = (CompoundTag)tag;
             this.LoadTag(t, false, true);
         }
         //TODO: IntArrayTag...
         //TDDO: LongArrayTag...
     }
 }
コード例 #2
0
        private Tag CreateTag(string name, TagType type)
        {
            Tag newTag;

            switch (type)
            {
            case TagType.Double:
                newTag = new DoubleTag(name, this.aeonDb);
                break;

            case TagType.Float:
                newTag = new FloatTag(name, this.aeonDb);
                break;

            case TagType.Boolean:
                newTag = new BooleanTag(name, this.aeonDb);
                break;

            case TagType.Int16:
                newTag = new Int16Tag(name, this.aeonDb);
                break;

            case TagType.Int32:
                newTag = new Int32Tag(name, this.aeonDb);
                break;

            case TagType.Int64:
                newTag = new Int64Tag(name, this.aeonDb);
                break;

            default:
                throw new AeonException("Unrecognised tag type.");
            }

            return(newTag);
        }
コード例 #3
0
ファイル: FindBackControl.cs プロジェクト: xubinvc/HPlus
        /// <summary>
        /// 查找带回
        /// </summary>
        /// <param name="options"> new { Text="",ID="",FindClick="",RemoveClick="" } </param>
        /// <param name="Readonly">【是否设置 文本框为 非只读】</param>
        /// <param name="KO">是否采用 KO 双向绑定值</param>
        /// <returns></returns>
        public MvcHtmlString Html(object Options, bool Readonly = true, bool KO = true)
        {
            var di = new Dictionary <string, object>();

            Type ty = Options.GetType();

            var fields = ty.GetProperties().ToList();

            foreach (var item in fields)
            {
                di.Add(item.Name, item.GetValue(Options));
            }

            if (!di.ContainsKey("Text"))
            {
                throw new Exception("查找带回控件缺少 Text 属性");
            }
            if (!di.ContainsKey("ID"))
            {
                throw new Exception("查找带回控件缺少 ID 属性");
            }
            if (!di.ContainsKey("FindClick"))
            {
                throw new Exception("查找带回控件缺少 FindClick 属性");
            }
            if (!di.ContainsKey("RemoveClick"))
            {
                throw new Exception("查找带回控件缺少 RemoveClick 属性");
            }
            if (!di.ContainsKey("Placeholder"))
            {
                throw new Exception("查找带回控件缺少 Placeholder 属性");
            }

            /*     var Html = "<div class=\"input-group\">" +
             *                   "<input type=\"text\" class=\"form-control\">" +
             *                   "<span class=\"input-group-btn\">" +
             *                       "<button type=\"button\" class=\"btn btn-outline btn-default\">" +
             *                           "<i class=\"fa fa-search\"></i>" +
             *                       "</button>" +
             *                       "<button type=\"button\" class=\"btn btn-outline btn-default\">" +
             *                           "<i class=\"fa fa-close\"></i>" +
             *                       "</button>" +
             *                   "</span>" +
             *               "</div>";
             */

            var input_attr = new Dictionary <string, string>()
            {
                { "type", "text" }, { "class", "form-control" }, { "name", di["Text"].ToString() }, { "data-bind", "value:" + di["Text"].ToString() }
            };

            //判断是否有 placeholder 属性
            if (di.ContainsKey("Placeholder"))
            {
                input_attr.Add("placeholder", di["Placeholder"].ToString());
            }

            //判断是否要设置 文本框的 readonly 属性
            if (Readonly)
            {
                input_attr.Add("readonly", "readonly");
            }

            //Text 属性文本框
            var input = new NoDoubleTag("input", input_attr).Create().ToHtmlString();
            //ID 属性文本框
            var input_attr_id = new Dictionary <string, string>()
            {
                { "type", "text" }, { "class", "form-control" }, { "style", "display:none" }, { "name", di["ID"].ToString() }, { "data-bind", "value:" + di["ID"].ToString() }
            };
            var input_id = new NoDoubleTag("input", input_attr_id).Create().ToHtmlString();

            //判断绑定值是否使用 KO 插件
            if (!KO)
            {
                input_attr.Remove("data-bind");
                input_attr.Add("value", "");
                input_attr_id.Remove("data-bind");
                input_attr_id.Add("value", "");
            }

            //打开窗口按钮
            var find = new DoubleTag("button", new Dictionary <string, string>()
            {
                { "type", "button" }, { "class", "btn btn-outline btn-default" }, { "onclick", di["FindClick"].ToString() }
            }).Append(new DoubleTag("i", new Dictionary <string, string>()
            {
                { "class", "fa fa-search" }
            }).Create().ToHtmlString()).Create().ToHtmlString();
            //清空信息按钮
            var close = new DoubleTag("button", new Dictionary <string, string>()
            {
                { "type", "button" }, { "class", "btn btn-outline btn-default" }, { "onclick", di["RemoveClick"].ToString() }
            }).Append(new DoubleTag("i", new Dictionary <string, string>()
            {
                { "class", "fa fa-close" }
            }).Create().ToHtmlString()).Create().ToHtmlString();
            //按钮组div
            var span = new DoubleTag("span", new Dictionary <string, string>()
            {
                { "class", "input-group-btn" }
            }).Append(find + close).Create().ToHtmlString();

            //创建 查找带回Html
            var CreateHtml = new DoubleTag("div", new Dictionary <string, string>()
            {
                { "class", "input-group" },
            }).Append(input + input_id + span).Create();

            return(CreateHtml);
        }
コード例 #4
0
ファイル: NbtFileFixture.cs プロジェクト: andywhite37/NCraft
        private CompoundTag CreateBigTestNbtTag()
        {
            var tag = new CompoundTag()
            {
                Name = "Level",
            };

            var longTest = new LongTag()
            {
                Name = "longTest",
                Value = 9223372036854775807L,
            };
            tag.Items.Add(longTest);

            var shortTest = new ShortTag()
            {
                Name = "shortTest",
                Value = 32767,
            };
            tag.Items.Add(shortTest);

            var stringTest = new StringTag()
            {
                Name = "stringTest",
                Value = @"HELLO WORLD THIS IS A TEST STRING ÅÄÖ!",
            };
            tag.Items.Add(stringTest);

            var floatTest = new FloatTag()
            {
                Name = "floatTest",
                Value = 0.49823147F,
            };
            tag.Items.Add(floatTest);

            var intTest = new IntTag()
            {
                Name = "intTest",
                Value = 2147483647,
            };
            tag.Items.Add(intTest);

            var nestedCompoundTest = new CompoundTag()
            {
                Name = "nested compound test",
                Items = new List<Tag>()
                {
                    new CompoundTag()
                    {
                        Name = "ham",
                        Items = new List<Tag>()
                        {
                            new StringTag()
                            {
                                Name = "name",
                                Value = "Hampus",
                            },
                            new FloatTag()
                            {
                                Name = "value",
                                Value = 0.75F,
                            }
                        },
                    },
                    new CompoundTag()
                    {
                        Name = "egg",
                        Items = new List<Tag>()
                        {
                            new StringTag()
                            {
                                Name = "name",
                                Value = "Eggbert",
                            },
                            new FloatTag()
                            {
                                Name = "value",
                                Value = 0.5F,
                            }
                        },
                    }
                },
            };
            tag.Items.Add(nestedCompoundTest);

            var listTestLong = new ListTag()
            {
                Name = "listTest (long)",
                ItemType = TagType.Long,
                Length = 5,
                Items = new Tag[]
                {
                    new LongTag()
                    {
                        Value = 11,
                    },
                    new LongTag()
                    {
                        Value = 12,
                    },
                    new LongTag()
                    {
                        Value = 13,
                    },
                    new LongTag()
                    {
                        Value = 14,
                    },
                    new LongTag()
                    {
                        Value = 15,
                    },
                },
            };
            tag.Items.Add(listTestLong);

            var listTestCompound = new ListTag()
            {
                Name = "listTest (compound)",
                ItemType = TagType.Compound,
                Length = 2,
                Items = new Tag[]
                {
                    new CompoundTag()
                    {
                        Items = new List<Tag>()
                        {
                            new StringTag()
                            {
                                Name = "name",
                                Value = "Compound tag #0",
                            },
                            new LongTag()
                            {
                                Name = "created-on",
                                Value = 1264099775885L,
                            },
                        },
                    },
                    new CompoundTag()
                    {
                        Items = new List<Tag>()
                        {
                            new StringTag()
                            {
                                Name = "name",
                                Value = "Compound tag #1",
                            },
                            new LongTag()
                            {
                                Name = "created-on",
                                Value = 1264099775885L,
                            },
                        },
                    },
                },
            };
            tag.Items.Add(listTestCompound);

            var byteTest = new ByteTag()
            {
                Name = "byteTest",
                Value = 127,
            };
            tag.Items.Add(byteTest);

            var byteArrayTest = new ByteArrayTag()
            {
                Name = "byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))",
                Length = 1000,
                Items = new byte[1000],
            };
            for (int i = 0; i < 1000; ++i)
            {
                byteArrayTest.Items[i] = (byte)((i * i * 255 + i * 7) % 100);
            }
            tag.Items.Add(byteArrayTest);

            var doubleTest = new DoubleTag()
            {
                Name = "doubleTest",
                Value = 0.4931287132182315,
            };
            tag.Items.Add(doubleTest);

            return tag;
        }
コード例 #5
0
        private void LoadTag(CompoundTag tags, bool isRoot = false, bool isList = false)
        {
            if (!isRoot)
            {
                if (isList)
                {
                    this.AddListInCompoundTagHeader(tags);
                }
                else
                {
                    this.AddCompoundTagHeader(tags);
                }
            }

            foreach (KeyValuePair <string, Tag> tagKV in tags.Tags)
            {
                Tag tag = tagKV.Value;
                if (tag is EndTag)
                {
                    this.AddEndTag();
                }
                else if (tag is ByteTag)
                {
                    ByteTag t = (ByteTag)tag;
                    this.AddTag(t.Name, t.Data, t.TagType);
                }
                else if (tag is ShortTag)
                {
                    ShortTag t = (ShortTag)tag;
                    this.AddTag(t.Name, t.Data, t.TagType);
                }
                else if (tag is IntTag)
                {
                    IntTag t = (IntTag)tag;
                    this.AddTag(t.Name, t.Data, t.TagType);
                }
                else if (tag is LongTag)
                {
                    LongTag t = (LongTag)tag;
                    this.AddTag(t.Name, t.Data, t.TagType);
                }
                else if (tag is FloatTag)
                {
                    FloatTag t = (FloatTag)tag;
                    this.AddTag(t.Name, t.Data, t.TagType);
                }
                else if (tag is DoubleTag)
                {
                    DoubleTag t = (DoubleTag)tag;
                    this.AddTag(t.Name, t.Data, t.TagType);
                }
                //TODO: ByteArrayTag...
                else if (tag is StringTag)
                {
                    StringTag t = (StringTag)tag;
                    this.AddTag(t.Name, t.Data, t.TagType);
                }
                else if (tag is ListTag)
                {
                    ListTag t = (ListTag)tag;
                    this.AddListTagHeader(t);
                    this.LoadTag(t);
                }
                else if (tag is CompoundTag)
                {
                    CompoundTag t = (CompoundTag)tag;
                    this.LoadTag(t);
                }
                //TODO: IntArrayTag...
                //TDDO: LongArrayTag...
            }

            if (!isRoot)
            {
                this.AddEndTag();
            }
        }
コード例 #6
0
        public void DoubleTagTest()
        {
            var tag = new DoubleTag();

            Assert.AreEqual(TagType.Double, tag.Type);
        }