Beispiel #1
0
        private string GetIntegerValue <T>(IByteProvider provider, long pos, bool littleEndian) where T : struct
        {
            GenericDataValue <T> value = new GenericDataValue <T>("", new T(), littleEndian);

            byte[] data = GetBytesFromProvider(provider, pos, Marshal.SizeOf(typeof(T)));

            if (data != null)
            {
                value.FromArray(data);

                return(String.Format("{0}/0x{0:X}", value.Value));
            }
            else
            {
                return("?");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Extend selection syntax for nodes to handle global and meta parameters through
        /// # and $ prefixes
        /// </summary>
        /// <param name="path">The path to select</param>
        /// <param name="frame">The data frame to select off</param>
        /// <param name="node">The current node</param>
        /// <param name="globalMeta">Global meta</param>
        /// <param name="properties">Property bag</param>
        /// <param name="uuid">The uuid for private names</param>
        /// <param name="meta">Meta</param>
        /// <returns>An array of nodes</returns>
        public static DataNode[] SelectNodes(string path, DataFrame frame, MetaDictionary meta, MetaDictionary globalMeta, 
            PropertyBag properties, Guid uuid, BasePipelineNode node)
        {
            DataNode[] nodes = new DataNode[0];

            path = path.Trim();

            if (path.StartsWith("#"))
            {
                if (meta != null)
                {
                    string name = path.Substring(1);
                    object n = meta.GetMeta(MakePrivateMetaName(uuid, name));
                    if(n == null)
                    {
                        n = meta.GetMeta(name);
                    }

                    if (n != null)
                    {
                        nodes = new DataNode[1];
                        nodes[0] = new StringDataValue(path, n.ToString());
                    }
                }
            }
            else if (path.StartsWith("$"))
            {
                if (globalMeta != null)
                {
                    string name = path.Substring(1);
                    object n = globalMeta.GetMeta(MakePrivateMetaName(uuid, name));
                    if (n == null)
                    {
                        n = globalMeta.GetMeta(name);
                    }

                    if (n != null)
                    {
                        nodes = new DataNode[1];
                        nodes[0] = new StringDataValue(path, n.ToString());
                    }
                }
            }
            else if (path.StartsWith("~"))
            {
                if(properties != null)
                {
                    string name = path.Substring(1);
                    dynamic val = properties.GetRelativeValue(name);

                    if (val != null)
                    {
                        nodes = new DataNode[1];
                        nodes[0] = new StringDataValue(path, val.ToString());
                    }
                }
            }
            else if (path.StartsWith("&"))
            {
                DataNode n = null;

                if (path.Equals("&incount", StringComparison.OrdinalIgnoreCase))
                {
                    n = new GenericDataValue<int>(path, node != null ? node.InputPacketCount : 0);
                }
                else if (path.Equals("&outcount", StringComparison.OrdinalIgnoreCase))
                {
                    n = new GenericDataValue<int>(path, node != null ? node.OutputPacketCount : 0);
                }
                else if (path.Equals("&bytecount", StringComparison.OrdinalIgnoreCase))
                {
                    n = new GenericDataValue<long>(path, node != null ? node.ByteCount : 0);
                }
                else if (path.Equals("&length", StringComparison.OrdinalIgnoreCase))
                {
                    n = new GenericDataValue<long>(path, frame.Length);
                }
                else if (path.Equals("&md5", StringComparison.OrdinalIgnoreCase))
                {
                    n = new StringDataValue(path, frame.Hash);
                }
                else if (path.Equals("&display", StringComparison.OrdinalIgnoreCase))
                {
                    n = new StringDataValue(path, frame.ToString());
                }

                if (n != null)
                {
                    nodes = new DataNode[1];
                    nodes[0] = n;
                }
            }
            else
            {
                nodes = frame.SelectNodes(path);
            }

            return nodes;
        }
Beispiel #3
0
        /// <summary>
        /// Add a new signed byte value
        /// </summary>
        /// <param name="name">The name of the value</param>
        /// <param name="value">The value itself</param>
        /// <returns>The added value object</returns>
        public DataValue AddValue(string name, sbyte value)
        {
            DataValue dataValue = new GenericDataValue<sbyte>(name, value);
            AddSubNode(dataValue);

            return dataValue;
        }
Beispiel #4
0
        /// <summary>
        /// Add a ulong value to the key
        /// </summary>
        /// <param name="name">The name of the value</param>
        /// <param name="value">The value itself</param>
        /// <param name="littleEndian">True to add as little endian</param>
        /// <returns>The added data value</returns>
        public DataValue AddValue(string name, ulong value, bool littleEndian)
        {
            DataValue dataValue = new GenericDataValue<ulong>(name, value, littleEndian);
            AddSubNode(dataValue);

            return dataValue;
        }
Beispiel #5
0
        /// <summary>
        /// Add a boolean value
        /// </summary>
        /// <param name="name">The name of the value</param>
        /// <param name="value">The value itself</param>
        /// <returns>The added value object</returns>
        public DataValue AddValue(string name, bool value)
        {
            DataValue dataValue = new GenericDataValue<bool>(name, value);

            AddSubNode(dataValue);

            return dataValue;
        }