Ejemplo n.º 1
0
 public void MenuClicking(IScriptEditor scriptEditor,
                          Design.Controls.TreeNode node, RuntimeScript runtimeScript, KeyObject obj)
 {
     ScriptEditor  = scriptEditor;
     RuntimeScript = runtimeScript;
     KeyObject     = obj;
     if (AddMenu != null && EditMenu != null)
     {
         EditMenu.Visible = runtimeScript != null &&
                            VirtualInputRuntime.RuntimeNames.Contains(runtimeScript.RuntimeName);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取_模型_数据
        /// </summary>
        /// <param name="info">行信息</param>
        /// <param name="model">数据来源</param>
        /// <returns>键值数据</returns>
        public KeyString GetValue_KeyString(ShineUponInfo info, AbsShineUpon model)
        {
            KeyObject ko = GetValue_KeyObject(info, model);

            if (CheckData.IsObjectNull(ko))
            {
                return(null);
            }
            string sv = ConvertTool.ToString(ko.Value);

            return(new KeyString(ko.Key, sv));
        }
Ejemplo n.º 3
0
 public void MenuClicking(IScriptEditor scriptEditor,
                          NUMC.Design.Controls.TreeNode node, RuntimeScript runtimeScript, KeyObject obj)
 {
     _scriptEditor  = scriptEditor;
     _runtimeScript = runtimeScript;
     _keyObject     = obj;
     if (_editMenu != null)
     {
         _editMenu.Visible = _editMenu.Enabled = runtimeScript != null &&
                                                 AppCommandRuntime.AppCommandRuntimeName == runtimeScript.RuntimeName;
     }
 }
Ejemplo n.º 4
0
        public override Task <BooleanObject> DeleteItemCls(KeyObject request, ServerCallContext context)
        {
            var success = _itemClsDao.Delete(new ItemCls()
            {
                Id = request.Body
            });

            return(Task.FromResult(new BooleanObject()
            {
                Body = success
            }));
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Just remove the first value, null if nothing to remove
    /// </summary>
    /// <returns></returns>
    public KeyObject RemoveFirst()
    {
        KeyObject retVal = null;

        if (items.Count > 0)
        {
            retVal = items[0];
            items.RemoveAt(0);

            onItemChangedCallback();
        }
        return(retVal);
    }
Ejemplo n.º 6
0
        public override Task <BooleanObject> DeleteBranchGroup(KeyObject request, Grpc.Core.ServerCallContext context)
        {
            var branchGroup = new BranchGroup()
            {
                Id = Convert.ToInt32(request.Body)
            };
            var success = _branchGroupDao.Delete(branchGroup);

            return(Task.FromResult(new BooleanObject()
            {
                Body = success
            }));
        }
Ejemplo n.º 7
0
        public override Task <BooleanObject> DeleteSupplierRegion(KeyObject request, ServerCallContext context)
        {
            var id      = Convert.ToInt32(request.Body);
            var success = _supplierRegionDao.Delete(new SupplierRegion()
            {
                Id = id
            });

            return(Task.FromResult(new BooleanObject()
            {
                Body = success
            }));
        }
Ejemplo n.º 8
0
        public void Have_in_SelectedKeyObject_first_list_item_selected()
        {
            var ko1A = new KeyObject("123");
            var ko2A = new KeyObject("789");

            var canDo = new ListOfKeyObjects(new List <KeyObject>()
            {
                ko1A, ko2A
            });
            var unit = new Unit(canDo);

            Check.That(unit.KeyObject).IsEqualTo(ko1A);
        }
Ejemplo n.º 9
0
        public override Task <BooleanObject> DeleteItemDepartment(KeyObject request, ServerCallContext context)
        {
            var id      = Convert.ToInt32(request.Body);
            var success = _itemDepartmentDao.Update(new ItemDepartment()
            {
                Id = id
            });

            return(Task.FromResult(new BooleanObject()
            {
                Body = success
            }));
        }
        public void TestRemoveDeadItemWhenAddMoreThanCurrentRefreshIntervalItems()
        {
            var weakDict = CreateDictWithoutItem();

            for (int i = 0; i < 2; i++)
            {
                AddKeyObject(weakDict, i);
            }

            for (int i = 0; i < 2; i++)
            {
                AddTupleObject(weakDict, i);
            }

            // Force gc to collect dead items
            GC.Collect();
            if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
            {
                var key1 = new Tuple <object, MemberInfo>(new KeyObject(11), memberInfo);
                weakDict.Add(key1, 11);

                var key2 = new KeyObject(12);
                //Weak dictionary will remove dead items during this adding operation.
                //Then the currentRefreshInterval will be 1(still alive)+5=6.
                weakDict.Add(key2, 12);

                Assert.Equal(2, weakDict.Count);

                for (int i = 0; i < 3; i++)
                {
                    AddTupleObject(weakDict, i);
                }

                // Force gc to collect dead items
                GC.Collect();
                if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
                {
                    //Add the six item to dictionary.
                    var key6 = new KeyObject(16);
                    //Weak dictionary will not clean dead entities.
                    weakDict.Add(key6, 16);
                    Assert.Equal(6, weakDict.Count);

                    var key14 = new Tuple <object, MemberInfo>(new KeyObject(114), memberInfo);
                    //Weak dictionary will remove dead items during this adding operation.
                    //Then the currentRefreshInterval will be 3(still alive)+5=8.
                    weakDict.Add(key14, 114);
                    Assert.Equal(4, weakDict.Count);
                }
            }
        }
        private object CreateTupleObj(KeyObject obj, RefType RefType)
        {
            switch (RefType)
            {
            case RefType.StrongRef:
                return(new Tuple <object, MemberInfo>(obj, this.memberInfo));

            case RefType.AliveWeak:
                return(this.comparer.CreateKey(new Tuple <object, MemberInfo>(obj, this.memberInfo)));

            default:
                return(this.comparer.CreateKey(new Tuple <object, MemberInfo>(this.CreateKeyObj(obj.ID), this.memberInfo)));
            }
        }
        private object CreateKeyObj(KeyObject obj, RefType RefType)
        {
            switch (RefType)
            {
            case RefType.StrongRef:
                return(obj);

            case RefType.AliveWeak:
                return(new WeakKeyReference <object>(obj, this.comparer));

            default:
                return(new WeakKeyReference <object>(this.CreateKeyObj(obj.ID), this.comparer));
            }
        }
Ejemplo n.º 13
0
        public void Return_a_list_containing_all_items()
        {
            var ko1A = new KeyObject("123");
            var ko2A = new KeyObject("456");
            var ko3A = new KeyObject("321");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var listOfKeyObjects = new ListOfKeyObjects(list1);

            Check.That(listOfKeyObjects.ToList()).ContainsExactly(list1);
        }
Ejemplo n.º 14
0
        public void Have_count_returns_3_when3_items_are_given()
        {
            var ko1A = new KeyObject("123");
            var ko2A = new KeyObject("456");
            var ko3A = new KeyObject("321");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var listOfKeyObjects = new ListOfKeyObjects(list1);

            Check.That(listOfKeyObjects.Count()).IsEqualTo(3);
        }
Ejemplo n.º 15
0
        public void Have_GetFirstItem_returns_first_item_in_parameter_list()
        {
            var ko1A = new KeyObject("123");
            var ko2A = new KeyObject("456");
            var ko3A = new KeyObject("321");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var listOfKeyObjects = new ListOfKeyObjects(list1);

            Check.That(listOfKeyObjects.GetFirstItem()).IsEqualTo(ko1A);
        }
Ejemplo n.º 16
0
        public void Not_find_a_key_object_when_not_in_the_list()
        {
            var ko1A    = new KeyObject("123");
            var ko2A    = new KeyObject("456");
            var ko3A    = new KeyObject("321");
            var ko2Find = new KeyObject("548");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var listOfKeyObjects = new ListOfKeyObjects(list1);

            Check.That(listOfKeyObjects.Contains(ko2Find)).IsFalse();
        }
Ejemplo n.º 17
0
        //-------------------------------------------------
        void Awake()
        {
            gm = GetComponent <GameManager>();
            keyObjectScript   = GetComponent <KeyObject>();
            velocityEstimator = GetComponent <VelocityEstimator>();

            if (attachEaseIn)
            {
                attachmentFlags &= ~Hand.AttachmentFlags.SnapOnAttach;
            }

            Rigidbody rb = GetComponent <Rigidbody>();

            rb.maxAngularVelocity = 50.0f;
        }
Ejemplo n.º 18
0
        public void Find_a_key_object_present_in_the_list()
        {
            var ko1A    = new KeyObject("123");
            var ko2A    = new KeyObject("456");
            var ko3A    = new KeyObject("321");
            var ko2Find = new KeyObject("123");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var listOfKeyObjects = new ListOfKeyObjects(list1);

            Check.That(listOfKeyObjects.Contains(ko2Find)).IsTrue();
        }
Ejemplo n.º 19
0
        public void Return_a_list_containing_original_instances_of_KeyObject_not_copies()
        {
            var ko1A = new KeyObject("123");
            var ko2A = new KeyObject("456");
            var ko3A = new KeyObject("321");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var listOfKeyObjects = new ListOfKeyObjects(list1);
            var list2            = listOfKeyObjects.ToList();

            Check.That(ko1A).IsEqualTo(list2[0]).And.IsSameReferenceAs(list2[0]);
        }
Ejemplo n.º 20
0
        public override Task <GetRolePermissionsFlagResponse> GetRolePermissionsFlag(KeyObject request, ServerCallContext context)
        {
            int roleId = Convert.ToInt32(request.Body);
            var rolePermissionsFlag = _roleDao.GetRolePermissionsFlag(roleId);
            var response            = new GetRolePermissionsFlagResponse();

            response.Flags.AddRange(rolePermissionsFlag.Select(rpf => new RolePermissionFlag()
            {
                MenuCode       = rpf.MenuCode,
                PermissionCode = rpf.PermissionCode,
                PermissionName = rpf.PermissionName,
                Flag           = rpf.Flag
            }));

            return(Task.FromResult(response));
        }
Ejemplo n.º 21
0
        public async Task AdKey_User_Success()
        {
            Guid id = Guid.NewGuid();
            //arrange
            var key = new KeyObject
            {
                Id     = id,
                AudNum = "017",
            };
            //Action
            await keyObjectService.Add(key);

            var exp = await keyObjectService.GetBy(id);

            //Assert
            Assert.AreEqual(id, exp.Id, "cant add key");
        }
        private WeakDictionary <object, int> CreateDict(out List <object> keys)
        {
            WeakDictionary <object, int> weakDict = CreateDictWithoutItem();

            keys = new List <object>();
            for (int i = 0; i < 5; i++)
            {
                KeyObject key = new KeyObject(i);
                keys.Add(key);
                weakDict.Add(key, 2 * i);
                var tuple = new Tuple <object, MemberInfo>(key, this.memberInfo);
                keys.Add(tuple);
                weakDict.Add(tuple, 2 * i + 1);
            }

            return(weakDict);
        }
Ejemplo n.º 23
0
        // item
        public override Task <ItemInfo> GetItem(KeyObject request, ServerCallContext context)
        {
            var itemId = request.Body;

            var response = new ItemInfo();
            var item     = _itemDao.Get(itemId);
            var barcodes = _itemBarcodeDao.GetItemBarcodesByItemId(itemId);
            var subs     = _itemSubDao.GetItemSubsByItemId(itemId);
            var packages = _itemPackageDao.GetItemPackagesByItemId(itemId);

            response.Item = _mapper.Map <ItemDTO>(item);
            response.Barcodes.AddRange(barcodes.Select(b => _mapper.Map <ItemBarcodeDTO>(b)));
            response.Packages.AddRange(packages.Select(p => _mapper.Map <ItemPackageDTO>(p)));
            response.Subs.AddRange(subs.Select(s => _mapper.Map <ItemSubDTO>(s)));

            return(Task.FromResult(response));
        }
Ejemplo n.º 24
0
        public void Have_SelectKeyObject_can_not_select_a_KeyObject_not_in_the_list()
        {
            var ko1A    = new KeyObject("123");
            var ko2A    = new KeyObject("789");
            var koOther = new KeyObject("999");

            var canDoKOs = new ListOfKeyObjects(new List <KeyObject>()
            {
                ko1A, ko2A
            });
            var unit = new Unit(canDoKOs);

            Check.That(unit.KeyObject == ko1A).IsTrue();

            Check.That(unit.SelectKeyObject(koOther)).IsFalse();
            Check.That(unit.KeyObject).IsEqualTo(ko1A);
        }
Ejemplo n.º 25
0
        public void Be_equal_to_another_containing_same_key_objects()
        {
            var ko1A = new KeyObject("123");
            var ko2A = new KeyObject("456");
            var ko3A = new KeyObject("321");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var list2 = new List <KeyObject>()
            {
                ko2A, ko3A, ko1A
            };

            Check.That(new ListOfKeyObjects(list1)).IsEqualTo(new ListOfKeyObjects(list2));
        }
Ejemplo n.º 26
0
        public void Not_be_equal_to_another_containing_different_number_of_key_objects()
        {
            var ko1A = new KeyObject("123");
            var ko2A = new KeyObject("456");
            var ko3A = new KeyObject("321");

            var list1 = new List <KeyObject>()
            {
                ko1A, ko2A, ko3A
            };
            var list2 = new List <KeyObject>()
            {
                ko2A, ko1A
            };

            Check.That(new ListOfKeyObjects(list1)).IsNotEqualTo(new ListOfKeyObjects(list2));
        }
Ejemplo n.º 27
0
        public void TestObjectKeyDictionary()
        {
            var dict = new Dictionary <KeyObject, int>();

            var k1 = new KeyObject();
            var k2 = new KeyObject();

            dict.Add(k1, 3);
            dict.Add(k2, 4);

            int val;

            Assert.IsTrue(dict.TryGetValue(k1, out val));
            Assert.IsTrue(val == 3);

            Assert.IsTrue(dict.TryGetValue(k2, out val));
            Assert.IsTrue(val == 4);
        }
 public CaseModel Func_SystemConfig()
 {
     return(new CaseModel()
     {
         NameSign = @"系统配置",
         ExeEvent = () => {
             SystemConfig sys_config = GlobalSystemService.GetInstance().Config.Get <SystemConfig>();
             Console.WriteLine("Config:");
             ShineUponParser parser = new ShineUponParser(typeof(SystemConfig));
             foreach (ShineUponInfo info in parser.GetDictionary().Values)
             {
                 KeyObject ko = parser.GetValue_KeyObject(info, sys_config);
                 Console.WriteLine("info.Name: {0}  ko.Key: {1}  ko.Value: {2}", info.Name, ko.Key, ko.Value);
             }
             return true;
         },
     });
 }
Ejemplo n.º 29
0
        /// <summary>
        /// ___Add object with dateStart___
        /// </summary>
        /// <param name="bookingAction"></param>
        /// <returns></returns>
        public async Task StartSession(User user, KeyObject keyObject)
        {
            try
            {
                keyObject.IsBooked = true;
                keyObject.User     = user;
                keyObject.UserId   = user.Id;
                var res = new BookingAction().AddStartSessionBookingAction(user, keyObject, Guid.NewGuid());
                await Add(res);

                _service.KeyObjects.Update(keyObject);
                await _service.SaveChangesAsync();
            }
            catch (Exception e)
            {
                GC.Collect();
                throw;
            }
        }
        private void TestCompareRefImplement(RefType leftRefType, RefType rightRefType, bool isTupleObject)
        {
            KeyObject obj   = new KeyObject(1);
            var       left  = CreateObj(obj, leftRefType, isTupleObject);
            var       right = CreateObj(obj, rightRefType, isTupleObject);

            if (leftRefType != RefType.DeadWeak && rightRefType != RefType.DeadWeak)
            {
                Assert.True(this.comparer.Equals(left, right));
            }
            else
            {
                GC.Collect();
                if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
                {
                    Assert.False(this.comparer.Equals(left, right));
                }
            }
        }
 private object CreateObj(KeyObject obj, RefType RefType, bool isTupleObject)
 {
     return isTupleObject ? CreateTupleObj(obj, RefType) : CreateKeyObj(obj, RefType);
 }
 private void AddKeyObject(WeakDictionary<object, int> dict, int id)
 {
     KeyObject key = new KeyObject(id);
     dict.Add(key, rand.Next());
 }
 private void AddTupleObject(WeakDictionary<object, int> dict, int id)
 {
     KeyObject key = new KeyObject(id);
     var tuple = new Tuple<object, MemberInfo>(key, this.memberInfo);
     dict.Add(tuple, rand.Next());
 }
        private WeakDictionary<object, int> CreateDict(out List<object> keys)
        {
            WeakDictionary<object, int> weakDict = CreateDictWithoutItem();

            keys = new List<object>();
            for (int i = 0; i < 5; i++)
            {
                KeyObject key = new KeyObject(i);
                keys.Add(key);
                weakDict.Add(key, 2 * i);
                var tuple = new Tuple<object, MemberInfo>(key, this.memberInfo);
                keys.Add(tuple);
                weakDict.Add(tuple, 2 * i + 1);
            }

            return weakDict;
        }
 private object CreateKeyObj(KeyObject obj, RefType RefType)
 {
     switch (RefType)
     {
         case RefType.StrongRef:
             return obj;
         case RefType.AliveWeak:
             return new WeakKeyReference<object>(obj, this.comparer);
         default:
             return new WeakKeyReference<object>(this.CreateKeyObj(obj.ID), this.comparer);
     }
 }
 private object CreateTupleObj(KeyObject obj, RefType RefType)
 {
     switch (RefType)
     {
         case RefType.StrongRef:
             return new Tuple<object, MemberInfo>(obj, this.memberInfo);
         case RefType.AliveWeak:
             return this.comparer.CreateKey(new Tuple<object, MemberInfo>(obj, this.memberInfo));
         default:
             return this.comparer.CreateKey(new Tuple<object, MemberInfo>(this.CreateKeyObj(obj.ID), this.memberInfo));
     }
 }
        public void TestRemoveDeadItemWhenAddMoreThanCurrentRefreshIntervalItems()
        {
            var weakDict = CreateDictWithoutItem();
            for (int i = 0; i < 2; i++)
            {
                AddKeyObject(weakDict, i);
            }

            for (int i = 0; i < 2; i++)
            {
                AddTupleObject(weakDict, i);
            }

            // Force gc to collect dead items
            GC.Collect();
            if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
            {
                var key1 = new Tuple<object, MemberInfo>(new KeyObject(11), memberInfo);
                weakDict.Add(key1, 11);

                var key2 = new KeyObject(12);
                //Weak dictionary will remove dead items during this adding operation.
                //Then the currentRefreshInterval will be 1(still alive)+5=6.
                weakDict.Add(key2, 12);

                Assert.AreEqual(2, weakDict.Count);

                for (int i = 0; i < 3; i++)
                {
                    AddTupleObject(weakDict, i);
                }

                // Force gc to collect dead items
                GC.Collect();
                if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
                {
                    //Add the six item to dictionary.
                    var key6 = new KeyObject(16);
                    //Weak dictionary will not clean dead entities.
                    weakDict.Add(key6, 16);
                    Assert.AreEqual(6, weakDict.Count);

                    var key14 = new Tuple<object, MemberInfo>(new KeyObject(114), memberInfo);
                    //Weak dictionary will remove dead items during this adding operation.
                    //Then the currentRefreshInterval will be 3(still alive)+5=8.
                    weakDict.Add(key14, 114);
                    Assert.AreEqual(4, weakDict.Count);
                }
            }
        }
        public void TestRemoveDeadItemWhenAddMoreThanRefreshIntervalItems()
        {
            WeakDictionary<object, int> weakDict = new WeakDictionary<object, int>(this.comparer, 5);
            for (int i = 0; i < 2; i++)
            {
                AddKeyObject(weakDict, i);
            }

            for (int i = 0; i < 3; i++)
            {
                AddTupleObject(weakDict, i);
            }

            // Force gc to collect dead items
            GC.Collect();
            if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
            {
                var key = new KeyObject(6);
                weakDict.Add(key, 6);

                // The countLimit after the first clean is 6 now.
                Assert.AreEqual(1, weakDict.Count);
            }
        }
        private void TestCompareSameRef(bool isTupleObj)
        {
            var array = Enum.GetValues(typeof(RefType));

            foreach (RefType refType in array)
            {
                KeyObject keyObj = new KeyObject(1);
                var obj = CreateObj(keyObj, refType, isTupleObj);

                if (refType != RefType.DeadWeak)
                {
                    Assert.IsTrue(this.comparer.Equals(obj, obj));
                }
                else
                {
                    GC.Collect();
                    if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
                    {
                        Assert.IsTrue(this.comparer.Equals(obj, obj));
                    }
                }
            }
        }
        private void TestCompareRefImplement(RefType leftRefType, RefType rightRefType, bool isTupleObject)
        {
            KeyObject obj = new KeyObject(1);
            var left = CreateObj(obj, leftRefType, isTupleObject);
            var right = CreateObj(obj, rightRefType, isTupleObject);

            if (leftRefType != RefType.DeadWeak && rightRefType != RefType.DeadWeak)
            {
                Assert.IsTrue(this.comparer.Equals(left, right));
            }
            else
            {
                GC.Collect();
                if (GC.WaitForFullGCComplete() == GCNotificationStatus.Succeeded)
                {
                    Assert.IsFalse(this.comparer.Equals(left, right));
                }
            }
        }