Exemplo n.º 1
0
    //=========================================================================
    /// <summary>
    /// Get a list of component properties from the component description.
    /// This will include all arrays, records and scalars.
    /// This function is primarily used by the TextOutput component
    /// to display the readable properties that can be selected
    /// for output.
    /// </summary>
    /// <param name="TypeName"></param>
    /// <returns>List of properties</returns>
    public List <TCompProperty> VariableList(string TypeName)
    {
        List <TCompProperty> Vars = new List <TCompProperty>();

        foreach (string FileName in Dlls(TypeName))
        {
            string DLLFileName = Configuration.RemoveMacros(FileName);
            string ClassName   = ProxyClassName(TypeName, DLLFileName);

            //attempt to get these details from getDescription()
            String descr = "";
            descr = DLLProber.ProbeDLLForDescriptionXML(ClassName, DLLFileName);
            if (descr.Length > 0)
            {
                TComponentDescrParser comp = new TComponentDescrParser(descr);
                //need to read all the properties information
                String propertySDML = comp.firstProperty();
                while (propertySDML.Length > 0)
                {
                    //create a property attribute of this class
                    TCompProperty newProperty;
                    newProperty = new TCompProperty(propertySDML);
                    if ((newProperty.Name.ToLower() != STRSUBEVENT_ARRAY) &&
                        (newProperty.Name.ToLower() != STRPUBEVENT_ARRAY) &&
                        (newProperty.Name.ToLower() != STRDRIVER_ARRAY))
                    {
                        Vars.Add(newProperty);
                    }
                    propertySDML = comp.nextProperty();
                }
            }
        }
        return(Vars);
    }
Exemplo n.º 2
0
        //=======================================================================
        /// <summary>
        /// Creates a new TCompProperty that represents a property in the
        /// component description.
        /// </summary>
        /// <param name="xmltext"></param>
        //=======================================================================
        protected void defineNewProperty(String xmltext)
        {
            TCompProperty newProperty;

            newProperty = new TCompProperty(xmltext);
            propertyList.Add(newProperty);
        }
Exemplo n.º 3
0
        //=======================================================================
        /// <summary>
        /// Initialise the lists of properties with values from the init section
        /// SDML. And reload the tree with the values.
        /// </summary>
        /// <param name="initXML">The init section which is <code><initsection>...</initsection></code></param>
        //=======================================================================
        private Boolean InitFromInitSection(String initXML)
        {
            if (initXML.Length > 0)
            {
                typedvals.Clear();
                TInitParser initPsr = new TInitParser(initXML);

                for (int i = 1; i <= initPsr.initCount(); i++)
                {
                    String     initText = initPsr.initText((uint)i);
                    TSDMLValue sdmlinit = new TSDMLValue(initText, "");
                    typedvals.Add(sdmlinit);
                }
            }
            //if the component description is valid then use it.
            if (propertyList.Count > 0)
            {
                foreach (TTypedValue value in typedvals)    //for every init section value
                {
                    //find the property in the component description list
                    int           i    = 0;
                    TCompProperty prop = propertyList[i];
                    while ((prop != null) && (i < propertyList.Count))
                    {
                        if (value.Name.ToLower() == prop.Name.ToLower())
                        {
                            prop.InitValue.setValue(value); //set the property's value
                        }
                        i++;
                        if (i < propertyList.Count)
                        {
                            prop = propertyList[i];
                        }
                    }
                }
            }
            if (propertyList.Count > 0)
            {
                populateTreeModel(propertyList);            //can populate with the full list
            }
            else
            {
                populateTreeModel();                        //use init section only
            }
            return((initXML.Length > 0) || (propertyList.Count > 0));
        }
Exemplo n.º 4
0
    //=========================================================================
    public List <MetaDataInfo> Variables(string TypeName)
    {
        List <MetaDataInfo> Names = new List <MetaDataInfo>();

        foreach (string FileName in Dlls(TypeName))
        {
            string DLLFileName = Configuration.RemoveMacros(FileName);
            string ClassName   = ProxyClassName(TypeName, DLLFileName);

            Type T = GetProbeInfoAssembly().GetType("ModelFramework." + ClassName);
            if (T != null)
            {
                foreach (PropertyInfo Property in T.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public))
                {
                    string Description = "";
                    string Units       = "";
                    foreach (object Attribute in Property.GetCustomAttributes(false))
                    {
                        if (Attribute.GetType().Name == "Description")
                        {
                            Description = Attribute.ToString();
                        }
                        if (Attribute.GetType().Name == "Units")
                        {
                            Units = Attribute.ToString();
                        }
                    }
                    MetaDataInfo Info = new MetaDataInfo();
                    Info.Name        = Property.Name;
                    Info.Description = Description;
                    Info.Units       = Units;
                    Info.IsArray     = Property.PropertyType.IsArray;
                    Info.IsRecord    = (Property.GetType().IsValueType&& !Property.GetType().IsEnum&& !Property.GetType().IsPrimitive&& Property.GetType() != typeof(decimal));
                    Names.Add(Info);
                }
            }
            else
            {
                //attempt to get these details from getDescription()
                String descr = "";
                descr = DLLProber.ProbeDLLForDescriptionXML(ClassName, DLLFileName);
                if (descr.Length > 0)
                {
                    TComponentDescrParser comp = new TComponentDescrParser(descr);
                    //need to read all the properties information
                    String propertySDML = comp.firstProperty();
                    while (propertySDML.Length > 0)
                    {
                        //create a property attribute of this class
                        TCompProperty newProperty;
                        newProperty = new TCompProperty(propertySDML);
                        if ((newProperty.Name.ToLower() != STRSUBEVENT_ARRAY) &&
                            (newProperty.Name.ToLower() != STRPUBEVENT_ARRAY) &&
                            (newProperty.Name.ToLower() != STRDRIVER_ARRAY))
                        {
                            MetaDataInfo Info = new MetaDataInfo();
                            Info.Name        = newProperty.Name;
                            Info.Description = "Descr " + newProperty.sDescr;
                            Info.Units       = newProperty.InitValue.units();
                            Info.IsArray     = newProperty.InitValue.isArray();
                            Info.IsRecord    = newProperty.InitValue.isRecord();
                            Names.Add(Info);
                        }
                        propertySDML = comp.nextProperty();
                    }
                }
            }
        }
        return(Names);
    }