public static void RegisterItem(string schema, string key)
        {
            Dictionary <string, object> dict;

            if (!ModifiedData.TryGetValue(key, out dict))
            {
                dict = new Dictionary <string, object>();
                dict.TryAddOrUpdateValue(GDMConstants.SchemaKey, schema);
                ModifiedData.TryAddOrUpdateValue(key, dict);

                HashSet <string> keys;
                DataKeysBySchema.TryGetValue(schema, out keys);

                if (keys != null)
                {
                    keys.Add(key);
                }
                else
                {
                    keys = new HashSet <string>();
                    keys.Add(key);
                    DataKeysBySchema.Add(schema, keys);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Returns a subset of the data containing only data sets by the given schema
        /// </summary>
        /// <returns><c>true</c>, if the given schema exists <c>false</c> otherwise.</returns>
        /// <param name="type">Schema.</param>
        /// <param name="data">Subset of the Data Set list containing entries with the specified schema.</param>
        public static bool GetAllDataBySchema(string schema, out Dictionary <string, object> data)
        {
            if (masterData == null)
            {
                data = null;
                return(false);
            }

            HashSet <string> dataKeys;
            bool             result = true;

            data = new Dictionary <string, object>();

            if (DataKeysBySchema.TryGetValue(schema, out dataKeys))
            {
                foreach (string dataKey in dataKeys)
                {
                    Dictionary <string, object> currentDataSet;
                    if (Get(dataKey, out currentDataSet))
                    {
                        data.Add(dataKey.Clone().ToString(), currentDataSet.DeepCopy());
                    }
                }
            }
            else
            {
                result = false;
            }

            return(result);
        }
        public static void DeregisterItem(string schema, string key)
        {
            ModifiedData.Remove(key);
            HashSet <string> keys;

            DataKeysBySchema.TryGetValue(schema, out keys);
            if (keys != null)
            {
                keys.Remove(key);
            }
        }
Пример #4
0
        /// <summary>
        /// Gets all data keys by schema.
        /// </summary>
        /// <returns><c>true</c>, if the given schema exists <c>false</c> otherwise.</returns>
        /// <param name="schema">Schema.</param>
        /// <param name="dataKeys">Data Key List.</param>
        public static bool GetAllDataKeysBySchema(string schema, out List <string> dataKeys)
        {
            if (masterData == null)
            {
                dataKeys = null;
                return(false);
            }

            HashSet <string> keyList;

            if (DataKeysBySchema.TryGetValue(schema, out keyList))
            {
                dataKeys = keyList.ToList();
                return(true);
            }

            dataKeys = null;
            return(false);
        }