Beispiel #1
0
 /// <summary>
 /// Sets the title text.
 /// </summary>
 /// <param name="key">The key to consider.</param>
 /// <param name="text">The text to consider.</param>
 public void SetTitleText(string key = "*", string text = "*")
 {
     if (Title == null)
     {
         Title = new DictionaryDataItem();
     }
     Title.Set(key, text);
 }
Beispiel #2
0
 /// <summary>
 /// Adds the title text.
 /// </summary>
 /// <param name="key">The key to consider.</param>
 /// <param name="text">The text to consider.</param>
 public void AddDescriptionText(string key, string text)
 {
     if (Description == null)
     {
         Description = new DictionaryDataItem();
     }
     Description.Add(key, text);
 }
        public void GetAccessor_ArrayMemberExpression_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary <string, object>
            {
                { "prop1", new[] { "Item1", "Item2", "Item3" } },
                { "prop2", "some value" },
            });

            Assert.AreEqual("Item3", EvaluateProperty(dataItem, "prop1[2]"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_DirectMember_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary<string, object>
            {
                { "prop1", "Hello world!" },
                { "prop2", 10 },
            });

            Assert.AreEqual("Hello world!", EvaluateProperty(dataItem, "prop1"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_ArrayMemberExpression_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary<string, object>
            {
                { "prop1", new[] { "Item1", "Item2", "Item3" } },
                { "prop2", "some value" },
            });

            Assert.AreEqual("Item3", EvaluateProperty(dataItem, "prop1[2]"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_DirectMember_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary <string, object>
            {
                { "prop1", "Hello world!" },
                { "prop2", 10 },
            });

            Assert.AreEqual("Hello world!", EvaluateProperty(dataItem, "prop1"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_NestedMember_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary <string, object>
            {
                { "prop1", new Dictionary <string, object>
                  {
                      { "nested", 42 }
                  } },
                { "prop2", "some value" },
            });

            Assert.AreEqual(42, EvaluateProperty(dataItem, "prop1.nested"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_EscapedDictionaryStyleExpression_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary <string, object>
            {
                { "prop1", new Dictionary <string, object>
                  {
                      { "nes'ted", "Hello!" }
                  } },
                { "prop2", "some value" },
            });

            Assert.AreEqual("Hello!", EvaluateProperty(dataItem, @"prop1.['nes\'ted']"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_EscapedDictionaryStyleExpression_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary<string, object>
            {
                { "prop1", new Dictionary<string, object> 
                    {
                        { "nes'ted", "Hello!" }
                    }
                },
                { "prop2", "some value" },
            });

            Assert.AreEqual("Hello!", EvaluateProperty(dataItem, @"prop1.['nes\'ted']"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_NestedMember_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary<string, object>
            {
                { "prop1", new Dictionary<string, object> 
                    {
                        { "nested", 42 }
                    }
                },
                { "prop2", "some value" },
            });

            Assert.AreEqual(42, EvaluateProperty(dataItem, "prop1.nested"), TestResources.InvalidValueFromEvaluatedExpression);
        }
Beispiel #11
0
        // ------------------------------------------
        // MUTATORS
        // ------------------------------------------

        #region Mutators

        /// <summary>
        /// Updates the connection string with the specified string.
        /// </summary>
        /// <param name="connectionString">The connection string to consider.</param>
        public override IBdoConnector WithConnectionString(string connectionString = null)
        {
            base.WithConnectionString(connectionString);
            DictionaryDataItem item = ItemFactory.CreateDictionary(connectionString);

            Provider = item.GetContent("Provider").Trim().ToLower();
            DatabaseConnectorKind = EstimateDbConnectorKind();
            ServerAddress         = item.GetContent("Data Source");
            InitialCatalog        = item.GetContent("Initial Catalog");
            UserName = item.GetContent("User Id");
            Password = item.GetContent("Password");

            return(this);
        }
        public void GetAccessor_ArrayMemberExpressionWithNestedDataItem_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary <string, object>
            {
                { "prop1", new object[]
                  {
                      "Item1",
                      "Item2",
                      new Dictionary <string, object>
                      {
                          { "nested", "test" },
                          { "nested2", "another" }
                      }
                  } },
                { "prop2", "some value" },
            });

            Assert.AreEqual("another", EvaluateProperty(dataItem, "prop1[2].nested2"), TestResources.InvalidValueFromEvaluatedExpression);
        }
        public void GetAccessor_ArrayMemberExpressionWithNestedDataItem_CanEvaluate()
        {
            var dataItem = new DictionaryDataItem(new Dictionary<string, object>
            {
                { "prop1", new object[]
                    {
                        "Item1",
                        "Item2",
                        new Dictionary<string, object>
                        {
                            { "nested", "test" },
                            { "nested2", "another" }
                        }
                    }
                },
                { "prop2", "some value" },
            });

            Assert.AreEqual("another", EvaluateProperty(dataItem, "prop1[2].nested2"), TestResources.InvalidValueFromEvaluatedExpression);
        }
Beispiel #14
0
        /// <summary>
        /// Sets the title text.
        /// </summary>
        /// <param name="key">The key to consider.</param>
        /// <param name="text">The text to consider.</param>
        public ITitledDataItem WithTitle(string key = "*", string text = "*")
        {
            (Title ?? (Title = new DictionaryDataItem())).Set(key, text);

            return(this);
        }
Beispiel #15
0
 /// <summary>
 /// Adds the title text.
 /// </summary>
 /// <param name="key">The key to consider.</param>
 /// <param name="text">The text to consider.</param>
 public void AddTitleText(string key, string text)
 {
     (Title ?? (Title = new DictionaryDataItem())).Add(key, text);
 }
 /// <summary>
 /// Adds the title text.
 /// </summary>
 /// <param name="key">The key to consider.</param>
 /// <param name="text">The text to consider.</param>
 public void AddDescription(string key, string text)
 {
     (Description ?? (Description = new DictionaryDataItem())).Add(key, text);
 }
Beispiel #17
0
        /// <summary>
        /// Adds the title text.
        /// </summary>
        /// <param name="key">The key to consider.</param>
        /// <param name="text">The text to consider.</param>
        public ITitledDataItem AddTitle(string key, string text)
        {
            (Title ?? (Title = new DictionaryDataItem())).Add(key, text);

            return(this);
        }
 /// <summary>
 /// Sets the title text.
 /// </summary>
 /// <param name="key">The key to consider.</param>
 /// <param name="text">The text to consider.</param>
 public void SetDescription(string key = "*", string text = "*")
 {
     (Description ?? (Description = new DictionaryDataItem())).Set(key, text);
 }