Esempio n. 1
0
        /// <summary>
        /// Helper that converts members of an Enum to pairs name and corresponding value and fills up the Hashtable.
        /// </summary>
        /// <param name="AddressSpaceEnum">The address space enum.</param>
        /// <param name="StartEndPairs">The start end pairs. SortedList that represents Start and End Points for selected AddressSpace.
        /// The Key of the SortedList is linked to values in the Enum that is passed as AddressSpaceEnum</param>
        /// <returns>table of descriptors</returns>
        protected IAddressSpaceDescriptor[] GetAvailiableAddressspacesHelper(Type AddressSpaceEnum, SortedList <short, StartEndPair> StartEndPairs)
        {
            Array EnumValues = Enum.GetValues(AddressSpaceEnum);

            if (StartEndPairs == null)
            {
                StartEndPairs = new SortedList <short, StartEndPair>();
                //default starts and end should be used
                StartEndPair defaultStartEndPair = new StartEndPair(0, long.MaxValue);
                for (int idx = 0; idx < EnumValues.Length; idx++)
                {
                    StartEndPairs.Add(System.Convert.ToInt16(EnumValues.GetValue(idx)), defaultStartEndPair);
                }
            }
            IAddressSpaceDescriptor[] table = new IAddressSpaceDescriptor[EnumValues.Length];
            for (int idx = 0; idx < EnumValues.Length; idx++)
            {
                short currentidentifier    = System.Convert.ToInt16(EnumValues.GetValue(idx));
                AddressSpaceDescriptor asd = new AddressSpaceDescriptor(
                    Enum.GetName(AddressSpaceEnum, EnumValues.GetValue(idx)),
                    currentidentifier, StartEndPairs[currentidentifier].StartAddress,
                    StartEndPairs[currentidentifier].EndAddress);
                table[idx] = asd;
            }
            return(table);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AddressSpaceDescriptor"/> class.
 /// </summary>
 /// <param name="_Name">Name of the address space.</param>
 /// <param name="_Identifier">The identifier.</param>
 /// <param name="_StartAddress">The start address.</param>
 /// <param name="_EndAddress">The end address.</param>
 public AddressSpaceDescriptor(string _Name, short _Identifier, long _StartAddress, long _EndAddress)
 {
     name         = _Name;
     identifier   = _Identifier;
     startendpair = new StartEndPair(_StartAddress, _EndAddress);
 }