本文整理汇总了C#中Shared类的典型用法代码示例。如果您正苦于以下问题:C# Shared类的具体用法?C# Shared怎么用?C# Shared使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Shared类属于命名空间,在下文中一共展示了Shared类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
void IUIWidget.OnOperationChange(Shared.Core.Operation operation)
{
string lineOne = null;
if (!string.IsNullOrWhiteSpace(_expressionLineOne))
{
lineOne = operation != null ? operation.ToString(_expressionLineOne) : "(n/A)";
}
string lineTwo = null;
if (!string.IsNullOrWhiteSpace(_expressionLineTwo))
{
lineTwo = operation != null ? operation.ToString(_expressionLineTwo) : "(n/A)";
}
string lineThree = null;
if (!string.IsNullOrWhiteSpace(_expressionLineThree))
{
lineThree = operation != null ? operation.ToString(_expressionLineThree) : "(n/A)";
}
LineOne.Inlines.Clear();
LineTwo.Inlines.Clear();
LineThree.Inlines.Clear();
LineOne.Inlines.Add(Helper.Execute(lineOne));
LineTwo.Inlines.Add(Helper.Execute(lineTwo));
LineThree.Inlines.Add(Helper.Execute(lineThree));
}
示例2: Broadcast
public void Broadcast(Shared.InamStream stream, byte type)
{
foreach (IEntity entity in this.Senses[type])
{
entity.EventManager.Enqueue(stream);
}
}
示例3: triggerInternal
protected override void triggerInternal(Shared lastState, Shared currentState)
{
if (CommonData.isRaceStarted)
{
if (pushDataInFront == null || pushDataBehind == null)
{
clearState();
}
if (CommonData.isNewLap)
{
if (CommonData.racingSameCarInFront)
{
pushDataInFront.Add(new PushData(currentState.LapTimePrevious, currentState.TimeDeltaFront));
}
else
{
pushDataInFront.Clear();
}
if (CommonData.racingSameCarBehind)
{
pushDataBehind.Add(new PushData(currentState.LapTimePrevious, currentState.TimeDeltaBehind));
}
else
{
pushDataBehind.Clear();
}
}
if (currentState.NumberOfLaps == -1 && !playedNearEndTimePush &&
currentState.SessionTimeRemaining < 4 * 60 && currentState.SessionTimeRemaining > 2 * 60)
{
// estimate the number of remaining laps - be optimistic...
int numLapsLeft = (int)Math.Ceiling((double)currentState.SessionTimeRemaining / (double)currentState.LapTimeBest);
playedNearEndTimePush = checkGaps(currentState, numLapsLeft);
}
else if (currentState.NumberOfLaps > 0 && currentState.NumberOfLaps - currentState.CompletedLaps <= 4 &&
!playedNearEndLapsPush)
{
playedNearEndLapsPush = checkGaps(currentState, currentState.NumberOfLaps - currentState.CompletedLaps);
}
else if (currentState.PitWindowStatus == (int)Constant.PitWindow.Completed && lastState.PitWindowStatus == (int)Constant.PitWindow.StopInProgress)
{
drivingOutOfPits = true;
}
else if (drivingOutOfPits && currentState.ControlType == (int)Constant.Control.Player && lastState.ControlType == (int)Constant.Control.AI)
{
drivingOutOfPits = false;
// we've just been handed control back after a pitstop
if (currentState.TimeDeltaFront > 3 && currentState.TimeDeltaBehind > 4)
{
// we've exited into clean air
audioPlayer.queueClip(folderPushExitingPits, 0, this);
}
else if (currentState.TimeDeltaBehind <= 4)
{
// we've exited the pits but there's traffic behind
audioPlayer.queueClip(folderTrafficBehindExitingPits, 0, this);
}
}
}
}
示例4: AuthenticateUser
public Shared.Types.BooleanResult AuthenticateUser(Shared.Types.SessionProperties properties)
{
Shared.Types.UserInformation userInfo = properties.GetTrackedSingle<Shared.Types.UserInformation>();
m_logger.DebugFormat("Authenticate: {0}", userInfo.Username);
UserEntry entry = GetUserEntry(userInfo.Username);
if (entry != null)
{
m_logger.DebugFormat("Retrieved info for user {0} from MySQL. Password uses {1}.",
entry.Name, entry.HashAlg.ToString());
bool passwordOk = entry.VerifyPassword(userInfo.Password);
if (passwordOk)
{
m_logger.DebugFormat("Authentication successful for {0}", userInfo.Username);
return new Shared.Types.BooleanResult() { Success = true, Message = "Success." };
}
else
{
m_logger.DebugFormat("Authentication failed for {0}", userInfo.Username);
return new Shared.Types.BooleanResult() { Success = false, Message = "Invalid username or password." };
}
}
else
{
m_logger.DebugFormat("Authentication failed for {0}", userInfo.Username);
return new Shared.Types.BooleanResult() { Success = false, Message = "Invalid username or password." };
}
}
示例5: CreateEvent
/// <summary>
/// This should read in a Type byte and create an instance of the correct type
/// Each event type should include a custom 'Execute' method that handles it
/// </summary>
protected override IEvent CreateEvent(Shared.InamStream stream)
{
int ID = stream.ReadInt32();
BrainEventType type = (BrainEventType)stream.ReadByte();
if (type == BrainEventType.System)
{
}
else if (type == BrainEventType.Sight)
{
return new BrainSightEvent(this, stream, this.entity);
}
else if (type == BrainEventType.Touch)
{
return new BrainTouchEvent(this, stream, this.entity);
}
else if (type == BrainEventType.Hear)
{
}
else if (type == BrainEventType.Taste)
{
}
// bad
return null;
}
示例6: SendContact
public bool SendContact(string sessionKey, Shared.Dto.Contact contact)
{
var dbContext = DbContextFactory.GetContext();
var sessionService = new SessionService();
var user = sessionService.GetUser(sessionKey);
if (user == null) return false;
User recipient;
try
{
recipient =
dbContext.Users.Single(u => u.Id == contact.ReceiverId);
}
catch (Exception)
{
return false;
}
var newContact = new Contact
{
PublicKey = contact.PublicKey,
Name = contact.Name,
Sender = user,
Recipient = recipient
};
dbContext.Add(newContact);
dbContext.SaveChanges();
var userService = new PushService();
userService.Push(recipient, "Recieved new contact!");
return true;
}
示例7: AuthenticatedUserGateway
public Shared.Types.BooleanResult AuthenticatedUserGateway(Shared.Types.SessionProperties properties)
{
UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();
try
{
using (MySqlUserDataSource dataSource = new MySqlUserDataSource())
{
List<GroupGatewayRule> rules = GroupRuleLoader.GetGatewayRules();
foreach (GroupGatewayRule rule in rules)
{
m_logger.DebugFormat("Checking rule: {0}", rule.ToString());
if (rule.RuleMatch(dataSource.IsMemberOfGroup(userInfo.Username, rule.Group)))
{
m_logger.DebugFormat("Rule is a match, adding to {0}", rule.LocalGroup);
userInfo.Groups.Add(new GroupInformation { Name = rule.LocalGroup });
}
else
{
m_logger.DebugFormat("Rule is not a match");
}
}
}
}
catch (Exception e)
{
m_logger.ErrorFormat("Unexpected error: {0}", e);
throw;
}
// Always return success
return new Shared.Types.BooleanResult { Success = true };
}
示例8: OnPolling
protected async override Task<ProcessResult> OnPolling(
Shared.Jobs.PollerJobParameters parameters,
string workingFolder)
{
string pathToFile = await DownloadBlob(parameters.TenantId, parameters.JobId, parameters.FileName, workingFolder);
Logger.DebugFormat("Downloaded file {0} to be converted to pdf", pathToFile);
var converter = Converters.FirstOrDefault(c => c.CanConvert(pathToFile));
if (converter == null)
{
Logger.InfoFormat("No converter for extension {0}", Path.GetExtension(pathToFile));
return ProcessResult.Ok;
}
string outFile = Path.Combine(workingFolder, Guid.NewGuid() + ".pdf");
if (!converter.Convert(pathToFile, outFile))
{
Logger.ErrorFormat("Error converting file {0} to pdf", pathToFile);
return ProcessResult.Fail;
}
await AddFormatToDocumentFromFile(
parameters.TenantId,
parameters.JobId,
new DocumentFormat(DocumentFormats.Pdf),
outFile,
new Dictionary<string, object>());
return ProcessResult.Ok;
}
示例9: CreateEvent
protected override IEvent CreateEvent(Shared.InamStream stream)
{
//int ID = stream.ReadInt32(); // there is no ID here, as we are just choosing the correct sense to send this to
byte type = stream.ReadByte();
// bad
return null;
}
示例10: ToString_returns_a_string_representation_of_the_object
public void ToString_returns_a_string_representation_of_the_object()
{
var shared = new Shared<object>();
const string expected = "Shared<System.Object>";
Assert.AreEqual(expected, shared.ToString());
}
示例11: NavigateToMainView
public void NavigateToMainView(Shared.ViewModels.MainViewModel.SubView? subView)
{
if (!subView.HasValue || subView.Value == Shared.ViewModels.MainViewModel.SubView.Auction)
{
Navigate(typeof(AuctionView));
return;
}
throw new NotImplementedException();
}
示例12: Constructor_when_given_a_value_instantiates_with_it
public void Constructor_when_given_a_value_instantiates_with_it()
{
var value = new object();
var shared = new Shared<object>(value);
var actual = shared.Value;
Assert.AreEqual(value, actual);
}
示例13: AddContact
public IHttpActionResult AddContact([FromUri]string sessionKey, Shared.Dto.Contact contact)
{
var contactService = new ContactService();
if (contactService.SendContact(sessionKey, contact))
{
return Ok();
}
return Unauthorized();
}
示例14: trigger
public void trigger(Shared lastState, Shared currentState)
{
// don't trigger events if someone else is driving the car (or it's a replay). No way to tell the difference between
// watching an AI 'live' and the AI being in control of your car for starts / pitstops
if (!CommonData.isNew && currentState.ControlType != (int)Constant.Control.Remote &&
currentState.ControlType != (int)Constant.Control.Replay)
{
triggerInternal(lastState, currentState);
}
}
示例15: Prepare
public override SkillResults Prepare(World.MabiCreature creature, World.MabiSkill skill, Shared.Network.MabiPacket packet, uint castTime)
{
creature.StopMove();
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, creature.Id).PutInt(Effect.SkillInit).PutString("thunder").PutShort((ushort)skill.Id), SendTargets.Range, creature);
Send.SkillPrepare(creature.Client, creature, skill.Id, castTime);
return SkillResults.Okay;
}