本文整理汇总了C#中Activity类的典型用法代码示例。如果您正苦于以下问题:C# Activity类的具体用法?C# Activity怎么用?C# Activity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Activity类属于命名空间,在下文中一共展示了Activity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestTransport
public void RequestTransport(CPos destination, Activity afterLandActivity)
{
var destPos = self.World.Map.CenterOfCell(destination);
if (destination == CPos.Zero || (self.CenterPosition - destPos).LengthSquared < info.MinDistance.LengthSquared)
{
WantsTransport = false; // Be sure to cancel any pending transports
return;
}
Destination = destination;
this.afterLandActivity = afterLandActivity;
WantsTransport = true;
if (locked || Reserved)
return;
// Inform all idle carriers
var carriers = self.World.ActorsWithTrait<Carryall>()
.Where(c => !c.Trait.IsBusy && !c.Actor.IsDead && c.Actor.Owner == self.Owner && c.Actor.IsInWorld)
.OrderBy(p => (self.Location - p.Actor.Location).LengthSquared);
// Is any carrier able to transport the actor?
// Any will return once it finds a carrier that returns true.
carriers.Any(carrier => carrier.Trait.RequestTransportNotify(self));
}
示例2: Tick
public override Activity Tick(Actor self)
{
if (!target.IsValidFor(self))
return NextActivity;
// Move to the next activity only if all ammo pools are depleted and none reload automatically
// TODO: This should check whether there is ammo left that is actually suitable for the target
if (ammoPools.All(x => !x.Info.SelfReloads && !x.HasAmmo()))
return NextActivity;
if (attackPlane != null)
attackPlane.DoAttack(self, target);
if (inner == null)
{
if (IsCanceled)
return NextActivity;
// TODO: This should fire each weapon at its maximum range
if (attackPlane != null && target.IsInRange(self.CenterPosition, attackPlane.Armaments.Select(a => a.Weapon.MinRange).Min()))
inner = ActivityUtils.SequenceActivities(new FlyTimed(ticksUntilTurn, self), new Fly(self, target), new FlyTimed(ticksUntilTurn, self));
else
inner = ActivityUtils.SequenceActivities(new Fly(self, target), new FlyTimed(ticksUntilTurn, self));
}
inner = ActivityUtils.RunActivity(self, inner);
return this;
}
示例3: addActivity
public void addActivity(Activity act)
{
if(LstActivity.Count() < Parameter.DIX)
LstActivity.Add(act);
else
System.Console.Write("Le nombre maximum d'activités est déjà atteint");
}
示例4: Cancelled
public ActivityGroup Cancelled(SingleActivity next)
{
if (next == null) throw new ArgumentNullException("next");
OnCancel = next;
return this;
}
示例5: CreateOrUpdateActivity
static Activity CreateOrUpdateActivity(Activity activity, string packageName)
{
Console.WriteLine("Creating/Updating Activity...");
bool newlyCreated = false;
if (activity == null)
{
activity = new Activity() { Id = ActivityName };
newlyCreated = true;
}
activity.Instruction = new Instruction()
{
Script = "_test\n"
};
activity.Parameters = new Parameters()
{
InputParameters = {
new Parameter() { Name = "HostDwg", LocalFileName = "$(HostDwg)" },
new Parameter() { Name = "ProductDb", LocalFileName="dummy.txt"}
},
OutputParameters = { new Parameter() { Name = "Result", LocalFileName = "result.pdf" } }
};
activity.RequiredEngineVersion = "20.1";
if (newlyCreated)
{
activity.AppPackages.Add(packageName); // reference the custom AppPackage
container.AddToActivities(activity);
}
else
container.UpdateObject(activity);
container.SaveChanges();
return activity;
}
示例6: Queue
public virtual void Queue(Activity activity)
{
if (NextActivity != null)
NextActivity.Queue(activity);
else
NextActivity = activity;
}
示例7: AddActivity
public void AddActivity(Activity activ)
{
if (LstActivities.Count <= Parameter.MAX_ACTIVITY)
{
LstActivities.Add(activ);
}
}
示例8: GetFrequency
public static int GetFrequency(ITashaPerson person, Activity activity, Random random, int maxFrequency, int householdPD, int workPD, GenerationAdjustment[] generationAdjustments)
{
int freq = 0;
freq = Distribution.GetRandomFrequencyValue(
0, maxFrequency, random, Distribution.GetDistributionID(person, activity), householdPD, workPD, generationAdjustments);
return freq;
}
示例9: Add
public void Add(Activity value)
{
if (value.Created == null || value.ChallengeID == 0)
return;
if (value.RowKey == null)
value.RowKey = value.Created.ToString();
if (value.PartitionKey == null)
value.PartitionKey = "Chal" + value.ChallengeID.ToString();
context.AttachTo(TableName, value, null);
context.UpdateObject(value);
context.SaveChangesWithRetries();
context.Detach(value);
/*
try
{
using (var redisClient = GetRedisClient())
{
IRedisTypedClient<Activity> redis = redisClient.As<Activity>();
redis.SetEntry(this.RedisKeyForLatestActivity(value.ChallengeID), value);
}
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine("Activity repo exception: " + e.ToString());
} */
}
示例10: InsertActivityLogTest
public void InsertActivityLogTest()
{
var log = new Activity(DateTime.Now, "Test", "Test Activity");
repository.Insert(log, "Contact", 1);
Assert.IsNotNull(log.Id);
}
示例11: NewActivity
public static Activity NewActivity(this IActivityRepository activityRepository, byte[] streamId, int pattern)
{
var id = Encoding.UTF8.GetBytes($"activity_{pattern}");
var activity = new Activity(streamId, id, new TestActivityBody($"body_{pattern}"), $"author_{pattern}", new DateTime(2000, 1, pattern));
activityRepository.Append(activity);
return activity;
}
示例12: benchmarkSystem_JobTerminated
static void benchmarkSystem_JobTerminated(object sender, JobEventArgs e)
{
Activity ac = new Activity(e.job, Job.JobState.Succesfull, System.DateTime.Now.Ticks);
BenchmarkSystem.db.Activities.Add(ac);
BenchmarkSystem.db.SaveChanges();
Console.WriteLine("Job Terminated: " + e.job);
}
示例13: benchmarkSystem_JobRemoved
static void benchmarkSystem_JobRemoved(object sender, JobEventArgs e)
{
Activity ac = new Activity(e.job, Job.JobState.Failed, System.DateTime.Now.Ticks);
BenchmarkSystem.db.Activities.Add(ac);
BenchmarkSystem.db.SaveChanges();
Console.WriteLine("Job Cancelled: " + e.job);
}
示例14: _GetPerformance
private static string _GetPerformance(string interval, Activity mg_old, Activity mg_new)
{
Activity mg_dif = mg_new - mg_old;
if (mg_dif.Score > 0 || mg_dif.Rank != 0)
{
string result = @"\u{0}:\u ".FormatWith(interval);
if (mg_dif.Score > 0)
{
result += @"\c03{0}\c score, ".FormatWith(mg_dif.Score);
}
if (mg_dif.Rank > 0)
{
result += @"\c3+{0}\c rank{1};".FormatWith(mg_dif.Rank, mg_dif.Rank > 1 ? "s" : string.Empty);
}
else if (mg_dif.Rank < 0)
{
result += @"\c4{0}\c rank{1};".FormatWith(mg_dif.Rank, mg_dif.Rank < -1 ? "s" : string.Empty);
}
return result.EndsWithI(", ") ? result.Substring(0, result.Length - 2) + ";" : result;
}
return null;
}
示例15: GenerateProfileUpdatedActivity
/// <summary>
/// Make a profile updated joined activity object from the more generic database activity object
/// </summary>
/// <param name="activity"></param>
/// <returns></returns>
private ProfileUpdatedActivity GenerateProfileUpdatedActivity(Activity activity)
{
var cacheKey = string.Concat(CacheKeys.Activity.StartsWith, "GenerateProfileUpdatedActivity-", activity.GetHashCode());
return _cacheService.CachePerRequest(cacheKey, () =>
{
var dataPairs = ActivityBase.UnpackData(activity);
if (!dataPairs.ContainsKey(ProfileUpdatedActivity.KeyUserId))
{
// Log the problem then skip
_loggingService.Error($"A profile updated activity record with id '{activity.Id}' has no user id in its data.");
return null;
}
var userId = dataPairs[ProfileUpdatedActivity.KeyUserId];
var user = _context.MembershipUser.FirstOrDefault(x => x.Id == new Guid(userId));
if (user == null)
{
// Log the problem then skip
_loggingService.Error($"A profile updated activity record with id '{activity.Id}' has a user id '{userId}' that is not found in the user table.");
return null;
}
return new ProfileUpdatedActivity(activity, user);
});
}