Inheritance: MonoBehaviour
コード例 #1
0
ファイル: GoalBrain.cs プロジェクト: rc183/igf
 /// <summary>
 /// Removes a Goal from the brain
 /// </summary>
 /// <param name="behavior"></param>
 public override void Remove(Behavior behavior)
 {
     if(behavior is Goal)
         _root.Remove(behavior as Goal);
     else
         base.Remove(behavior);
 }
コード例 #2
0
ファイル: GoalBrain.cs プロジェクト: rc183/igf
 /// <summary>
 /// Adds a new Goal to the brain
 /// </summary>
 /// <param name="behavior"></param>
 public override void Add(Behavior behavior)
 {
     if(behavior is Goal)
         _root.Add(behavior as Goal);
     else
         base.Add(behavior);
 }
コード例 #3
0
 public override void OnAwake()
 {
     // If behavior is null use the behavior that this task is attached to.
     if (behavior == null) {
         behavior = Owner;
     }
 }
コード例 #4
0
 public void TheStudentIsLooking( Vector3 position)
 {
     if (curBehavior == Behavior.PayingAttention) {
         theStudentPos = position;
         curBehavior = pickOneBehavior();
     }
 }
コード例 #5
0
ファイル: Camera.cs プロジェクト: aizotov/CancerSimulation
        /// <summary>
        /// Constructs a new instance of the camera class. The camera will
        /// have a flight behavior, and will be initially positioned at the
        /// world origin looking down the world negative z axis.
        /// </summary>
        public Camera()
        {
            behavior = Behavior.Flight;
            preferTargetYAxisOrbiting = true;

            fovx = DEFAULT_FOVX;
            znear = DEFAULT_ZNEAR;
            zfar = DEFAULT_ZFAR;

            accumPitchDegrees = 0.0f;
            orbitMinZoom = DEFAULT_ORBIT_MIN_ZOOM;
            orbitMaxZoom = DEFAULT_ORBIT_MAX_ZOOM;
            orbitOffsetLength = DEFAULT_ORBIT_OFFSET_LENGTH;
            firstPersonYOffset = 0.0f;

            eye = Vector3.Zero;
            target = Vector3.Zero;
            targetYAxis = Vector3.UnitY;
            xAxis = Vector3.UnitX;
            yAxis = Vector3.UnitY;
            zAxis = Vector3.UnitZ;

            orientation = Quaternion.Identity;
            viewMatrix = Matrix.Identity;

            savedEye = eye;
            savedOrientation = orientation;
            savedAccumPitchDegrees = 0.0f;
        }
コード例 #6
0
ファイル: AI.cs プロジェクト: settrbrg/ethanolpunk
        /// <summary>
        /// 
        /// </summary>
        /// <param name="world"></param>
        /// <param name="texture"></param>
        /// <param name="size"></param>
        /// <param name="startPosition"></param>
        /// <param name="mass"></param>
        /// <param name="wheelSize"></param>
        /// <param name="game"></param>
        /// <param name="behaviors"></param>
        /// <param name="userdata"></param>
        public AI(World world, Texture2D texture, Vector2 size, Vector2 startPosition, float mass, float wheelSize, Game1 game, Behavior behaviors, string userdata)
            : base(world, texture, size, mass, startPosition, game, userdata)
        {
            //Load(texture, 2, 11, 1,0);
            torso.body.CollisionCategories = Category.Cat2;
            speed = 0.5f;
            //jumpForce = new Vector2(0, -5f);

            Load(texture, 2, 5, 1, 1);
            direction = Direction.Right;
            lastCheck = DateTime.Now;

            //not used yet
            OnGround = true;

            //sets behavior for this AI
            switch (behaviors)
            {
                case Behavior.Patrol:
                    behaviorDel = Patrol;
                    damage = 34;
                    break;

                case Behavior.PatrolDistance:
                    behaviorDel = PatrolDistance;
                    damage = 40;
                    break;

                case Behavior.Turret:
                    fireRate = 0.08f;
                    enemyHP += 100;
                    behaviorDel = Turret;
                    damage = 45;
                    Load(texture, 1, 8, 1, 0);
                    break;

                case Behavior.Boss:
                    Load(texture, 2, 7, 60, 1);
                    fireRate = 0.5f;
                    enemyHP = 1512;
                    jumpForce = new Vector2(0, -21);
                    behaviorDel = Boss;
                    jumpInterval = 2f;
                    direction = Direction.Left;
                    damage = 70;
                    speed = 0.5f;
                    atSpawn = true;
                    break;

                case Behavior.None:
                    behaviorDel = None;
                    break;
            }

            this.behaviors = behaviors;

            //test (leave in peace)
            bossRay = game.Content.Load<Texture2D>("ProgressBar");
            bossRectRay = new Rectangle((int)wheel.Position.X, (int)wheel.Position.Y, 20, 20);
        }
コード例 #7
0
        public override void OnStart()
        {
            var behaviorTrees = GetDefaultGameObject(behaviorGameObject.Value).GetComponents<Behavior>();
            if (behaviorTrees.Length == 1) {
                behavior = behaviorTrees[0];
            } else if (behaviorTrees.Length > 1) {
                for (int i = 0; i < behaviorTrees.Length; ++i) {
                    if (behaviorTrees[i].Group == group.Value) {
                        behavior = behaviorTrees[i];
                        break;
                    }
                }
                // If the group can't be found then use the first behavior tree
                if (behavior == null) {
                    behavior = behaviorTrees[0];
                }
            }

            if (behavior != null) {
                var variables = Owner.GetAllVariables();
                for (int i = 0; i < variables.Count; ++i) {
                    behavior.SetVariable(variables[i].Name, variables[i]);
                }

                behavior.EnableBehavior();

                if (waitForCompletion.Value) {
                    behaviorComplete = false;
                    behavior.OnBehaviorEnd += BehaviorEnded;
                }
            }
        }
コード例 #8
0
ファイル: Behavior.cs プロジェクト: BiBongNet/JustMockLite
		public static object Create(this MocksRepository repository, Type type, object[] constructorArgs, Behavior? behavior,
			Type[] additionalMockedInterfaces, bool? mockConstructorCall, IEnumerable<CustomAttributeBuilder> additionalProxyTypeAttributes = null,
			List<IBehavior> supplementaryBehaviors = null, List<IBehavior> fallbackBehaviors = null, List<object> mixins = null, Expression<Predicate<MethodInfo>> interceptorFilter = null)
		{
			if (behavior == null)
				behavior = DefaultBehavior;

			if (supplementaryBehaviors == null)
				supplementaryBehaviors = new List<IBehavior>();
			if (fallbackBehaviors == null)
				fallbackBehaviors = new List<IBehavior>();
			if (mixins == null)
				mixins = new List<object>();

			DissectBehavior(behavior.Value, mixins, supplementaryBehaviors, fallbackBehaviors, constructorArgs, ref mockConstructorCall);

			return repository.Create(type,
				new MockCreationSettings
				{
					Args = constructorArgs,
					Mixins = mixins,
					SupplementaryBehaviors = supplementaryBehaviors,
					FallbackBehaviors = fallbackBehaviors,
					AdditionalMockedInterfaces = additionalMockedInterfaces,
					MockConstructorCall = mockConstructorCall.Value,
					AdditionalProxyTypeAttributes = additionalProxyTypeAttributes,
					InterceptorFilter = interceptorFilter,
				});
		}
コード例 #9
0
ファイル: Unit.cs プロジェクト: JohnnyVox/schoolfire
 public void Start()
 {
     // cache for quick lookup
     behavior = GetComponent<Behavior>();
     health = GetComponent<Health>();
     health.onDeath += destroySelf;
 }
コード例 #10
0
 internal Level(string n, Behavior loadBehavior, Behavior updateBehavior, Behavior endBehavior, Condition winCondition)
 {
     mName = n;
     LoadBehavior = loadBehavior;
     UpdateBehavior = updateBehavior;
     EndBehavior = endBehavior;
     WinCondition = winCondition;
 }
コード例 #11
0
 private static Behavior<double> Accumulate(
         Event<int> ePulses, Behavior<double> calibration) {
     BehaviorLoop<int> total = new BehaviorLoop<int>();
     total.Loop(ePulses.Snapshot(total,(pulses_, total_) => pulses_ + total_).Hold(0));
     return Behavior<double>.Lift(
         (total_, calibration_) => total_ * calibration_,
         total, calibration);
 }
コード例 #12
0
ファイル: SmartObjectNodes.cs プロジェクト: alerdenisov/ADAPT
 public static Node Node_Affordance(
     this SmartObject o,
     Behavior b,
     Val<string> affordance)
 {
     return new LeafInvoke(
         () => o.Affordance(b.Character, affordance.Value));
 }
コード例 #13
0
 public void TestConstantBehavior()
 {
   var b = new Behavior<int>(12);
   var @out = new List<int>();
   Listener l = b.Value().Listen(x => { @out.Add(x); });
   l.Unlisten();
   CollectionAssert.AreEqual(new[] { 12 }, @out);
 }
コード例 #14
0
ファイル: Preset.cs プロジェクト: davideGiovannini/sodium
 public Preset(
   Behavior<int> presetDollars,
   Fill fi,
   Behavior<Optional<Fuel>> fuelFlowing,
   Behavior<Boolean> fillActive)
 {
   Behavior<Speed> speed = Behavior<Speed>.Lift(
     (presetDollars_, price, dollarsDelivered, litersDelivered) =>
     {
       if (presetDollars_ == 0)
         return Speed.FAST;
       else
       {
         if (dollarsDelivered >= (double)presetDollars_)
           return Speed.STOPPED;
         double slowLiters =
           (double)presetDollars_ / price - 0.10;
         if (litersDelivered >= slowLiters)
           return Speed.SLOW;
         else
           return Speed.FAST;
       }
     },
     presetDollars,
     fi.Price,
     fi.DollarsDelivered,
     fi.LitersDelivered);
   Delivery = Behavior<Delivery>.Lift(
     (of, speed_) =>
       speed_ == Speed.FAST
         ? (
           of.Equals(Optional<Fuel>.Of(Fuel.ONE))
             ? Pump.Delivery.FAST1
             : of.Equals(Optional<Fuel>.Of(Fuel.TWO))
               ? Pump.Delivery.FAST2
               : of.Equals(Optional<Fuel>.Of(Fuel.THREE))
                 ? Pump.Delivery.FAST3
                 : Pump.Delivery.OFF
           )
         : speed_ == Speed.SLOW
           ? (
             of.Equals(Optional<Fuel>.Of(Fuel.ONE))
               ? Pump.Delivery.SLOW1
               : of.Equals(Optional<Fuel>.Of(Fuel.TWO))
                 ? Pump.Delivery.SLOW2
                 : of.Equals(Optional<Fuel>.Of(Fuel.THREE))
                   ? Pump.Delivery.SLOW3
                   : Pump.Delivery.OFF
             )
           : Pump.Delivery.OFF,
     fuelFlowing,
     speed);
   KeypadActive = Behavior<bool>.Lift(
     (of, speed_) =>
       !of.IsPresent || speed_ == Speed.FAST,
     fuelFlowing,
     speed);
 }
コード例 #15
0
ファイル: TreeEditor.cs プロジェクト: fry/refw
        private TreeBehaviorWrapper BuildTree(Behavior node)
        {
            var wrap = new TreeBehaviorWrapper(node);
            foreach (var child in node.GetChildren()) {
                wrap.Nodes.Add(BuildTree(child));
            }

            return wrap;
        }
コード例 #16
0
 // Show animation and loop until the user clicks
 static void ShowAndWait(Behavior<IDrawing> anim)
 {
     af.Animation = anim;
     waiting = true;
     while (waiting) {
         if (!af.Visible) throw new Exception();
         Application.DoEvents();
     }
 }
コード例 #17
0
ファイル: TreeEditor.cs プロジェクト: fry/refw
        bool AddChildToNode(Behavior node, Behavior child)
        {
            if (node.GetChildren().Count < node.GetMaxChildren()) {
                node.GetChildren().Add(child);
                return true;
            }

            return false;
        }
コード例 #18
0
ファイル: LifeCycle.cs プロジェクト: davideGiovannini/sodium
 private static Event<End> WhenSetDown(Event<UpDown> eNozzle,
             Fuel nozzleFuel,
             Behavior<Optional<Fuel>> fillActive) 
 {
     return Event<End>.FilterOptional(
         eNozzle.Snapshot(fillActive,
             (u,f) => u == UpDown.DOWN &&
                      f.Equals(Optional<Fuel>.Of(nozzleFuel))
                                    ? Optional<End>.Of(End.END)
                                    : Optional<End>.Empty()));
 }
コード例 #19
0
 static Behavior<String> perFuel(
   Event<UpDown> eNozzle,
   Behavior<Double> price)
 {
   Behavior<Double> capPrice = eNozzle.Snapshot(price).Hold(0.0);
   Behavior<UpDown> nozzle = eNozzle.Hold(UpDown.DOWN);
   return Behavior<UpDown>.Lift(
     (u, price_) => u.Equals(UpDown.UP) ? Formatters.FormatPrice(price_) : "",
     nozzle,
     capPrice);
 }
コード例 #20
0
        public ConstraintMesher(Mesh mesh, Configuration config)
        {
            this.mesh = mesh;
            this.predicates = config.Predicates();

            this.behavior = mesh.behavior;
            this.locator = mesh.locator;

            this.viri = new List<Triangle>();

            logger = Log.Instance;
        }
コード例 #21
0
        public ConstraintMesher(Mesh mesh, IPredicates predicates)
        {
            this.mesh = mesh;
            this.predicates = predicates;

            this.behavior = mesh.behavior;
            this.locator = mesh.locator;

            this.viri = new List<Triangle>();

            logger = Log.Instance;
        }
コード例 #22
0
 static Behavior<String> perFuel(
   Event<UpDown> eNozzle,
   Behavior<Double> price)
 {
   Event<StartFill> eStartFill = eNozzle.Filter(u => u == UpDown.UP) .Map(u => StartFill.START_FILL);
   Behavior<Double> capPrice = eStartFill.Snapshot(price).Hold(0.0);
   Behavior<UpDown> nozzle = eNozzle.Hold(UpDown.DOWN);
   return Behavior<UpDown>.Lift(
     (u, price_) => u.Equals(UpDown.UP) ? Formatters.FormatPrice(price_) : "",
     nozzle,
     capPrice);
 }
コード例 #23
0
ファイル: MainForm.cs プロジェクト: kevincos/Vexed
 public void update_behavior_data(Behavior b)
 {
     this.behaviorToggle.Checked = b.toggle;
     this.behaviorPrimaryValue.Text = b.primaryValue.ToString();
     this.behaviorSecondaryValue.Text = b.secondaryValue.ToString();
     this.behaviorOffset.Text = b.offset.ToString();
     this.behaviorPeriod.Text = b.period.ToString();
     this.behaviorDuration.Text = b.duration.ToString();
     this.behaviorNextBehavior.Text = b.nextBehavior;
     this.behaviorDestinationX.Text = b.destination.X.ToString();
     this.behaviorDestinationY.Text = b.destination.Y.ToString();
     this.behaviorDestinationZ.Text = b.destination.Z.ToString();
 }
コード例 #24
0
ファイル: Fill.cs プロジェクト: davideGiovannini/sodium
 public Fill(
         Event<Unit> eClearAccumulator, Event<int> eFuelPulses,
         Behavior<Double> calibration, Behavior<Double> price1,
         Behavior<Double> price2, Behavior<Double> price3,
         Event<Fuel> eStart) 
 {
     Price = CapturePrice(eStart, price1, price2, price3);
     LitersDelivered = AccumulatePulsesPump.Accumulate(
             eClearAccumulator, eFuelPulses, calibration);
     DollarsDelivered = Behavior<double>.Lift(
             (liters, price_) => liters * price_,
             LitersDelivered, Price);
 }
コード例 #25
0
 public static Behavior<double> Accumulate(
         Event<Unit> eClearAccumulator,
         Event<int> ePulses,
         Behavior<double> calibration) {
     BehaviorLoop<int> total = new BehaviorLoop<int>();
     total.Loop(ePulses.Snapshot(total,
         (pulses_, total_) => pulses_ + total_)
            .Merge(eClearAccumulator.Map(f => 0))
            .Hold(0));
     return Behavior<double>.Lift(
         (total_, calibration_) => total_ * calibration_,
         total, calibration);
 }
コード例 #26
0
        internal IkController(InverseKinematics inverseKinematics, 
                              SparkFunSerial16X2Lcd display, 
                              IoTClient ioTClient,
                              Gps.Gps gps)
        {
            _inverseKinematics = inverseKinematics;
            _display = display;
            _ioTClient = ioTClient;
            _gps = gps;

            _perimeterInInches = 15;

            _selectedIkFunction = SelectedIkFunction.BodyHeight;
            _behavior = Behavior.Bounce;
        }
コード例 #27
0
        public QualityMesher(Mesh mesh, Configuration config)
        {
            logger = Log.Instance;

            badsubsegs = new Queue<BadSubseg>();
            queue = new BadTriQueue();

            this.mesh = mesh;
            this.predicates = config.Predicates();

            this.behavior = mesh.behavior;

            newLocation = new NewLocation(mesh, predicates);

            newvertex_tri = new Triangle();
        }
コード例 #28
0
        public void Clear()
        {
            foreach (Behavior behavior in _stateBehaviorDurations.Keys.ToList())
            {
                _stateBehaviorDurations[behavior] = 0L;
            }
            foreach (Behavior behavior in _instantBehaviorCounts.Keys.ToList())
            {
                _instantBehaviorCounts[behavior] = 0;
            }

            UpdateDurationCountCells();

            _lastStateBehavior = null;
            _lastMilliseconds = 0L;
        }
コード例 #29
0
        public void AddRunEvent(RunEvent runEvent)
        {
            UpdateInterval(runEvent.TimeTracked);

            switch (runEvent.Behavior.Type)
            {
                case Behavior.BehaviorType.State:
                    _lastStateBehavior = runEvent.Behavior;
                    break;
                case Behavior.BehaviorType.Instant:
                    _instantBehaviorCounts[runEvent.Behavior]++;
                    break;
            }

            UpdateDurationCountCells();
        }
コード例 #30
0
ファイル: BTViewer.cs プロジェクト: RossM/AIBTExplorer
        private static BTPath ExtendPath(BTPath btPath, Behavior behavior)
        {
            var newBTPath = new BTPath { Path = new List<Behavior>() };
            if (btPath.Path != null)
                newBTPath.Path.AddRange(btPath.Path);
            newBTPath.Path.Add(behavior);

            while (true)
            {
                var newBehavior = Analyzer.HideNodes(btPath, behavior);
                if (newBehavior == null)
                    return newBTPath;

                behavior = newBehavior;
                newBTPath.Path.Add(behavior);
            }
        }
コード例 #31
0
 public Task Faulted <TException>(BehaviorExceptionContext <OrderState, OrderAccepted, TException> context, Behavior <OrderState, OrderAccepted> next)
     where TException : Exception
 {
     return(next.Faulted(context));
 }
コード例 #32
0
 public void GetValidationResult_ReturnsResultOfNextBehavior()
 {
     Assert.AreEqual(PropertyResult, Behavior.GetValidationResult(Context, ValidationResultScope.PropertiesOnly));
     Assert.AreEqual(ViewModelResult, Behavior.GetValidationResult(Context, ValidationResultScope.ViewModelValidationsOnly));
     Assert.AreEqual(DescendantResult, Behavior.GetValidationResult(Context, ValidationResultScope.Descendants));
 }
コード例 #33
0
 public Task Faulted <TException>(BehaviorExceptionContext <BookingState, BookingAccepted, TException> context, Behavior <BookingState, BookingAccepted> next) where TException : Exception
 {
     return(next.Faulted(context));
 }
コード例 #34
0
        /// <summary>Handles the testing of fake samples.</summary>
        /// <typeparam name="T">Type of sample to test.</typeparam>
        private static void FakeTester <T>() where T : IFakeSample
        {
            Fake <T> fake = Tools.Faker.Mock <T>(typeof(IClashingFakeSample));

            Behavior <string> hintBehavior = Behavior.Returns("Hint");

            fake.Setup(m => m.Hint, hintBehavior);
            fake.Verify(Times.Never, m => m.Hint);
            Tools.Asserter.Is("Hint", fake.Dummy.Hint);
            fake.Verify(Times.Once, m => m.Hint);
            Tools.Asserter.Is("Hint", fake.Dummy.Hint);
            fake.Verify(Times.Exactly(2), m => m.Hint);

            Fake <IClashingFakeSample> fake2 = fake.ToFake <IClashingFakeSample>();

            fake2.SetupSet(m => m.Text, Arg.LambdaAny <string>(), Behavior.None());
            fake2.VerifySet(Times.Never, m => m.Text, Arg.LambdaAny <string>());
            fake2.Dummy.Text = "What";
            fake2.VerifySet(Times.Once, m => m.Text, Arg.LambdaAny <string>());

            fake2.SetupSet(m => m.Text, "Hinter", Behavior.Set((string input) => { }));
            fake2.VerifySet(Times.Never, m => m.Text, "Hinter");
            fake2.Dummy.Text = "Hinter";
            fake2.VerifySet(Times.Once, m => m.Text, "Hinter");
            fake2.VerifySet(Times.Exactly(2), m => m.Text, Arg.LambdaAny <string>());

            fake.Setup(m => m.Read(), Behavior.Set(() => "Test"));
            fake.Verify(Times.Never, m => m.Read());
            Tools.Asserter.Is("Test", fake.Dummy.Read());
            fake.Verify(Times.Once, m => m.Read());

            fake.Setup(m => m.Calc(), Behavior.Returns(5));
            fake.Verify(Times.Never, m => m.Calc());
            Tools.Asserter.Is(5, fake.Dummy.Calc());
            fake.Verify(Times.Once, m => m.Calc());

            fake.Setup(m => m.Read("Hey"), Behavior.Returns("Test2"));
            fake.Verify(Times.Never, m => m.Read("Hey"));
            Tools.Asserter.Is("Test2", fake.Dummy.Read("Hey"));
            fake.Verify(Times.Once, m => m.Read("Hey"));

            fake.Setup(m => m.Calc(3), Behavior.Returns(4));
            Tools.Asserter.Is(4, fake.Dummy.Calc(3));

            Tools.Asserter.Is("Test", fake.Dummy.Read());
            Tools.Asserter.Is(5, fake.Dummy.Calc());
            Tools.Asserter.Is("Test2", fake.Dummy.Read("Hey"));

            fake.Setup(m => m.Calc(Arg.Where <int>(i => i > 8)), Behavior.Returns(1));
            fake.Verify(Times.Never, m => m.Calc(Arg.Where <int>(i => i > 8)));
            fake.Dummy.Calc(9);
            fake.Verify(Times.Once, m => m.Calc(Arg.Where <int>(i => i > 8)));

            fake.Setup(m => m.Calc(Arg.Any <int>()), Behavior.Returns(7));
            Tools.Asserter.Is(7, fake.Dummy.Calc(0));

            fake.Setup(m => m.Read(Arg.Any <string>()), Behavior.Returns("Wow!"));
            Tools.Asserter.Is("Wow!", fake.Dummy.Read("Okay?"));

            fake.Setup(m => m.Combo(2, "Finally"),
                       Behavior.Set((int num, string text) => { }));
            fake.Verify(Times.Never, m => m.Combo(2, "Finally"));
            fake.Dummy.Combo(2, "Finally");
            fake.Verify(Times.Once, m => m.Combo(2, "Finally"));

            Tools.Asserter.Is(2, hintBehavior.Calls);
        }
コード例 #35
0
        public async Task Execute(BehaviorContext <FutureState, SubmitOrder> context, Behavior <FutureState, SubmitOrder> next)
        {
            ConsumeEventContext <FutureState, SubmitOrder> consumeContext = context.CreateConsumeContext();

            if (context.Data.Shakes != null)
            {
                await Task.WhenAll(context.Data.Shakes.Select(shake => consumeContext.Publish <OrderShake>(new
                {
                    context.Data.OrderId,
                    OrderLineId = shake.ShakeId,
                    shake.Flavor,
                    shake.Size,
                    __RequestId       = InVar.Id,
                    __ResponseAddress = consumeContext.ReceiveContext.InputAddress
                }, context.CancellationToken)));

                context.Instance.Pending.UnionWith(context.Data.Shakes.Select(x => x.ShakeId));
            }

            await next.Execute(context);
        }
コード例 #36
0
        /// <summary>
        /// Register an implementation of IPipelineBehavior for all handlers.
        /// </summary>
        /// <param name="type">The behavior type to register.</param>
        protected void Register(Type type)
        {
            var behavior = new Behavior(type);

            RegisterBehavior(behavior);
        }
コード例 #37
0
        public override Task Execute(BehaviorContext <DeleteDocumentState, DocumentDeletedFromStorageEvent> context, Behavior <DeleteDocumentState, DocumentDeletedFromStorageEvent> next)
        {
            var doc = context.Data.PayLoad.ToEmptyDocumentWithId();

            _documentRepository.DeleteAsync(doc).Wait();
            _documentUnitOfWork.CommitAsync().Wait();
            return(next.Execute(context));
        }
コード例 #38
0
 async Task Activity <TInstance> .Faulted <T, TException>(BehaviorExceptionContext <TInstance, T, TException> context, Behavior <TInstance, T> next)
 {
     await next.Faulted(context);
 }
コード例 #39
0
        async Task Activity <TInstance> .Execute <T>(BehaviorContext <TInstance, T> context, Behavior <TInstance, T> next)
        {
            await Execute(context);

            await next.Execute(context);
        }
コード例 #40
0
 public Timer(float targetTimeInput, Behavior behaviorInput)
 {
     targetTime = targetTimeInput;
     behavior   = behaviorInput;
 }
コード例 #41
0
ファイル: RespondActivity.cs プロジェクト: lsfera/MassTransit
        async Task Activity <TInstance, TData> .Execute(BehaviorContext <TInstance, TData> context, Behavior <TInstance, TData> next)
        {
            var consumeContext = context.CreateConsumeContext();

            TMessage message = _messageFactory(consumeContext);

            await consumeContext.RespondAsync(message, _responsePipe);

            await next.Execute(context);
        }
コード例 #42
0
        public Animate(AnimationDelegate animation, Size size)
        {
            TaskCompletionSource <Renderer> tcs = new TaskCompletionSource <Renderer>();

            this.renderer = tcs.Task;

            void CreateTimerSystem(object sender, EventArgs args)
            {
                CompositionTargetSecondsTimerSystem timerSystem = CompositionTargetSecondsTimerSystem.Create(((RenderingEventArgs)args).RenderingTime.TotalSeconds, e => this.Dispatcher.Invoke(() => throw e));
                Point extents = new Point(size.Width / 2, size.Height / 2);

                tcs.SetResult(new Renderer(timerSystem, Transaction.Run(() => Shapes.Translate(animation(timerSystem, extents), Behavior.Constant(extents))), size, this, this.isStarted));
                CompositionTarget.Rendering -= CreateTimerSystem;
            }

            CompositionTarget.Rendering += CreateTimerSystem;
        }
コード例 #43
0
ファイル: Decorator.cs プロジェクト: MUDV587/StratusFramework
 //------------------------------------------------------------------------/
 // Method
 //------------------------------------------------------------------------/
 public void Set(Behavior child)
 {
     this.child = child;
 }
コード例 #44
0
 private void RegisterBehavior(Behavior behavior) =>
 services.AddTransient(
     behavior.InterfaceType,
     behavior.ImplementationType);
コード例 #45
0
 public async Task Faulted<TException>(
     BehaviorExceptionContext<CourierState, CourierDispatchCanceled, TException> context,
     Behavior<CourierState, CourierDispatchCanceled> next) where TException : Exception
 {
     await next.Faulted(context);
 }
コード例 #46
0
        async Task Activity <TInstance> .Execute <TData>(BehaviorContext <TInstance, TData> context, Behavior <TInstance, TData> next)
        {
            _action(context);

            await next.Execute(context);
        }
コード例 #47
0
 internal static void Setup_GuardsNulls()
 {
     Tools.Asserter.Throws <ArgumentNullException>(
         () => Tools.Faker.Stub <IFakeSample>().Setup(null, Behavior.None()));
 }
コード例 #48
0
 Task Activity <TInstance> .Faulted <T, TException>(BehaviorExceptionContext <TInstance, T, TException> context, Behavior <TInstance, T> next)
 {
     return(next.Faulted(context));
 }
コード例 #49
0
 public async Task Faulted <TException>(BehaviorExceptionContext <OrderState, OrderCanceled, TException> context,
                                        Behavior <OrderState, OrderCanceled> next) where TException : Exception
 {
     await next.Faulted(context);
 }
コード例 #50
0
        internal static void FindLoadedTypes_IgnoresMissingAssembly(Fake <Assembly> assembly, FileNotFoundException error)
        {
            assembly.Setup(d => d.GetExportedTypes(), Behavior.Throw(error));

            TypeExtensions.FindLoadedTypes(assembly.Dummy).Assert().IsEmpty();
        }
コード例 #51
0
        public async Task Execute(BehaviorContext <BookingState, BookingAccepted> context, Behavior <BookingState, BookingAccepted> next)
        {
            var consumeContext = context.GetPayload <ConsumeContext>();

            var sendEndpoint = await consumeContext.GetSendEndpoint(new Uri("queue:booking"));

            await sendEndpoint.Send(new BookingModel
            {
                BookingId = context.Data.BookingId,
                Car       = context.Data.Car,
                Flight    = context.Data.Flight,
                Hotel     = context.Data.Hotel,
            });

            await next.Execute(context).ConfigureAwait(false);
        }
コード例 #52
0
        internal static void FindLoadedTypes_IgnoresReflectError(Fake <Assembly> assembly, ReflectionTypeLoadException error)
        {
            assembly.Setup(d => d.GetExportedTypes(), Behavior.Throw(error));

            TypeExtensions.FindLoadedTypes(assembly.Dummy).Assert().IsEmpty();
        }
コード例 #53
0
 public MockProvider(Type type, Behavior behavior)
 {
     this.Type     = type;
     this.behavior = behavior;
 }
コード例 #54
0
 public Timed(int period, Behavior behavior)
 {
     this.behavior = behavior;
     this.period   = period;
 }
コード例 #55
0
        public static void Main(string[] args)
        {
            Utils.InitLog();
            _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
            if (args.Length == 6 || args.Length == 8 || args.Length == 10 || args.Length == 4)
            {
                for (var i = 0; i < args.Length; i++)
                {
                    var arg = args[i];
                    switch (arg)
                    {
                    case "--p":
                        i++;
                        ArtifactPath = args[i];
                        continue;

                    case "--n":
                        i++;
                        ArtifactName = args[i];
                        continue;

                    case "--t":
                        i++;
                        var t = Convert.ToInt32(args[i]);
                        ArtifactType = (ArtifactType)t;
                        continue;

                    case "--b":
                        i++;
                        var b = Convert.ToInt32(args[i]);
                        BaseType = (TokenType)b;
                        continue;

                    case "--c":
                        i++;
                        var c = Convert.ToInt32(args[i]);
                        TemplateType = (TemplateType)c;
                        continue;

                    case "--v":
                        i++;
                        var v = args[i];
                        TaxonomyVersion = new TaxonomyVersion
                        {
                            Id      = Guid.NewGuid().ToString(),
                            Version = v
                        };
                        continue;

                    default:
                        continue;
                    }
                }
            }
            else
            {
                if (args.Length == 0)
                {
                    _log.Info(
                        "Usage: dotnet factgen --p [PATH_TO_ARTIFACTS FOLDER] --t [ARTIFACT_TYPE: 0 = Base, 1 = Behavior, 2 = BehaviorGroup, 3 = PropertySet, 4 - TemplateFormula or 5 - TemplateDefinition] --n [ARTIFACT_NAME],");
                    _log.Info(
                        "--b [baseTokenType: 0 = fungible, 1 = non-fungible, 2 = hybrid]");
                    _log.Info(
                        "--c [templateType: 0 = singleToken, 1 = hybrid] Is required for a Template Type");
                    _log.Info(
                        "To update the TaxonomyVersion: dotnet factgen --v [VERSION_STRING] --p [PATH_TO_ARTIFACTS FOLDER]");
                    return;
                }

                _log.Error(
                    "Required arguments --p [path-to-artifact folder] --n [artifactName] --t [artifactType: 0 = Base, 1 = Behavior, 2 = BehaviorGroup, 3 = PropertySet or 4 - TokenTemplate],");
                _log.Error(
                    "--b [baseTokenType: 0 = fungible, 1 = non-fungible, 2 = hybrid-fungibleBase, 3 = hybrid-non-fungibleBase, 4 = hybrid-fungibleBase-hybridChildren, 5 = hybrid-non-fungibleBase-hybridChildren]");
                _log.Error(
                    "To update the TaxonomyVersion: dotnet factgen --v [VERSION_STRING] --p [PATH_TO_ARTIFACTS FOLDER]");
                throw new Exception("Missing required parameters.");
            }

            _log.Info("Generating Artifact: " + ArtifactName + " of type: " + ArtifactType);

            var folderSeparator = "/";
            var fullPath        = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (Os.IsWindows())
            {
                fullPath       += "\\" + ArtifactPath + "\\";
                folderSeparator = "\\";
            }
            else
            {
                fullPath += "/" + ArtifactPath + "/";
            }

            Latest = folderSeparator + "latest";


            string artifactTypeFolder;
            var    jsf = new JsonFormatter(new JsonFormatter.Settings(true));


            if (string.IsNullOrEmpty(ArtifactPath))
            {
                throw new Exception("Missing value for --p.");
            }

            if (TaxonomyVersion != null)
            {
                _log.Info("Updating Taxonomy Version Only.");
                var tx = new Taxonomy
                {
                    Version = TaxonomyVersion
                };
                var txVersionJson = jsf.Format(tx);

                var formattedTxJson = JToken.Parse(txVersionJson).ToString();

                //test to make sure formattedJson will Deserialize.
                try
                {
                    JsonParser.Default.Parse <Taxonomy>(formattedTxJson);
                    _log.Info("Taxonomy: " + TaxonomyVersion.Version + " successfully deserialized.");
                }
                catch (Exception e)
                {
                    _log.Error("Json failed to deserialize back into Taxonomy");
                    _log.Error(e);
                    return;
                }

                _log.Info("Creating Taxonomy: " + formattedTxJson);
                var txStream = File.CreateText(fullPath + "Taxonomy.json");
                txStream.Write(formattedTxJson);
                txStream.Close();


                _log.Info("Creating Formula and Grammar Definitions");
                var formula = GenerateFormula();

                var formulaJson = jsf.Format(formula);

                var formattedFormulaJson = JToken.Parse(formulaJson).ToString();

                //test to make sure formattedJson will Deserialize.
                try
                {
                    JsonParser.Default.Parse <FormulaGrammar>(formattedFormulaJson);
                    _log.Info("FormulaGrammar successfully deserialized.");
                }
                catch (Exception e)
                {
                    _log.Error("Json failed to deserialize back into FormulaGrammar.");
                    _log.Error(e);
                    return;
                }

                var formulaStream = File.CreateText(fullPath + "FormulaGrammar.json");
                formulaStream.Write(formattedFormulaJson);
                formulaStream.Close();

                return;
            }


            if (string.IsNullOrEmpty(ArtifactName))
            {
                throw new Exception("Missing value for  --n ");
            }

            string        artifactJson;
            DirectoryInfo outputFolder;
            var           artifact = new Artifact
            {
                Name           = ArtifactName,
                ArtifactSymbol = new ArtifactSymbol
                {
                    Id      = Guid.NewGuid().ToString(),
                    Type    = ArtifactType,
                    Tooling = "",
                    Visual  = "",
                    Version = "1.0"
                },
                ArtifactDefinition = new ArtifactDefinition
                {
                    BusinessDescription = "This is a " + ArtifactName + " of type: " + ArtifactType,
                    BusinessExample     = "",
                    Comments            = "",
                    Analogies           =
                    {
                        new ArtifactAnalogy
                        {
                            Name        = "Analogy 1",
                            Description = ArtifactName + " analogy 1 description"
                        }
                    }
                },
                Maps = new Maps
                {
                    CodeReferences =
                    {
                        new MapReference
                        {
                            MappingType   = MappingType.SourceCode,
                            Name          = "Code 1",
                            Platform      = TargetPlatform.Daml,
                            ReferencePath = ""
                        }
                    },
                    ImplementationReferences =
                    {
                        new MapReference
                        {
                            MappingType   = MappingType.Implementation,
                            Name          = "Implementation 1",
                            Platform      = TargetPlatform.ChaincodeGo,
                            ReferencePath = ""
                        }
                    },
                    Resources =
                    {
                        new MapResourceReference
                        {
                            MappingType  = MappingType.Resource,
                            Name         = "Regulation Reference 1",
                            Description  = "",
                            ResourcePath = ""
                        }
                    }
                },
                IncompatibleWithSymbols =
                {
                    new ArtifactSymbol
                    {
                        Type    = ArtifactType,
                        Tooling = "",
                        Visual  = ""
                    }
                },
                Dependencies =
                {
                    new SymbolDependency
                    {
                        Description = "",
                        Symbol      = new ArtifactSymbol()
                    }
                },
                Aliases = { "alias1", "alias2" }
            };

            switch (ArtifactType)
            {
            case ArtifactType.Base:
                artifactTypeFolder = "base";
                outputFolder       =
                    Directory.CreateDirectory(
                        fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest);
                var artifactBase = new Base
                {
                    Artifact = AddArtifactFiles(outputFolder, folderSeparator,
                                                artifact, "Base"),
                    TokenType = BaseType
                };
                artifactBase.Artifact.InfluencedBySymbols.Add(new SymbolInfluence
                {
                    Description =
                        "Whether or not the token class will be divisible will influence the decimals value of this token. If it is non-divisible, the decimals value should be 0.",
                    Symbol = new ArtifactSymbol
                    {
                        Id      = "d5807a8e-879b-4885-95fa-f09ba2a22172",
                        Type    = ArtifactType.Behavior,
                        Tooling = "~d",
                        Visual  = "<i>~d</i>",
                        Version = ""
                    }
                });
                artifactBase.Artifact.InfluencedBySymbols.Add(new SymbolInfluence
                {
                    Description =
                        "Whether or not the token class will be divisible will influence the decimals value of this token. If it is divisible, the decimals value should be greater than 0.",
                    Symbol = new ArtifactSymbol
                    {
                        Id      = "6e3501dc-5800-4c71-b59e-ad11418a998c",
                        Type    = ArtifactType.Behavior,
                        Tooling = "d",
                        Visual  = "<i>d</i>",
                        Version = ""
                    }
                });
                artifactBase.TokenType = BaseType;
                artifactJson           = jsf.Format(artifactBase);
                break;

            case ArtifactType.Behavior:
                artifactTypeFolder = "behaviors";
                outputFolder       =
                    Directory.CreateDirectory(
                        fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest);
                var artifactBehavior = new Behavior
                {
                    Artifact = AddArtifactFiles(outputFolder, folderSeparator,
                                                artifact, "Behaviors"),
                    Invocations =
                    {
                        new Invocation
                        {
                            Name        = "InvocationRequest1",
                            Description =
                                "Describe the what the this invocation triggers in the behavior",
                            Request = new InvocationRequest
                            {
                                ControlMessageName = "InvocationRequest",
                                Description        = "The request",
                                InputParameters    =
                                {
                                    new InvocationParameter
                                    {
                                        Name             = "Input Parameter 1",
                                        ValueDescription =
                                            "Contains some input data required for the invocation to work."
                                    }
                                }
                            },
                            Response = new InvocationResponse
                            {
                                ControlMessageName = "InvocationResponse",
                                Description        = "The response",
                                OutputParameters   =
                                {
                                    new InvocationParameter
                                    {
                                        Name             = "Output Parameter 1",
                                        ValueDescription =
                                            "One of the values that the invocation should return."
                                    }
                                }
                            }
                        }
                    }
                };
                artifactBehavior.Properties.Add(new Property
                {
                    Name                = "Property1",
                    ValueDescription    = "Some Value",
                    TemplateValue       = "",
                    PropertyInvocations =
                    {
                        new Invocation
                        {
                            Name        = "PropertyGetter",
                            Description = "The property value.",
                            Request     = new InvocationRequest
                            {
                                ControlMessageName = "GetProperty1Request",
                                Description        = "",
                                InputParameters    =
                                {
                                    new InvocationParameter
                                    {
                                        Name             = "input1",
                                        ValueDescription = "value"
                                    }
                                }
                            },
                            Response = new InvocationResponse
                            {
                                ControlMessageName = "GetProperty1Response",
                                Description        = "Return value",
                                OutputParameters   =
                                {
                                    new InvocationParameter
                                    {
                                        Name             = "Output1",
                                        ValueDescription = "value of property"
                                    }
                                }
                            }
                        }
                    }
                });
                artifactBehavior.Artifact.InfluencedBySymbols.Add(new SymbolInfluence
                {
                    Description = "",
                    Symbol      = new ArtifactSymbol
                    {
                        Tooling = "",
                        Visual  = ""
                    }
                });
                artifactBehavior.Artifact.Dependencies.Add(new SymbolDependency
                {
                    Description = "",
                    Symbol      = new ArtifactSymbol
                    {
                        Tooling = "",
                        Visual  = ""
                    }
                });
                artifact.IncompatibleWithSymbols.Add(new ArtifactSymbol());
                artifactJson = jsf.Format(artifactBehavior);
                break;

            case ArtifactType.BehaviorGroup:
                artifactTypeFolder = "behavior-groups";
                outputFolder       =
                    Directory.CreateDirectory(
                        fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest);
                var artifactBehaviorGroup = new BehaviorGroup
                {
                    Artifact = AddArtifactFiles(outputFolder, folderSeparator,
                                                artifact, "BehaviorGroups")
                };
                artifactBehaviorGroup.Behaviors.Add(new BehaviorReference
                {
                    Reference = new ArtifactReference
                    {
                        Id             = "",
                        ReferenceNotes = "",
                        Type           = ArtifactType.Behavior,
                        Values         = new ArtifactReferenceValues
                        {
                            ControlUri = ""
                        }
                    },
                    Properties = { new Property
                                   {
                                       Name             = "",
                                       TemplateValue    = "",
                                       ValueDescription = ""
                                   } }
                });

                artifactJson = jsf.Format(artifactBehaviorGroup);
                break;

            case ArtifactType.PropertySet:
                artifactTypeFolder = "property-sets";
                outputFolder       =
                    Directory.CreateDirectory(
                        fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest);
                var artifactPropertySet = new PropertySet
                {
                    Artifact = AddArtifactFiles(outputFolder, folderSeparator,
                                                artifact, "PropertySets"),
                    Properties =
                    {
                        new Property
                        {
                            Name             = "Property1",
                            ValueDescription =
                                "This is the property required to be implemented and should be able to contain data of type X.",
                            TemplateValue       = "",
                            PropertyInvocations =
                            {
                                new Invocation
                                {
                                    Name        = "Property1 Getter",
                                    Description = "Request the value of the property",
                                    Request     = new InvocationRequest
                                    {
                                        ControlMessageName = "GetProperty1Request",
                                        Description        = "The request"
                                    },
                                    Response = new InvocationResponse
                                    {
                                        ControlMessageName = "GetProperty1Response",
                                        Description        = "The response",
                                        OutputParameters   =
                                        {
                                            new InvocationParameter
                                            {
                                                Name             = "Property1.Value",
                                                ValueDescription =
                                                    "Returning the value of the property."
                                            }
                                        }
                                    }
                                },
                                new Invocation
                                {
                                    Name        = "Property1 Setter",
                                    Description =
                                        "Set the Value of the Property, note if Roles should be applied to the Setter.",
                                    Request = new InvocationRequest
                                    {
                                        ControlMessageName = "SetProperty1Request",
                                        Description        = "The request",
                                        InputParameters    =
                                        {
                                            new InvocationParameter
                                            {
                                                Name             = "New Value of Property",
                                                ValueDescription =
                                                    "The data to set the property to."
                                            }
                                        }
                                    },
                                    Response = new InvocationResponse
                                    {
                                        ControlMessageName = "SetProperty1Response",
                                        Description        = "The response",
                                        OutputParameters   =
                                        {
                                            new InvocationParameter
                                            {
                                                Name             = "Result, true or false",
                                                ValueDescription =
                                                    "Returning the value of the set request."
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                };
                artifactPropertySet.Artifact.InfluencedBySymbols.Add(new SymbolInfluence
                {
                    Description = "",
                    Symbol      = new ArtifactSymbol
                    {
                        Tooling = "",
                        Visual  = ""
                    }
                });
                artifactJson = jsf.Format(artifactPropertySet);
                break;

            case ArtifactType.TemplateFormula:
                artifactTypeFolder = "token-templates/formulas";
                outputFolder       =
                    Directory.CreateDirectory(
                        fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest);

                var templateFormula = new TemplateFormula {
                    Artifact = AddArtifactFiles(outputFolder, folderSeparator,
                                                artifact, "TemplateFormulas"),
                    TokenBase    = GetTemplateBase(fullPath, folderSeparator),
                    TemplateType = TemplateType,
                    Behaviors    =
                    {
                        new TemplateBehavior
                        {
                            Behavior = new ArtifactSymbol
                            {
                                Type = ArtifactType.Behavior
                            }
                        }
                    },
                    BehaviorGroups =
                    {
                        new TemplateBehaviorGroup
                        {
                            BehaviorGroup = new ArtifactSymbol
                            {
                                Type = ArtifactType.BehaviorGroup
                            }
                        }
                    },
                    PropertySets =
                    {
                        new TemplatePropertySet
                        {
                            PropertySet = new ArtifactSymbol
                            {
                                Type = ArtifactType.PropertySet
                            }
                        }
                    }
                };

                artifactJson = jsf.Format(templateFormula);
                break;

            case ArtifactType.TemplateDefinition:
                artifactTypeFolder = "token-templates/definitions";
                outputFolder       =
                    Directory.CreateDirectory(
                        fullPath + artifactTypeFolder + folderSeparator + ArtifactName + Latest);

                var templateDefinition = new TemplateDefinition {
                    Artifact = AddArtifactFiles(outputFolder, folderSeparator,
                                                artifact, "TemplateDefinition"),
                    TokenBase = GetBaseReference(fullPath, folderSeparator),
                    Behaviors =
                    {
                        new BehaviorReference
                        {
                            Reference = new ArtifactReference
                            {
                                Type           = ArtifactType.Behavior,
                                Id             = "a guid",
                                ReferenceNotes = ""
                            },
                            ConstructorType   = "",
                            IsExternal        = true,
                            Invocations       =   { new Invocation()                     },
                            InfluenceBindings =   { new InfluenceBinding
                                                    {
                                                        InfluencedId           = "",
                                                        InfluencedInvocationId = "",
                                                        InfluenceType          = InfluenceType.Intercept,
                                                        InfluencingInvocation  = new Invocation(),
                                                        InfluencedInvocation   = new Invocation()
                                                    } },
                            Properties =
                            {
                                new Property
                                {
                                    TemplateValue = "definition value"
                                }
                            }
                        }
                    },
                    BehaviorGroups =
                    {
                        new BehaviorGroupReference
                        {
                            Reference = new ArtifactReference
                            {
                                Type           = ArtifactType.BehaviorGroup,
                                Id             = "a guid",
                                ReferenceNotes = ""
                            }
                        }
                    },
                    PropertySets =
                    {
                        new PropertySetReference
                        {
                            Reference = new ArtifactReference
                            {
                                Type           = ArtifactType.PropertySet,
                                Id             = "a guid",
                                ReferenceNotes = ""
                            },
                            Properties =
                            {
                                new Property
                                {
                                    TemplateValue = "template value"
                                }
                            }
                        }
                    }
                };

                templateDefinition.FormulaReference = new ArtifactReference();

                artifactJson = jsf.Format(templateDefinition);
                break;

            default:
                _log.Error("No matching type found for: " + ArtifactType);
                throw new ArgumentOutOfRangeException();
            }

            _log.Info("Artifact Destination: " + outputFolder);
            var formattedJson = JToken.Parse(artifactJson).ToString();

            //test to make sure formattedJson will Deserialize.
            try
            {
                switch (ArtifactType)
                {
                case ArtifactType.Base:

                    var testBase = JsonParser.Default.Parse <Base>(formattedJson);
                    _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " +
                              testBase.Artifact.Name);
                    break;

                case ArtifactType.Behavior:
                    var testBehavior = JsonParser.Default.Parse <Behavior>(formattedJson);
                    _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " +
                              testBehavior.Artifact.Name);
                    break;

                case ArtifactType.BehaviorGroup:
                    var testBehaviorGroup = JsonParser.Default.Parse <BehaviorGroup>(formattedJson);
                    _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " +
                              testBehaviorGroup.Artifact.Name);
                    break;

                case ArtifactType.PropertySet:
                    var testPropertySet = JsonParser.Default.Parse <PropertySet>(formattedJson);
                    _log.Info("Artifact type: " + ArtifactType + " successfully deserialized: " +
                              testPropertySet.Artifact.Name);
                    break;

                case ArtifactType.TemplateFormula:
                    break;

                case ArtifactType.TemplateDefinition:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                _log.Error("Json failed to deserialize back into: " + ArtifactType);
                _log.Error(e);
                return;
            }

            _log.Info("Creating Artifact: " + formattedJson);
            var artifactStream =
                File.CreateText(outputFolder.FullName + folderSeparator + ArtifactName + ".json");

            artifactStream.Write(formattedJson);
            artifactStream.Close();

            _log.Info("Complete");
        }
コード例 #56
0
        async Task Activity <TInstance> .Execute(BehaviorContext <TInstance> context, Behavior <TInstance> next)
        {
            await Execute(context).ConfigureAwait(false);

            await next.Execute(context).ConfigureAwait(false);
        }
コード例 #57
0
        public async Task Execute(BehaviorContext <OrderState, OrderAccepted> context, Behavior <OrderState, OrderAccepted> next)
        {
            Console.WriteLine("Hello, World. Order is {0}", context.Data.OrderId);

            var consumeContext = context.GetPayload <ConsumeContext>();

            var sendEndpoint = await consumeContext.GetSendEndpoint(new Uri("queue:fulfill-order"));

            await sendEndpoint.Send <FulfillOrder>(new
            {
                context.Data.OrderId,
                context.Instance.CustomerNumber,
                context.Instance.PaymentCardNumber,
            });

            await next.Execute(context).ConfigureAwait(false);
        }
コード例 #58
0
 public Task Faulted <TException>(BehaviorExceptionContext <FutureState, SubmitOrder, TException> context, Behavior <FutureState, SubmitOrder> next)
     where TException : Exception
 {
     return(next.Faulted(context));
 }
コード例 #59
0
 static void OnArgumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     Behavior.Update(d);
 }
コード例 #60
0
 private static void SetOriginalBehavior(DependencyObject obj, Behavior value)
 {
     obj.SetValue(OriginalBehaviorProperty, value);
 }