示例#1
0
 public override bool Set(EcmaPropertyKey propertyKey, EcmaValue value, RuntimeObject receiver)
 {
     if (propertyKey.IsArrayIndex)
     {
         if (isReadOnly || (isFixedSize && propertyKey.ToArrayIndex() > Target.Count))
         {
             return(false);
         }
         Target[(int)propertyKey.ToArrayIndex()] = value;
         return(true);
     }
     if (propertyKey == WellKnownProperty.Length)
     {
         if (isFixedSize)
         {
             return(false);
         }
         int len = (int)value;
         while (Target.Count < len)
         {
             Target.Add(EcmaValue.Undefined);
         }
         while (Target.Count > len)
         {
             Target.RemoveAt(Target.Count - 1);
         }
         return(true);
     }
     return(base.Set(propertyKey, value, receiver));
 }
示例#2
0
    void CreateItem(Collectible.Type type, GridPosition pos)
    {
        var newItem = new Collectible(gameAtlas, type);

        newItem.MoveTo(pos);
        Target.Add(newItem);
    }
示例#3
0
 public void Add(TKey key, TValue value)
 {
     using (Lock.CreateWriterScope())
     {
         Target.Add(key, value);
     }
 }
示例#4
0
    void CreateObstacle(Collectible.Type type, GridPosition pos)
    {
        var newObstacle = new Interractable(gameAtlas, type);

        newObstacle.MoveTo(pos);
        Target.Add(newObstacle);
    }
 protected override void Invoke(object parameter)
 {
     if (Target != null && Item != null && !Target.Contains(Item))
     {
         Target.Add(Item);
     }
 }
 protected override void Invoke(object parameter)
 {
     if (Target != null && Key != null && !Target.Contains(Key))
     {
         Target.Add(Key, Value);
     }
 }
示例#7
0
 public void Add(KeyValuePair <TKey, TValue> item)
 {
     using (Lock.CreateWriterScope())
     {
         Target.Add(item);
     }
 }
示例#8
0
 void DoAdd(int start, int count)
 {
     for (var idx = 0; idx < count; idx += 1)
     {
         var s = SourceList[start + idx];
         Target.Add(s.Widget, start + idx, s.Constraint);
     }
 }
示例#9
0
 public void Add(IWindow window)
 {
     if (IsWrappingNullReference)
     {
         return;
     }
     Target.Add(((Window)window).Target);
 }
示例#10
0
        public void GivenAServiceRequestFulfillment_WhenAdd_ThenAddToContext()
        {
            var expected = TestData.ServiceRequestFulfillments[0];

            Target.Add(expected);

            MockDbSet.AssertWasCalled(m => m.Add(expected));
        }
示例#11
0
 void DoReplace(int start, int count)
 {
     for (var idx = 0; idx < count; idx += 1)
     {
         var s = SourceList[idx];
         Target.Remove(idx + start);
         Target.Add(s.Widget, idx, s.Constraint);
     }
 }
示例#12
0
        protected override void UndoForce()
        {
            switch (Command.Action)
            {
            case CollectionUniqueChanged.Add: Target.Remove(Command.Item); break;

            case CollectionUniqueChanged.Remove: Target.Add(Command.Item); break;

            default: throw new InvalidEnumException();
            }
        }
示例#13
0
文件: Method.cs 项目: hythof/csharp
 public static void Main()
 {
     Target t = new Target();
     int a = t.Add(1,2);
     int b = (int)t.GetType().GetMethod("Add").Invoke(t, new object[]{ 1, 2 });
     int c = (int)t.GetType().GetMethod("Sub", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(t, new object[]{ 4, 3 });
     int d = (int)typeof(Target).GetMethod("Mul", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[]{ 2, 5 });
     Console.WriteLine("1 + 2 = " + a);
     Console.WriteLine("1 + 2 = " + b);
     Console.WriteLine("4 - 3 = " + c);
     Console.WriteLine("2 * 5 = " + d);
 }
 protected override void Invoke(object parameter)
 {
     if (Target != null && Items != null)
     {
         foreach (object o in Items)
         {
             if (!Target.Contains(o))
             {
                 Target.Add(o);
             }
         }
     }
 }
示例#15
0
    public static void Main()
    {
        Target t = new Target();
        int    a = t.Add(1, 2);
        int    b = (int)t.GetType().GetMethod("Add").Invoke(t, new object[] { 1, 2 });
        int    c = (int)t.GetType().GetMethod("Sub", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(t, new object[] { 4, 3 });
        int    d = (int)typeof(Target).GetMethod("Mul", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { 2, 5 });

        Console.WriteLine("1 + 2 = " + a);
        Console.WriteLine("1 + 2 = " + b);
        Console.WriteLine("4 - 3 = " + c);
        Console.WriteLine("2 * 5 = " + d);
    }
        // super factory method

        public static void AddTargets(TargetStorage storage, XPathNavigator topicsNode, ReferenceLinkType type)
        {
            XPathNodeIterator topicNodes = topicsNode.Select("/*/apis/api[not(topicdata/@notopic)]");

            foreach (XPathNavigator topicNode in topicNodes)
            {
                Target target = CreateTarget(topicNode, type);
                if (target != null)
                {
                    target.Add(storage);
                }
            }
        }
示例#17
0
        public TValue GetOrAdd(TKey key, Func <TKey, TValue> factory)
        {
            TValue value;

            using (Lock.CreateWriterScope())
            {
                if (!Target.TryGetValue(key, out value))
                {
                    Target.Add(key, value = factory(key));
                }
            }

            return(value);
        }
示例#18
0
            public void Update(Action <TTarget, TSource> action)
            {
                List <TSource> Matched = new List <TSource>();

                foreach (var item in Target.ToList())
                {
                    TSource matched;
                    if (Predicate != null)
                    {
                        matched = Source.SingleOrDefault(a => Predicate(item, a));
                    }
                    else
                    {
                        matched = Find(item);
                    }
                    if (matched == null)
                    {
                        if (WhenRemovedAction == null)
                        {
                            Target.Remove(item);
                        }
                        else
                        {
                            WhenRemovedAction(item);
                        }
                    }
                    else
                    {
                        Matched.Add(matched);
                        action(item, matched);
                    }
                }

                foreach (var item in Source)
                {
                    if (!Matched.Contains(item))
                    {
                        if (WhenAddedAction == null)
                        {
                            var newObject = new TTarget();
                            Target.Add(newObject);
                            action(newObject, item);
                        }
                        else
                        {
                            WhenAddedAction(item);
                        }
                    }
                }
            }
示例#19
0
        void DoMove(int oldStart, int newStart, int count)
        {
            if (oldStart == newStart)
            {
                return;
            }

            for (var idx = 0; idx < count; idx += 1)
            {
                var old = Target.WidgetsWithConstraints[idx + oldStart];
                Target.Remove(idx + oldStart);
                Target.Add(old.Widget, idx + newStart, old.Constraint);
            }
        }
        public void Save()
        {
            if (HasErrorVM == null)
            {
                if (package.Description == newDescription)
                {
                    MessageBox.Show("Invalid Description name.");
                    return;
                }

                CreatingNew = false;
                Target.Add(Package);
                Modified = false;
            }
        }
示例#21
0
        public TValue GetOrAdd(TKey key, TValue newValue)
        {
            TValue value;

            using (Lock.CreateWriterScope())
            {
                if (!Target.TryGetValue(key, out value))
                {
                    Target.Add(key, newValue);
                    return(newValue);
                }
            }

            return(value);
        }
示例#22
0
        public bool TryAdd(TKey key, TValue value)
        {
            using (Lock.CreateWriterScope())
            {
                if (Target.ContainsKey(key))
                {
                    return(false);
                }
                else
                {
                    Target.Add(key, value);

                    return(true);
                }
            }
        }
        private void Source_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems != null)
            {
                var index = e.NewStartingIndex;

                foreach (var item in e.NewItems.Cast <TFrom>())
                {
                    Target.Insert(index++, Mapper(item));
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Move)
            {
                throw new NotImplementedException();
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems != null)
            {
                for (int i = 0; i < e.OldItems.Count; i++)
                {
                    var index = e.OldStartingIndex + i;

                    var item = Target[index];
                    Target.RemoveAt(index);

                    RemoveHandler?.Invoke(item);
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                throw new NotImplementedException();
            }
            else if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                foreach (var item in Target)
                {
                    RemoveHandler?.Invoke(item);
                }

                Target.Clear();

                foreach (var item in Source)
                {
                    Target.Add(Mapper(item));
                }
            }
        }
示例#24
0
        public override bool Run()
        {
            try
            {
                List <Item> allChoices = new List <Item>();

                foreach (KeyValuePair <FishType, FishData> pair in Fish.sFishData)
                {
                    allChoices.Add(new Item(pair.Key, pair.Value));
                }

                CommonSelection <Item> .Results choices = new CommonSelection <Item>(Common.Localize("StockAny:MenuName"), allChoices).SelectMultiple();
                if ((choices == null) || (choices.Count == 0))
                {
                    return(true);
                }

                int maxInventoryCapacity = Target.Inventory.mMaxInventoryCapacity;

                try
                {
                    Target.Inventory.mMaxInventoryCapacity = 0;

                    foreach (Item choice in choices)
                    {
                        Fish fish = Fish.MakeFish(choice.Value, false);
                        if (fish == null)
                        {
                            continue;
                        }

                        Target.Add(fish);
                    }
                }
                finally
                {
                    Target.Inventory.mMaxInventoryCapacity = maxInventoryCapacity;
                }
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
            }
            return(true);
        }
示例#25
0
 private static IEnumerable <Target> GetTargetResults(IEnumerable <ModuleMetric> metrics)
 {
     foreach (ModuleMetric metric in metrics)
     {
         Target target = new Target();
         target.Name = metric.ProjectFile;
         Target            target1     = target;
         ModuleProjectKind projectKind = metric.ProjectKind;
         if (projectKind == ModuleProjectKind.CSharp)
         {
             target1.ProjectKind = "cs";
         }
         else if (projectKind == ModuleProjectKind.VisualBasic)
         {
             target1.ProjectKind = "vb";
         }
         target1.Add(MetricsReportBuilder.GetModulesResult(metric));
         yield return(target1);
     }
 }
示例#26
0
 void DoWin(int id)
 {
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("Add"))
     {
         Undo.RegisterSceneUndo("Insert Control Point");
         Selection.activeTransform = Target.Add().transform;
     }
     GUI.enabled = Target.ControlPointCount > 0;
     if (GUILayout.Button("Clear") && EditorUtility.DisplayDialog("Clear Spline", "Really remove all Control Points?", "Yes", "No"))
     {
         Target.Clear();
     }
     if (GUILayout.Button("First CP"))
     {
         Selection.activeObject = Target.ControlPoints[0];
     }
     GUI.enabled = true;
     GUILayout.EndHorizontal();
 }
        private int CheckNewTarget()
        {
            int    result    = 0;
            string newTarget = textBox4.Text;
            bool   valid     = FormValidation.CheckProfileString(newTarget);

            if (!valid)
            {
                ValidationMessage += "Numele către/dinspre nu este valid! ";
            }
            else
            {
                Target addedTarget = new Target();
                if (addedTarget.Add(newTarget, Core.CurrentProfile.Id))
                {
                    result = addedTarget.Id;
                }
            }
            return(result);
        }
示例#28
0
        public override void Convert()
        {
            try
            {
                foreach (var jobService in Source)
                {
                    var newAgent = GetInstance();

                    ConvertAgentDetails(jobService, newAgent);

                    Target.Add(newAgent);
                }

                SerializerHelper.Serialize(Target, "Agents");
            }
            catch (Exception exception)
            {
                Log.Logger.Error(exception, exception.Message);
                throw;
            }
        }
    public override void OnInspector()
    {
        SGT_EditorGUI.Separator();

        for (var i = 0; i < Target.Count; i++)
        {
            var material    = Target.GetMaterial(i);
            var renderQueue = Target.GetRenderQueue(i);

            SGT_EditorGUI.BeginIndent();
            {
                bool pressed; material = SGT_EditorGUI.ObjectFieldWithButton("Material", null, material, "X", out pressed, 25.0f, true);

                renderQueue = SGT_EditorGUI.IntField("Render Queue", null, renderQueue);

                if (pressed == true)
                {
                    Target.Remove(i);
                }
                else
                {
                    Target.SetMaterial(material, i);
                    Target.SetRenderQueue(renderQueue, i);
                }
            }
            SGT_EditorGUI.EndIndent();

            SGT_EditorGUI.Separator();
        }

        var addMaterial = SGT_EditorGUI.ObjectField <Material>("Add Material", null, null);

        if (addMaterial != null)
        {
            Target.Add(addMaterial, addMaterial.renderQueue);
        }

        SGT_EditorGUI.Separator();
    }
        public override void Convert()
        {
            try
            {
                foreach (var category in Source)
                {
                    var newFolder = GetInstance();

                    newFolder.FolderName = category.CategoryName;
                    newFolder.Properties.SetValue("Enabled", true);

                    Target.Add(newFolder);
                }

                SerializerHelper.Serialize(Target, "Folders");
            }
            catch (Exception exception)
            {
                Log.Logger.Error(exception, exception.Message);
                throw;
            }
        }
示例#31
0
 public override void Restore()
 {
     if (IsValid)
     {
         if (Args.Action == NotifyCollectionChangedAction.Add) // Remove added items
         {
             foreach (object item in Args.NewItems)
             {
                 Target.Remove(item);
             }
         }
         else if (Args.Action == NotifyCollectionChangedAction.Remove) // Add back removed items
         {
             if (Args.OldItems.Count == 1 && Args.OldStartingIndex.InRange(0, Target.Count - 1))
             {
                 Target.Insert(Args.OldStartingIndex, Args.OldItems[0]);
             }
             else
             {
                 foreach (object item in Args.OldItems)
                 {
                     Target.Add(item); //Will change position... OK?
                 }
             }
         }
         else if (Args.Action == NotifyCollectionChangedAction.Replace)
         {
             if (Args.OldItems.Count == 1)
             {
                 Target[Args.OldStartingIndex] = Args.OldItems[0];
             }
             else
             {
                 //TODO?
             }
         }
     }
 }