Example #1
0
 /// <param name="allowUserKeys">
 /// if set to true, then it is allowed to supply own key values in the _key attribute of a document. If
 /// set to false, then the key generator will solely be responsible for generating keys and supplying own
 /// key values in the _key attribute of documents is considered an error.
 /// </param>
 /// <param name="type">
 /// specifies the type of the key generator. The currently available generators are traditional and
 /// autoincrement.
 /// </param>
 /// <param name="increment">increment value for autoincrement key generator. Not used for other key generator types.
 ///     </param>
 /// <param name="offset">Initial offset value for autoincrement key generator. Not used for other key generator types.
 ///     </param>
 /// <returns>options</returns>
 public virtual CollectionCreateOptions keyOptions(bool allowUserKeys
                                                   , KeyType type, int increment, int offset)
 {
     this.keyOptions = new KeyOptions(allowUserKeys, type, increment
                                      , offset);
     return(this);
 }
Example #2
0
        public void KeyOptions_Should_Produce_Squirley_Brackets_for_CouchValueMax2()
        {
            var arry   = new KeyOptions(CouchValue.MaxValue, 1);
            var result = arry.ToString();

            Assert.AreEqual("[{},1]", result);
        }
Example #3
0
        /// <summary>
        /// 通用单表数据删除
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public virtual WebResponseContent Del(KeyOptions options)
        {
            Type entityType  = typeof(T);
            var  tableName   = entityType.Name;
            var  keyProperty = entityType.GetKeyProperty();

            if (keyProperty == null || options == null || options.Key.Count == 0)
            {
                return(Response.Error(ResponseType.KeyError));
            }
            //查找key
            var tKey = keyProperty.Name;

            if (string.IsNullOrEmpty(tKey))
            {
                return(Response);
            }
            //判断条件
            FieldType fieldType = entityType.GetFieldType();
            string    joinKeys  = (fieldType == FieldType.Int || fieldType == FieldType.BigInt)
                 ? string.Join(",", options.Key)
                 : $"'{string.Join("','", options.Key)}'";
            //逻辑删除
            string sql = $"update {tableName} set Enable=2 where {tKey} in ({joinKeys});";

            Response.Status = repository.Sql_ExecuteCommand(sql) > 0;
            if (Response.Status && string.IsNullOrEmpty(Response.Message))
            {
                Response.OK(ResponseType.DelSuccess);
            }
            return(Response);
        }
Example #4
0
 public void KeyOptions_Should_Produce_Single_Value_For_A_Single_Array()
 {
     var arry = new KeyOptions();
     arry.Add(1);
     var result = arry.ToString();
     Assert.AreEqual("1", result);
 }
Example #5
0
 public void KeyOptions_Should_Produce_IsoTime()
 {
     var arry = new KeyOptions();
     arry.Add(CouchValue.MinValue);
     arry.Add(new DateTime(2011,1,1));
     var result = arry.ToString();
     Assert.AreEqual("[null,%222011-01-01T00%3a00%3a00%22]", result);
 }
Example #6
0
        public void MultipleValues()
        {
            KeyOptions keyOptions = new KeyOptions("somevalue", 1);

            Assert.IsTrue(keyOptions.HasValues);
            Assert.AreEqual(2, keyOptions.Count);
            Assert.AreEqual("[\"somevalue\",1]", keyOptions.ToString());
        }
Example #7
0
        public void SingleStringValue()
        {
            KeyOptions keyOptions = new KeyOptions("somevalue");

            Assert.IsTrue(keyOptions.HasValues);
            Assert.AreEqual(1, keyOptions.Count);
            Assert.AreEqual("\"somevalue\"", keyOptions.ToString());
        }
Example #8
0
        public void EmptyKeyOptionsTest()
        {
            KeyOptions keyOptions = new KeyOptions();

            Assert.IsFalse(keyOptions.HasValues);
            Assert.IsTrue(keyOptions.Count == 0);
            Assert.AreEqual(String.Empty, keyOptions.ToString());
        }
Example #9
0
 public void KeyOptions_Should_Produce_Squirley_Brackets_for_CouchValueMax()
 {
     var arry = new KeyOptions();
     arry.Add(CouchValue.MaxValue);
     arry.Add(1);
     var result = arry.ToString();
     Assert.AreEqual("[{},1]", result);
 }
Example #10
0
 public void KeyOptions_Should_Produce_IsoTime()
 {
     var arry = new KeyOptions();
     arry.Add(CouchValue.Empty);
     arry.Add(new DateTime(2011,1,1));
     var result = arry.ToString();
     Assert.AreEqual("[{},\"2011-01-01T00:00:00\"]", result);
 }
Example #11
0
 public void KeyOptions_Should_Produce_A_Complex_Array_For_Multiple_Values()
 {
     var arry = new KeyOptions();
     arry.Add(1);
     arry.Add(new DateTime(2011,1,1));
     var result = arry.ToString();
     Assert.AreEqual("[1,%222011-01-01T00%3a00%3a00%22]", result);
 }
Example #12
0
        public void KeyOptions_Should_Produce_Single_Value_For_A_Single_Array()
        {
            var arry = new KeyOptions();

            arry.Add(1);
            var result = arry.ToString();

            Assert.AreEqual("1", result);
        }
Example #13
0
        public void KeyOptions_Should_Produce_IsoTime()
        {
            var arry = new KeyOptions();

            arry.Add(CouchValue.MinValue);
            arry.Add(new DateTime(2011, 1, 1));
            var result = arry.ToString();

            Assert.AreEqual("[null,%222011-01-01T00%3a00%3a00%22]", result);
        }
Example #14
0
        public void KeyOptions_Should_Produce_A_Complex_Array_For_Multiple_Values()
        {
            var arry = new KeyOptions();

            arry.Add(1);
            arry.Add(new DateTime(2011, 1, 1));
            var result = arry.ToString();

            Assert.AreEqual("[1,%222011-01-01T00%3a00%3a00%22]", result);
        }
Example #15
0
        public async Task <ActionResult> Del([FromBody] object[] keys)
        {
            var r = new KeyOptions {
                Key = new List <string>()
            };

            foreach (var item in keys)
            {
                r.Key.Add(item.ToString());
            }
            return(await base.Del(r));
        }
Example #16
0
        public void CheckInput()
        {
            ConsoleKeyInfo buttonPressed = Console.ReadKey(true);

            switch (buttonPressed.Key)
            {
                case ConsoleKey.A:
                case ConsoleKey.LeftArrow:
                    ChosenKey = KeyOptions.Left;
                    break;
                case ConsoleKey.D:
                case ConsoleKey.RightArrow:
                    ChosenKey = KeyOptions.Right;
                    break;
                case ConsoleKey.W:
                case ConsoleKey.UpArrow:
                    ChosenKey = KeyOptions.Up;
                    break;
                case ConsoleKey.S:
                case ConsoleKey.DownArrow:
                    ChosenKey = KeyOptions.Down;
                    break;
                case ConsoleKey.Spacebar:
                    ChosenKey = KeyOptions.Pause;
                    break;
                case ConsoleKey.Escape:
                    ChosenKey = KeyOptions.Quit;
                    break;
            }

            switch (ChosenKey)
            {
                case KeyOptions.Left:
                    mover.MoveLeft();
                    break;
                case KeyOptions.Right:
                    mover.MoveRight();
                    break;
                case KeyOptions.Up:
                    mover.MoveUp();
                    break;
                case KeyOptions.Down:
                    mover.MoveDown();
                    break;
                case KeyOptions.Pause:
                    //do this
                    break;
                case KeyOptions.Quit:
                    //do this
                    break;
            }
        }
Example #17
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var path       = new PathService();
            var keyOpitons = new KeyOptions {
                AppId   = "39791",
                KeyFile = path.GetAbsolutePath(@"DataModel/label-issue.pem")
            };

            services.AddSingleton <KeyOptions>(keyOpitons);
            services.AddSingleton <KeyService>();
            services.AddSingleton <PredicService>();
            services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddGitHubWebHooks();
        }
Example #18
0
        public void AddKeyRequest(KeyOptions Options, KeyMask KeyMask)
        {
            string command = ((char)CommandCode.Key).ToString();

            command += (char)Options;
            command += "008";
            command += ((byte)KeyMask & 0x01) > 0 ? '1' : '0';
            command += ((byte)KeyMask & 0x02) > 0 ? '1' : '0';
            command += ((byte)KeyMask & 0x04) > 0 ? '1' : '0';
            command += ((byte)KeyMask & 0x08) > 0 ? '1' : '0';
            command += ((byte)KeyMask & 0x10) > 0 ? '1' : '0';
            command += ((byte)KeyMask & 0x20) > 0 ? '1' : '0';
            command += ((byte)KeyMask & 0x40) > 0 ? '1' : '0';
            command += ((byte)KeyMask & 0x80) > 0 ? '1' : '0';
            commands.Add(command);
        }
Example #19
0
        private static bool ReadKeyFromUser(out KeyOptions keyOptions, out bool isValid)
        {
            var key = Console.ReadKey();

            keyOptions = new KeyOptions();
            isValid    = keyOptions.IsValidKey(key);

            if (isValid == false)
            {
                EndOfProgram();
                return(true);
            }

            Console.WriteLine();
            return(false);
        }
Example #20
0
        /// <summary>
        /// Create a key pair for packaging.
        /// </summary>
        /// <param name="options"></param>
        private static void RunKeysCreation(KeyOptions options)
        {
            try
            {
                _log.Information("Keys creation started");

                if (string.IsNullOrEmpty(options.OutPath))
                {
                    options.OutPath = "./";
                }

                if (!Directory.Exists(options.OutPath))
                {
                    Directory.CreateDirectory(options.OutPath);
                }

                var(privateKey, publicKey) = Ed25519KeyGenerator.Create();

                var privPath = Path.Combine(options.OutPath, "private_key.json");
                var pubPath  = Path.Combine(options.OutPath, "public_key.json");

                File.WriteAllText(privPath, JsonSerializer.Serialize(privateKey), Encoding.UTF8);
                File.WriteAllText(pubPath, JsonSerializer.Serialize(publicKey), Encoding.UTF8);

                _log.Information($"Keys have been created: {Path.GetFullPath(privPath)} {Path.GetFullPath(pubPath)}");
            }
            catch (IOException e)
            {
                _log.Error($"unable to create keys: {e.Message}");
                Environment.Exit(Codes.ERROR_IO_EXCEPTION);
            }
            catch (UnauthorizedAccessException e)
            {
                _log.Error($"unable to create keys: {e.Message}");
                Environment.Exit(Codes.ERROR_ACCESS_EXCEPTION);
            }
        }
 public KeyDescriptionAttribute(string name, KeyCode code, EventModifiers modifier, KeyOptions options = KeyOptions.CreateMenu)
 {
     var keys = new KeyCodeWithModifier[1] {
         new KeyCodeWithModifier(code, modifier, options)
     }; KeyEvent = new KeyEvent(name, keys);
 }
Example #22
0
        [ApiExplorerSettings(IgnoreApi = true)]//todo: 打上标记 swagger不会报错
        public virtual async Task <ActionResult> Del(KeyOptions keys)
        {
            var r = await Task.FromResult(InvokeService("Del", new object[] { keys }));

            return(Ok(r));
        }
Example #23
0
        public void SubArrayTest()
        {
            KeyOptions keyOptions = new KeyOptions("somevalue", new JArray(1, 2, 3));

            Assert.AreEqual("[\"somevalue\",[1,2,3]]", keyOptions.ToString());
        }
Example #24
0
 public void KeyOptions_Constructor_Fails()
 {
     var arry = new KeyOptions(CouchValue.MinValue);
     var result = arry.ToString();
 }
Example #25
0
 /// <summary>
 /// 填充指定密钥。
 /// </summary>
 /// <param name="options">给定的 <see cref="KeyOptions"/>。</param>
 public virtual void Populate(KeyOptions options)
 {
     Key        = options.Key;
     KeyMaxSize = options.KeyMaxSize;
 }
Example #26
0
        public void EmptyObjectTest()
        {
            KeyOptions keyOptions = new KeyOptions("somevalue", new JObject());

            Assert.AreEqual("[\"somevalue\",{}]", keyOptions.ToString());
        }
Example #27
0
 public virtual void setKeyOptions(KeyOptions keyOptions)
 {
     this.keyOptions = keyOptions;
 }
Example #28
0
 public Task UpdateKey(KeyOptions option)
 {
     return(Task.CompletedTask);
 }
Example #29
0
 public void KeyOptions_Constructor_Fails()
 {
     var arry   = new KeyOptions(CouchValue.MinValue);
     var result = arry.ToString();
 }
 public KeyCodeWithModifier(KeyCode code, EventModifiers modifier = EventModifiers.None, KeyOptions options = KeyOptions.CreateMenu)
 {
     KeyCode = code; Modifiers = modifier; Options = options;
 }
Example #31
0
 public ViewOptions()
 {
     Key      = new KeyOptions();
     StartKey = new KeyOptions();
     EndKey   = new KeyOptions();
 }