예제 #1
0
        public static String GetDescription(this uint identifier, ContainerType map, Dictionary <uint, string> customDict = null)
        {
            Dictionary <uint, string> NameDictionary = new Dictionary <uint, string>();

            if (customDict == null)
            {
                switch (map)
                {
                case ContainerType.SummaryInfo:
                    NameDictionary = CommonIdentifiers.PropertyIdentifiersSummaryInfo;
                    break;

                case ContainerType.DocumentSummaryInfo:
                    NameDictionary = CommonIdentifiers.PropertyIdentifiersDocumentSummaryInfo;
                    break;
                }
            }
            else
            {
                NameDictionary = customDict;
            }

            if (NameDictionary.ContainsKey(identifier))
            {
                return(NameDictionary[identifier]);
            }

            return("0x" + identifier.ToString("x8"));
        }
예제 #2
0
        static DataManager()
        {
            using (FileStream fs = new FileStream(@".\Data\data_large.json", FileMode.Open, FileAccess.Read))
                using (StreamReader sr = new StreamReader(fs))
                    using (JsonTextReader reader = new JsonTextReader(sr))
                    {
                        reader.Read();
                        if (reader.TokenType == JsonToken.StartObject)
                        {
                            while (reader.Read())
                            {
                                if (reader.TokenType == JsonToken.StartObject)
                                {
                                    JsonSerializer serializer = new JsonSerializer();
                                    var            place      = serializer.Deserialize <Place>(reader);
                                    PlaceDictionary[place.ID] = place;
                                }
                                else if (reader.TokenType == JsonToken.EndArray)
                                {
                                    break;
                                }
                            }
                        }

                        while (reader.Read())
                        {
                            if (reader.TokenType == JsonToken.StartObject)
                            {
                                JsonSerializer serializer = new JsonSerializer();
                                var            person     = serializer.Deserialize <Person>(reader);
                                if (person.Place_Id.HasValue && PlaceDictionary.ContainsKey(person.Place_Id.Value))
                                {
                                    person.PlaceObj = PlaceDictionary[person.Place_Id.Value];
                                }
                                PersonDictionary[person.ID] = person;

                                if (!NameDictionary.ContainsKey(person.Name))
                                {
                                    NameDictionary[person.Name] = person.ID;
                                }

                                if (!DirectAncestors.ContainsKey(person.ID))
                                {
                                    DirectAncestors[person.ID] = new HashSet <int>();
                                }

                                var fatherId = person.Father_Id ?? -1;

                                if (fatherId != -1)
                                {
                                    if (!DirectDesendants.ContainsKey(fatherId))
                                    {
                                        DirectDesendants[fatherId] = new HashSet <int>();
                                    }
                                    DirectAncestors[person.ID].Add(fatherId);
                                    DirectDesendants[fatherId].Add(person.ID);
                                }

                                var motherId = person.Mother_Id ?? -1;
                                if (motherId != -1)
                                {
                                    if (!DirectDesendants.ContainsKey(motherId))
                                    {
                                        DirectDesendants[motherId] = new HashSet <int>();
                                    }
                                    DirectAncestors[person.ID].Add(motherId);
                                    DirectDesendants[motherId].Add(person.ID);
                                }
                            }
                        }
                    }
        }