Esempio n. 1
0
        public static string ToString(object value, EPropAssoc assoc)
        {
            if (value is bool)
            {
                bool bvalue = (bool)value;
                return(bvalue ? "true" : "false");
            }
            Type             type      = value.GetType();
            IList <PropDesc> allFields = EnumProps(type);
            PropDesc         pd        = (from PropDesc pdi in allFields
                                          where pdi.EnumValue.Equals(value)
                                          select pdi).SingleOrDefault();
            string result;

            if (pd == null || !pd.IDs.TryGetValue(assoc, out result))
            {
                if (value is double)
                {
                    double dbl = (double)value;
                    result = dbl.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    result = value.ToString();
                }
            }
            return(result);
        }
Esempio n. 2
0
        private CoreGenDescription CreateCoreGenFile(string path, EPropAssoc assoc)
        {
            CoreGenDescription cdesc = new CoreGenDescription(path);

            cdesc.FromProject(this, assoc);
            return(cdesc);
        }
Esempio n. 3
0
 public static string ToString(PropertyInfo pi, EPropAssoc assoc)
 {
     object[] attrs = pi.GetCustomAttributes(typeof(PropID), true);
     foreach (PropID propID in attrs)
     {
         if (propID.Assoc == assoc)
         {
             return(propID.ID);
         }
     }
     throw new InvalidOperationException("No property ID found for given association");
 }
Esempio n. 4
0
        public PropertyBag Copy(EPropAssoc assoc)
        {
            PropertyBag result = new PropertyBag();

            foreach (var pd in PropEnum.EnumProps(typeof(EXilinxProjectProperties)))
            {
                EXilinxProjectProperties key = (EXilinxProjectProperties)pd.EnumValue;
                object value;
                if (pd.IDs.ContainsKey(assoc) && Properties.TryGetValue(key, out value))
                {
                    result.PutProperty(key, value);
                }
            }
            return(result);
        }
Esempio n. 5
0
        internal static void FromProject(this CoreGenDescription desc, XilinxProject proj, EPropAssoc assoc)
        {
            PropertyBag pbag = proj.PBag.Copy(assoc);
            if (assoc == EPropAssoc.CoreGenProj)
            {
                string fname = Path.GetFileNameWithoutExtension(desc.Path);
                string wdir = "./tmp/" + fname + "/";
                pbag.PutProperty(EXilinxProjectProperties.CoreGen_WorkingDirectory, wdir);
            }
            IList<PropDesc> allProps = PropEnum.EnumProps(typeof(EXilinxProjectProperties));
            foreach (PropDesc pd in allProps)
            {
                if (!pd.IDs.ContainsKey(assoc))
                    continue;

                object value = pbag.GetProperty((EXilinxProjectProperties)pd.EnumValue);
                desc.Set(pd.IDs[assoc], PropEnum.ToString(value, assoc), value.GetType());
            }
        }
Esempio n. 6
0
        internal static void FromProject(this CoreGenDescription desc, XilinxProject proj, EPropAssoc assoc)
        {
            PropertyBag pbag = proj.PBag.Copy(assoc);

            if (assoc == EPropAssoc.CoreGenProj)
            {
                string fname = Path.GetFileNameWithoutExtension(desc.Path);
                string wdir  = "./tmp/" + fname + "/";
                pbag.PutProperty(EXilinxProjectProperties.CoreGen_WorkingDirectory, wdir);
            }
            IList <PropDesc> allProps = PropEnum.EnumProps(typeof(EXilinxProjectProperties));

            foreach (PropDesc pd in allProps)
            {
                if (!pd.IDs.ContainsKey(assoc))
                {
                    continue;
                }

                object value = pbag.GetProperty((EXilinxProjectProperties)pd.EnumValue);
                desc.Set(pd.IDs[assoc], PropEnum.ToString(value, assoc), value.GetType());
            }
        }
Esempio n. 7
0
 public PropID(EPropAssoc assoc, string id)
 {
     Assoc = assoc;
     ID    = id;
 }
Esempio n. 8
0
 public PropID(EPropAssoc assoc, string id)
 {
     Assoc = assoc;
     ID = id;
 }
Esempio n. 9
0
 public PropertyBag Copy(EPropAssoc assoc)
 {
     PropertyBag result = new PropertyBag();
     foreach (var pd in PropEnum.EnumProps(typeof(EXilinxProjectProperties)))
     {
         EXilinxProjectProperties key = (EXilinxProjectProperties)pd.EnumValue;
         object value;
         if (pd.IDs.ContainsKey(assoc) && Properties.TryGetValue(key, out value))
             result.PutProperty(key, value);
     }
     return result;
 }
Esempio n. 10
0
 public static string ToString(PropertyInfo pi, EPropAssoc assoc)
 {
     object[] attrs = pi.GetCustomAttributes(typeof(PropID), true);
     foreach (PropID propID in attrs)
     {
         if (propID.Assoc == assoc)
             return propID.ID;
     }
     throw new InvalidOperationException("No property ID found for given association");
 }
Esempio n. 11
0
 public static string ToString(object value, EPropAssoc assoc)
 {
     if (value is bool)
     {
         bool bvalue = (bool)value;
         return bvalue ? "true" : "false";
     }
     Type type = value.GetType();
     IList<PropDesc> allFields = EnumProps(type);
     PropDesc pd = (from PropDesc pdi in allFields
                    where pdi.EnumValue.Equals(value)
                    select pdi).SingleOrDefault();
     string result;
     if (pd == null || !pd.IDs.TryGetValue(assoc, out result))
     {
         if (value is double)
         {
             double dbl = (double)value;
             result = dbl.ToString(CultureInfo.InvariantCulture);
         }
         else
         {
             result = value.ToString();
         }
     }
     return result;
 }