Ejemplo n.º 1
0
        //[Variation("Close on inner reader with CloseInput should not close the outer reader", Pri = 1, Params = new object[] { "true" })]
        //[Variation("Close on inner reader with CloseInput should not close the outer reader", Pri = 1, Params = new object[] { "false" })]

        public int v7()
        {
            if (!(IsFactoryTextReader() || IsBinaryReader() || IsFactoryValidatingReader()))
            {
                return(TEST_SKIPPED);
            }

            string            fileName = GetTestFileName(EREADER_TYPE.GENERIC);
            bool              ci       = bool.Parse(CurVariation.Params[0].ToString());
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.CloseInput = ci;
            CError.WriteLine(ci);
            MyDict <string, object> options = new MyDict <string, object>();

            options.Add(ReaderFactory.HT_FILENAME, fileName);
            options.Add(ReaderFactory.HT_READERSETTINGS, settings);

            ReloadSource(options);

            DataReader.PositionOnElement("elem2");
            XmlReader r = DataReader.ReadSubtree();

            CError.Compare(DataReader.ReadState, ReadState.Interactive, "ReadState not interactive");

            DataReader.Close();
            return(TEST_PASS);
        }
Ejemplo n.º 2
0
    static void Main(string[] args)
    {
        MyDict <string, int> d = new MyDict <string, int>();

        d.Add("hello", 666);
        d.Add("A", 1);
        d.Add("B", 2);
        d.Add("C", 3);

        MyDictInfo <string, int>(d);
        Console.ReadKey();
    }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            MyDict <string, MyObj> dict;

            dict = new MyDict <string, MyObj>();
            MyObj sampleObj = new MyObj();

            dict.Add("aaa", sampleObj);
            MyObj xxx = dict["aaa"];
        }
    public T Invoke(FastFunc <T, int> f, int bla)
    {
        if (cache == null)
        {
            cache = new MyDict <int, T> ();
        }

        T value = f.Invoke(bla);

        cache.Add(bla, value);

        return(value);
    }
    public static int Main()
    {
        StringFastFunc          sff = new StringFastFunc();
        ArrayFastFunc           aff = new ArrayFastFunc();
        IntCache <string>       ics = new IntCache <string> ();
        MyDict <string, string> dss = new MyDict <string, string> ();

        dss.Add("123", "456");

        ics.Invoke(sff, 123);
        ics.Invoke(sff, 456);

        IntCache <byte []> ica = new IntCache <byte []> ();

        ica.Invoke(aff, 1);
        ica.Invoke(aff, 2);
        ica.Invoke(aff, 3);

        return(0);
    }
Ejemplo n.º 6
0
        public bool CompareStringWithPrefixes(string strExpected)
        {
            MyDict <string, object> AutoIDs   = new MyDict <string, object>();
            List <string>           AttNames  = new List <string>();
            List <string>           AttScopes = new List <string>();

            string strActual = this.GetString();

            int expLen = (strExpected == null ? 0 : strExpected.Length);
            int actLen = (strActual == null ? 0 : strActual.Length);

            int minLen = (expLen < actLen ? expLen : actLen);

            // find the first different character
            int i, j = 0;

            for (i = 0; i < actLen; i++)
            {
                if (j >= expLen)
                {
                    CError.WriteLine("Output longer than expected!");
                    CError.WriteLine("Actual string: '" + strActual + "'");
                    return(false);
                }

                if (strExpected[j] != strActual[i])
                {
                    if (strExpected[j] != PREFIX_CHAR)
                    {
                        CError.WriteLine("Position:" + i);
                        CError.WriteLine("Expected char:'" + strExpected[i] + "'(" + Convert.ToInt32(strExpected[i]) + ")");
                        CError.WriteLine("Actual char:'" + strActual[i] + "'(" + Convert.ToInt32(strActual[i]) + ")");
                        return(false);
                    }

                    bool AutoGenerated = strExpected[++j] == AUTOGENERATED;
                    j += 2;
                    string ActName = "";
                    string ExpName = "";
                    string Scope   = "";
                    while (i <= actLen)
                    {
                        if (strActual[i] == '=' || strActual[i] == ' ' || strActual[i] == ':')
                        {
                            i--;
                            break;
                        }
                        else
                        {
                            ActName += strActual[i];
                        }
                        i++;
                    }
                    while (strExpected[j] != ' ')
                    {
                        ExpName += strExpected[j++];
                    }
                    j++;
                    while (strExpected[j] != PREFIX_CHAR)
                    {
                        Scope += strExpected[j++];
                    }

                    if (AutoGenerated)
                    {
                        if (AutoIDs.ContainsKey(ExpName))
                        {
                            if ((string)AutoIDs[ExpName] != ActName)
                            {
                                CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                                return(false);
                            }
                        }
                        else
                        {
                            AutoIDs.Add(ExpName, ActName);
                        }
                    }
                    else
                    {
                        if (ExpName != ActName)
                        {
                            CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                            return(false);
                        }
                    }

                    for (int k = 0; k < AttNames.Count; k++)
                    {
                        if ((string)AttNames[k] == ActName)
                        {
                            for (int m = 0; m < ((string)AttScopes[k]).Length; m++)
                            {
                                for (int n = 0; n < Scope.Length; n++)
                                {
                                    if (((string)AttScopes[k])[m] == Scope[n])
                                    {
                                        CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    AttNames.Add(ActName);
                    AttScopes.Add(Scope);
                }
                j++;
            }
            if (j != expLen)
            {
                CError.WriteLine("Output shorter than expected!");
                CError.WriteLine("Actual string: '" + strActual + "'");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        //[Variation("Close on inner reader with CloseInput should not close the outer reader", Pri = 1, Params = new object[] { "true" })]
        //[Variation("Close on inner reader with CloseInput should not close the outer reader", Pri = 1, Params = new object[] { "false" })]

        public int v7()
        {
            if (!(IsFactoryTextReader() || IsBinaryReader() || IsFactoryValidatingReader()))
            {
                return TEST_SKIPPED;
            }

            string fileName = GetTestFileName(EREADER_TYPE.GENERIC);
            bool ci = Boolean.Parse(CurVariation.Params[0].ToString());
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.CloseInput = ci;
            CError.WriteLine(ci);
            MyDict<string, object> options = new MyDict<string, object>();
            options.Add(ReaderFactory.HT_FILENAME, fileName);
            options.Add(ReaderFactory.HT_READERSETTINGS, settings);

            ReloadSource(options);

            DataReader.PositionOnElement("elem2");
            XmlReader r = DataReader.ReadSubtree();

            CError.Compare(DataReader.ReadState, ReadState.Interactive, "ReadState not interactive");

            DataReader.Close();
            return TEST_PASS;
        }
Ejemplo n.º 8
0
        public bool CompareStringWithPrefixes(string strExpected)
        {
            MyDict<string, object> AutoIDs = new MyDict<string, object>();
            List<string> AttNames = new List<string>();
            List<string> AttScopes = new List<string>();

            string strActual = this.GetString();

            int expLen = (strExpected == null ? 0 : strExpected.Length);
            int actLen = (strActual == null ? 0 : strActual.Length);

            int minLen = (expLen < actLen ? expLen : actLen);

            // find the first different character
            int i, j = 0;
            for (i = 0; i < actLen; i++)
            {
                if (j >= expLen)
                {
                    CError.WriteLine("Output longer than expected!");
                    CError.WriteLine("Actual string: '" + strActual + "'");
                    return false;
                }

                if (strExpected[j] != strActual[i])
                {
                    if (strExpected[j] != PREFIX_CHAR)
                    {
                        CError.WriteLine("Position:" + i);
                        CError.WriteLine("Expected char:'" + strExpected[i] + "'(" + Convert.ToInt32(strExpected[i]) + ")");
                        CError.WriteLine("Actual char:'" + strActual[i] + "'(" + Convert.ToInt32(strActual[i]) + ")");
                        return false;
                    }

                    bool AutoGenerated = strExpected[++j] == AUTOGENERATED;
                    j += 2;
                    string ActName = "";
                    string ExpName = "";
                    string Scope = "";
                    while (i <= actLen)
                    {
                        if (strActual[i] == '=' || strActual[i] == ' ' || strActual[i] == ':')
                        {
                            i--;
                            break;
                        }
                        else
                        {
                            ActName += strActual[i];
                        }
                        i++;
                    }
                    while (strExpected[j] != ' ')
                    {
                        ExpName += strExpected[j++];
                    }
                    j++;
                    while (strExpected[j] != PREFIX_CHAR)
                    {
                        Scope += strExpected[j++];
                    }

                    if (AutoGenerated)
                    {
                        if (AutoIDs.ContainsKey(ExpName))
                        {
                            if ((string)AutoIDs[ExpName] != ActName)
                            {
                                CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                                return false;
                            }
                        }
                        else
                        {
                            AutoIDs.Add(ExpName, ActName);
                        }
                    }
                    else
                    {
                        if (ExpName != ActName)
                        {
                            CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                            return false;
                        }
                    }

                    for (int k = 0; k < AttNames.Count; k++)
                    {
                        if ((string)AttNames[k] == ActName)
                        {
                            for (int m = 0; m < ((string)AttScopes[k]).Length; m++)
                                for (int n = 0; n < Scope.Length; n++)
                                    if (((string)AttScopes[k])[m] == Scope[n])
                                    {
                                        CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                                        return false;
                                    }
                        }
                    }
                    AttNames.Add(ActName);
                    AttScopes.Add(Scope);
                }
                j++;
            }
            if (j != expLen)
            {
                CError.WriteLine("Output shorter than expected!");
                CError.WriteLine("Actual string: '" + strActual + "'");
                return false;
            }

            return true;
        }