Ejemplo n.º 1
0
 public FuncSymbol(string identifier, TwisterType type, SymbolAttribute attributes, object value)
 {
     Identifier = identifier;
     DataType   = type;
     Attributes = attributes;
     Value      = value;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// This methods implements 'ToString' for the object <code>obj</code> using reflection.
        /// <code>Filter</code> allows you to filter properties or fields: which properties are visibles.
        /// </summary>
        /// <param name="obj">Object.</param>
        /// <param name="filter">Filter properties: which properties are visibles.</param>
        /// <returns>ToString.</returns>
        public static string ReflectionToString(object obj, Func <string, bool> filter)
        {
            StringBuilder buff = new StringBuilder();

            Type type = obj.GetType();

            foreach (MemberInfo memberInfo in GetBottomUpPropertiesAndFieldsFor(type))
            {
                if (filter(memberInfo.Name))
                {
                    object value = Utils.GetValue(obj, memberInfo);

                    FormatAttribute formatAttr = memberInfo.GetCustomAttribute <FormatAttribute>();
                    string          format     = (formatAttr != null) ? formatAttr.Format : "";

                    buff.AppendFormat("{0} = {1}", memberInfo.Name, ToString(value, format));

                    SymbolAttribute attr = memberInfo.GetCustomAttribute <SymbolAttribute>();
                    if (attr != null && attr.SymbolProperty != null)
                    {
                        object symbol = GetValue(obj, attr.SymbolProperty);
                        if (symbol != null)
                        {
                            buff.AppendFormat(" {0}", ToString(symbol, ""));
                        }
                    }

                    buff.AppendLine();
                }
            }

            return(buff.ToString());
        }
Ejemplo n.º 3
0
 public BasicSymbol(string identifier, SymbolKind kind, SymbolAttribute attributes,
                    TwisterType dataType, object value)
 {
     Identifier = identifier;
     Kind       = kind;
     Attributes = attributes;
     DataType   = dataType;
     Value      = value;
 }