Пример #1
0
        public void RegisterValue_Throws_InvalidOperationException_When_Registering_Setting_Already_Registered()
        {
            IValueCache cache = new ValueCache();

            cache.RegisterValue(Utilities.SettingNames.TEST_SETTING_NAME);
            Assert.That(() => cache.RegisterValue(Utilities.SettingNames.TEST_SETTING_NAME), Throws.InvalidOperationException);
        }
Пример #2
0
 internal T4Context(StringBuilder text, ITextTemplatingEngineHost host)
 {
     _text = text;
     _host = host;
     _fileItems = new FunctionCache<string, Box<string>>(fileName => new Box<string>(""));
     _dte = new ValueCache<DTE>(ObtainDTE);
 }
Пример #3
0
        public void GetValue_Throws_Exception_When_Custom_Type_Cast_Not_Provided()
        {
            IValueCache cache = new ValueCache();

            cache.RegisterValue(Utilities.SettingNames.TEST_SETTING_NAME, typeof(TestCustomClass), true, null);
            Assert.That(() => cache.GetValue(Utilities.SettingNames.TEST_SETTING_NAME), Throws.Exception);
        }
Пример #4
0
                public override ComparisonKey Cache(ValueCache valueCache)
                {
                    var comparisonKey = this;

                    if (valueCache.TryGetCachedValue(ref comparisonKey))
                    {
                        return(comparisonKey);
                    }
                    ImmutableList <string> modificationNames = ModificationNames;

                    if (ModificationNames != null)
                    {
                        if (!valueCache.TryGetCachedValue(ref modificationNames))
                        {
                            modificationNames = ImmutableList.ValueOf(modificationNames.Select(valueCache.CacheValue));
                            modificationNames = valueCache.CacheValue(modificationNames);
                        }
                    }
                    comparisonKey = new Peptide(LibraryKey.ValueFromCache(valueCache))
                    {
                        ModificationIndexes = valueCache.CacheValue(ModificationIndexes),
                        ModificationNames   = modificationNames
                    };
                    return(valueCache.CacheValue(comparisonKey));
                }
Пример #5
0
        public void GetValue_From_Template_Type_Returns_Not_Null_Or_Empty()
        {
            IValueCache cache = new ValueCache();

            cache.RegisterValue(Utilities.SettingNames.TEST_SETTING_NAME);
            Assert.That(cache.GetValue <string>(Utilities.SettingNames.TEST_SETTING_NAME), Is.Not.Null.And.Not.Empty);
        }
Пример #6
0
        public SourceView(string text)
            : base("SourceView")
        {
            TextBox = new Scintilla
            {
                Lexer = ScintillaNET.Lexer.Container,
                VirtualSpaceOptions = VirtualSpace.UserAccessible
            };

            foreach (var id in TextStyle.All)
                StyleConfig(id);

            TextBox.StyleNeeded += (s, args) => SignalStyleNeeded(args.Position);
            TextBox.TextChanged += (s, args) => OnTextChanged();

            TextBox.ContextMenu = new ContextMenu();
            TextBox.ContextMenu.Popup += (s, args) => OnContextMenuPopup();

            CompilerCache = new ValueCache<CompilerBrowser>(CreateCompilerBrowser);

            ResultCachesViews = new FunctionCache<Value, ResultCachesView>
                (item => new ResultCachesView(item, this));
            ChildViews = new FunctionCache<object, ChildView>(CreateView);

            Client = TextBox;

            TextBox.Text = text;

            TraceLog = new BrowseTraceCollector(this);
            LogView = new TraceLogView(this);
        }
Пример #7
0
        public static LibraryKey Read(ValueCache valueCache, Stream stream)
        {
            int length = PrimitiveArrays.ReadOneValue <int>(stream);

            byte[] buffer = new byte[length];
            stream.Read(buffer, 0, length);
            var proto = new LibraryKeyProto();

            proto.MergeFrom(new CodedInputStream(buffer));
            switch (proto.KeyType)
            {
            case LibraryKeyProto.Types.KeyType.Peptide:
                return(new PeptideLibraryKey(proto.ModifiedSequence, proto.Charge).ValueFromCache(valueCache));

            case LibraryKeyProto.Types.KeyType.PrecursorMz:
                return(new PrecursorLibraryKey(proto));

            case LibraryKeyProto.Types.KeyType.SmallMolecule:
                return(new MoleculeLibraryKey(valueCache, proto));

            case LibraryKeyProto.Types.KeyType.Crosslink:
                return(new CrosslinkLibraryKey(proto));
            }
            return(null);
        }
Пример #8
0
            public static ElibSpectrumInfo Read(ValueCache valueCache, Stream stream)
            {
                byte[] peptideModSeqBytes = new byte[PrimitiveArrays.ReadOneValue <int>(stream)];
                stream.Read(peptideModSeqBytes, 0, peptideModSeqBytes.Length);
                var peptideModSeq  = valueCache.CacheValue(Encoding.UTF8.GetString(peptideModSeqBytes));
                int charge         = PrimitiveArrays.ReadOneValue <int>(stream);
                int bestFileId     = PrimitiveArrays.ReadOneValue <int>(stream);
                int peakBoundCount = PrimitiveArrays.ReadOneValue <int>(stream);
                var peakBounds     = new List <KeyValuePair <int, FileData> >();

                while (peakBounds.Count < peakBoundCount)
                {
                    var    fileId       = PrimitiveArrays.ReadOneValue <int>(stream);
                    var    startTime    = PrimitiveArrays.ReadOneValue <double>(stream);
                    var    endTime      = PrimitiveArrays.ReadOneValue <double>(stream);
                    var    score        = PrimitiveArrays.ReadOneValue <double>(stream);
                    byte   bHasApexTime = PrimitiveArrays.ReadOneValue <byte>(stream);
                    double?apexTime;
                    if (bHasApexTime == 0)
                    {
                        apexTime = null;
                    }
                    else
                    {
                        apexTime = PrimitiveArrays.ReadOneValue <double>(stream);
                    }
                    peakBounds.Add(new KeyValuePair <int, FileData>(fileId, new FileData(apexTime, new ExplicitPeakBounds(startTime, endTime, score))));
                }
                return(new ElibSpectrumInfo(peptideModSeq, charge, bestFileId, peakBounds));
            }
Пример #9
0
        private static SmallMoleculeLibraryAttributes Normalize(
            ValueCache valueCache,
            SmallMoleculeLibraryAttributes smallMoleculeLibraryAttributes)
        {
            if (smallMoleculeLibraryAttributes == null)
            {
                return(SmallMoleculeLibraryAttributes.EMPTY);
            }

            if (null == smallMoleculeLibraryAttributes.MoleculeName ||
                null == smallMoleculeLibraryAttributes.ChemicalFormula ||
                null == smallMoleculeLibraryAttributes.InChiKey ||
                null == smallMoleculeLibraryAttributes.OtherKeys)
            {
                smallMoleculeLibraryAttributes = SmallMoleculeLibraryAttributes.Create(
                    smallMoleculeLibraryAttributes.MoleculeName ?? string.Empty,
                    smallMoleculeLibraryAttributes.ChemicalFormula ?? string.Empty,
                    smallMoleculeLibraryAttributes.InChiKey ?? string.Empty,
                    smallMoleculeLibraryAttributes.OtherKeys ?? string.Empty);
            }
            if (valueCache != null)
            {
                if (!valueCache.TryGetCachedValue(ref smallMoleculeLibraryAttributes))
                {
                    smallMoleculeLibraryAttributes = valueCache.CacheValue(SmallMoleculeLibraryAttributes.Create(
                                                                               valueCache.CacheValue(smallMoleculeLibraryAttributes.MoleculeName),
                                                                               valueCache.CacheValue(smallMoleculeLibraryAttributes.ChemicalFormula),
                                                                               valueCache.CacheValue(smallMoleculeLibraryAttributes.InChiKey),
                                                                               valueCache.CacheValue(smallMoleculeLibraryAttributes.OtherKeys)
                                                                               ));
                }
            }
            return(smallMoleculeLibraryAttributes);
        }
Пример #10
0
 protected Enumeration(string name, int value)
 {
     Name  = name;
     Value = value;
     ValueCache.Add(value, this);
     NameCache.Add(name, this);
 }
Пример #11
0
        public void GetValue_Throws_ConfigurationErrorsException_When_Setting_Not_Found_And_Required()
        {
            IValueCache cache = new ValueCache();

            cache.RegisterValue(Utilities.SettingNames.SETTING_THAT_NOT_EXISTS, typeof(string));
            Assert.That(() => cache.GetValue(Utilities.SettingNames.SETTING_THAT_NOT_EXISTS), Throws.TypeOf <ConfigurationErrorsException>());
        }
Пример #12
0
        public void GetValue_Returns_Correct_Type()
        {
            TypeParameterTest(Utilities.SettingNames.TEST_SETTING_NAME, typeof(string));
            TypeParameterTest(Utilities.SettingNames.TEST_CHARACTER_NAME, typeof(char));
            TypeParameterTest(Utilities.SettingNames.TEST_BOOLEAN_NAME, typeof(bool));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(byte));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(sbyte));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(decimal));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(double));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(float));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(int));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(uint));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(long));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(ulong));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(short));
            TypeParameterTest(Utilities.SettingNames.TEST_INTEGER_NAME, typeof(ushort));

            GenericTypeTest <string>(Utilities.SettingNames.TEST_SETTING_NAME);
            GenericTypeTest <char>(Utilities.SettingNames.TEST_CHARACTER_NAME);
            GenericTypeTest <bool>(Utilities.SettingNames.TEST_BOOLEAN_NAME);
            GenericTypeTest <byte>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <sbyte>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <decimal>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <double>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <float>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <int>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <uint>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <long>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <ulong>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <short>(Utilities.SettingNames.TEST_INTEGER_NAME);
            GenericTypeTest <ushort>(Utilities.SettingNames.TEST_INTEGER_NAME);

            void TypeParameterTest(string setting, Type type)
            {
                try
                {
                    IValueCache cache = new ValueCache();
                    cache.RegisterValue(setting, type);
                    Assert.That(cache.GetValue(setting), Is.TypeOf(type), $"Failed for {type.Name}");
                }
                catch (Exception ex)
                {
                    throw new ApplicationException($"Failed for {type.Name}", ex);
                }
            }

            void GenericTypeTest <T>(string setting)
            {
                try
                {
                    IValueCache cache = new ValueCache();
                    cache.RegisterValue(setting, typeof(T));
                    Assert.That(cache.GetValue <T>(setting), Is.TypeOf <T>(), $"Failed for {typeof(T).Name}");
                }
                catch (Exception ex)
                {
                    throw new ApplicationException($"Failed for {typeof(T).Name}", ex);
                }
            }
        }
 internal ConsoleVariable(string id)
     : base(id)
 {
     _stringCache = new ValueCache<string>(new ValueCache<string>.UpdateHandler(UpdateCachedString));
     _floatCache = new ValueCache<float>(new ValueCache<float>.UpdateHandler(UpdateCachedFloat));
     _intCache = new ValueCache<int>(new ValueCache<int>.UpdateHandler(UpdateCachedInt));
     _vectorCache = new ValueCache<Vector2>(new ValueCache<Vector2>.UpdateHandler(UpdateCachedVector));
 }
Пример #14
0
 internal IniFile(SmbFile path, string commentString, Action onExternalModification)
 {
     Path                   = path;
     CommentString          = commentString;
     OnExternalModification = onExternalModification;
     Data                   = new ValueCache <IniData>(() => Path.FromIni(CommentString));
     Watcher                = CreateWatcher(path);
 }
Пример #15
0
 BitsConst(Size size)
     : base(_nextObjectId++)
 {
     Size = size;
     _data = CreateDataArray();
     _dataCache = new ValueCache<BigInteger>(() => new BigInteger(_data));
     StopByObjectIds(-7);
 }
 internal CachingTokenFactory(ITokenFactory target)
 {
     Target = target;
     EndOfTextCache = new ValueCache<IScannerTokenType>(() => Target.EndOfText);
     BeginOfTextCache = new ValueCache<object>(() => Target.BeginOfText);
     InvalidCharacterErrorCache = new ValueCache<IScannerTokenType>(() => Target.InvalidCharacterError);
     ClassesCache = new ValueCache<LexerItem[]>(() => Target.Classes);
 }
Пример #17
0
 internal AccessFeature(CompoundView compoundView, int position)
     : base(_nextObjectId++)
 {
     View = compoundView;
     Position = position;
     FunctionFeature = new ValueCache<IFunction>(ObtainFunctionFeature);
     StopByObjectIds();
 }
Пример #18
0
 private void ConstructorCommon(int localEdge)
 {
     this.localEdge = localEdge;
     edgeNodeCache  = new EdgeNodeCache(Context.NSC, this, localEdge);
     monomialCache  = new MonomialCache(Context.NSC, this);
     valueCache     = new ValueCache(Context.NSC, this);
     gradientCache  = new GradientCache(Context.NSC, this);
 }
Пример #19
0
 public ReferenceItem(DataBase parent, SQLSysViews.foreign_keysClass constraint, Func<SQLSysViews.all_objectsClass, TypeItem> getType)
     : base(parent, constraint.name)
 {
     var columns = constraint.Columns.OrderBy(c => c.constraint_column_id).ToArray();
     Columns = columns.Select(c => c.ParentColumn.name).ToArray();
     TargetColumns = columns.Select(c => c.ReferenceColumn.name).ToArray();
     _targetTypeCache = new ValueCache<TypeItem>(() => getType(constraint.Reference));
 }
Пример #20
0
        public void RegisterValue_Cannot_Register_Duplicate()
        {
            IValueCache cache = new ValueCache();

            // First one shouldn't fail. Second one should.
            Assert.That(() => cache.RegisterValue(Utilities.SettingNames.TEST_SETTING_NAME), Throws.Nothing);
            Assert.That(() => cache.RegisterValue(Utilities.SettingNames.TEST_SETTING_NAME), Throws.Exception);
        }
Пример #21
0
 public LibKeyIndex(ValueCache valueCache, IEnumerable <IndexItem> items)
 {
     _allEntries = ImmutableList.ValueOf(items
                                         .Select(entry => new KeyValuePair <ComparisonKey, IndexItem>(
                                                     ComparisonKey.Get(entry.LibraryKey).Cache(valueCache), entry))
                                         .OrderBy(kvp => kvp.Key, MakeComparer(ComparisonLevel.Full)));
     _indexByUnmodifiedSequence = MakeIndexByUnmodifiedSequence();
 }
Пример #22
0
 internal void NotifyChange()
 {
     cache = null;
     if (!isExpired)
     {
         OnChanged(new ValueEventArgs(this));
     }
 }
Пример #23
0
 public MoleculeLibraryKey(ValueCache valueCache, SmallMoleculeLibraryAttributes smallMoleculeLibraryAttributes,
                           Adduct adduct)
 {
     SmallMoleculeLibraryAttributes = Normalize(valueCache, smallMoleculeLibraryAttributes);
     PreferredKey = SmallMoleculeLibraryAttributes.GetPreferredKey() ??
                    SmallMoleculeLibraryAttributes.MoleculeName ?? String.Empty;
     _adduct = adduct;
 }
Пример #24
0
 public AssessmentDomain(IConfiguration configuration)
 {
     Configuration = configuration;
     OldCache      = new(GetOldValue);
     NewCache      = new(GetNewValue);
     CurrentCache  = new(GetCurrentValue);
     File          = new(GetFile);
 }
Пример #25
0
 public EngineImportSingleRowDesc(String className, String methodName, ValueCache valueCache, FilterOptimizable filterOptimizable, bool rethrowExceptions)
 {
     ClassName         = className;
     MethodName        = methodName;
     ValueCache        = valueCache;
     FilterOptimizable = filterOptimizable;
     RethrowExceptions = rethrowExceptions;
 }
Пример #26
0
 internal MoleculeLibraryKey(ValueCache valueCache, LibraryKeyProto libraryKeyProto) : this(
         valueCache,
         SmallMoleculeLibraryAttributes.Create(
             valueCache.CacheValue(libraryKeyProto.MoleculeName),
             valueCache.CacheValue(libraryKeyProto.ChemicalFormula),
             libraryKeyProto.InChiKey, libraryKeyProto.OtherKeys),
         Adduct.FromString(libraryKeyProto.Adduct, Adduct.ADDUCT_TYPE.non_proteomic, null))
 {
 }
Пример #27
0
 internal CodeContainer
     (string moduleName, Root root, Syntax syntax, string description)
 {
     ModuleName = moduleName;
     Root = root;
     MainCache = new ValueCache<Container>
         (() => root.MainContainer(syntax, description));
     CSharpStringCache = new ValueCache<string>(GetCSharpStringForCache);
     _functions = new FunctionCache<int, FunctionContainer>(Root.FunctionContainer);
 }
Пример #28
0
 Frame(Syntax target, Frame parent = null, HierachicalFormatter formatter = null)
 {
     Parent = parent;
     Formatter = parent?.Formatter ?? formatter;
     Target = target;
     LeftCache = new ValueCache<Frame>(() => new Frame(Target.Left, this));
     RightCache = new ValueCache<Frame>(() => new Frame(Target.Right, this));
     ItemsWithoutLeadingBreaksCache = new ValueCache<ResultItems>
         (GetItemsWithoutLeadingBreaks);
     LeadingLineBreaksCache = new ValueCache<int>(GetLeadingLineBreaksForCache);
     HasInnerLineBreaksCache = new ValueCache<bool>(GetHasInnerLineBreaksForCache);
 }
Пример #29
0
 public CacheClass(IDataProvider provider, SQLSysViews parent)
 {
     all_columns = new ValueCache<IEnumerable<all_columnsClass>>(() => provider.Select<all_columnsClass>("sys", "all_columns", r => new all_columnsClass(r, parent)));
     all_objects = new ValueCache<IEnumerable<all_objectsClass>>(() => provider.Select<all_objectsClass>("sys", "all_objects", r => new all_objectsClass(r, parent)));
     key_constraints = new ValueCache<IEnumerable<key_constraintsClass>>(() => provider.Select<key_constraintsClass>("sys", "key_constraints", r => new key_constraintsClass(r, parent)));
     foreign_keys = new ValueCache<IEnumerable<foreign_keysClass>>(() => provider.Select<foreign_keysClass>("sys", "foreign_keys", r => new foreign_keysClass(r, parent)));
     foreign_key_columns = new ValueCache<IEnumerable<foreign_key_columnsClass>>(() => provider.Select<foreign_key_columnsClass>("sys", "foreign_key_columns", r => new foreign_key_columnsClass(r, parent)));
     indexes = new ValueCache<IEnumerable<indexesClass>>(() => provider.Select<indexesClass>("sys", "indexes", r => new indexesClass(r, parent)));
     index_columns = new ValueCache<IEnumerable<index_columnsClass>>(() => provider.Select<index_columnsClass>("sys", "index_columns", r => new index_columnsClass(r, parent)));
     schemas = new ValueCache<IEnumerable<schemasClass>>(() => provider.Select<schemasClass>("sys", "schemas", r => new schemasClass(r, parent)));
     types = new ValueCache<IEnumerable<typesClass>>(() => provider.Select<typesClass>("sys", "types", r => new typesClass(r, parent)));
 }
Пример #30
0
        protected CsvSpliter(StreamReader innerStream, int bufferSize)
        {
            this.innerStream = innerStream;

            this.charBuffer = new char[bufferSize];
            this.charIndex  = 0;

            this.oneLineBuffer = new List <char>();

            this.temporary = new ValueKey();
            this.cache     = new ValueCache();
        }
Пример #31
0
        public void GetValue_Supports_Custom_Type_Casting()
        {
            IValueCache cache = new ValueCache();

            cache.RegisterValue(Utilities.SettingNames.TEST_SETTING_NAME, typeof(TestCustomClass), true,
                                setting => new TestCustomClass
            {
                TestStringProperty = setting
            }
                                );
            Assert.That(cache.GetValue <TestCustomClass>(Utilities.SettingNames.TEST_SETTING_NAME)?.TestStringProperty, Is.Not.Null.And.EqualTo(ApplicationSettings.AsString(Utilities.SettingNames.TEST_SETTING_NAME)));
        }
Пример #32
0
 internal UserInteraction(string name, Action handler,
     Bitmap bitmap = null,
     Func<bool> getIsEnabled = null,
     string text = null)
 {
     _name = name;
     _handler = handler;
     _bitmap = bitmap;
     _text = text;
     _getIsEnabled = getIsEnabled ?? (() => true);
     _buttonCache = new ValueCache<ToolStripButton>(GetButton);
     _menuItemCache = new ValueCache<ToolStripMenuItem>(GetMenuItem);
 }
Пример #33
0
    UserConfiguration(SmbFile path, SmbFile[] allPaths, MmasfContext parent)
    {
        Path     = path;
        AllPaths = allPaths;
        Parent   = parent;
        ModConfigurationCache = new(GetModConfiguration);
        ModFilesCache         = new(GetModFiles);
        SaveFilesCache        = new(GetSaveFiles);
        return;

/*
 *      RunLua();
 *      LogfileWatcher = new(Path);
 */
    }
Пример #34
0
        public DirectoryEncodingInputStream(string path, IFileSystemService fileSystemService, IPlatformService platform)
        {
            Guard.IsNotNullOrEmpty(path, nameof(path));
            Guard.IsNotNull(fileSystemService, nameof(fileSystemService));
            Guard.IsNotNull(platform, nameof(platform));

            this.isTraversed       = false;
            this.sizeInBytes       = 0;
            this.path              = path;
            this.currentPath       = string.Empty;
            this.fileSystemService = fileSystemService;
            this.platform          = platform;
            this.fileStream        = null;
            this.fileSystemEntries = new ValueCache <IEnumerator <FileSystemEntry> >(() => this.fileSystemService.EnumFileSystemEntries(this.path).GetEnumerator());
        }
Пример #35
0
        internal Value GetValueFor(LLVMValueRef valueRef, Func <LLVMValueRef, Value> constructor)
        {
            if (valueRef.Pointer == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(valueRef));
            }

            if (ValueCache.TryGetValue(valueRef.Pointer, out Value retVal))
            {
                return(retVal);
            }

            retVal = constructor(valueRef);
            ValueCache.Add(valueRef.Pointer, retVal);
            return(retVal);
        }
        public static TRet Calculate(string text, string name, Func <ROMol, TRet> calculator)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            var key          = new Tuple <string, string>(name, text);
            var nReturnValue = ValueCache.GetOrAdd(key, tuple =>
            {
                var mol = Parse(text);
                return(calculator(mol));
            });

            return(nReturnValue);
        }
Пример #37
0
        public override LibraryKey ValueFromCache(ValueCache valueCache)
        {
            var libraryKey = this;

            if (valueCache.TryGetCachedValue(ref libraryKey))
            {
                return(libraryKey);
            }
            libraryKey = new PeptideLibraryKey
            {
                ModifiedSequence   = valueCache.CacheValue(ModifiedSequence),
                UnmodifiedSequence = valueCache.CacheValue(UnmodifiedSequence),
                Charge             = Charge,
            };
            return(valueCache.CacheValue(libraryKey));
        }
Пример #38
0
        public static ChromLibSpectrumInfo Read(ValueCache valueCache, Stream stream)
        {
            LibKey key      = LibKey.Read(valueCache, stream);
            int    id       = PrimitiveArrays.ReadOneValue <int>(stream);
            double peakArea = PrimitiveArrays.ReadOneValue <double>(stream);
            var    retentionTimesByFileId = IndexedRetentionTimes.Read(stream);
            int    mzCount = PrimitiveArrays.ReadOneValue <int>(stream);
            var    mzs     = PrimitiveArrays.Read <double>(stream, mzCount);
            var    areas   = PrimitiveArrays.Read <float>(stream, mzCount);
            var    mzAreas = ImmutableList.ValueOf(Enumerable.Range(0, mzCount)
                                                   .Select(index => new SpectrumPeaksInfo.MI // TODO (bspratt) annotation?
            {
                Mz        = mzs[index],
                Intensity = areas[index]
            }));

            return(new ChromLibSpectrumInfo(key, id, peakArea, retentionTimesByFileId, mzAreas));
        }
Пример #39
0
        public void AddSingleRow(
            String functionName,
            String singleRowFuncClass,
            String methodName,
            ValueCache valueCache,
            FilterOptimizable filterOptimizable,
            bool rethrowExceptions)
        {
            ValidateFunctionName("single-row", functionName);

            if (!IsTypeNameOrNamespace(singleRowFuncClass))
            {
                throw new EngineImportException("Invalid class name for aggregation '" + singleRowFuncClass + "'");
            }
            _singleRowFunctions.Put(
                functionName.ToLower(),
                new EngineImportSingleRowDesc(
                    singleRowFuncClass, methodName, valueCache, filterOptimizable, rethrowExceptions));
        }
Пример #40
0
 private bool LoadFromCache(ILoadMonitor loader)
 {
     if (!loader.StreamManager.IsCached(FilePath, CachePath))
     {
         return(false);
     }
     try
     {
         ValueCache valueCache = new ValueCache();
         using (var stream = loader.StreamManager.CreateStream(CachePath, FileMode.Open, true))
         {
             int version = PrimitiveArrays.ReadOneValue <int>(stream);
             if (version != FORMAT_VERSION_CACHE)
             {
                 return(false);
             }
             int           fileCount   = PrimitiveArrays.ReadOneValue <int>(stream);
             List <String> sourceFiles = new List <string>(fileCount);
             while (sourceFiles.Count < fileCount)
             {
                 int    byteCount = PrimitiveArrays.ReadOneValue <int>(stream);
                 byte[] bytes     = new byte[byteCount];
                 stream.Read(bytes, 0, bytes.Length);
                 sourceFiles.Add(Encoding.UTF8.GetString(bytes));
             }
             int spectrumInfoCount = PrimitiveArrays.ReadOneValue <int>(stream);
             _sourceFiles = ImmutableList.ValueOf(sourceFiles);
             List <ElibSpectrumInfo> spectrumInfos = new List <ElibSpectrumInfo>();
             while (spectrumInfos.Count < spectrumInfoCount)
             {
                 spectrumInfos.Add(ElibSpectrumInfo.Read(valueCache, stream));
             }
             SetLibraryEntries(spectrumInfos);
             return(true);
         }
     }
     catch (Exception exception)
     {
         Trace.TraceWarning(@"Exception loading cache: {0}", exception);
         return(false);
     }
 }
Пример #41
0
            private void ReadEntries()
            {
                var valueCache = new ValueCache();

                _stream.Seek(_locationEntries, SeekOrigin.Begin);
                int entryCount = PrimitiveArrays.ReadOneValue <int>(_stream);
                var entries    = new ChromLibSpectrumInfo[entryCount];

                for (int i = 0; i < entryCount; i++)
                {
                    entries[i] = ChromLibSpectrumInfo.Read(valueCache, _stream);
                }
                _library.SetLibraryEntries(entries);
                int irtCount = PrimitiveArrays.ReadOneValue <int>(_stream);

                _library._libraryIrts = new ChromatogramLibraryIrt[irtCount];
                for (int i = 0; i < irtCount; i++)
                {
                    _library._libraryIrts[i] = ChromatogramLibraryIrt.Read(_stream);
                }
            }
Пример #42
0
        internal CompoundView(Compound compound, int viewPosition)
            : base(_nextObjectId++)
        {
            Compound = compound;
            ViewPosition = viewPosition;
            CompoundContextCache = new ValueCache<CompoundContext>
                (() => new CompoundContext(this));

            _typeCache = new ValueCache<CompoundType>(() => new CompoundType(this));

            _accessFeaturesCache
                = new FunctionCache<int, AccessFeature>
                    (position => new AccessFeature(this, position));

            _fieldAccessTypeCache
                = new FunctionCache<int, FieldAccessType>
                    (position => new FieldAccessType(this, position));

            _functionBodyTypeCache
                = new FunctionCache<FunctionSyntax, FunctionBodyType>
                    (syntax => new FunctionBodyType(this, syntax));

            StopByObjectIds();
        }
Пример #43
0
 public ReniService()
 {
     _preferencesCache = new ValueCache<LanguagePreferences>
         (CreateLanguagePreferences);
 }
Пример #44
0
 public Data(Statement rawStatement, int position)
 {
     RawStatement = rawStatement;
     Position = position;
     StatementCache = new ValueCache<Result<Value>>(GetStatement);
     AllNamesCache = new ValueCache<string[]>(GetAllNames);
     PublicNamesCache = new ValueCache<string[]>(GetPublicNames);
     Tracer.Assert(RawStatement != null);
 }
Пример #45
0
		internal void NotifyChange()
		{
			cache = null;
			if (!isExpired) {
				OnChanged(new ValueEventArgs(this));
			}
		}
 public FileSourceProvider(File file, bool useCache = true)
 {
     File = file;
     if(useCache)
         DataCache = new ValueCache<string>(() => File.String);
 }
Пример #47
0
 public CompountType(SQLSysViews.all_objectsClass @object)
 {
     Object = @object;
     _membersCache = new ValueCache<Member[]>(()=>Object.Members);
     _uniquesCache = new ValueCache<int[][]>(GetUniques);
 }
Пример #48
0
 SQLSysViews()
 {
     _compountTypesCache = new ValueCache<all_objectsClass[]>(GetCompountTypes);
     _objectsCache = new ValueCache<Dictionary<string, all_objectsClass>>(CreateObjects);
     Columns = new FunctionCache<all_objectsClass, all_columnsClass[]>(CreateColumns);
 }
Пример #49
0
 public ReaderBatch(SqlConnection connection, Sql[] sqls)
 {
     _sqls = sqls;
     _readerCache = new ValueCache<DbDataReader>(() => ObtainDataReader(connection, SqlText));
     _sqlTextCache = new ValueCache<string>(GetSqlText);
 }
Пример #50
0
 public RemoveLocalReferences(CodeBase body, CodeBase copier)
     : base(_nextObjectId++)
 {
     Body = body;
     Copier = copier;
     _referencesCache = new ValueCache<LocalReference[]>(GetReferencesForCache);
     _reducedBodyCache = new ValueCache<CodeBase>(GetReducedBodyForCache);
 }
Пример #51
0
 internal ParseRequestWrapper(ParseRequest parent)
 {
     _parent = parent;
     _source = new Source(_parent.Text ?? "");
     _currenCache = new ValueCache<Token>(GetCurrentForCache);
 }
Пример #52
0
 public ClassWithCache() { Cache = new ValueCache(); }
Пример #53
0
 public Source(string text)
 {
     _compilerCache = new ValueCache<CompilerBrowser>(() => CreateCompilerForCache(text));
 }
Пример #54
0
 public Controller()
 {
     Tracer.Dumper.Configuration.Handlers.Force(typeof(Control), methodCheck: IsDumpable);
     Tracer.Dumper.Configuration.Handlers.Force(typeof(Component), methodCheck: IsDumpable);
     _configurationCache = new ValueCache<PersistentConfiguration>(GetConfiguration);
 }
Пример #55
0
 void SetUp()
 {
     target = new ValueCache<Guid>(Guid.NewGuid().ToString());
 }
Пример #56
0
 public Channel()
 {
     ResultCache = new ValueCache<StringStream>(GetResult);
     CompilerCache = new ValueCache<CompilerBrowser>(CreateCompiler);
 }
Пример #57
0
 protected Item(DataBase parent, string name)
 {
     Parent = parent;
     Name = name;
     _itemsCache = new ValueCache<Item[]>(GetItems);
 }