Пример #1
0
        private FeatureRow SaveFeature(IDbContext dbContext, FeatureContextRow context, string featureName)
        {
            var contextId = context.Id;

            List <FeatureRow> features;

            if (this.Features.TryGetValue(contextId, out features))
            {
                foreach (var f in features)
                {
                    if (f.Name.Equals(featureName, StringComparison.OrdinalIgnoreCase))
                    {
                        return(f);
                    }
                }
            }
            else
            {
                // Create feature collection for this context
                features = new List <FeatureRow>();
                this.Features.Add(contextId, features);
            }

            // Insert into database
            var newFeatureId = FeatureAdapter.InsertFeature(dbContext, featureName, contextId);

            var feature = new FeatureRow(newFeatureId, featureName, contextId);

            //Insert the new feature into the cache
            features.Add(feature);

            return(feature);
        }
Пример #2
0
        private FeatureContextRow SaveContext(IDbContext dbContext, string contextName)
        {
            FeatureContextRow context;

            if (!this.Contexts.TryGetValue(contextName, out context))
            {
                // Insert into database
                var newContextId = FeatureAdapter.InsertContext(dbContext, contextName);

                context = new FeatureContextRow(newContextId, contextName);

                // Insert the new context into the cache
                this.Contexts.Add(contextName, context);
            }

            return(context);
        }