Ejemplo n.º 1
0
        private ModelMeta EnsureModelDictionaryEntryExists <TModel>(IDictionary <string, ModelMeta> metadataDictionary)
        {
            var modelType    = typeof(TModel);
            var modelMetaKey = modelType.AssemblyQualifiedName;
            var modelMeta    = default(ModelMeta);

            if (metadataDictionary.ContainsKey(modelMetaKey))
            {
                modelMeta = metadataDictionary[modelMetaKey];
            }
            else
            {
                lock (MetaSyncRoot)
                {
                    if (!metadataDictionary.ContainsKey(modelMetaKey))
                    {
                        modelMeta = new ModelMeta();
                        var propertyMetaBuilder = new PropertyMetaBuilder();
                        modelMeta.PropertyMap = propertyMetaBuilder.BuildPropertyMetaMap <TModel>();
                        metadataDictionary.Add(modelMetaKey, modelMeta);
                    }
                }
            }
            return(modelMeta);
        }
Ejemplo n.º 2
0
        public void PropertyMetaBuilderShouldCorrectNumberOfMappedProperties()
        {
            var propertyMetaBuilder    = new PropertyMetaBuilder();
            var myModelPropertyMetaMap = propertyMetaBuilder.BuildPropertyMetaMap <MyModel>();

            Assert.AreEqual(1, myModelPropertyMetaMap.Count());
        }
Ejemplo n.º 3
0
        private ModelMeta EnsureModelDictionaryEntryExists <TModel>(IDictionary <string, ModelMeta> metadataDictionary)
        {
            var       modelType    = typeof(TModel);
            var       modelMetaKey = modelType.AssemblyQualifiedName;
            ModelMeta tmp          = null;

            if (metadataDictionary.TryGetValue(modelMetaKey, out tmp))
            {
                return(tmp);
            }

            lock (MetaSyncRoot)
            {
                if (metadataDictionary.TryGetValue(modelMetaKey, out tmp))
                {
                    return(tmp);
                }

                var modelMeta           = new ModelMeta();
                var propertyMetaBuilder = new PropertyMetaBuilder();

                modelMeta.PropertyMap = propertyMetaBuilder.BuildPropertyMetaMap <TModel>();
                metadataDictionary.Add(modelMetaKey, modelMeta);

                return(modelMeta);
            }
        }