示例#1
0
    private void EnumerableTest()
    {
        ValueList <CustomValue> a = new ValueList <CustomValue>();

        a.Add(new CustomValue()
        {
            B = true, F = 2.1f, I = 3
        });
        a.Add(new CustomValue()
        {
            B = false, F = 2.2f, I = 2
        });
        a.Add(new CustomValue()
        {
            B = true, F = 2.3f, I = 1
        });

        IRefEnumerator <CustomValue> e = a.GetEnumerator();
        CustomValue v = default(CustomValue);

        e.Reset();
        while (e.MoveNext(ref v))
        {
            Debug.Log(v.ToString());
        }
        e.Dispose();
        e = null;
    }
示例#2
0
        public override void Visit(ArraySyntax array)
        {
            if (_currentValue != null)
            {
                throw new InvalidOperationException("An Array value must not have an active value.");
            }

            var tomlArray = new ValueList()
            {
                MirrorSyntax = array,
            };
            var items = array.Items;

            for (int i = 0; i < items.ChildrenCount; i++)
            {
                var item = items.GetChildren(i);

                // Visit the child which will set the current value
                item.Accept(this);
                if (_currentValue == null)
                {
                    throw new InvalidOperationException("The current value must be set for Array item");
                }

                // Move the value into the array
                tomlArray.Add(_currentValue);
                _currentValue = null;
            }

            // Set the array as the current value
            _currentValue = new Value(tomlArray);
        }
示例#3
0
        ValueList <GraphicsAdapter> GetAdapters(IDXGIFactory3 *dxgiFactory)
        {
            IDXGIAdapter1 *dxgiAdapter1 = null;

            var adapters = new ValueList <GraphicsAdapter>();
            var index    = 0u;

            do
            {
                var result = dxgiFactory->EnumAdapters1(index, &dxgiAdapter1);

                if (result.FAILED)
                {
                    if (result != DXGI_ERROR_NOT_FOUND)
                    {
                        ReleaseIfNotNull(dxgiAdapter1);
                        ExceptionUtilities.ThrowExternalException(nameof(IDXGIFactory1.EnumAdapters1), result);
                    }
                    index = 0;
                }
                else
                {
                    var adapter = new GraphicsAdapter(this, dxgiAdapter1);
                    adapters.Add(adapter);

                    index++;
                    dxgiAdapter1 = null;
                }
            }while (index != 0);

            return(adapters);
        }
    public override void Update(float frameTime)
    {
        base.Update(frameTime);

        var toDisable = new ValueList <JetpackComponent>();

        foreach (var(active, comp, gasTank) in EntityQuery <ActiveJetpackComponent, JetpackComponent, GasTankComponent>())
        {
            active.Accumulator += frameTime;
            if (active.Accumulator < UpdateCooldown)
            {
                continue;
            }

            active.Accumulator -= UpdateCooldown;
            var air = gasTank.RemoveAir(comp.MoleUsage);

            if (air == null || !MathHelper.CloseTo(air.TotalMoles, comp.MoleUsage, 0.1f))
            {
                toDisable.Add(comp);
                continue;
            }

            gasTank.UpdateUserInterface();
        }

        foreach (var comp in toDisable)
        {
            SetEnabled(comp, false);
        }
    }
示例#5
0
        /// <summary>
        /// Build creation delegate using public and protected .ctors.
        /// </summary>
        TObjectCreator BuildCreatorProtected()
        {
            lock (this)
            {
                if (_lazyCreatorProtected == null)
                {
                    if (ReflectionUtils.IsInstantiable(_type) && !IsTrait)
                    {
                        var  ctorsList    = new ValueList <ConstructorInfo>();
                        bool hasProtected = false;
                        foreach (var c in _type.DeclaredConstructors)
                        {
                            if (!c.IsStatic && !c.IsPrivate && !c.IsPhpFieldsOnlyCtor() && !c.IsPhpHidden())
                            {
                                ctorsList.Add(c);
                                hasProtected |= c.IsFamily;
                            }
                        }
                        _lazyCreatorProtected = hasProtected
                            ? Dynamic.BinderHelpers.BindToCreator(_type.AsType(), ctorsList.ToArray())
                            : this.Creator;
                    }
                    else
                    {
                        _flags |= Flags.InstantiationNotAllowed;
                        _lazyCreatorProtected = this.Creator;
                    }
                }
            }

            return(_lazyCreatorProtected);
        }
示例#6
0
    private bool Update(StepTriggerComponent component, TransformComponent transform, EntityQuery <PhysicsComponent> query)
    {
        if (!component.Active ||
            component.Colliding.Count == 0)
        {
            return(true);
        }

        var remQueue = new ValueList <EntityUid>();

        foreach (var otherUid in component.Colliding)
        {
            var shouldRemoveFromColliding = UpdateColliding(component, transform, otherUid, query);
            if (!shouldRemoveFromColliding)
            {
                continue;
            }

            remQueue.Add(otherUid);
        }

        if (remQueue.Count > 0)
        {
            foreach (var uid in remQueue)
            {
                component.Colliding.Remove(uid);
                component.CurrentlySteppedOn.Remove(uid);
            }

            Dirty(component);
        }

        return(false);
    }
示例#7
0
                public override ValueList <string> /*!*/ Flatten()
                {
                    var result = new ValueList <string>(); // root
                    var first  = true;

                    foreach (var node in _nodes)
                    {
                        var node_flattern = node.Flatten();

                        if (first)
                        {
                            first  = false;
                            result = node_flattern;
                            continue;
                        }

                        var tmp = new ValueList <string>(node_flattern.Count);

                        foreach (var next in node_flattern)
                        {
                            foreach (var current in result)
                            {
                                tmp.Add(current + next);
                            }
                        }

                        result = tmp;
                    }

                    return(result);
                }
示例#8
0
 private void AddKeyToList(TreeNode node)
 {
     ValueList.Add(node.ImageKey);
     for (int i = 0; i < node.Nodes.Count; i++)
     {
         AddKeyToList(node.Nodes[i]);
     }
 }
示例#9
0
 public void ValueListWithInitialCapacity()
 {
     using ValueList <int> list = new ValueList <int>(Size);
     for (int i = 0; i < Size; i++)
     {
         list.Add(i);
     }
 }
示例#10
0
 public void AddValue(AbstractModel value)
 {
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     ValueList.Add(value);
 }
示例#11
0
        public ValueList<double> Next(int numberOfBytes)
        {
            var byteValues = new ValueList<double>();

            for (var i = 0; i < numberOfBytes; i++)
                byteValues.Add(_fileStream.ReadByte() / 255.0);

            return byteValues;
        }
示例#12
0
        public ValueList<double> GetLastLayerExitValues()
        {
            var exitValues = new ValueList<double>();

            foreach (Perceptron perceptron in _lastLayer.Perceptrons)
                exitValues.Add(perceptron.ExitValue());

            return exitValues;
        }
示例#13
0
        public void AddObjectValue(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            ValueList.Add(value);
        }
示例#14
0
        public void Execute()
        {
            // Register the test systems
            var testListener = new TestTraceListener();

            using (var scopedTraceListener = new ScopedTraceListenerRegister(testListener))
            {
                // Setup the input build state
                var buildState = new MockBuildState();
                var state      = buildState.ActiveState;

                // Set the sdks
                var sdks = new ValueList();
                sdks.Add(new Value(new ValueTable()
                {
                    { "Name", new Value("Roslyn") },
                    {
                        "Properties",
                        new Value(new ValueTable()
                        {
                            { "ToolsRoot", new Value("C:/Roslyn/ToolsRoot/") }
                        })
                    },
                }));

                // Setup parameters table
                var parametersTable = new ValueTable();
                state.Add("Parameters", new Value(parametersTable));
                parametersTable.Add("SDKs", new Value(sdks));
                parametersTable.Add("System", new Value("win32"));
                parametersTable.Add("Architecture", new Value("x64"));

                // Setup build table
                var buildTable = new ValueTable();
                state.Add("Build", new Value(buildTable));

                var factory = new ValueFactory();
                var uut     = new ResolveToolsTask(buildState, factory);

                uut.Execute();

                // Verify expected logs
                Assert.Equal(
                    new List <string>()
                {
                },
                    testListener.GetMessages());

                // Verify build state
                var expectedBuildOperations = new List <BuildOperation>();

                Assert.Equal(
                    expectedBuildOperations,
                    buildState.GetBuildOperations());
            }
        }
示例#15
0
        private void OnTemplateArraryItemChanged()
        {
            var templateItem = new ArrayItem()
            {
                IsTemplate = true
            };

            templateItem.PropetyChangedEvent += OnTemplateArraryItemChanged;
            ValueList.Add(templateItem);
        }
示例#16
0
        public Table(List <string> headers, List <double> Values)
        {
            Headers = headers;
            var groupedList = Values.ChunkBy(headers.Count);

            foreach (var item in groupedList)
            {
                ValueList.Add(headers.Zip(item, (x, y) => new { Key = x, Value = y }).ToDictionary(x => x.Key, y => y.Value));
            }
        }
示例#17
0
 public void SetValue(string name, double value)
 {
     if (ValueList.ContainsKey(name))
     {
         ValueList[name] = value;
     }
     else
     {
         ValueList.Add(name, value);
     }
 }
        public override bool AddKeyedValue(string key, T value)
        {
            if (!base.AddKeyedValue(key, value))
            {
                return(false);
            }

            PairList.Add(new KeyValuePair <string, T>(key, value));
            ValueList.Add(value);
            return(true);
        }
示例#19
0
        public void LoadValuesFor(NeuralNetwork neuralNetwork)
        {
            var firstLayerWeights = new ValueList<double>();
            var secondLayerWeights = new ValueList<double>();

            var secondLayerThresholds = new ValueList<double>();
            var thirdLayerThresholds = new ValueList<double>();

            try
            {
                var connection = new NpgsqlConnection(ConnectionString);
                connection.Open();
                var command = new NpgsqlCommand { Connection = connection };

                command.CommandText = "SELECT weight FROM pr4_weights_layer1 ORDER BY id ASC";
                var reader = command.ExecuteReader();

                while (reader.Read())
                    firstLayerWeights.Add(reader.GetDouble(0));

                reader.Close();
                command.CommandText = "SELECT weight FROM pr4_weights_layer2 ORDER BY id ASC";
                reader = command.ExecuteReader();

                while (reader.Read())
                    secondLayerWeights.Add(reader.GetDouble(0));

                reader.Close();
                command.CommandText = "SELECT threshold FROM pr4_thresholds_layer2 ORDER BY id ASC";
                reader = command.ExecuteReader();

                while (reader.Read())
                    secondLayerThresholds.Add(reader.GetDouble(0));

                reader.Close();
                command.CommandText = "SELECT threshold FROM pr4_thresholds_layer3 ORDER BY id ASC";
                reader = command.ExecuteReader();

                while (reader.Read())
                    thirdLayerThresholds.Add(reader.GetDouble(0));

                neuralNetwork.SetWeightsForLayer(1, firstLayerWeights);
                neuralNetwork.SetWeightsForLayer(2, secondLayerWeights);

                neuralNetwork.SetThresholdsForLayer(2, secondLayerThresholds);
                neuralNetwork.SetThresholdsForLayer(3, thirdLayerThresholds);
            }
            catch (Exception)
            {
                Console.WriteLine("There was a problem loading values from the database.");
                throw;
            }
        }
示例#20
0
 public HourTimeCondition(Context Context)
 {
     ValueListView = ((Activity)Context).FindViewById <TimeListView>(Resource.Id.HourList);
     for (int Minutes = 0; Minutes < 25; Minutes++)
     {
         ValueList.Add(Minutes.ToString());
     }
     ValueAdapter = new TimeAdapter(Context, ValueList);
     ValueListView.SetVisibleItemCount(3);
     ValueListView.Adapter = ValueAdapter;
     SetToNow();
     ValueListView.SelectionChangeLisenter = this;
 }
示例#21
0
        public void AddValue(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (value.GetType() != typeof(AbstractModel) && !value.IsAbstractModelValueType())
            {
                throw new ArgumentException("Must be an abstract model value type", nameof(value));
            }

            ValueList.Add(value);
        }
示例#22
0
 public MonthCondition(Context Context)
 {
     ValueListView = ((Activity)Context).FindViewById <TimeListView>(Resource.Id.MonthList);
     for (int Month = 1; Month < 13; Month++)
     {
         ValueList.Add(Month.ToString());
     }
     ValueAdapter = new TimeAdapter(Context, ValueList);
     ValueListView.SetVisibleItemCount(3);
     ValueListView.Adapter = ValueAdapter;
     SetToNow();
     ValueListView.SelectionChangeLisenter = this;
 }
示例#23
0
        public static void AddTest()
        {
            var valueList = new ValueList <int>(new int[] { 1, 2, 3 });

            valueList.Add(4);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(6)
                        .And.Count.EqualTo(4)
                        );

            Assert.That(() => valueList[3],
                        Is.EqualTo(4)
                        );

            valueList.Add(5);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(6)
                        .And.Count.EqualTo(5)
                        );

            Assert.That(() => valueList[4],
                        Is.EqualTo(5)
                        );

            valueList = new ValueList <int>();
            valueList.Add(6);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(1)
                        .And.Count.EqualTo(1)
                        );

            Assert.That(() => valueList[0],
                        Is.EqualTo(6)
                        );
        }
示例#24
0
        public Bucket Append(Bucket bucket)
        {
            if (bucket is null || bucket is EmptyBucket)
            {
                return(this);
            }

            lock (LockOn)
            {
                _buckets.Add(bucket);
            }

            return(this);
        }
示例#25
0
 public DayTimeCondition(Context Context, Condition condition)
 {
     this.condition = condition;
     ValueListView  = ((Activity)Context).FindViewById <TimeListView>(Resource.Id.DayList);
     for (int day = 1; day < 32; day++)
     {
         ValueList.Add(day.ToString());
     }
     ValueAdapter = new TimeAdapter(Context, ValueList);
     ValueListView.SetVisibleItemCount(3);
     ValueListView.Adapter = ValueAdapter;
     SetToNow();
     ValueListView.SelectionChangeLisenter = this;
 }
示例#26
0
        public void ValueListTest()
        {
            var list = new ValueList <int>();

            for (int i = 0; i < 10; i++)
            {
                list.AddRange(new[] { 0, 1, 2, 3 });
                list.Add(4);
                list.Insert(list.Count, 5);
            }

            list.Insert(0, -1);
            list.Insert(1, 1);
        }
示例#27
0
        public static void TrimExcessTest()
        {
            var valueList = new ValueList <int>(new int[] { 1, 2, 3 });

            valueList.TrimExcess();

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(3)
                        .And.Count.EqualTo(3)
                        );

            valueList.Add(4);
            valueList.Add(5);

            valueList.TrimExcess();

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(5)
                        .And.Count.EqualTo(5)
                        );

            valueList.EnsureCapacity(15);
            valueList.TrimExcess(0.3f);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(15)
                        .And.Count.EqualTo(5)
                        );

            valueList = new ValueList <int>();
            valueList.TrimExcess();

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(0)
                        .And.Count.EqualTo(0)
                        );
        }
示例#28
0
        /// <exception cref="BadSyntaxException">
        /// The name does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        /// The name is a reserved name.
        /// </exception>
        public EnumItem AddValue(string declaration)
        {
            EnumItem value = EnumItem.LoadFromString(declaration);

            for (int i = 0; i < ValueList.Count; i++)
            {
                if (ValueList[i].Name == value.Name)
                {
                    throw new ReservedNameException(value.Name);
                }
            }

            ValueList.Add(value);
            return(value);
        }
示例#29
0
        public void OnTimeChange()
        {
            int days      = DateTime.DaysInMonth(condition.Time.Year, condition.Time.Month);
            int Selectday = int.Parse(ValueListView.GetItemAtPosition(ValueListView.FirstVisiblePosition + 1).ToString());

            ValueList.Clear();
            for (int day = 1; day < days + 1; day++)
            {
                ValueList.Add(day.ToString());
            }
            ValueAdapter.NotifyDataSetChanged();
            Selectday = (Selectday > ValueList.Count) ? ValueList.Count : Selectday;
            ValueListView.SetSelection(((int.MaxValue / 2) - ((int.MaxValue / 2) % ValueList.Count)) + Selectday - 1 - ValueListView.mVisibleItemCount / 2);
            Value = Selectday.ToString();
        }
示例#30
0
    private void KnockOverKids(TransformComponent xform, EntityQuery <BuckleComponent> buckleQuery, EntityQuery <StatusEffectsComponent> statusQuery, ref ValueList <EntityUid> toKnock)
    {
        // Not recursive because probably not necessary? If we need it to be that's why this method is separate.
        var childEnumerator = xform.ChildEnumerator;

        while (childEnumerator.MoveNext(out var child))
        {
            if (!buckleQuery.TryGetComponent(child.Value, out var buckle) || buckle.Buckled)
            {
                continue;
            }

            toKnock.Add(child.Value);
        }
    }
示例#31
0
 public YearTimeCondition(Context Context)
 {
     ValueListView = ((Activity)Context).FindViewById <TimeListView>(Resource.Id.YearList);
     ValueList.Add(null);
     for (int ye = 2016; ye < 2030; ye++)
     {
         ValueList.Add(ye.ToString());
     }
     ValueList.Add(null);
     ValueAdapter          = new TimeAdapter(Context, ValueList);
     ValueAdapter.Loop     = false;
     ValueListView.Adapter = ValueAdapter;
     SetToNow();
     ValueListView.SelectionChangeLisenter = this;
 }
示例#32
0
 public void LoadData(Dictionary <string, List <DataPoint> > distributeList, List <DistributeValue> trendList)
 {
     DistributeDictionary = distributeList;
     if (DistributeDictionary != null && DistributeDictionary.Count > 0)
     {
         CurrentTarget = DistributeDictionary.FirstOrDefault().Key;
         CurrentValue  = CurrentValueList.LastOrDefault();
         LendList.Clear();
         foreach (var k in DistributeDictionary.Keys)
         {
             LendList.Add(k);
         }
     }
     ValueList.Clear();
     trendList.ForEach(v => ValueList.Add(v));
 }
示例#33
0
 public int this[string s]
 {
     get { return(Values[GetOffset(s)]); }
     set
     {
         if (GetOffset(s) == -1)
         {
             ValueList.Add(s);
             Values.Add(value);
         }
         else
         {
             Values[GetOffset(s)] = value;
         }
     }
 }
示例#34
0
 /// <summary>
 /// Clones a Value. Because Value is a struct, and structs are pass-by-value, we only really
 /// worry about a subset of situations where we have pass-by-ref data inside the Value.
 /// </summary>
 /// <returns></returns>
 public Value Clone()
 {
     Value v = this; // Structs are pass-by-val
     switch (this.Type) {
         case ValueTypes.ANY_TYPE:
             break;
         case ValueTypes.ARRAY:
             ValueList lv = new ValueList();
             foreach (Value av in this.Array_Value) {
                 lv.Add(av.Dupe());
             }
             v.Array_Value = lv;
             break;
         case ValueTypes.BOOLEAN:
             break;
         case ValueTypes.BYTE:
             break;
         case ValueTypes.CODE_BLOCK:
             CodeBlock cb = new CodeBlock();
             cb.Closure = this.CodeBlock_Value.Closure;
             cb.EndProgramCounter = this.CodeBlock_Value.EndProgramCounter;
             cb.StartProgramCounter = this.CodeBlock_Value.StartProgramCounter;
             List<Value> arity = new List<Value>();
             foreach (Value av in this.CodeBlock_Value.ArgumentsArity) {
                 arity.Add(av.Dupe());
             }
             v.CodeBlock_Value.ArgumentsArity = arity;
             v.CodeBlock_Value = cb;
             break;
         case ValueTypes.DATETIME:
             break;
         case ValueTypes.DECIMAL:
             break;
         case ValueTypes.DOUBLE:
             break;
         case ValueTypes.EMPTY:
             break;
         case ValueTypes.FLOAT:
             break;
         case ValueTypes.GUID:
             break;
         case ValueTypes.INT_16:
             break;
         case ValueTypes.INT_32:
             break;
         case ValueTypes.INT_64:
             break;
         case ValueTypes.NULL:
             break;
         case ValueTypes.OBJECT:
             break;
         case ValueTypes.REFERENCE:
             Reference r = new Reference();
             r.HomeEnvironment = this.Reference_Value.HomeEnvironment;
             r.Name = this.Reference_Value.Name;
             v.Reference_Value = r;
             break;
         case ValueTypes.STRING:
             break;
         case ValueTypes.UINT_16:
             break;
         case ValueTypes.UINT_32:
             break;
         case ValueTypes.UINT_64:
             break;
     }
     return v;
 }
示例#35
0
        private static ValueList CalculateSpaceList(ExpressionNode[] nodes)
        {
            var result = new ValueList();
            var skip = 0;
            for (var i = 1; i < nodes.Length; i++)
            {
                var filter = nodes[i];

                if (filter.Operator == ' ')
                {
                    var a = CalculateList(nodes.Skip(skip).Take(i - skip).ToArray());
                    result.Add(a);
                    skip = i;
                }
            }

            result.Add(CalculateList(nodes.Skip(skip).ToArray()));

            return result;
        }