Example #1
0
        public void should_return_expected_rule_given_name()
        {
            // given
            var serverVariables = new ServerVariables()
            {
                ServerVariablesList = new[]
                {
                    new ServerVariable {
                        Name = "not-me"
                    },
                    new ServerVariable {
                        Name = "not-me"
                    },
                    new ServerVariable {
                        Name = "not-me"
                    },
                    new ServerVariable {
                        Name = "me"
                    },
                }
            };

            // when
            ServerVariable rule = serverVariables["me"];

            // then
            Assert.That(rule, Is.EqualTo(serverVariables.ServerVariablesList[3]));
        }
Example #2
0
        public static ServerVariable LoadServerVariable(ParseNode node)
        {
            var mapNode = node.CheckMapNode("serverVariable");

            var serverVariable = new ServerVariable();

            ParseMap(mapNode, serverVariable, ServerVariableFixedFields, ServerVariablePatternFields);

            return(serverVariable);
        }
Example #3
0
        public static void WriteServerVariable(IParseNodeWriter writer, ServerVariable variable)
        {
            writer.WriteStartMap();

            writer.WriteList("enum", variable.Enum, (nodeWriter, s) => nodeWriter.WriteValue(s));
            writer.WriteStringProperty("default", variable.Default);
            writer.WriteStringProperty("description", variable.Description);
            writer.WriteExtensions(variable.Extensions);

            writer.WriteEndMap();
        }
		public Variable RegisterVariable (string name, object value, VariableChangedAction changedAction = null)
		{
			var v = new ServerVariable {
				Server = this,
				ChangedAction = changedAction,
				Id = id++,
				Name = name,
				Value = value,  
				IsWriteable = changedAction != null,
			};
			variables.Add (v);
			SendVariable (v);
			return v;
		}
Example #5
0
        // GET: Home
        public ActionResult Index()
        {
            List <ServerVariable> list = new List <ServerVariable>();
            var keys  = Request.ServerVariables.Keys;
            var count = keys.Count;

            for (int i = 0; i < count; i++)
            {
                var s = new ServerVariable();
                s.key   = keys[i];
                s.value = Request.ServerVariables.Get(keys[i]);
                list.Add(s);
            }
            return(View(list));
        }
Example #6
0
        public Variable RegisterVariable(string name, object value, VariableChangedAction changedAction = null)
        {
            var v = new ServerVariable {
                Server        = this,
                ChangedAction = changedAction,
                Id            = id++,
                Name          = name,
                Value         = value,
                IsWriteable   = changedAction != null,
            };

            variables.Add(v);
            SendVariable(v);
            return(v);
        }
        /// <summary>
        /// Serializes a <see cref="ServerVariable"/> value.
        /// </summary>
        /// <param name="value">The <see cref="ServerVariable"/> value to serialize.</param>
        /// <returns>The <see cref="JsonValue"/>.</returns>
        protected virtual JsonValue SerializeServerVariable(ServerVariable value)
        {
            if (value is null)
            {
                return(null);
            }

            var json = new JsonObject();

            SetJsonArray(json, PropertyConstants.Enum, value.Enum);
            SetJsonValue(json, PropertyConstants.Default, value.Default);
            SetJsonValue(json, PropertyConstants.Description, value.Description);

            return(json);
        }
Example #8
0
        public void should_return_expected_rule_given_index()
        {
            // given
            var serverVariables = new ServerVariables()
            {
                ServerVariablesList = new[]
                {
                    new ServerVariable(),
                    new ServerVariable(),
                    new ServerVariable(),
                    new ServerVariable()
                }
            };

            // when
            ServerVariable rule = serverVariables[3];

            // then
            Assert.That(rule, Is.EqualTo(serverVariables.ServerVariablesList[3]));
        }