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); }
private static void Map(string key, DocumentOption option) { if (Options.ContainsKey(key)) { Options[key] = option; } else { Options.TryAdd(key, option); } }
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(); }
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); } }
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)); }
public static void Initialize(DocumentOption option) { Initialize(new DocumentProvider(), option); }
public static void Initialize(IDbConnection connection, DocumentOption option = null) { Initialize(new DocumentProvider(connection), option); }
public static void Initialize(string baseDirectory, DocumentOption option = null) { Initialize(new DocumentProvider(baseDirectory), option); }
public static void Map(Type type, DocumentOption option) { var key = type.Name; Map(key, option); }
public ObjectiksOf(IDbConnection connection, DocumentOption options = null) { Engine = Core.Get(new DocumentProvider(connection), options); }
public ObjectiksOf(DocumentProvider documentProvider, DocumentOption options = null) { Engine = Core.Get(documentProvider, options); }
public ObjectiksOf(string baseDirectory, DocumentOption options = null) { Engine = Core.Get(new DocumentProvider(baseDirectory), options); }
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; }