コード例 #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);
 }
コード例 #2
0
ファイル: NewtonSoftTests.cs プロジェクト: Almarida/couchdb
        public void KeyOptions_Should_Produce_Squirley_Brackets_for_CouchValueMax2()
        {
            var arry   = new KeyOptions(CouchValue.MaxValue, 1);
            var result = arry.ToString();

            Assert.AreEqual("[{},1]", result);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: NewtonSoftTests.cs プロジェクト: kpisman/LoveSeat
 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);
 }
コード例 #5
0
ファイル: NewtonSoftTests.cs プロジェクト: kpisman/LoveSeat
 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);
 }
コード例 #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());
        }
コード例 #7
0
        public void SingleStringValue()
        {
            KeyOptions keyOptions = new KeyOptions("somevalue");

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

            Assert.IsFalse(keyOptions.HasValues);
            Assert.IsTrue(keyOptions.Count == 0);
            Assert.AreEqual(String.Empty, keyOptions.ToString());
        }
コード例 #9
0
ファイル: NewtonSoftTests.cs プロジェクト: kpisman/LoveSeat
 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);
 }
コード例 #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);
 }
コード例 #11
0
ファイル: NewtonSoftTests.cs プロジェクト: kpisman/LoveSeat
 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);
 }
コード例 #12
0
ファイル: NewtonSoftTests.cs プロジェクト: Almarida/couchdb
        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);
        }
コード例 #13
0
ファイル: NewtonSoftTests.cs プロジェクト: Almarida/couchdb
        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);
        }
コード例 #14
0
ファイル: NewtonSoftTests.cs プロジェクト: Almarida/couchdb
        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);
        }
コード例 #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));
        }
コード例 #16
0
ファイル: Input.cs プロジェクト: Road11/PGInnlevering
        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;
            }
        }
コード例 #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();
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: amelkor/IcyLight
        /// <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);
            }
        }
コード例 #21
0
 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);
 }
コード例 #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));
        }
コード例 #23
0
        public void SubArrayTest()
        {
            KeyOptions keyOptions = new KeyOptions("somevalue", new JArray(1, 2, 3));

            Assert.AreEqual("[\"somevalue\",[1,2,3]]", keyOptions.ToString());
        }
コード例 #24
0
ファイル: NewtonSoftTests.cs プロジェクト: Rychard/LoveSeat
 public void KeyOptions_Constructor_Fails()
 {
     var arry = new KeyOptions(CouchValue.MinValue);
     var result = arry.ToString();
 }
コード例 #25
0
 /// <summary>
 /// 填充指定密钥。
 /// </summary>
 /// <param name="options">给定的 <see cref="KeyOptions"/>。</param>
 public virtual void Populate(KeyOptions options)
 {
     Key        = options.Key;
     KeyMaxSize = options.KeyMaxSize;
 }
コード例 #26
0
        public void EmptyObjectTest()
        {
            KeyOptions keyOptions = new KeyOptions("somevalue", new JObject());

            Assert.AreEqual("[\"somevalue\",{}]", keyOptions.ToString());
        }
コード例 #27
0
 public virtual void setKeyOptions(KeyOptions keyOptions)
 {
     this.keyOptions = keyOptions;
 }
コード例 #28
0
 public Task UpdateKey(KeyOptions option)
 {
     return(Task.CompletedTask);
 }
コード例 #29
0
ファイル: NewtonSoftTests.cs プロジェクト: Almarida/couchdb
 public void KeyOptions_Constructor_Fails()
 {
     var arry   = new KeyOptions(CouchValue.MinValue);
     var result = arry.ToString();
 }
コード例 #30
0
 public KeyCodeWithModifier(KeyCode code, EventModifiers modifier = EventModifiers.None, KeyOptions options = KeyOptions.CreateMenu)
 {
     KeyCode = code; Modifiers = modifier; Options = options;
 }
コード例 #31
0
 public ViewOptions()
 {
     Key      = new KeyOptions();
     StartKey = new KeyOptions();
     EndKey   = new KeyOptions();
 }