public void DummyMethod() { CompositeBuilderInfo <MyComposite> cbi = null; CompositeBuilder cb = null; { #region CompositeCreationCode6 // 'cbi' is of type CompositeBuilderInfo<MyComposite> MyComposite prototype = cbi.Prototype(); prototype.MyProperty = "InitialValue"; MyComposite instance = cbi.Instantiate(); // 'instance' and 'prototype' now reference to same object, // but setting instance.MyProperty to null will fail. #endregion } { #region CompositeCreationCode7 // 'cb' is of type CompositeBuilder MyComposite prototype = cb.Prototype <MyComposite>(); // Alternatively, prototype could be acquired this way: MyComposite prototype2 = (MyComposite)cb.PrototypeFor(typeof(MyComposite)); // 'prototype' and 'prototype2' reference to same object prototype.MyProperty = "InitialValue"; MyComposite instance = cb.Instantiate <MyComposite>(); // 'instance, 'prototype' and 'prototype2' all reference // to the same object. // Setting instance.MyProperty to null will fail. #endregion } }
public IComposite Map() { var builder = new CompositeBuilder <TInterface, TState>(); Map(builder); return(builder.Build()); }
private Compose(params Dependency[] dependencies) { if (dependencies == null) { throw new ArgumentNullException(nameof(dependencies)); } HostProvider.EnforceEnvironmentVariables(); var tuples = dependencies.Select(_ => (_.FileName, _.ReadinessProbe)) .Select(_ => { var(fileName, (service, probe)) = _; var composeFile = Path.IsPathRooted(fileName) ? fileName : Path.Combine(VisualStudioProvider.TryGetSolutionDirectoryInfo().FullName, fileName); return(composeFile, service, probe); }).ToArray(); var nw = new Builder().UseNetwork("demo").ReuseIfExist().Build(); ComposeBuilder = new Builder() .UseContainer() .UseNetwork(nw) .UseCompose() .UseColor() .FromFile(tuples.Select(_ => _.composeFile).ToArray()) .ForceRecreate(); foreach (var(_, service, probe) in tuples) { ComposeBuilder = ComposeBuilder.Wait(service, probe); } }
public bool CreateBehaviors() { int count; _combat = CompositeBuilder.GetComposite(Class, BehaviorType.Combat, out count); if (count == 0 || _combat == null) { Log.InfoFormat("Combat support for {0} is not currently implemented.", Class); return(false); } _combat = new Sequence( new Action(ctx => { if (BelphegorSettings.Instance.Debug.IsDebugTreeExecutionLoggingActive) { _stopwatch.Restart(); } }), _combat, new Action(ctx => { if (BelphegorSettings.Instance.Debug.IsDebugTreeExecutionLoggingActive) { _stopwatch.Stop(); Log.DebugFormat("Tree execution took {0}ms.", _stopwatch.ElapsedMilliseconds); } }) ); _buff = CompositeBuilder.GetComposite(Class, BehaviorType.Buff, out count); if (count == 0 || _buff == null) { Log.InfoFormat("Buff support for {0} is not currently implemented.", Class); } _movement = CompositeBuilder.GetComposite(Class, BehaviorType.Movement, out count); if (count == 0 || _movement == null) { Log.InfoFormat("Movement support for {0} is not currently implemented.", Class); } Hotbar.Update(); return(true); }
public static void DummyMethod() { StructureServiceProvider ssp = null; Type myCompositeType = null; #region CompositeCreationCode1 // Acquiring CompositeBuilderInfo CompositeBuilderInfo <MyComposite> cbi = ssp.NewPlainCompositeBuilder <MyComposite>(); // Acquiring CompositeBuilder, type of composite not known at compile time CompositeBuilder cb = ssp.NewPlainCompositeBuilder(myCompositeType); // myCompositeType is of System.Type // Acquiring CompositeBuilder and using multiple types to filter out possible composites CompositeBuilder cbm = ssp.NewPlainCompositeBuilder(new[] { typeof(MyCompositePartialType1), typeof(MyCompositePartialType2) }); #endregion { #region CompositeCreationCode2 MyComposite composite = cbi.Instantiate(); #endregion } { #region CompositeCreationCode3 MyComposite composite = cb.Instantiate <MyComposite>(); MyComposite composite2 = (MyComposite)cb.InstantiateWithType(typeof(MyComposite)); // Both composite and composite2 will be same object. #endregion } { #region CompositeCreationCode4 MyCompositePartialType1 composite1 = cbm.Instantiate <MyCompositePartialType1>(); MyCompositePartialType2 composite2 = cbm.Instantiate <MyCompositePartialType2>(); // composite1 and composite2 may be different objects. #endregion } }
public void Setup() { _builder = new CompositeBuilder(_client, _appSettings.SalesforceApiVersion); }
/// <summary> /// Creates a new instance of <see cref="CompositeBuilderInfo{T}"/> wrapping existing <see cref="CompositeBuilder"/>. /// Qi4CS runtime will use this constructor so there is no need to user code to invoke this. /// </summary> /// <param name="builder">The <see cref="CompositeBuilder"/> to wrap.</param> /// <exception cref="ArgumentNullException">If <paramref name="builder"/> is <c>null</c>.</exception> public CompositeBuilderInfo(CompositeBuilder builder) { ArgumentValidator.ValidateNotNull("Builder", builder); this._builder = builder; }
/// <summary> /// Helper method to easily invoke <see cref="CompositeBuilder.PrototypeFor(Type)"/> method when type is known at compile-time. /// </summary> /// <typeparam name="TComposite">The type of the composite.</typeparam> /// <param name="builder">The <see cref="CompositeBuilder"/>.</param> /// <returns>The return value of <see cref="CompositeBuilder.PrototypeFor(Type)"/> casted to <typeparamref name="TComposite"/>.</returns> public static TComposite Prototype <TComposite>(this CompositeBuilder builder) { return((TComposite)builder.PrototypeFor(typeof(TComposite))); }
/// <summary> /// Helper method to easily invoke <see cref="CompositeBuilder.InstantiateWithType(Type)"/> method when type is known at compile-time. /// </summary> /// <typeparam name="TComposite">The type of the composite.</typeparam> /// <param name="builder">The <see cref="CompositeBuilder"/>.</param> /// <returns>The return value of <see cref="CompositeBuilder.InstantiateWithType(Type)"/> casted to <typeparamref name="TComposite"/>.</returns> public static TComposite Instantiate <TComposite>(this CompositeBuilder builder) { return((TComposite)builder.InstantiateWithType(typeof(TComposite))); }
public void Setup() { _compositeBuilder = new CompositeBuilder(null, _salesforceApiVersion); }