Beispiel #1
0
        private MetadataLibrary()
        {
            fIdDefLookup  = new Dictionary <int, MetadataDefinition>();
            fNameIdLookup = new Dictionary <string, int>();

            try
            {
                //        using (Stream stream = new FileStream("TagDefinitions.json", FileMode.Open, FileAccess.Read))
                using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(RESOURCENAME))
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string input = reader.ReadToEnd();
                        var    json  = Json.Deserialize <MetadataDefinition>(input);

                        foreach (KeyValuePair <string, MetadataDefinition> kv in json)
                        {
                            MetadataDefinition defn = kv.Value;

                            if (String.IsNullOrEmpty(defn.Category))
                            {
                                defn.Category = "General";
                            }

                            fIdDefLookup.Add(defn.Id, defn);
                            fNameIdLookup.Add(defn.Category + "." + defn.Name, defn.Id);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                fIdDefLookup.Clear();
                fNameIdLookup.Clear();
            }
        }
Beispiel #2
0
 public MetadataItem(MetadataDefinition defn, object value = null)
 {
     Definition = defn;
     Value      = value;
 }