Ejemplo n.º 1
0
            public static DocumentOption GetOption(DocumentProvider provider)
            {
                var key = provider.Key;

                if (!Options.TryGetValue(key, out DocumentOption option))
                {
                    key = provider.Connection != null?provider.Connection.GetType().Name : typeof(DocumentProvider).Name;

                    Options.TryGetValue(key, out option);
                }

                if (option == null)
                {
                    option = new DocumentOption();
                    option.RegisterDefaults();

                    if (option.CacheInstance == null)
                    {
                        option.CacheInstance = new DocumentInMemory(option.Name, new DocumentBsonSerializer());
                    }
                }

                if (Options.ContainsKey(key))
                {
                    Options[key] = option;
                }
                else
                {
                    Options.TryAdd(key, option);
                }

                return(option);
            }
Ejemplo n.º 2
0
            public static void Initialize(DocumentProvider provider, DocumentOption option = null)
            {
                Provider = provider;

                if (option == null)
                {
                    option = GetOption(provider);
                }
                else
                {
                    Map(provider.Key, option);
                }

                var engine = Get(provider, option).Initialize();
            }
Ejemplo n.º 3
0
        public DocumentEngine(DocumentProvider documentProvider, DocumentOption option)
        {
            Option   = option;
            Provider = documentProvider;
            Cache    = option.CacheInstance;
            Logger   = option.DocumentLogger;
            Watcher  = option.DocumentWatcher;
            ParseOf  = option.ParserOfTypes;
            Monitor  = new DocumentMonitor();

            if (Option.SupportDocumentWatcher)
            {
                Watcher?.WaitForChanged(this);
            }
        }
Ejemplo n.º 4
0
 public DocumentMeta(string typeOf, DocumentType documentType, DocumentProvider fileProvider, DocumentOption option)
 {
     TypeOf             = typeOf;
     ParseOf            = documentType.ParseOf;
     WorkOf             = documentType.WorkOf;
     PrimaryOf          = documentType.PrimaryOf;
     UserOf             = documentType.UserOf;
     KeyOfNames         = documentType.KeyOf;
     Cache              = documentType.Cache;
     Keys               = new DocumentKeyIndex();
     Partitions         = new DocumentPartitions();
     Partitions.Current = 0;
     Partitions.Next    = 0;
     Directory          = Path.Combine(fileProvider.BaseDirectory, DocumentDefaults.Documents, typeOf);
     Extention          = option.Extention;
     Exists             = true;
 }
Ejemplo n.º 5
0
            internal static IDocumentEngine Get(DocumentProvider documentProvider, DocumentOption option)
            {
                if (documentProvider == null)
                {
                    throw new Exception("DocumentProvider is null");
                }

                if (option == null)
                {
                    option = GetOption(documentProvider);
                }

                if (option.CacheInstance == null)
                {
                    option.CacheInstance = new DocumentInMemory(option.Name, new DocumentBsonSerializer());
                }

                if (option.EngineProvider == null)
                {
                    throw new Exception("Engine undefined..");
                }

                return((DocumentEngine)Activator.CreateInstance(option.EngineProvider, documentProvider, option));
            }
Ejemplo n.º 6
0
 public ObjectiksOf(DocumentProvider documentProvider, DocumentOption options = null)
 {
     Engine = Core.Get(documentProvider, options);
 }