/// <summary>
        /// Prepares the descriptor for hard-wiring.
        /// The descriptor fills the passed table with all the needed data for hardwire generators to generate the appropriate code.
        /// </summary>
        /// <param name="t">The table to be filled</param>
        public void PrepareForWiring(Table t)
        {
            t.Set("class", DynValue.NewString(this.GetType().FullName));
            t.Set("name", DynValue.NewString(this.Name));
            t.Set("decltype", DynValue.NewString(this.DeclaringType.FullName));
            DynValue mst = DynValue.NewPrimeTable();

            t.Set("overloads", mst);

            int i = 0;

            foreach (var m in this.m_Overloads)
            {
                IWireableDescriptor sd = m as IWireableDescriptor;

                if (sd != null)
                {
                    DynValue mt = DynValue.NewPrimeTable();
                    mst.Table.Set(++i, mt);
                    sd.PrepareForWiring(mt.Table);
                }
                else
                {
                    mst.Table.Set(++i, DynValue.NewString(string.Format("unsupported - {0} is not serializable", m.GetType().FullName)));
                }
            }
        }
Ejemplo n.º 2
0
        private void Serialize(Table t, IEnumerable <KeyValuePair <string, IMemberDescriptor> > members)
        {
            foreach (var pair in members)
            {
                IWireableDescriptor sd = pair.Value as IWireableDescriptor;

                if (sd != null)
                {
                    DynValue mt = DynValue.NewPrimeTable();
                    t.Set(pair.Key, mt);
                    sd.PrepareForWiring(mt.Table);
                }
                else
                {
                    t.Set(pair.Key, DynValue.NewString("unsupported member type : " + pair.Value.GetType().FullName));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a table with the description of registered types.
        /// </summary>
        /// <param name="useHistoricalData">if set to true, it will also include the last found descriptor of all unregistered types.</param>
        /// <returns></returns>
        public static Table GetDescriptionOfRegisteredTypes(bool useHistoricalData = false)
        {
            DynValue output = DynValue.NewPrimeTable();
            var      registeredTypesPairs = useHistoricalData ? TypeDescriptorRegistry.RegisteredTypesHistory : TypeDescriptorRegistry.RegisteredTypes;

            foreach (var descpair in registeredTypesPairs)
            {
                IWireableDescriptor sd = descpair.Value as IWireableDescriptor;

                if (sd != null)
                {
                    DynValue t = DynValue.NewPrimeTable();
                    output.Table.Set(descpair.Key.FullName, t);
                    sd.PrepareForWiring(t.Table);
                }
            }

            return(output.Table);
        }