示例#1
0
        /// <summary />
        public static void SelectDescendentsSpeed(object it)
        {
            int iterations = (int)it;

            long            start;
            long            end;
            XPathNavigator  context = new XPathDocument(@"..\data.xml").CreateNavigator();
            XPathExpression expr    = context.Compile("descendant-or-self::publishers");

            context.MoveToFirstChild();

            start = DateTime.Now.Ticks;
            for (int i = 0; i < iterations; i++)
            {
                context.Select(expr);
            }
            end = DateTime.Now.Ticks;
            //Console.WriteLine("Elapsed time for compiled expression select: {0}", TimeSpan.FromTicks(end - start).TotalMilliseconds);

            string ns = Schema.Namespace;

            start = DateTime.Now.Ticks;
            for (int i = 0; i < iterations; i++)
            {
                context.SelectDescendants("publisher", ns, true);
            }
            end = DateTime.Now.Ticks;
            //Console.WriteLine("Elapsed time for descendents select: {0}", TimeSpan.FromTicks(end - start).TotalMilliseconds);
        }
示例#2
0
        /// <summary />
        public static void SelectChildrenSpeed(int it)
        {
            int            iterations = (int)it;
            long           start;
            long           end;
            XPathNavigator context = new XPathDocument(@"..\data.xml").CreateNavigator();

            context.MoveToFirstChild();
            XPathExpression     expr = context.Compile("child::sch:assert");
            XmlNamespaceManager mgr  = new XmlNamespaceManager(context.NameTable);

            mgr.AddNamespace("dv", "deverest:schemas");
            mgr.AddNamespace("sch", Schema.Namespace);
            expr.SetContext(mgr);

            start = DateTime.Now.Ticks;
            for (int i = 0; i < iterations; i++)
            {
                context.Select(expr);
            }
            end = DateTime.Now.Ticks;
            //Console.WriteLine("Elapsed time for compiled expression select: {0}", TimeSpan.FromTicks(end - start).TotalMilliseconds);

            string ns = Schema.Namespace;

            start = DateTime.Now.Ticks;
            for (int i = 0; i < iterations; i++)
            {
                context.SelectChildren("assert", ns);
            }
            end = DateTime.Now.Ticks;
            //Console.WriteLine("Elapsed time for children select: {0}", TimeSpan.FromTicks(end - start).TotalMilliseconds);
        }
示例#3
0
    private static string FindNativeLibraryForDllMap(string asmConfig, string pinvokeModule)
    {
        var navigator  = new XPathDocument(asmConfig).CreateNavigator();
        var expression = navigator.Compile("/configuration/dllmap");
        var iter       = navigator.Select(expression);

        while (iter.MoveNext())
        {
            if (iter.Current.GetAttribute("dll", navigator.NamespaceURI) != pinvokeModule)
            {
                continue;
            }

            // FIXME: make this configurable on the confinement
            var os = iter.Current.GetAttribute("os", navigator.NamespaceURI);
            if (String.IsNullOrEmpty(os) || os == "osx" || os == "!windows")
            {
                return(iter.Current.GetAttribute("target", navigator.NamespaceURI));
            }
        }

        return(pinvokeModule);
    }
示例#4
0
    private static string FindNativeLibraryForDllMap(string asmConfig, string pinvokeModule)
    {
        var navigator = new XPathDocument (asmConfig).CreateNavigator ();
        var expression = navigator.Compile ("/configuration/dllmap");
        var iter = navigator.Select (expression);

        while (iter.MoveNext ()) {
            if (iter.Current.GetAttribute ("dll", navigator.NamespaceURI) != pinvokeModule) {
                continue;
            }

            // FIXME: make this configurable on the confinement
            var os = iter.Current.GetAttribute ("os", navigator.NamespaceURI);
            if (String.IsNullOrEmpty (os) || os == "osx" || os == "!windows") {
                return iter.Current.GetAttribute ("target", navigator.NamespaceURI);
            }
        }

        return pinvokeModule;
    }
示例#5
0
        internal static ArrayList GetMessageStructure(string inputMsgFile, CommunicationManager.ReceiverType RxType, int mid, int sid, string protocol, string version)
        {
            XPathNavigator navigator = new XPathDocument(inputMsgFile).CreateNavigator();
            int            num       = 2;
            int            num2      = 2;
            int            num3      = 0;

            if (RxType == CommunicationManager.ReceiverType.SLC)
            {
                num3 = 1;
            }
            ArrayList         list      = new ArrayList();
            SLCMsgStructure   structure = new SLCMsgStructure();
            int               num4      = 0;
            XPathExpression   expr      = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '", sid, "']/field" }));
            XPathNodeIterator iterator  = navigator.Select(expr);

            if (iterator.Count == 0)
            {
                expr     = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '']/field" }));
                iterator = navigator.Select(expr);
            }
            try
            {
                int num5 = 0;
                int num6 = 0;
                while (iterator.MoveNext())
                {
                    XPathNavigator navigator2 = iterator.Current.Clone();
                    if (navigator2.GetAttribute("name", "").Contains("LOOP"))
                    {
                        num5 = int.Parse(navigator2.GetAttribute("numloops", ""));
                        num6 = int.Parse(navigator2.GetAttribute("numlines", ""));
                        for (int i = 0; i < num5; i++)
                        {
                            for (int j = 0; j < num6; j++)
                            {
                                iterator.MoveNext();
                                navigator2            = iterator.Current.Clone();
                                structure.fieldNumber = iterator.CurrentPosition;
                                structure.fieldName   = navigator2.GetAttribute("name", "");
                                structure.bytes       = int.Parse(navigator2.GetAttribute("bytes", ""));
                                structure.datatype    = navigator2.GetAttribute("datatype", "");
                                structure.units       = navigator2.GetAttribute("units", "");
                                if (navigator2.GetAttribute("scale", "") == "")
                                {
                                    structure.scale = 1.0;
                                }
                                else
                                {
                                    structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                                }
                                structure.startByte    = (((num + num2) + num3) + 1) + num4;
                                structure.endByte      = (structure.startByte + structure.bytes) - 1;
                                structure.defaultValue = navigator2.GetAttribute("default", "");
                                num4 += structure.bytes;
                                list.Add(structure);
                            }
                        }
                    }
                    else
                    {
                        structure.fieldNumber = iterator.CurrentPosition;
                        structure.fieldName   = navigator2.GetAttribute("name", "");
                        structure.bytes       = int.Parse(navigator2.GetAttribute("bytes", ""));
                        structure.datatype    = navigator2.GetAttribute("datatype", "");
                        structure.units       = navigator2.GetAttribute("units", "");
                        if (navigator2.GetAttribute("scale", "") == "")
                        {
                            structure.scale = 1.0;
                        }
                        else
                        {
                            structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                        }
                        structure.startByte    = (((num + num2) + num3) + 1) + num4;
                        structure.endByte      = (structure.startByte + structure.bytes) - 1;
                        structure.defaultValue = navigator2.GetAttribute("default", "");
                        num4 += structure.bytes;
                        list.Add(structure);
                    }
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(list);
        }