コード例 #1
0
        private static void OnValuesPropertyChanged(DependencyObject sourceObject, DependencyPropertyChangedEventArgs e)
        {
            Grid grid = sourceObject as Grid;

            //TODO: Сделать оптимизацию - вместо удаления ячеек сделать замену контента (если возможно, и если нужно)
            grid.Children.OfType <ValueCell>().ToList().ForEach(_ => grid.Children.Remove(_));


            IList <double> newValues = e.NewValue as IList <double>;
            double         count     = Math.Sqrt(newValues.Count);

            int valueIndex = 0;

            for (int i = 0; i < count; i++)
            {
                for (int t = 0; t < count; t++)
                {
                    ValueCell valueCell = new ValueCell(newValues[valueIndex]);
                    valueCell.CreateBorder();

                    grid.Children.Add(valueCell);

                    valueIndex++;
                }

                ValueCell.ResetColumnIndex();
                ValueCell.IncrementRowIndex();
            }
            ValueCell.ResetAllIndexes();
        }
コード例 #2
0
ファイル: Node.cs プロジェクト: KonstantinDavidov/Bigio
        public void SetValue(int hash, IKeyValuePair <TKey, TValue> pair)
        {
            int index = hash % Count;

            //Normally just add one more collision
            if (!_isSubNodesOn)
            {
                if (_innerArray[index] == null)
                {
                    _innerArray[index] = new ValueCell <TKey, TValue>();
                }
            }
            //But if node it too large - rebuild asked cell to NodeCell (and add one more node)
            else
            {
                if (_innerArray[index] == null)
                {
                    _innerArray[index] = new NodeCell <TKey, TValue>(new Node <TKey, TValue>(
                                                                         _balancer.GetNewNodeSize(_level + 1),
                                                                         _level + 1,
                                                                         _balancer));
                }
            }

            var cell = _innerArray[index];

            cell.Add(hash, pair);

            ElementCount++;
        }
コード例 #3
0
 public Delegate SymbolFunction(Symbol id)
 {
     ILocation<Delegate> binding;
     if (functions.TryGetValue (id, out binding))
         return binding.Value;
     if (id.NamesDotnetMethod ()) {
         Delegate gf = (Delegate) CL.EnsureGenericFunction (id, KW.GenericFunctionClass, CLOS.DotnetGenericFunction,
                                                                KW.Environment, this,
                                                                KW.StudlyName, id.Name);
         binding = new ValueCell<Delegate> (gf);
         return binding.Value;
     }
     else
         throw new NotImplementedException ();
 }
コード例 #4
0
        public void QuotedOfT_NoValue()
        {
            var c = new ValueCell(42);

            Expression <Func <int> > f = () => c.Value;

            var e = f.Body;

            var q = new Quoted <int>(e);

            var v = q.Value;

            Assert.AreEqual(42, q.Value);
            Assert.AreSame(e, q.Expression);

            Assert.IsTrue(c.HasAccessed);

            Assert.IsTrue(q.ToString().Contains("42"));
        }
コード例 #5
0
        internal static Cell Parse(RegistryHive hive, int index, byte[] buffer, int pos)
        {
            string type = Utilities.BytesToString(buffer, pos, 2);

            Cell result = null;

            switch (type)
            {
            case "nk":
                result = new KeyNodeCell(index);
                break;

            case "sk":
                result = new SecurityCell(index);
                break;

            case "vk":
                result = new ValueCell(index);
                break;

            case "lh":
            case "lf":
                result = new SubKeyHashedListCell(hive, index);
                break;

            case "li":
            case "ri":
                result = new SubKeyIndirectListCell(hive, index);
                break;

            default:
                throw new RegistryCorruptException("Unknown cell type '" + type + "'");
            }

            result.ReadFrom(buffer, pos);
            return(result);
        }
コード例 #6
0
ファイル: Cell.cs プロジェクト: marinehero/ThinkAway.net
        internal static Cell Parse(RegistryHive hive, int index, byte[] buffer, int pos)
        {
            string type = Utilities.BytesToString(buffer, pos, 2);

            Cell result = null;

            switch (type)
            {
                case "nk":
                    result = new KeyNodeCell(index);
                    break;

                case "sk":
                    result = new SecurityCell(index);
                    break;

                case "vk":
                    result = new ValueCell(index);
                    break;

                case "lh":
                case "lf":
                    result = new SubKeyHashedListCell(hive, index);
                    break;

                case "li":
                case "ri":
                    result = new SubKeyIndirectListCell(hive, index);
                    break;

                default:
                    throw new RegistryCorruptException("Unknown cell type '" + type + "'");
            }

            result.ReadFrom(buffer, pos);
            return result;
        }