public FieldGetter(FieldInfo fieldInfo) { _fieldInfo = fieldInfo; Name = fieldInfo.Name; MemberType = fieldInfo.FieldType; _lateBoundFieldGet = LazyFactory.Create(() => DelegateFactory.CreateGet(fieldInfo)); }
public MethodGetter(MethodInfo methodInfo) { _methodInfo = methodInfo; Name = _methodInfo.Name; _memberType = _methodInfo.ReturnType; _lateBoundMethod = LazyFactory.Create(() => DelegateFactory.CreateGet(methodInfo)); }
public ConstructorMap(ConstructorInfo ctor, IEnumerable<ConstructorParameterMap> ctorParams) { Ctor = ctor; CtorParams = ctorParams; _runtimeCtor = LazyFactory.Create(() => DelegateFactory.CreateCtor(ctor, CtorParams)); }
public PropertyAccessor(PropertyInfo propertyInfo) : base(propertyInfo) { HasSetter = propertyInfo.GetSetMethod(true) != null; if (HasSetter) { _lateBoundPropertySet = LazyFactory.Create(() => DelegateFactory.CreateSet(propertyInfo)); } }
public ResGlobalMemberTerm( SourceRange range, ILazy<IResModuleDecl> module, IResMemberDecl decl) { _range = range; _module = module; _decl = decl; _subst = new Substitution(); }
public PropertyGetter(PropertyInfo propertyInfo) { _propertyInfo = propertyInfo; Name = _propertyInfo.Name; MemberType = _propertyInfo.PropertyType; _lateBoundPropertyGet = _propertyInfo.GetGetMethod(true) != null ? LazyFactory.Create(() => DelegateFactory.CreateGet(propertyInfo)) : LazyFactory.Create<LateBoundPropertyGet>(() => src => null); }
public ResFieldDecl( ILazy <IResMemberLineDecl> line, SourceRange range, Identifier name, ILazy <IResTypeExp> type, ILazy <IResExp> init) : base(line, range, name) { _type = type; _init = init; }
/// <summary> /// 获取实例 /// </summary> /// <returns>实例</returns> public ILazy GetInstance() { if (pool.Any()) { ILazy instance = pool.First(); pool.Remove(instance); instance.SetActive(true); return(instance); } return(instantiate()); }
public ResConceptClassDecl( ILazy <IResMemberLineDecl> line, SourceRange range, Identifier name, ILazy <IResVarDecl> thisParameter, ILazy <IEnumerable <IResMemberNameGroup> > memberNameGroups) : base(line, range, name) { _thisParameter = thisParameter; _memberNameGroups = memberNameGroups; }
public ILeafContainer ReadTypeLazy(bool hasSize = true) { long typePos = Position; ILazy <ILeafContainer> delayedLeaf = LazyFactory.CreateLazy <ILeafContainer>(() => { Position = typePos; return(ReadTypeDirect(hasSize)); }); return(new LazyLeafProvider(ctx, delayedLeaf)); }
internal TagAnnotation(Repository repo, ObjectId id) : base(repo, id) { lazyName = GitObjectLazyGroup.Singleton(repo, id, Proxy.git_tag_name); lazyTarget = GitObjectLazyGroup.Singleton(repo, id, obj => BuildFrom(repo, Proxy.git_tag_target_oid(obj), Proxy.git_tag_target_type(obj), null)); group = new GitObjectLazyGroup(repo, id); lazyTagger = group.AddLazy(Proxy.git_tag_tagger); lazyMessage = group.AddLazy(Proxy.git_tag_message); }
public MidAttributeFetch( SourceRange range, MidPath obj, MidAttributeDecl attribute, ILazyFactory lazyFactory ) : base(range, new MidDummyType()) { _obj = obj; _type = lazyFactory.New(() => _attribute.Value.Type); _attribute = Lazy.Value(attribute); }
public ResVarDecl( SourceRange range, Identifier name, ILazy<IResTypeExp> type, ResVarFlags flags = ResVarFlags.None) { _range = range; _name = name; _type = type; _flags = flags; }
public DebugReader(IServiceContainer ctx, SpanStream stream) : base(stream) { this.StreamTable = ctx.GetService <StreamTableReader>(); for (int i = 0; i < (int)DebugType.DebugTypeMax; i++) { DebugStreams[i] = ReadInt16(); } lazyFPO = LazyFactory.CreateLazy(CreateFPOReader); }
public MidAttributeFetch( SourceRange range, MidPath obj, MidType type, ILazy<MidAttributeDecl> attribute) : base(range, new MidDummyType()) { _obj = obj; _type = Lazy.Value(type); _attribute = attribute; }
public ResAttributeRef( SourceRange range, ResAttributeDecl decl, IResMemberTerm memberTerm, ILazy <IResFreqQualType> lazyType, ILazy <IResExp> lazyInit) : base(range, decl, memberTerm) { _lazyType = lazyType; _lazyInit = lazyInit; }
public ResGenericDecl( ILazy <IResMemberLineDecl> line, SourceRange range, Identifier name, ILazy <IEnumerable <IResGenericParamDecl> > parameters, ILazy <IResMemberDecl> innerDecl) : base(line, range, name) { _parameters = parameters; _innerDecl = innerDecl; }
/* * [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] * public static Maybe<TResult> Select<TSource, TResult>(this Maybe<TSource> source, Func<TSource, TResult> selector) { * if (source.IsJust) { * var source_Value = source.Value; * if (source_Value.IsEvaluated) { * return new Maybe<TResult>(selector.Invoke(source_Value.Cache).ToLazy()); * } * return new Maybe<TResult>(new Lazy<TResult>(() => selector.Invoke(source_Value.Value))); * } * return default; * } */ public static Lazy <Maybe <TResult> > Select <TSource, TResult>(this ILazy <Maybe <TSource> > source, Expression <Func <TSource, TResult> > selector) { throw new NotImplementedException(); /* * if (null != source) { * var f = ToNonstrict.FromUncurried(selector).Compile(); * return source.Select(f); * } * return null; */ }
private void PopulateLazyValue(List <object> references, ILazy lazy) { Action <object> onValueCreated = null; onValueCreated = a => { refMgr.RegisterHandle(a, lazy.Kernel, lazy.Component); references.Add(a); lazy.ValueCreated -= onValueCreated; }; lazy.ValueCreated += onValueCreated; }
public static void RegisterLazyAndReferred(this ILazy lazy, object owner) { Action <object> onValueCreated = null; onValueCreated = o => { ReferenceManager.Instance.RegisterHandle(o, lazy.Kernel, lazy.Component); ReferenceManager.Instance.RegisterReference(owner, o); lazy.ValueCreated -= onValueCreated; }; lazy.ValueCreated += onValueCreated; }
public ExecCommand(IConsole console, ILazy <GetHelloMessageHandler> getHelloMessageHandler, ILazy <GetHelloWorldMessageHandler> getHelloWorldMessageHandler) { Checker.NotNullArgument(console, nameof(console)); Checker.NotNullArgument(console.Out, () => console.Out); Checker.NotNullArgument(getHelloMessageHandler, nameof(getHelloMessageHandler)); Checker.NotNullArgument(getHelloWorldMessageHandler, nameof(getHelloWorldMessageHandler)); Out = console.Out; GetHelloMessageHandler = getHelloMessageHandler; GetHelloWorldMessageHandler = getHelloWorldMessageHandler; }
public void Add <T>(ILazy <T> reader) { var type = typeof(T); if (!this.impl_.TryGetValue(type, out var fileReaders)) { fileReaders = new List <ILazy>(); this.impl_[type] = fileReaders; } fileReaders.Add(reader); }
public LazyTuple(ILazy <TItem1> item1, ILazy <TItem2> item2, ILazy <TItem3> item3, ILazy <TItem4> item4) { Checker.NotNullArgument(item1, nameof(item1)); Checker.NotNullArgument(item2, nameof(item2)); Checker.NotNullArgument(item3, nameof(item3)); Checker.NotNullArgument(item4, nameof(item4)); _item1 = item1; _item2 = item2; _item3 = item3; _item4 = item4; }
public ResAttributeDecl( ILazy <IResMemberLineDecl> line, SourceRange range, Identifier name, ILazy <IResFreqQualType> type, ILazy <IResExp> init, ILazy <ResAttributeFlags> flags) : base(line, range, name) { _type = type; _init = init; _flags = flags; }
public override TAbstraction Load(IContainer container) { ILazy <IStartPage> startPage = container.GetInstance <ILazy <IStartPage> >(); if (startPage == null || ContentReference.IsNullOrEmpty(startPage.Service.SettingsPageReference)) { return(new TSettings()); } var contentLoader = container.GetInstance <IContentLoader>(); return(contentLoader.Get <TSettings>(startPage.Service.SettingsPageReference) ?? new TSettings()); }
public override TAbstraction Load(IContainer container) { ILazy <ISiteSettings> siteSettings = container.GetInstance <ILazy <ISiteSettings> >(); if (siteSettings == null || ContentReference.IsNullOrEmpty(siteSettings.Service.ContentLink)) { return(new TSettings()); } var contentLoader = container.GetInstance <IContentLoader>(); return(contentLoader.GetChildren <TSettings>(siteSettings.Service.ContentLink).FirstOrDefault() ?? new TSettings()); }
public void Setup() { count = 0; if (typeof(TLazy) == typeof(LazySingleThreaded <int>)) { lazy = LazyFactory.CreateSingleThreaded(() => { ++count; return(1); }); } else { lazy = LazyFactory.CreateMultiThreaded(() => { ++count; return(1); }); } }
public CodeViewModuleReader(IServiceContainer ctx, ModuleInfo mod, SpanStream stream) : base(stream) { this.ctx = ctx; this.mod = mod; CodeViewSignature signature = ReadEnum <CodeViewSignature>(); if (signature != CodeViewSignature.C13) { throw new NotImplementedException($"CodeView {signature} not supported yet"); } lazySymbols = LazyFactory.CreateLazy(ReadSymbols); }
// ResMemberDecl public override IResMemberDecl CreateInheritedDeclImpl( ResolveContext resContext, IResContainerBuilderRef resContainer, ILazy <IResMemberLineDecl> resLine, SourceRange range, IResMemberRef memberRef) { var firstRef = (ResMethodRef)memberRef; var firstDecl = firstRef.Decl; var result = ResMethodDecl.Build( resContext.LazyFactory, resLine, range, firstDecl.Name, (builder) => { // \todo: More substitution needed? // \todo: Add back in inheritance-related validation checks? /* * if (firstRef.Body == null * && memberRefs.OfType<IResMethodRef>().Any((mr) => (mr.Body != null))) * { * throw new NotImplementedException(); * } */ var subst = new Substitution(); var newParams = new List <ResVarDecl>(); foreach (var oldParam in firstRef.Parameters) { var newParam = new ResVarDecl( range, oldParam.Name, oldParam.Type, oldParam.Decl.Flags); subst.Insert(oldParam.Decl, newParam); newParams.Add(newParam); } builder.Parameters = newParams; builder.ResultType = firstRef.ResultType; builder.LazyBody = resContext.LazyFactory.New(() => firstRef.Body == null ? null : firstRef.Body.Substitute(subst)); }); return(result); }
public void GetInManyThreads() { int number = 1; lazy = LazyFactory <int> .CreateMultiLazy(() => ++ number); threads = new Thread[10]; for (int i = 0; i < 10; i++) { threads[i] = new Thread(() => { Assert.AreEqual(2, lazy.Get()); }); } }
public ResMethodDecl( ILazy <IResMemberLineDecl> line, SourceRange range, Identifier name, ILazy <IEnumerable <IResVarDecl> > parameters, ILazy <IResTypeExp> resultType, ILazy <IResExp> body, ILazy <ResMethodFlavor> flavor) : base(line, range, name) { _parameters = parameters; _resultType = resultType; _body = body; _flavor = flavor; }
public override IResMemberDecl CreateInheritedDeclImpl( ResolveContext resContext, IResContainerBuilderRef resContainer, ILazy <IResMemberLineDecl> resLine, SourceRange range, IResMemberRef memberRef) { var first = (IResElementRef)memberRef; var result = new ResElementDecl( resLine, range, first.Decl.Name); return(result); }
public ResGenericDeclBuilder( ILazyFactory lazy, ILazy <IResMemberLineDecl> line, SourceRange range, Identifier name) : base(lazy) { var resGenericDecl = new ResGenericDecl( line, range, name, NewLazy(() => _parameters), NewLazy(() => _innerDecl)); SetValue(resGenericDecl); }
public ResFieldDeclBuilder( ILazyFactory lazyFactory, ILazy <IResMemberLineDecl> resLine, SourceRange range, Identifier name) : base(lazyFactory) { var resFieldDecl = new ResFieldDecl( resLine, range, name, NewLazy(() => _type), NewLazy(() => _init)); SetValue(resFieldDecl); }
public ResConceptClassDeclBuilder( ILazyFactory lazyFactory, ILazy <IResMemberLineDecl> line, SourceRange range, Identifier name) : base(lazyFactory) { var resConceptClassDecl = new ResConceptClassDecl( line, range, name, NewLazy(() => _thisParameter), NewLazy(() => (from mngb in _memberNameGroups.Values select mngb.Value).Eager())); SetValue(resConceptClassDecl); }
public PropertiesConfigurationProvider(string fileName) { this.properties = new OneTryLazy <Properties>( () => { if (!File.Exists(fileName)) { return(new Properties()); } using (var fileContent = File.OpenRead(fileName)) { return(Properties.Load(fileContent)); } }); }
internal Commit(Repository repo, ObjectId id) : base(repo, id) { lazyTree = GitObjectLazyGroup.Singleton(this.repo, id, obj => new Tree(this.repo, Proxy.git_commit_tree_oid(obj), null)); group = new GitObjectLazyGroup(this.repo, id); lazyAuthor = group.AddLazy(Proxy.git_commit_author); lazyCommitter = group.AddLazy(Proxy.git_commit_committer); lazyMessage = group.AddLazy(Proxy.git_commit_message); lazyEncoding = group.AddLazy(RetrieveEncodingOf); lazyShortMessage = new Lazy <string>(ExtractShortMessage); lazyNotes = new Lazy <IEnumerable <Note> >(() => RetrieveNotesOfCommit(id).ToList()); parents = new ParentsCollection(repo, id); }
public Lazy <TResult> Invoke(ILazy <T2> arg) { var f = this.c1.arg; var v1 = this.arg; var v2 = arg; if (v1.IsEvaluated) { return(ToNonstrict <T2, TResult, TFuncB1> .Value.Invoke(f.Invoke(v1.Cache)).Invoke(v2)); } if (v2.IsEvaluated) { var u2 = v2.Cache; return(new Lazy <TResult>(() => f.Invoke(v1.Value).Invoke(u2))); } return(new Lazy <TResult>(() => f.Invoke(v1.Value).Invoke(v2.Value))); }
public SectionContrib40(IServiceContainer ctx, SpanStream stream) : base(stream) { SectionIndex = ReadUInt16(); ReadUInt16(); Offset = ReadUInt32(); Size = ReadUInt32(); Characteristics = ReadUInt32(); ModuleIndex = ReadInt16(); ReadUInt16(); //////// DBIReader dbi = ctx.GetService <DBIReader>(); moduleLazy = LazyFactory.CreateLazy(() => ModuleIndex == -1 ? null : dbi.Modules[this.ModuleIndex]); }
internal Blob(Repository repo, ObjectId id) : base(repo, id) { lazySize = GitObjectLazyGroup.Singleton(repo, id, Proxy.git_blob_rawsize); lazyIsBinary = GitObjectLazyGroup.Singleton(repo, id, Proxy.git_blob_is_binary); }
public FieldAccessor(FieldInfo fieldInfo) : base(fieldInfo) { _lateBoundFieldSet = LazyFactory.Create(() => DelegateFactory.CreateSet(fieldInfo)); }
private void PopulateLazyValue(List<object> references, ILazy lazy) { Action<object> onValueCreated = null; onValueCreated = a => { refMgr.RegisterHandle(a, lazy.Kernel, lazy.Component); references.Add(a); lazy.ValueCreated -= onValueCreated; }; lazy.ValueCreated += onValueCreated; }
public CountedTextFile(ITextFile textFile, Func<Func<FileLineCount>, ILazy<FileLineCount>> makeLazy) { this.textFile = textFile; lazyCount = makeLazy(CountLines); }