示例#1
0
        public static RealStorageSettings Create(IMainStorageContext context, List <IStorage> parentStorages)
        {
            var result = new RealStorageSettings();

            result.MainStorageContext = context;

            result.ParentsStorages             = (parentStorages?.ToList()) ?? new List <IStorage>();
            result.DefaultSettingsOfCodeEntity = parentStorages?.FirstOrDefault()?.DefaultSettingsOfCodeEntity;

            return(result);
        }
示例#2
0
        public RealStorage(KindOfStorage kind, RealStorageSettings settings)
            : base(settings.MainStorageContext.Logger)
        {
#if DEBUG
            //Log($"kind = {kind}");
            //Log($"settings = {settings}");
#endif

            _kind = kind;
            _realStorageContext                    = new RealStorageContext();
            _realStorageContext.Storage            = this;
            _realStorageContext.MainStorageContext = settings.MainStorageContext;
            _realStorageContext.InheritancePublicFactsReplicator = settings.InheritancePublicFactsReplicator;

            DefaultSettingsOfCodeEntity = settings.DefaultSettingsOfCodeEntity;

            var parents = settings.ParentsStorages;

            if (parents == null)
            {
                _realStorageContext.Parents = new List <IStorage>();
            }
            else
            {
                _realStorageContext.Parents = parents;
            }

            _realStorageContext.LogicalStorage     = new LogicalStorage.LogicalStorage(_kind, _realStorageContext);
            _realStorageContext.MethodsStorage     = new MethodsStorage.MethodsStorage(_kind, _realStorageContext);
            _realStorageContext.TriggersStorage    = new TriggersStorage.TriggersStorage(_kind, _realStorageContext);
            _realStorageContext.InheritanceStorage = new InheritanceStorage.InheritanceStorage(_kind, _realStorageContext);
            _realStorageContext.SynonymsStorage    = new SynonymsStorage.SynonymsStorage(_kind, _realStorageContext);
            _realStorageContext.OperatorsStorage   = new OperatorsStorage.OperatorsStorage(_kind, _realStorageContext);
            _realStorageContext.ChannelsStorage    = new ChannelsStorage.ChannelsStorage(_kind, _realStorageContext);
            _realStorageContext.MetadataStorage    = new MetadataStorage.MetadataStorage(_kind, _realStorageContext);
            _realStorageContext.VarStorage         = new VarStorage.VarStorage(_kind, _realStorageContext);
            _realStorageContext.FuzzyLogicStorage  = new FuzzyLogicStorage(_kind, _realStorageContext);
        }
示例#3
0
 public LocalStorage(RealStorageSettings settings)
     : base(KindOfStorage.Local, settings)
 {
 }
示例#4
0
 public HostStorage(RealStorageSettings settings)
     : base(KindOfStorage.Host, settings)
 {
 }
        //private List<RealStorage> _storagesList;

        public void LoadFromSourceCode()
        {
            //_storagesList = new List<RealStorage>();

            var globalStorageSettings = new RealStorageSettings();

            var parentStoragesList = new List <IStorage>();

            switch (_kindGlobalOfStorage)
            {
            case KindOfStorage.Global:
            {
                var publicFactsStorageSettings = new RealStorageSettings();
                publicFactsStorageSettings.MainStorageContext = _context;

                _publicFactsStorage = new RealStorage(KindOfStorage.PublicFacts, publicFactsStorageSettings);

                _inheritancePublicFactsReplicator = new InheritancePublicFactsReplicator(_context, _publicFactsStorage);
                globalStorageSettings.InheritancePublicFactsReplicator = _inheritancePublicFactsReplicator;

                //_storagesList.Add(_publicFactsStorage);

                _selfFactsStorage = new RealStorage(KindOfStorage.PublicFacts, publicFactsStorageSettings);

                parentStoragesList.Add(_selfFactsStorage);

                var perceptedFactsStorageSettings = new RealStorageSettings();
                perceptedFactsStorageSettings.MainStorageContext = _context;

                _perceptedFactsStorage = new RealStorage(KindOfStorage.PerceptedFacts, perceptedFactsStorageSettings);

                //_storagesList.Add(_perceptedFactsStorage);

                parentStoragesList.Add(_perceptedFactsStorage);
            }
            break;

            case KindOfStorage.Host:
            {
                var publicFactsStorageSettings = new RealStorageSettings();
                publicFactsStorageSettings.MainStorageContext = _context;

                _publicFactsStorage = new RealStorage(KindOfStorage.PublicFacts, publicFactsStorageSettings);

                _inheritancePublicFactsReplicator = new InheritancePublicFactsReplicator(_context, _publicFactsStorage);
                globalStorageSettings.InheritancePublicFactsReplicator = _inheritancePublicFactsReplicator;

                //_storagesList.Add(_publicFactsStorage);

                _selfFactsStorage = new RealStorage(KindOfStorage.PublicFacts, publicFactsStorageSettings);

                parentStoragesList.Add(_selfFactsStorage);
            }
            break;
            }

            globalStorageSettings.MainStorageContext = _context;

            if (_parentStorage != null && _parentStorage.Storage != null)
            {
                parentStoragesList.Add(_parentStorage.Storage);
            }

            if (parentStoragesList.Any())
            {
                globalStorageSettings.ParentsStorages = parentStoragesList;
            }

            switch (_kindGlobalOfStorage)
            {
            case KindOfStorage.Global:
                _globalStorage = new GlobalStorage(globalStorageSettings);
                break;

            case KindOfStorage.World:
                _globalStorage = new WorldStorage(globalStorageSettings);
                break;

            case KindOfStorage.Host:
                _globalStorage = new HostStorage(globalStorageSettings);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(_kindGlobalOfStorage), _kindGlobalOfStorage, null);
            }

            //_storagesList.Add(_globalStorage);

            _globalStorage.DefaultSettingsOfCodeEntity = CreateDefaultSettingsOfCodeEntity();

#if IMAGINE_WORKING
            //Log("Do");
#else
            throw new NotImplementedException();
#endif
        }
示例#6
0
 public GlobalStorage(RealStorageSettings settings)
     : base(KindOfStorage.Global, settings)
 {
 }
示例#7
0
 public WorldStorage(RealStorageSettings settings)
     : base(KindOfStorage.World, settings)
 {
 }