예제 #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="t"></param>
 public void AddChild(T t)
 {
     if (Child == null)
         Child = t;
     else
         Child.Add(t);
 }
예제 #2
0
 protected bool AddNode(TreeNode rNode)
 {
     try
     {
         if (Child == null)
         {
             Child = new List <TreeNode>();
         }
         if (Child.Count == 0)
         {
             Child.Add(rNode);
         }
         else
         {
             for (int i = 0; i < Child.Count; i++)
             {
                 if (Child[i].Priority < rNode.Priority)
                 {
                     Child.Insert(i, rNode);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Debug.LogError($"增加节点失败:{e}");
     }
     return(true);
 }
예제 #3
0
        public ActionResult Create(FormCollection collection, Child child)
        {
            try
            {
                if (string.IsNullOrEmpty(child.FirstName))
                {
                    // do nothing
                }
                else
                {
                    var response = child.Add(SessionInfo.UserIDLogged);
                    if (response.ReturnCode < 0000)
                    {
                        ModelState.AddModelError("Error", response.Message);
                        return(View());
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #4
0
        protected void AddState<T>(State parent) where T : State, new()
        {
            if (Child.Find(x => x.GetType() == typeof(T)) != null) throw new Exception("State arledy exists");
            T state = new T();
            state.Parent = parent;

            Child.Add(state);
        }
        public void AddChild(Stop stop, Tree tree)
        {
            Node node = new Node();

            node.Parent = this;
            node.value  = stop;
            Child.Add(node);
            tree.nodeList.Add(node);
        }
예제 #6
0
        /// <summary>
        /// Добавлення нового дочірнього елемента в список
        /// </summary>
        /// <param name="child">Дочірній елемент типу завдання</param>
        public void AddChild(MyTask child)
        {
            var newTask = new TaskTree()
            {
                Value  = child,
                Parent = this
            };

            Child.Add(newTask);
        }
예제 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="t"></param>
 public void AddChild(T t)
 {
     if (Child == null)
     {
         Child = t;
     }
     else
     {
         Child.Add(t);
     }
 }
        public GraphRoot()
        {
            var id = Interlocked.Increment(ref _id);

            Name = this.GetType().Name + id;

            for (int i = 0; i < 2; i++)
            {
                Child.Add(new Child1());
            }
        }
예제 #9
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="name"></param>
        /// <param name="descriptin"></param>
        /// <returns></returns>
        public virtual Role AddChild(string name, string descriptin)
        {
            Role role = new Role(this, name, descriptin);

            if (Child == null)
            {
                Child = new List <Role>();
                Child.Add(role);
            }
            else
            {
                Child.Add(role);
            }
            return(role);
        }
예제 #10
0
 public void CreateChild(int id, int x, int y, int disToSecond, int maxCount)
 {
     if (CurrentLivingNpcNum < maxCount)
     {
         if (maxCount - CurrentLivingNpcNum >= 2)
         {
             Child.Add(((PVEGame)Game).CreateNpc(id, x + disToSecond, y, 1));
             Child.Add(((PVEGame)Game).CreateNpc(id, x, y, 1));
         }
         else if (maxCount - CurrentLivingNpcNum == 1)
         {
             Child.Add(((PVEGame)Game).CreateNpc(id, x, y, 1));
         }
     }
 }
예제 #11
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="name"></param>
        /// <param name="descriptin"></param>
        /// <returns></returns>
        public virtual Rights AddChild(string name, string url, string descriptin, bool isshow)
        {
            Rights rights = new Rights(this, name, url, descriptin, isshow, this.Level + 1);

            if (Child == null)
            {
                Child = new List <Rights>();
                Child.Add(rights);
            }
            else
            {
                Child.Add(rights);
            }

            return(rights);
        }
예제 #12
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="name"></param>
        /// <param name="descriptin"></param>
        /// <returns></returns>
        public virtual Organization AddChild(string name, string descriptin)
        {
            Organization organization = new Organization(this, name, descriptin, this.Level + 1);

            if (Child == null)
            {
                Child = new List <Organization>();
                Child.Add(organization);
            }
            else
            {
                Child.Add(organization);
            }

            return(organization);
        }
예제 #13
0
        /// <summary>
        /// Добавлення нового дочірнього елемента в список
        /// </summary>
        /// <param name="child">Дочірній елемент типу завдання</param>
        public void AddChild(MyTask child)
        {
            var newTask = new TaskTree()
            {
                Value   = child,
                _parent = this
            };

            Child.Add(newTask);
            ///
            //var items = new MyTask();


            //using (var client = new HttpClient())
            //{
            //    var response = client.PostAsJsonAsync("http://localhost:53181/api/MyTasks", child).Result;
            //    var resp = response.StatusCode.ToString();
            //}
        }
예제 #14
0
 public void SetChild(Person child)
 {
     if (child != this)
     {
         Child.Add(child);
     }
     if (maritalUnion != null)
     {
         maritalUnion.Child.Add(child);
     }
     child.childID = Child.Count();
     if (Sex == Sex.M)
     {
         child.SetParents(maritalUnion, this);
     }
     else
     {
         child.SetParents(this, maritalUnion);
     }
 }
예제 #15
0
 public virtual INode <T, Q> AddChild(T t)
 {
     if (Child.ContainsKey(t.Text))
     {
         return(null);
     }
     else if (t is INode <T, Q> )
     {
         Child.Add(t.Text, (t as INode <T, Q>)); (t as INode <T, Q>).Parent = this; return(t as INode <T, Q>);
     }
     else
     {
         INode <T, Q> r = Create(t); if (r != null)
         {
             Child.Add(t.Text, r); r.Parent = this; return(r);
         }
         else
         {
             return(null);
         }
     }
 }
예제 #16
0
 public override bool AddNode(TreeNode rNode)
 {
     try
     {
         rNode.Parent = this;
         if (Child == null)
         {
             Child = new List <TreeNode>();
         }
         if (Child.Count == 0)
         {
             Child.Add(rNode);
         }
         else
         {
             bool isAdd = false;
             for (int i = 0; i < Child.Count; i++)
             {
                 if (Child[i].Priority < rNode.Priority)
                 {
                     isAdd = true;
                     Debug.Log("index:" + i);
                     Child.Insert(i, rNode);
                     break;
                 }
             }
             if (!isAdd)
             {
                 Child.Add(rNode);
             }
         }
     }
     catch (Exception e)
     {
         Debug.LogError($"增加节点失败:{e}");
     }
     return(true);
 }
예제 #17
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="name"></param>
        /// <param name="descriptin"></param>
        /// <returns></returns>
        public virtual Rights AddChild(string name, string url, string description, bool isshow, string icon)
        {
            Rights rights = new Rights(this, name, url, description, isshow, this.Level + 1, icon);

            if (Child == null)
            {
                Child = new List <Rights>();
                Child.Add(rights);
            }
            else
            {
                Child.Add(rights);
            }
            if (this.Child.Count > 0)
            {
                this.IsLeaf = false;
            }
            else
            {
                this.IsLeaf = true;
            }
            return(rights);
        }
예제 #18
0
 protected void AddState<T>() where T : State, new()
 {
     if (Child.Find(x => x.GetType() == typeof(T)) != null) throw new Exception("State arledy exists");
     Child.Add(new T());
 }
예제 #19
0
 public void AddChild(ChildMenu menu)
 {
     this.HasChild = true;
     Child.Add(menu);
 }
예제 #20
0
        protected void btnOk_OnClick(object sender, EventArgs e)
        {
            var muidc = Request.Cookies.Get("userId");

            if (string.IsNullOrEmpty(muidc?.Value))
            {
                Response.Redirect("cause.aspx?need_login=1");
                return;
            }

            string mname       = txtName.Text;
            string maddress    = txtAddress.Text;
            string mshortStory = txtShortStory.Text;

            DateTime mbrith;
            DateTime mtill = DateTime.MaxValue;

            if (!DateTime.TryParse(txtBirthDate.Text.Split(' ')[0], Constants.DefaultCulture, DateTimeStyles.AssumeUniversal, out mbrith))
            {
                Utils.AlertJs(this, "Incorect birthdate format", "Validate");
                return;
            }

            if (!string.IsNullOrEmpty(txtUntil.Text) && !DateTime.TryParse(txtUntil.Text.Split(' ')[0], Constants.DefaultCulture, DateTimeStyles.AssumeUniversal, out mtill))
            {
                Utils.AlertJs(this, "Incorect until format", "Validate");
                return;
            }

            decimal mneed;

            if (!decimal.TryParse(txtNeed.Text, out mneed))
            {
                Utils.AlertJs(this, "Incorect amount format", "Validate");
                return;
            }

            if (string.IsNullOrEmpty(mname))
            {
                Utils.AlertJs(this, "Name cannot be empty", "Validate");
                return;
            }

            if (string.IsNullOrEmpty(maddress))
            {
                Utils.AlertJs(this, "Address cannot be empty", "Validate");
                return;
            }

            if (string.IsNullOrEmpty(mshortStory))
            {
                Utils.AlertJs(this, "Short story cannot be empty", "Validate");
                return;
            }


            Child.Add(new Child
            {
                FullName   = mname,
                Address    = maddress,
                Amount     = mneed,
                BirthDate  = mbrith == DateTime.MinValue ? (DateTime?)null : mbrith,
                To         = mtill,
                ShortStory = mshortStory,
                Story      = txtMessage.Value,
                UserId     = Convert.ToInt32(muidc.Value)
            });

            Response.Redirect("~/home.aspx?add_cause=1");
        }
예제 #21
0
파일: EnumNode.cs 프로젝트: ycllz/ProtoF
 public void AddValue(EnumValueNode n)
 {
     Child.Add(n);
     Value.Add(n);
 }
예제 #22
0
파일: FileNode.cs 프로젝트: ycllz/ProtoF
 public void AddEnum(EnumNode n)
 {
     Child.Add(n);
     Enum.Add(n);
 }
예제 #23
0
파일: FileNode.cs 프로젝트: ycllz/ProtoF
 public void AddMessage(MessageNode n)
 {
     Child.Add(n);
     Message.Add(n);
 }
예제 #24
0
        public override void Read(MBinaryIO io)
        {
            if (io.Version == 0)
            {
                if (IsRoot)
                {
                    EndScopeOffset = io.Stream.ReadInt32();
                    TypeName       = io.Stream.Read7BitString();
                }

                while (io.Stream.Position + 2 < EndScopeOffset)
                {
                    string fieldName = io.Stream.Read7BitString();

                    int endOffset = io.Stream.ReadInt32();

                    mTypeBase field;
                    byte[]    typeName = io.Stream.Read7BitStringBytes();
                    if (typeName.Length == 1)
                    {
                        FieldTypeOld old = (FieldTypeOld)typeName[0];
                        field = old switch
                        {
                            FieldTypeOld.String => new mString(),
                            FieldTypeOld.Array => new mArray(),
                            FieldTypeOld.Bool => new mBool(),
                            FieldTypeOld.Byte => new mUByte(),
                            FieldTypeOld.Double => new mDouble(),
                            FieldTypeOld.Float => new mFloat(),
                            FieldTypeOld.Long => new mLong(),
                            FieldTypeOld.SByte => new mSByte(),
                            FieldTypeOld.Short => new mShort(),
                            FieldTypeOld.UShort => new mUShort(),
                            FieldTypeOld.ULong => new mULong(),
                            FieldTypeOld.Int => new mInt(),
                            FieldTypeOld.UInt => new mUInt(),
                            _ => throw new NotSupportedException($"Received unsupported node type {old}"),
                        };
                    }
                    else
                    {
                        string customFieldType = Encoding.UTF8.GetString(typeName);

                        field = customFieldType switch
                        {
                            "rectangle" => new mRectangle(),
                            "RGBA" => new mColor(),
                            "color_name" => new mColorName(),
                            "vector" => new mVector(),
                            "vector3" => new mVector3(),
                            "region" => new mRegion(),
                            _ => null,
                        };

                        if (field is null)
                        {
                            field = new mNode();
                            ((mNode)field).EndScopeOffset = endOffset;
                            ((mNode)field).TypeName       = customFieldType;
                        }
                    }

                    field.Name = fieldName;
                    //Console.WriteLine($"Reading: {field.Name} ({field})");
                    field.Read(io);

                    Child.Add(field);
                }

                Debug.Assert(io.Stream.ReadInt16() == 0x18d, "Scope terminator did not match");
            }
            else if (io.Version == 1)
            {
                TypeName = io.Stream.Read7BitString();
                mTypeBase field = null;
                do
                {
                    field = io.ReadNext();
                    if (field is mString str) // Key Name
                    {
                        io.CurrentKeyName = str.String;
                        field             = io.ReadNext();

                        if (field is mString str2 && io.CurrentKeyName != "name")
                        {
                            // Specific types, kind of hardcoded
                            if (str2.String == "rectangle")
                            {
                                field = new mRectangle();
                                field.Read(io);
                            }
                            else if (str2.String == "RGBA")
                            {
                                field = new mColor();
                                field.Read(io);
                            }
                            else if (str2.String == "color_name")
                            {
                                field = new mColorName();
                                field.Read(io);
                            }
                            else if (str2.String == "vector")
                            {
                                field = new mVector();
                                field.Read(io);
                            }
                            else if (str2.String == "vector3")
                            {
                                field = new mVector3();
                                field.Read(io);
                            }
                            else if (str2.String == "region")
                            {
                                field = new mRegion();
                                field.Read(io);
                            }
                        }

                        field.Name = str.String;
                    }

                    if (field != null)
                    {
                        Child.Add(field);
                    }
                } while (field != null);
            }
        }
예제 #25
0
        public override void Read(MTextIO io)
        {
            string token  = null;
            string token2 = null;

            if (IsRoot)
            {
                token  = io.GetToken();
                token2 = io.GetToken();

                if (token2 == MTextIO.SCOPE_START.ToString())
                {
                    // We only have the type
                    TypeName = token;
                }
                else
                {
                    Name     = token;
                    TypeName = token2;
                    string token3 = io.GetToken();
                    if (token3 != MTextIO.SCOPE_START.ToString())
                    {
                        throw new Exception($"Expected '{MTextIO.SCOPE_START}' character for node definition.");
                    }
                }
            }

            mTypeBase field = null;

            while (true)
            {
                // Loop through all fields, now
                token = io.GetToken();
                if (token == MTextIO.SCOPE_END.ToString())
                {
                    break;
                }

                token2 = io.GetToken();

                if (token2 == MTextIO.SCOPE_START.ToString())
                {
                    // We only have the type
                    field = new mNode();
                    ((mNode)field).TypeName = token;
                }
                else if (token2.StartsWith(MTextIO.ARRAY_START)) // Array def
                {
                    int arrLen = int.Parse(token2.AsSpan(1, token2.Length - 2));
                    if (arrLen > byte.MaxValue)
                    {
                        throw new UISyntaxError($"Array length can only be {byte.MaxValue} elements maximum. Got {arrLen}.");
                    }

                    field = new mArray();
                    ((mArray)field).Length = (byte)arrLen;

                    if (io.GetToken() != MTextIO.SCOPE_START.ToString())
                    {
                        throw new Exception($"Expected '{MTextIO.SCOPE_START}' character for node array field definition.");
                    }

                    field.Name = token;
                }
                else
                {
                    string fieldName = token;
                    string fieldType = token2;
                    string token3    = io.GetToken();
                    if (token3 != MTextIO.SCOPE_START.ToString())
                    {
                        throw new Exception($"Expected '{MTextIO.SCOPE_START}' character for node field definition.");
                    }

                    if (fieldType == "digit")
                    {
                        // Search potentially colliding field names with different types
                        UIDefType digitType;
                        var       potentialOverride = WidgetDefinitions.TypeOverrides.FirstOrDefault(e => e.WidgetName == TypeName && e.FieldName == fieldName);
                        if (potentialOverride != null)
                        {
                            digitType = potentialOverride.ValueType;
                        }
                        else
                        {
                            WidgetDefinitions.Types.TryGetValue(fieldName, out digitType); // No collision, just try to find it by name
                        }
                        /* No real easier way, the component types i.e 'DialogParts::DialogFrame::Pane::Head::Close::Cross' do not expose their actual type */

                        if (digitType != UIDefType.Unknown)
                        {
                            field = digitType switch
                            {
                                UIDefType.Int => new mInt(),
                                UIDefType.UInt => new mUInt(),
                                UIDefType.Long => new mLong(),
                                UIDefType.ULong => new mULong(),
                                UIDefType.Short => new mShort(),
                                UIDefType.UShort => new mUShort(),
                                UIDefType.Byte => new mUByte(),
                                UIDefType.SByte => new mSByte(),
                                UIDefType.Float => new mFloat(),
                                UIDefType.Double => new mDouble(),
                                UIDefType.Bool => new mBool(),
                                _ => new mInt(),
                            };
                        }
                        else
                        {
                            Console.WriteLine($"Missing digit type for '{fieldName}', assuming Int");
                            field = new mInt();
                        }
                    }
                    else
                    {
                        field = fieldType switch
                        {
                            "RGBA" => new mColor(),
                            "color_name" => new mColorName(),
                            "string" => new mString(),
                            "region" => new mRegion(),
                            "vector" => new mVector(),
                            "vector3" => new mVector3(),
                            "rectangle" => new mRectangle(),
                            _ => new mNode(),
                        };
                    }

                    if (field is mNode)
                    {
                        ((mNode)field).TypeName = token2;
                    }

                    field.Name = token;
                }

                field.Read(io);
                Child.Add(field);
            }
        }
예제 #26
0
파일: MessageNode.cs 프로젝트: ycllz/ProtoF
 public void AddEnum(EnumNode n)
 {
     AddSymbol(n.Name);
     Child.Add(n);
     Enum.Add(n);
 }
예제 #27
0
파일: MessageNode.cs 프로젝트: ycllz/ProtoF
 public void AddField(FieldNode n)
 {
     AddSymbol(n.Name);
     Child.Add(n);
     Field.Add(n);
 }