コード例 #1
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public void associationsDo(FuncNs.Func <AssociationType, Object> enumerator1)
 {
     foreach (var kvp in bindings)
     {
         enumerator1(kvp.Value);
     }
 }
コード例 #2
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public virtual void keysAndValuesDo(FuncNs.Func <KeyType, ValueType, Object> enumerator2)
 {
     foreach (var kvp in bindings)
     {
         AssociationType association = kvp.Value;
         enumerator2(association.Key, association.Value);
     }
 }
コード例 #3
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public virtual void valuesDo(FuncNs.Func <ValueType, Object> enumerator1)
 {
     foreach (var kvp in bindings)
     {
         AssociationType association = kvp.Value;
         enumerator1(association.Value);
     }
 }
コード例 #4
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public void keysDo(FuncNs.Func <KeyType, Object> enumerator1)
 {
     foreach (var kvp in bindings)
     {
         AssociationType association = kvp.Value;
         enumerator1(association.Key);
     }
 }
コード例 #5
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
        public virtual AssociationType associationAtIfAbsent(KeyType key, FuncNs.Func <AssociationType> notFoundAction)
        {
            AssociationType association;

            if (bindings.TryGetValue(key, out association))
            {
                return(association);
            }
            return(notFoundAction == null ? null : notFoundAction());
        }
コード例 #6
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public ValueType atIfAbsentPut(KeyType key, FuncNs.Func <ValueType> computeValueToBeAdded)
 {
     return(atIfAbsent(
                key,
                delegate() {
         ValueType value = computeValueToBeAdded();
         AssociationType association = newAssociation(key, value);
         association.keyBeImmutable();
         bindings[key] = association;
         return value;
     }));
 }
コード例 #7
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
        public Object removeKeyIfAbsent(KeyType key, FuncNs.Func <Object> notFoundAction)
        {
            AssociationType association;

            if (bindings.TryGetValue(key, out association))
            {
                if (!association.IsDeletable)
                {
                    throw new PrimNonDeletableKeyException("The association with the key " + key.ToString() + " is not removable from the KeyedCollection.");
                }
                bindings.Remove(key);
                return(association.Value);
            }
            else if (notFoundAction == null)
            {
                return(null);
            }
            else
            {
                return(notFoundAction());
            }
        }
コード例 #8
0
ファイル: ESLexicalUtility.cs プロジェクト: vlastik01/cSharp
        public static String[] elementsFromStream(this TextReader stream, char[] separatorChars, FuncNs.Func <Object, Object> transformer)
        {
            if (separatorChars == null || separatorChars.Length < 1)
            {
                var value = stream.nextWhile(ch => true);
                return(new String[] { transformer == null ? value : (String)transformer(value) });
            }
            if (separatorChars.Length < 2)
            {
                return(elementsFromStream(stream, separatorChars[0], transformer));
            }
            List <String> segments = new List <string>();
            StringBuilder segment  = new StringBuilder();

            while (true)
            {
                int next = stream.Peek();
                while (next != -1 && Array.FindIndex <char>(separatorChars, ch => ch == next) < 0)
                {
                    segment.Append((char)stream.Read());
                    next = stream.Peek();
                }
                String element = transformer == null?segment.ToString() : (String)transformer(segment.ToString());

                if (!String.IsNullOrEmpty(element))
                {
                    segments.Add(element);
                }
                if (next == -1)
                {
                    return(segments.ToArray());
                }
                segment = new StringBuilder();                 // Should be segment.Clear(), but that's not supported in .Net 3.5
                stream.Read();
            }
        }
コード例 #9
0
ファイル: ESLexicalUtility.cs プロジェクト: vlastik01/cSharp
 public static String[]  elementsFromString(this String pathString, char[] separatorChars, FuncNs.Func <Object, Object> transformer)
 {
     return(elementsFromStream(new StringReader(pathString), separatorChars, transformer));
 }
コード例 #10
0
ファイル: ESLexicalUtility.cs プロジェクト: vlastik01/cSharp
        public static String[] elementsFromStream(this TextReader stream, char separatorChar, FuncNs.Func <Object, Object> transformer)
        {
            List <String> segments = new List <string>();
            StringBuilder segment  = new StringBuilder();

            while (true)
            {
                int next = stream.Peek();
                while (next != -1 && next != separatorChar)
                {
                    segment.Append((char)stream.Read());
                    next = stream.Peek();
                }
                String element = transformer == null?segment.ToString() : (String)transformer(segment.ToString());

                if (!String.IsNullOrEmpty(element))
                {
                    segments.Add(element);
                }
                if (next == -1)
                {
                    return(segments.ToArray());
                }
                segment = new StringBuilder();                 // Should be segment.Clear(), but that's not supported in .Net 3.5
                stream.Read();
            }
        }
コード例 #11
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public Object _keysAndValuesDo_(Object receiver, Object enumerator2)
 {
     FuncNs.Func <Object, Object, Object> f2 = asFunctor2(enumerator2);
     ((ESIdentityDictionary)receiver).keysAndValuesDo((key, value) => f2(key, value));
     return(receiver);
 }
コード例 #12
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public Object _valuesDo_(Object receiver, Object enumerator1)
 {
     FuncNs.Func <Object, Object> f1 = asFunctor1(enumerator1);
     ((ESIdentityDictionary)receiver).valuesDo(key => f1(key));
     return(receiver);
 }
コード例 #13
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
 public Object _associationsDo_(Object receiver, Object enumerator1)
 {
     FuncNs.Func <Object, Object> f1 = asFunctor1(enumerator1);
     ((ESIdentityDictionary)receiver).associationsDo(association => f1(association));
     return(receiver);
 }
コード例 #14
0
ファイル: ESDictionaries.cs プロジェクト: vlastik01/cSharp
        public virtual ValueType atIfAbsent(KeyType key, FuncNs.Func <ValueType> notFoundAction)
        {
            var association = associationAtIfAbsent(key, null);

            return(association == null ? (notFoundAction == null ? null : notFoundAction()) : association.Value);
        }