예제 #1
0
 private void Set(int index, T value)
 {
     if (Keys.Count == 0)
     {
         Keys.Add(index);
         Values.Add(value);
     }
     else
     {
         var itemIndex = Keys.BinarySearch(index);
         if (itemIndex >= 0)
         {
             Values[itemIndex] = value;
         }
         else
         {
             Keys.Insert(~itemIndex, index);
             Values.Insert(~itemIndex, value);
         }
         if (Keys.Count != Values.Count)
         {
             Console.WriteLine("Break!");
         }
     }
 }
예제 #2
0
        public void Add(KeyValuePair <TKey, TValue> data)
        {
            KeyValueNode <TKey, TValue> node = new KeyValueNode <TKey, TValue>(data);

            if (!Contains(data))
            {
                if (head == null)
                {
                    head = node;
                }
                else
                {
                    tail.Next = node;
                }
                tail = node;
                Count++;
                Keys.Add(data.Key);
                Values.Add(data.Value);
                Notify?.Invoke($"Added key {data.Key}, value {data.Value}");
            }
            else
            {
                throw new ArgumentException($"Key {data.Key} is already in the dictionary");
            }
        }
예제 #3
0
 public virtual void AddKey(string key)
 {
     if (!Keys.Contains(key))
     {
         Keys.Add(key);
     }
 }
예제 #4
0
        private void OpenFile(string filename)
        {
            var file = new W3StringFile();

            try
            {
                var stream = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read));
                file.Read(stream);
                stream.Close();
            }
            catch (Exception)
            {
                return;
            }

            foreach (var item in file.block1)
            {
                if (!Lines.ContainsKey(item.str_id))
                {
                    Lines.Add(item.str_id, new List <W3StringBlock1>());
                }
                Lines[item.str_id].Add(item);
            }


            foreach (var item in file.block2)
            {
                if (!Keys.ContainsKey(item.str_id))
                {
                    Keys.Add(item.str_id, true);
                }
            }
        }
예제 #5
0
 private void h_Fill()
 {
     Keys.Add(new Key(EKeyType.Normal, "1", "!"));
     Keys.Add(new Key(EKeyType.Normal, "2", "@"));
     Keys.Add(new Key(EKeyType.CapsLock, "CapsLock", String.Empty));
     // TODO...
 }
예제 #6
0
 public HashSet <Document> this[Clue key]
 {
     get
     {
         for (int i = 0; i < Keys.Count; i++)
         {
             if (Keys[i] == key)
             {
                 return(Values[i]);
             }
         }
         // Otherwise create one
         Keys.Add(key);
         HashSet <Document> newValue = new HashSet <Document>();
         Values.Add(newValue);
         return(newValue);
     }
     set
     {
         for (int i = 0; i < Keys.Count; i++)
         {
             if (Keys[i] == key)
             {
                 Values[i] = value; return;
             }
         }
         // Otherwise create one
         Keys.Add(key);
         Values.Add(value);
     }
 }
예제 #7
0
        /// <summary>
        /// Sets the provided value in the state to correspond with the provided key, in the scope indicated by the Scope property, and in the group indicated by the GroupKey property.
        /// </summary>
        /// <param name="key">The key to assign to the provided value.</param>
        /// <param name="value">The value to save to state along with the provided key, prefixed by scope and group key.</param>
        public void SetStateValue(string key, T value)
        {
            string fullKey = GetStateKey(groupKey, key);

            switch (Scope)
            {
            case StateScope.Application:
                StateAccess.State.SetApplication(fullKey, value);
                break;

            case StateScope.Session:
                StateAccess.State.SetSession(fullKey, value);
                break;

            case StateScope.Operation:
                StateAccess.State.SetOperation(fullKey, value);
                break;
            }

            if (value == null)
            {
                // Remove the key
                Keys.Remove(key);

                RemoveStateValue(key);
            }
            else
            {
                if (!Keys.Contains(key))
                {
                    Keys.Add(key);
                }
            }
        }
 public PSDatabaseAccountListKeys(DatabaseAccountListConnectionStringsResult databaseAccountConnectionString)
 {
     foreach (DatabaseAccountConnectionString connectionString in databaseAccountConnectionString.ConnectionStrings)
     {
         Keys.Add(connectionString.Description, connectionString.ConnectionString);
     }
 }
 public PSDatabaseAccountListKeys(DatabaseAccountListKeysResult databaseAccountListKeysResult)
 {
     Keys.Add("PrimaryMasterKey", databaseAccountListKeysResult.PrimaryMasterKey);
     Keys.Add("SecondaryMasterKey", databaseAccountListKeysResult.SecondaryMasterKey);
     Keys.Add("PrimaryReadonlyMasterKey", databaseAccountListKeysResult.PrimaryReadonlyMasterKey);
     Keys.Add("SecondaryReadonlyMasterKey", databaseAccountListKeysResult.SecondaryReadonlyMasterKey);
 }
        /// <summary>
        /// Create a simple command item with multiple commands.
        /// </summary>
        /// <param name="name">Display name.</param>
        /// <param name="actions">Actions to execute.</param>
        /// <param name="description">Item description.</param>
        /// <param name="iconPath">Path to icon.</param>
        public CommandItem(string name, IList <CommandAction> actions, string description = null, string iconPath = null)
        {
            TopLeft    = name;
            BottomLeft = description;

            if (!string.IsNullOrWhiteSpace(name))
            {
                Keys.Add(new CommandItemKey {
                    Key = name, Weight = 1f
                });
            }
            if (!string.IsNullOrWhiteSpace(description))
            {
                Keys.Add(new CommandItemKey {
                    Key = description, Weight = 0.9f
                });
            }

            if (actions is IList <CommandAction> )
            {
                foreach (var action in actions)
                {
                    Actions.Add(action);
                }
            }

            if (!string.IsNullOrEmpty(iconPath))
            {
                if (Uri.TryCreate(iconPath, UriKind.RelativeOrAbsolute, out var uri))
                {
                    Icon = uri;
                }
            }
        }
예제 #11
0
        public UserRepository(IConfiguration _config) : base(_config)
        {
            this._config = _config;

            Keys.Add("id");

            TableName = "dbo.\"IdentityUser\"";


            //   _MappingM2DB = Models.Mapping.MappingM2DB.BeanMap;
            DefaultTypeMap.MatchNamesWithUnderscores = true;



            //build GetByID sql query
            GetByIdString = "SELECT * FROM " + TableName + " WHERE " + "\"Id\" = @Id";


            //GetAll sql query
            // GetAllString = "SELECT * FROM" + " " + TableName + "INNER JOIN " + TableName +
            //                "_image on name = bean_name " +
            //               "INNER JOIN image_file_name = file_name where content_type = 'preview'";
            GetAllString = "select * from " + TableName;

            //Update sql query: UpdateString = "UPDATE table SET property1=@property1, property2=@property2... WHERE key1=@key1, key2=@key2...";


            //Delete sql query
            DeleteString = "DELETE FROM" + " " + TableName + " WHERE \"Id\" = @Id";
        }
예제 #12
0
        public void Split(TKey Key, T Value, int RightSibling, BNode <T, TKey> NewNode, ref TKey UpwardMovingKey, T UpwardMovingValue)
        {
            Keys.Add(KeyFactory.CreateNull());
            Values.Add(Value);
            ChildrenPointers.Add(SizesNSpecialCharacters.NullPointer);
            Insert(Key, Value, RightSibling, false);
            UpwardMovingKey   = Keys[Middle];
            UpwardMovingValue = Values[Middle];
            Keys[Middle]      = KeyFactory.CreateNull();
            int j = 0;

            for (int i = Middle + 1; i < Keys.Count; i++)
            {
                NewNode.Keys[j]   = Keys[i];
                NewNode.Values[j] = Values[i];
                Keys[i]           = KeyFactory.CreateNull();
                j++;
            }
            j = 0;
            for (int i = Middle + 1; i < ChildrenPointers.Count; i++)
            {
                NewNode.ChildrenPointers[j] = ChildrenPointers[i];
                ChildrenPointers[i]         = SizesNSpecialCharacters.NullPointer;
                j++;
            }
            Keys.RemoveAt(Keys.Count - 1);
            Values.RemoveAt(Values.Count - 1);
            ChildrenPointers.RemoveAt(ChildrenPointers.Count - 1);
        }
예제 #13
0
 public virtual void Write(string name, object obj)
 {
     lock (Sync)
     {
         ObjectKey key;
         Keys.TryGetValue(name, out key);
         if (key != null)
         {
             key.obj = obj;
             key.Init(this);
         }
         else
         {
             key = new ObjectKey(this, name, obj);
             Keys.Add(name, key);
             this.keysNumber++;
         }
         key.DateTime = DateTime.Now;
         if (key.TypeId == ObjectType.DataSeries)
         {
             ((DataSeries)obj).Init(this, key);
         }
         WriteKey(key);
     }
 }
예제 #14
0
        /// <summary>
        /// Establece las claves Primarias y foraneas de un objeto Table (No se usa actualmente)
        /// </summary>
        /// <param name="pDttClave"></param>
        /// <param name="pClavesPrimarias"></param>
        /// <param name="pClavesForaneas"></param>
        private void SetKeys(DataTable pDttClave, Keys pClavesPrimarias, Keys pClavesForaneas)
        {
            foreach (DataRow oClaveRow in pDttClave.Rows)
            {
                Key wClave = new Key();

                wClave.Name           = oClaveRow["cKeyCol1"].ToString();
                wClave.ConstraintName = oClaveRow["cName"].ToString();
                wClave.ConstraintType = oClaveRow["cType"].ToString();

                if (!oClaveRow.IsNull("cGroupName"))
                {
                    wClave.GroupName = oClaveRow["cGroupName"].ToString();
                }


                if (wClave.GroupName == "PRIMARY")
                {
                    pClavesPrimarias.Add(wClave);
                }
                else
                {
                    pClavesForaneas.Add(wClave);
                }
            }
        }
예제 #15
0
        private void GetIconOverlayKeys()
        {
            try
            {
                _overlayRegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers", true);
            }
            catch (SecurityException ex)
            {
                MessageBox.Show(Application.Current.MainWindow, ex.Message, App.MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (_overlayRegistryKey != null)
            {
                KeyName = _overlayRegistryKey.Name;

                foreach (var subKeyName in _overlayRegistryKey.GetSubKeyNames())
                {
                    Keys.Add(new RegistryKeyEntryViewModel {
                        Name = subKeyName, Priorities = _priorities
                    });
                    KeyCount++;
                }
            }

            AppGroups = new ObservableCollection <AppGroupViewModel>(Keys.GroupBy(key => Regex.Replace(key.Name.Trim(), @"[\d-]", " ").Split(' ')[0]).Select(x => new AppGroupViewModel(x.Key, x, _priorities)));
        }
예제 #16
0
        private SetResponse SaveSet(string key = null)
        {
            var updateBuilder = new UpdateSet.Builder(DefaultAdds, null)
                                .WithBucketType(BucketType)
                                .WithBucket(Bucket)
                                .WithTimeout(TimeSpan.FromMilliseconds(20000));

            if (!string.IsNullOrEmpty(key))
            {
                updateBuilder.WithKey(key);
            }

            UpdateSet  cmd  = updateBuilder.Build();
            RiakResult rslt = client.Execute(cmd);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            SetResponse response = cmd.Response;

            Keys.Add(response.Key);

            Assert.True(EnumerableUtil.NotNullOrEmpty(response.Context));

            return(response);
        }
예제 #17
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="token"></param>
        /// <param name="parent"></param>
        public ClassApi(JToken token, ClassApi parent)
        {
            Name      = token["text"].ToString();
            IndexName = Name.Replace("{", "").Replace("}", "");
            Parent    = parent;
            Resource  = token["path"].ToString();

            Keys.AddRange(parent.Keys);
            parent.SubClasses.Add(this);

            IsIndexed = token["text"].ToString().StartsWith("{");
            if (IsIndexed)
            {
                Keys.Add(IndexName);
            }

            if (token["info"] != null)
            {
                Methods.AddRange(token["info"].Select(a => new MethodApi(a.Parent[((JProperty)a).Name], this)).ToArray());
            }

            //tree children
            if (token["children"] != null)
            {
                foreach (var child in token["children"])
                {
                    new ClassApi(child, this);
                }
            }
        }
예제 #18
0
        /// <summary>
        /// Shows the menu items and return the user's choice
        /// </summary>
        /// <returns>string with the user selected option</returns>
        public string Show()
        {
            var tokenizer = new AcceleratorCharTokenizer();
            int i         = 0;

            Keys.Clear();
            foreach (var item in Items)
            {
                if (Options.NumerationStyle == MenuNumeration.AcceleratorKey)
                {
                    Console.WriteLine(tokenizer.Parse(item));
                    Keys.Add(GetAcceleratorChar(item).ToString());
                }
                else
                {
                    (string key, IEnumerable <ColorToken> tokens) = ComposeMenuItem(i, item);
                    Console.WriteLine(tokens);
                    Keys.Add(key);
                }
                i++;
            }
            Console.Ask(BuildMessage());
            string value = Console.ReadLine <string>(x => IsDefaultValue(x) || Keys.Contains(x));

            return(IsDefaultValue(value) ? Options.DefaultItem : value);
        }
예제 #19
0
        public override void Parse(byte[] contents)
        {
            if (contents.Length < 2)
            {
                throw new ArgumentOutOfRangeException(string.Format("length mismatch - expected at least 2, got {0} - {1}", contents.Length.ToString(), BitConverter.ToString(contents)));
            }

            /* message id */
            MessageIdAcknowledged = (MessageId)contents[0];

            /* number of items */
            NumberOfItems |= contents[1];

            /* items */
            if ((NumberOfItems == 0) && (contents.Length == 2))
            {
                return;
            }
            else if (((NumberOfItems * 4) % (contents.Length - 2)) == 0)
            {
                for (int i = 0; i < NumberOfItems; i++)
                {
                    byte[] status = new byte[4];
                    Array.Copy(contents, 2 + (i * 4), status, 0, 4);
                    KeyStatus status2 = new KeyStatus();
                    status2.Parse(status);
                    Keys.Add(status2);
                }
            }
            else
            {
                throw new Exception("number of items field and length mismatch");
            }
        }
예제 #20
0
        public void Push(int k)
        {
            if (Keys.Count == 3)
            {
                throw new InvalidOperationException("Cannot push value into a 3 keys node");
            }

            if (Keys.Count == 0)
            {
                Keys.Add(k);
            }
            else
            {
                int left = 0;
                for (int x = 0; x < Keys.Count; x++)
                {
                    if (left <= k && k < Keys[x])
                    {
                        Keys.Insert(x, k);
                        return;
                    }
                    else
                    {
                        left = Keys[x];
                    }
                }
                Keys.Add(k);
            }
        }
예제 #21
0
        private void OpenFile(string filename)
        {
            var file = new W3StringFile();

            try
            {
                var stream = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read));
                file.Read(stream);
                stream.Close();
            }
            catch (Exception)
            {
                //MessageBox.Show(string.Format("There was an error trying to open {0}.", filename), "Opening file failed.");
                return;
            }

            foreach (var item in file.block1)
            {
                if (!Lines.ContainsKey(item.str_id))
                {
                    Lines.Add(item.str_id, new List <W3StringBlock1>());
                }
                Lines[item.str_id].Add(item);
            }


            foreach (var item in file.block2)
            {
                if (!Keys.ContainsKey(item.str_id))
                {
                    Keys.Add(item.str_id, true);
                }
            }
        }
예제 #22
0
        /// <summary>
        /// 自动根据参数调整图像大小
        /// </summary>
        public void Fit(float Xstart, float Xend, float Ystart, float Yend, float Xslice, float Yslice)
        {
            Xsl         = Xslice;
            Ysl         = Yslice;
            YSliceValue = Yslice;
            XSliceBegin = Xstart;
            //计算字体距离
            intFontSpace = FontSize + 5;
            //计算图像边距
            float fltSpace = Math.Min(Width / 6, Height / 6);

            XSpace = fltSpace;
            YSpace = fltSpace;
            //计算X轴刻度宽度
            XSlice = (Width - 2 * XSpace) / ((Xend - Xstart) / Xslice);
            int num = (int)((Xend - Xstart) / Xslice);

            for (int g = 0; g <= num; g++)
            {
                Keys.Add(Xstart + Xslice * g);
            }
            //计算Y轴刻度宽度和Y轴刻度开始值
            float fltMinValue = 0;
            float fltMaxValue = 0;

            YSliceBegin = Ystart;

            int intYSliceCount = (int)((Yend - Ystart) / Yslice);

            if ((Yend - Ystart) % Yslice != 0)
            {
                intYSliceCount++;
            }
            YSlice = (Height - 2 * YSpace) / intYSliceCount;//y轴大间隔宽度,个数是5
        }
예제 #23
0
        /// <summary>
        /// Creates an instance with bucket name, keys and quiet flag.
        /// </summary>
        /// <param name="bucketName">bucket name</param>
        /// <param name="keys">object keys to delete</param>
        /// <param name="quiet">true: quiet mode; false: detail mode</param>
        public DeleteObjectsRequest(string bucketName, IList <string> keys, bool quiet)
        {
            if (keys == null)
            {
                throw new ArgumentException("The list of keys to be deleted should not be null");
            }

            if (keys.Count <= 0)
            {
                throw new ArgumentException("No any keys specified.");
            }

            if (keys.Count > OssUtils.DeleteObjectsUpperLimit)
            {
                throw new ArgumentException("Count of objects to be deleted exceeds upper limit");
            }

            BucketName = bucketName;

            foreach (var key in keys)
            {
                OssUtils.CheckObjectKey(key);
                Keys.Add(key);
            }

            Quiet = quiet;
        }
예제 #24
0
        public void Load(string key, string name)
        {
            Keys.Add(key);
            var ch   = name[0];
            var node = Nodes.FirstOrDefault(q => q.Char == ch);

            if (node == null)
            {
                node      = new NameTree();
                node.Char = ch;
                //node.IsNum = "0123456789".Contains(ch);
                node.Name = this.Name + ch;
                this.Nodes.Add(node);
            }
            if (name.Length == 1)
            {
                node.CurKeys.Add(key);
            }
            else
            {
                var next = name.Substring(1);
                node.NextKeys.Add(key);
                node.Load(key, next);
            }
        }
예제 #25
0
        private bool AddSetCombinations(
            Keys <TKey> .Enumerator startEnumerator,
            int currentElement,
            int offset,
            Keys <TKey> currentCombination)
        {
            bool found = false;

            for (int loop = offset + currentElement; !found && loop < set.Count - elements + currentElement + 1; loop++)
            {
                // Add key
                currentCombination.Add(startEnumerator.Current);
                // need another element?
                if (currentElement + 1 < this.elements)
                {
                    Keys <TKey> .Enumerator nextEnumerator = startEnumerator;
                    nextEnumerator.MoveNext();
                    found = this.AddSetCombinations(nextEnumerator, currentElement + 1, offset, currentCombination);
                }
                else
                {
                    found = this.setTester.Test(currentCombination, this.set);
                }
                currentCombination.Remove(startEnumerator.Current);
                startEnumerator.MoveNext();
                offset += 1;
            }
            return(found);
        }
예제 #26
0
        public void AddField(string name, JSONObject obj)
        {
            if (obj)
            {
                // Don't do anything if the object is null
                if (ObjectType != Type.Object)
                {
                    if (Keys == null)
                    {
                        Keys = new List <string>();
                    }

                    if (ObjectType == Type.Array)
                    {
                        for (var i = 0; i < List.Count; i++)
                        {
                            Keys.Add(i + string.Empty);
                        }
                    }
                    else if (List == null)
                    {
                        List = new List <JSONObject>();
                    }

                    ObjectType = Type.Object;        // Congratulations, son, you're an OBJECT now
                }

                Keys.Add(name);
                List.Add(obj);
            }
        }
예제 #27
0
        /// <summary>Fixed the update.</summary>
        public override void FixedUpdate()
        {
            for (int i = 0; i < KeyboardsValues.Length; i++)
            {
                TempKey = Enum.Parse <SFML.Window.Keyboard.Key>(KeyboardsNames[i]);
                if (SFML.Window.Keyboard.IsKeyPressed(TempKey))
                {
                    if (!Keys.Contains(KeyboardsValues[i]))
                    {
                        Keys.Add(KeyboardsValues[i]);
                        PressDown(KeyboardsValues[i]);
                        OnPressDownKey.Invoke(this, KeyboardsValues[i]);
                    }

                    PressKey(KeyboardsValues[i]);
                    OnPressKey.Invoke(this, KeyboardsValues[i]);
                }
                else
                {
                    if (Keys.Contains(KeyboardsValues[i]))
                    {
                        Keys.Remove(KeyboardsValues[i]);
                        PressUp(KeyboardsValues[i]);
                        OnReleaseKey.Invoke(this, KeyboardsValues[i]);
                    }
                }
            }
        }
예제 #28
0
        static JoystickKeys()
        {
            using (var reader = new StringReader(JoystickKeysResources.JoystickTxt))
            {
                string line;

                while ((line = reader.ReadLine()) != null)
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    int s1 = line.Length <= 1 ? -1 : line.IndexOf('!', 1);

                    if (s1 == -1)
                    {
                        continue;
                    }

                    int s2 = line.Length <= s1 + 1 ? -1 : line.IndexOf(' ', s1 + 1);

                    if (s2 == -1)
                    {
                        continue;
                    }

                    string keyString   = line.Substring(s1 + 1, s2 - s1 - 1);
                    int    key         = int.Parse(keyString, CultureInfo.InvariantCulture);
                    string description = line.Substring(s2 + 1);

                    Keys.Add(key, description);
                }
            }
        }
예제 #29
0
        public void Parse(PatternEntryViewModel sender)
        {
            if (sender.PatternKeysList.Count > 0)
            {
                if (sender.PatternKeysList.Where(w => w.PatternEntryKeyVisibility.Equals(Visibility.Visible)).Count() > 0)
                {
                    var split = sender.PatternDownloadLinkText.Split('/');
                    for (int ind = 0; ind < split.Count(); ind++)
                    {
                        if (split[ind].Contains(KeySeparator))
                        {
                            var keySplit = split[ind].Split(new string[] { KeySeparator }, StringSplitOptions.None);
                            for (int keyInd = 1; keyInd < keySplit.Length; keyInd += 2)
                            {
                                LinkPattern += ind + "," + keySplit[keyInd] + ";";
                                PatternKeyViewModel key = sender.PatternKeysList.Where(w => w.KeyName.Equals(keySplit[keyInd])).FirstOrDefault();
                                Keys.Add(key);
                            }
                        }
                    }
                }
            }

            Extension = "." + sender.PatternDownloadLinkText.Split('/').Last().Split('.').Last();
            if (string.IsNullOrEmpty(sender.PatternGlobalFileNameText))
            {
                GlobalFileNameVisibility = Visibility.Collapsed;
            }
            else
            {
                GlobalFileNameVisibility = Visibility.Visible;
            }

            SkipMissingFiles = sender.SkipMissingFilesCheck;
        }
예제 #30
0
 public ReplayKeyboardState(List <Key> keys)
 {
     foreach (var key in keys)
     {
         Keys.Add(key);
     }
 }
예제 #31
0
		/// <summary>
		/// Establece las claves Primarias y foraneas de un objeto Table (No se usa actualmente)
		/// </summary>
		/// <param name="pDttClave"></param>
		/// <param name="pClavesPrimarias"></param>
		/// <param name="pClavesForaneas"></param>
		private  void SetKeys (DataTable pDttClave,Keys pClavesPrimarias, Keys pClavesForaneas)
		{
			foreach(DataRow oClaveRow in pDttClave.Rows)
			{
				Key wClave = new Key (); 
				
				wClave.Name 	= oClaveRow["cKeyCol1"].ToString();
				wClave.ConstraintName = oClaveRow["cName"].ToString();
				wClave.ConstraintType = oClaveRow["cType"].ToString();

				if(!oClaveRow.IsNull("cGroupName"))
					wClave.GroupName = oClaveRow["cGroupName"].ToString();
				
					
				if(wClave.GroupName == "PRIMARY")
					pClavesPrimarias.Add (wClave);
				else
					pClavesForaneas.Add	(wClave);
				
					
			}
			
		}