private object GetComponent(IComponentBuilder builder) { object component; if (builder == null) { component = null; } else { component = builder.BuildComponent(); } return component; }
private void AddBuilder(Type contractType, IComponentBuilder builder) { lock (componentLock) { if (!componentTypes[contractType].ComponentBuilders.Contains(builder)) { componentTypes[contractType].ComponentBuilders.Add(builder); } if (!componentBuilders.Contains(builder)) { componentBuilders.Add(builder); } } }
private void AddBuilder(Type contractType, IComponentBuilder builder) { ComponentType componentType = GetComponentType(contractType); if (componentType != null) { ComponentBuilderCollection builders = componentType.ComponentBuilders; using (builders.GetWriteLock()) { builders.AddBuilder(builder, true); } using (_componentBuilders.GetWriteLock()) { _componentBuilders.AddBuilder(builder, false); } } }
/// <inheritdoc/> public override object GetComponent(Type contractType) { ComponentType componentType = this.GetComponentType(contractType); object component = null; if (componentType != null) { int builderCount; using (componentType.ComponentBuilders.GetReadLock()) { builderCount = componentType.ComponentBuilders.Count; } if (builderCount > 0) { IComponentBuilder builder = this.GetDefaultComponentBuilder(componentType); component = this.GetComponent(builder); } } return(component); }
public static void ConfigureWpfWindow <T>(this IComponentBuilder builder) where T : Window, IHostedWindow, new() { Resolve(builder.ParentScope).Register <T>(); }
public static void ConfigureUIModel <TPlugin, TOptions>(this IComponentBuilder builder) where TPlugin : Plugin where TOptions : class, new() { builder.Container.RegisterType <ConfigurationDependencySet <TPlugin, TOptions> >().SingleInstance(); }
public CreateComponentDescriptionTxtAction(IComponentBuilder componentBuilder) { _componentBuilder = componentBuilder; }
public override void BuildComponents(IComponentBuilder builder) { builder.ConfigureEventStatistic <PlayerInformationEvent>(); builder.ConfigureComponent <PlayerInformationCrawler>().SingleInstance().PropertiesAutowired(); }
public static dynamic GetCastedBuilder(this IComponentBuilder <IComponent, ComponentTypeInfo> generalizedBuilder) { return((generalizedBuilder as BuilderGeneralizer)?.CastedBuilder); }
public override void BuildComponents(IComponentBuilder builder) { builder.ConfigureDbContext <StatisticContext>(); builder.ConfigureComponent <StatisticManager>().SingleInstance().PropertiesAutowired(); }
public Director(IComponentBuilder b) { _componentBuilder = b; }
/// <summary> /// Creates an instance of the builder from the given builder. /// </summary> /// <param name="builder">The builder to start the new instance from.</param> public BootstrapComponentBuilder(IComponentBuilder builder) : base(builder) { }
internal static void SetEntityViewComponentImplementors <T>(this IComponentBuilder componentBuilder, ref T entityComponent, IEnumerable <object> implementors, ComponentBuilder <T> .EntityViewComponentCache localCache) where T : struct, IBaseEntityComponent { DBC.ECS.Check.Require(implementors != null, NULL_IMPLEMENTOR_ERROR.FastConcat(" entityComponent ", componentBuilder.GetEntityComponentType().ToString())); var cachedTypeInterfaces = localCache.cachedTypes; var implementorsByType = localCache.implementorsByType; var entityComponentBlazingFastReflection = localCache.cachedFields; foreach (var implementor in implementors) { DBC.ECS.Check.Require(implementor != null, "invalid null implementor used to build an entity"); { var type = implementor.GetType(); //fetch all the interfaces that the implementor implements if (cachedTypeInterfaces.TryGetValue(type, out var interfaces) == false) { interfaces = cachedTypeInterfaces[type] = type.GetInterfacesEx(); } for (var iindex = 0; iindex < interfaces.Length; iindex++) { var componentType = interfaces[iindex]; //an implementor can implement multiple interfaces, so for each interface we reference //the implementation object. Multiple entity view component fields can then be implemented //by the same implementor #if DEBUG && !PROFILE_SVELTO if (implementorsByType.TryGetValue(componentType, out var implementorData)) { implementorData.numberOfImplementations++; implementorsByType[componentType] = implementorData; } else { implementorsByType[componentType] = new ECSTuple <object, int>(implementor, 1); } #else implementorsByType[componentType] = implementor; #endif } } } //efficient way to collect the fields of every EntityComponentType var setters = FasterList <KeyValuePair <Type, FastInvokeActionCast <T> > > .NoVirt.ToArrayFast( entityComponentBlazingFastReflection, out var count); for (var i = 0; i < count; i++) { var fieldSetter = setters[i]; var fieldType = fieldSetter.Key; #if DEBUG && !PROFILE_SVELTO ECSTuple <object, int> implementor; #else object implementor; #endif if (implementorsByType.TryGetValue(fieldType, out implementor) == false) { var e = new ECSException(NOT_FOUND_EXCEPTION + " Component Type: " + fieldType.Name + " - EntityComponent: " + componentBuilder.GetEntityComponentType().Name); throw e; } #if DEBUG && !PROFILE_SVELTO if (implementor.numberOfImplementations > 1) { throw new ECSException(DUPLICATE_IMPLEMENTOR_ERROR.FastConcat( "Component Type: ", fieldType.Name, " implementor: ", implementor.instance.ToString()) + " - EntityComponent: " + componentBuilder.GetEntityComponentType().Name); } #endif #if DEBUG && !PROFILE_SVELTO fieldSetter.Value(ref entityComponent, implementor.instance); #else fieldSetter.Value(ref entityComponent, implementor); #endif } implementorsByType.Clear(); }
internal ComponentBuilderContext(IComponentBuilder builder) { Builder = builder; }
/// <summary> /// Creates an instance of the builder from the given builder. /// </summary> /// <param name="builder">The builder to start the new instance from.</param> public RowBuilder(IComponentBuilder builder) : base(builder) { }
public DeployFileAction(IComponentBuilder componentBuilder, IOutputFile outputFile, VersionNumber version) { _componentBuilder = componentBuilder; Version = version; OutputFile = outputFile; }
public override void BuildComponents(IComponentBuilder builder) { builder.ConfigureUIComponent <MyTab>(); }
public override void BuildComponents(IComponentBuilder builder) { }
public static void UseMemoryDataCollector <TCollector, TMatched, TTerminated>(this IComponentBuilder builder) where TCollector : MemoryDataCollector <TCollector, TMatched, TTerminated> where TMatched : ProcessMatchedEvent <TMatched> where TTerminated : ProcessTerminatedEvent <TTerminated> { builder.ConfigureComponent <TCollector>().SingleInstance(); builder.ConfigureStaticEventHandler <MemoryDataCollector <TCollector, TMatched, TTerminated> .MatchedHandler>(); builder.ConfigureStaticEventHandler <MemoryDataCollector <TCollector, TMatched, TTerminated> .TerminatedHandler>(); }
public static void ConfigureDownloadProvider <T>(this IComponentBuilder builder) where T : IDownloadProvier, IComponent, new() { Resolve(builder.ParentScope).RegisterComponent <T>(); builder.ConfigureComponent <T>().AsSelf().Named <IDownloadProvier>(typeof(T).Name); }
public abstract void BuildComponents(IComponentBuilder builder);
public static void ConfigureCommandContainer <T>(this IComponentBuilder _builder) where T : IComponent { var builder = _builder as ComponentBuilder; builder.Container.RegisterType <T>().SingleInstance(); }
/// <summary> /// Provides access to specified component bulder by way of IComponentBuilder<IComponent, AComponentTypeInfo> interface. /// </summary> /// <param name="builderInstance">Casting component builder. Should implement IComponentBuilder<TComponent, TTypeInfo> interface.</param> /// <returns>BuilderGeneralizer instance.</returns> public static IComponentBuilder <IComponent, ComponentTypeInfo> ToGeneralBuilderType <TComponent, TTypeInfo>(this IComponentBuilder <TComponent, TTypeInfo> builderInstance) where TComponent : class, IComponent where TTypeInfo : ComponentTypeInfo { return(new BuilderGeneralizer(builderInstance)); }
public ProcessListenerBuilder(IComponentBuilder builder) { Builder = builder; }
public override void BuildComponents(IComponentBuilder builder) { builder.ConfigureDbContext <OsuDatabaseContext>(); builder.ConfigureComponent <DatabaseSynchronizer>().SingleInstance(); }
/// <summary> /// Note: unluckily I didn't design the serialization system to be component order independent, so unless /// I do something about it, this method cannot be optimized, the logic of the component order must stay /// untouched (no reordering, no use of dictionaries). Components order must stay as it comes, as /// well as extracomponents order. /// Speed, however, is not a big issue for this class, as the data is always composed once per entity descriptor /// at static constructor time /// </summary> /// <returns></returns> IComponentBuilder[] Construct(int extraComponentsLength, IComponentBuilder[] extraComponents) { IComponentBuilder[] MergeLists (IComponentBuilder[] startingComponents, IComponentBuilder[] newComponents, int newComponentsLength) { var startComponents = new FasterDictionary <RefWrapper <IComponentBuilder, ComponentBuilderComparer>, IComponentBuilder>(); var xtraComponents = new FasterDictionary <RefWrapper <IComponentBuilder, ComponentBuilderComparer>, IComponentBuilder>(); for (uint i = 0; i < startingComponents.Length; i++) { startComponents [new RefWrapper <IComponentBuilder, ComponentBuilderComparer>(startingComponents[i])] = startingComponents[i]; } for (uint i = 0; i < newComponentsLength; i++) { xtraComponents[new RefWrapper <IComponentBuilder, ComponentBuilderComparer>(newComponents[i])] = newComponents[i]; } xtraComponents.Exclude(startComponents); if (newComponentsLength != xtraComponents.count) { newComponentsLength = xtraComponents.count; uint index = 0; foreach (var couple in xtraComponents) { newComponents[index++] = couple.key.type; } } IComponentBuilder[] componentBuilders = new IComponentBuilder[newComponentsLength + startingComponents.Length]; Array.Copy(startingComponents, 0, componentBuilders, 0, startingComponents.Length); Array.Copy(newComponents, 0, componentBuilders, startingComponents.Length, newComponentsLength); var entityInfoComponentIndex = FetchEntityInfoComponent(componentBuilders); DBC.ECS.Check.Assert(entityInfoComponentIndex != -1); componentBuilders[entityInfoComponentIndex] = new ComponentBuilder <EntityInfoComponent>( new EntityInfoComponent { componentsToBuild = componentBuilders }); return(componentBuilders); } if (extraComponentsLength == 0) { return(_componentsToBuild); } var safeCopyOfExtraComponents = new IComponentBuilder[extraComponentsLength]; Array.Copy(extraComponents, safeCopyOfExtraComponents, extraComponentsLength); return(MergeLists(_componentsToBuild, safeCopyOfExtraComponents, extraComponentsLength)); }
public static void ConfigureUIComponent <TComponent>(this IComponentBuilder builder) where TComponent : IViewComponent, new() { Resolve(builder.ParentScope).RegisterComponent <TComponent>(); builder.ConfigureComponent <TComponent>().SingleInstance(); }
public override object GetComponent(string name) { IComponentBuilder builder = GetComponentBuilder(name); return(GetComponent(builder)); }
public static void ConfigureUIComponent <TComponent>(this IComponentBuilder builder, string category) where TComponent : IViewComponent, new() { Resolve(builder.ParentScope).RegisterComponent <TComponent>(category); }
public override void BuildComponents(IComponentBuilder builder) { builder.ConfigureCommandContainer <PluginControlCommand>(); builder.UseConfigurationModel <MyPluginConfiguration>("MyPlugin"); }
/// <summary> /// Class constructor method. /// </summary> /// <param name="component"></param> public ComponentBuilder(IComponentBuilder <T> component) { this.component = component; }
public override void BuildComponents(IComponentBuilder builder) { builder.ConfigureComponent <StatisticEditorViewModel>().AsSelf().As <IEditorContextViewModel>().SingleInstance().PropertiesAutowired(); builder.ConfigureUIComponent <StatisticEditorTab>(); }
/// <summary> /// Creates an instance of the builder from the given builder. /// </summary> /// <param name="builder">The builder to start the new instance from.</param> public ColumnBuilder(IComponentBuilder builder) : base(builder) { }