Beispiel #1
0
        public override string ToString()
        {
            var sb = new StringBuilder("{");

            IEnumerator <KeyValuePair <object, V> > iter1 = IDictionaryExtensions.EntrySet(this).GetEnumerator();

            while (iter1.MoveNext())
            {
                KeyValuePair <object, V> entry = iter1.Current;
                if (sb.Length > 1)
                {
                    sb.Append(", ");
                }
                if (entry.Key.GetType().Equals(typeof(char[])))
                {
                    sb.Append(new string((char[])entry.Key));
                }
                else
                {
                    sb.Append(entry.Key);
                }
                sb.Append("=");
                sb.Append(entry.Value);
            }

            return(sb.Append('}').ToString());
        }
Beispiel #2
0
 public bool Equals(HttpFieldParameters other)
 {
     if (other != null)
     {
         return(IDictionaryExtensions.DictionaryEquals <string, string>((IDictionary <string, string>) this._parameters, (IDictionary <string, string>)other._parameters));
     }
     return(false);
 }
 public bool Equals(HttpHeader other)
 {
     if (other != null)
     {
         return(IDictionaryExtensions.DictionaryEquals <string, HttpField>((IDictionary <string, HttpField>) this._fields, (IDictionary <string, HttpField>)other._fields));
     }
     return(false);
 }
 public async Task Transform(BuildContext context)
 {
     if (IDictionaryExtensions.Value(context.Build.Parameters, SCRIPT, out string script) && !String.IsNullOrEmpty(script))
     {
         using (var serviceScope = _scopeFactory.CreateScope())
         {
             var helper = serviceScope.ServiceProvider.GetRequiredService <OfficialRazorViewToStringRenderer>();
             await helper.RenderViewToStringAsync(script, context);
         }
     }
 }
Beispiel #5
0
        private static void CountErrors(Dictionary <string, int> map, ImmutableArray <DiagnosticData> diagnostics)
        {
            if (diagnostics.IsDefaultOrEmpty)
            {
                return;
            }

            foreach (var group in diagnostics.GroupBy(d => d.Id))
            {
                map[group.Key] = IDictionaryExtensions.GetValueOrDefault(map, group.Key) + group.Count();
            }
        }
Beispiel #6
0
        public void Initialize(IDictionary <string, object> parameters)
        {
            if (parameters != null)
            {
                if (IDictionaryExtensions.Value(parameters, "XmlPath", out string xmlPath))
                {
                    _xmlPath = xmlPath;
                }
            }

            LoadMap();
            Initialized = true;
        }
 public void Initialize(IDictionary <string, object> parameters)
 {
     Initialized = true;
     if (parameters != null)
     {
         if (IDictionaryExtensions.Value(parameters, "Name", out string name))
         {
             Name = name;
         }
         if (IDictionaryExtensions.Value(parameters, "Root", out string root))
         {
             _root = root;
         }
     }
     InitializeServices();
 }
Beispiel #8
0
        public void Initialize(IDictionary <string, object> paramters)
        {
            var connectionString = $"Data Source={AppPath.Relative(DB_NAME)};Version=3;";

            if (IDictionaryExtensions.Value(paramters, CONNECTION_STRING, out string connStr))
            {
                connectionString = connStr;
            }

            SqlMapper = SmartSqlMapperFactory.Create(new SmartSqlMapperFactory.CreateSmartSqlMapperOptions
            {
                Alias         = "SQLiteETLRepository",
                LoggerFactory = _loggerFactory,
                ProviderName  = "SQLite",
                SqlMapPath    = DEFAULT_SQLMAP_PATH,
                DataSource    = new DataSource
                {
                    ConnectionString = connectionString,
                    Name             = "SQLiteETL"
                }
            });
            Initialized = true;
        }
Beispiel #9
0
        private static ISuspendState GetSuspendState(this DependencyObject depObj, DependencyProperty dependencyProperty, bool create)
        {
            var suspendProps = create
        ? depObj.GetValueOrCreate(SuspendedPropertiesProperty, () => new Dictionary <DependencyProperty, ISuspendState>())
        : depObj.GetValue <Dictionary <DependencyProperty, ISuspendState> >(SuspendedPropertiesProperty);

            if (suspendProps == null)
            {
                return(DummySuspendState.Instance);
            }

            return(create ? suspendProps.GetValueOrCreate(dependencyProperty, () => new SuspendState()) : IDictionaryExtensions.GetValueOrDefault(suspendProps, dependencyProperty, DummySuspendState.Instance));
        }
Beispiel #10
0
 public TValue GetValueOrDefault(TKey key, TValue defaultValue = default(TValue))
 {
     return(IDictionaryExtensions.GetValueOrDefault(_key2ValueDictionary, key, defaultValue));
 }
Beispiel #11
0
 public TValue GetValueOrCreate(TKey key, Func <TKey, TValue> factory)
 {
     return(IDictionaryExtensions.GetValueOrCreate(_key2ValueDictionary, key, factory));
 }
Beispiel #12
0
 public TKey GetKeyOrDefault(TValue value, TKey defaultKey = default(TKey))
 {
     return(IDictionaryExtensions.GetValueOrDefault(_value2KeyDictionary, value, defaultKey));
 }
Beispiel #13
0
 public TKey GetKeyOrCreate(TValue value, Func <TValue, TKey> factory)
 {
     return(IDictionaryExtensions.GetValueOrCreate(_value2KeyDictionary, value, factory));
 }
Beispiel #14
0
 public Size GetCustomSize(int reduceLevel)
 {
     EnsureCustomSizeDictionary();
     return(IDictionaryExtensions.GetValueOrDefault(_customSizes, reduceLevel, Size.Empty));
 }
        public virtual void TestMethods()
        {
            CharArrayMap <int?> cm = new CharArrayMap <int?>(TEST_VERSION_CURRENT, 2, false);
            //Dictionary<string, int?> hm = new Dictionary<string, int?>();
            Dictionary <object, int?> hm = new Dictionary <object, int?>(); // TODO: In .NET, we cannot implicitly convert from string to object using generics

            hm["foo"] = 1;
            hm["bar"] = 2;
            cm.PutAll(hm);
            assertEquals(hm.Count, cm.Count);
            hm["baz"] = 3;
            cm.PutAll(hm);
            assertEquals(hm.Count, cm.Count);

            // TODO: In .NET we cannot make this conversion implicitly.
            CharArraySet cs = cm.Keys as CharArraySet;
            int          n  = 0;

            foreach (object o in cs)
            {
                assertTrue(cm.ContainsKey(o));
                char[] co = (char[])o;
                assertTrue(cm.ContainsKey(co, 0, co.Length));
                n++;
            }
            assertEquals(hm.Count, n);
            assertEquals(hm.Count, cs.Count);
            assertEquals(cm.Count, cs.Count);

            // TODO: This directly contradicts the TestModifyOnUnmodifiable test,
            // where clear is not allowed from the Keys property.
            //cs.Clear();
            //assertEquals(0, cs.Count);
            //assertEquals(0, cm.Count);
            try
            {
                cs.Add("test");
                fail("keySet() allows adding new keys");
            }
            catch (System.NotSupportedException)
            {
                // pass
            }
            cm.PutAll(hm);
            assertEquals(hm.Count, cs.Count);
            assertEquals(cm.Count, cs.Count);

            IEnumerator <KeyValuePair <object, int?> > iter1 = IDictionaryExtensions.EntrySet(cm).GetEnumerator();

            n = 0;
            while (iter1.MoveNext())
            {
                KeyValuePair <object, int?> entry = iter1.Current;
                object key = entry.Key;
                int?   val = entry.Value;
                assertEquals(cm.Get(key), val);

                // TODO: In .NET the Value property of KeyValuePair is read-only. Do we need a solution?
                //entry.Value = val * 100;
                //assertEquals(val * 100, (int)cm.Get(key));
                n++;
            }
            assertEquals(hm.Count, n);
            cm.Clear();
            cm.PutAll(hm);
            assertEquals(cm.size(), n);

            CharArrayMap <int?> .EntryIterator iter2 = cm.EntrySet().GetEnumerator() as CharArrayMap <int?> .EntryIterator;
            n = 0;
            while (iter2.MoveNext())
            {
                char[] keyc = (char[])iter2.Current.Key;
                int?   val  = iter2.Current.Value;
                assertEquals(hm[new string(keyc)], val);

                // TODO: In .NET the Value property of KeyValuePair is read-only. Do we need a solution?
                //iter2.Value = val * 100;
                //assertEquals(val * 100, (int)cm.Get(keyc));
                n++;
            }
            assertEquals(hm.Count, n);

            // TODO: In .NET, the EntrySet extension method makes a copy of the data
            // so clearing it won't work like this.
            cm.EntrySet().clear();
            assertEquals(0, cm.size());
            assertEquals(0, cm.EntrySet().size());
            assertTrue(cm.Count == 0);
        }