本文整理汇总了C#中IAddressable类的典型用法代码示例。如果您正苦于以下问题:C# IAddressable类的具体用法?C# IAddressable怎么用?C# IAddressable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAddressable类属于命名空间,在下文中一共展示了IAddressable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterCancellationTokens
/// <summary>
/// Adds CancellationToken to the grain extension
/// so that it can be cancelled through remote call to the CancellationSourcesExtension.
/// </summary>
/// <param name="target"></param>
/// <param name="request"></param>
/// <param name="logger"></param>
internal static void RegisterCancellationTokens(IAddressable target, InvokeMethodRequest request, Logger logger)
{
for (var i = 0; i < request.Arguments.Length; i++)
{
var arg = request.Arguments[i];
if (!(arg is GrainCancellationToken)) continue;
var grainToken = ((GrainCancellationToken) request.Arguments[i]);
CancellationSourcesExtension cancellationExtension;
if (!SiloProviderRuntime.Instance.TryGetExtensionHandler(out cancellationExtension))
{
cancellationExtension = new CancellationSourcesExtension();
if (!SiloProviderRuntime.Instance.TryAddExtension(cancellationExtension))
{
logger.Error(
ErrorCode.CancellationExtensionCreationFailed,
$"Could not add cancellation token extension to: {target}");
return;
}
}
// Replacing the half baked GrainCancellationToken that came from the wire with locally fully created one.
request.Arguments[i] = cancellationExtension.RecordCancellationToken(grainToken.Id, grainToken.IsCancellationRequested);
}
}
示例2: M6502
public M6502(IAddressable mem)
{
this.mem = mem;
InstallOpcodes();
Clock = 0;
RunClocks = 0;
RunClocksMultiple = 1;
P = 1 << 5;
}
示例3: Invoke
public Task<object> Invoke(IAddressable grain, InvokeMethodRequest request)
{
var interceptor = grain as IGrainInvokeInterceptor;
if (interceptor != null)
{
var methodInfo = this.GetMethodInfo(request.MethodId);
return interceptor.Invoke(methodInfo, request, this.invoker);
}
return this.invoker.Invoke(grain, request);
}
示例4: DeleteObjectReference
public void DeleteObjectReference(IAddressable obj)
{
if (!(obj is GrainReference))
throw new ArgumentException("Argument reference is not a grain reference.");
var reference = (GrainReference) obj;
LocalObjectData ignore;
if (!localObjects.TryRemove(reference.ObserverId, out ignore))
throw new ArgumentException("Reference is not associated with a local object.", "reference");
}
示例5: Cast
public static IClient Cast(IAddressable grainRef)
{
return (IClient) GrainReference.CastInternal(typeof(IClient), (GrainReference gr) => { return new ClientReference(gr);}, grainRef, 523268002);
}
示例6: Invoke
public async System.Threading.Tasks.Task<Object> Invoke(IAddressable grain, int interfaceId, int methodId, object[] arguments)
{
if (grain == null) throw new System.ArgumentNullException("grain");
switch (interfaceId)
{
case 1662910789: // IDestination
switch (methodId)
{
case 1491328371:
await ((IDestination)grain).Ping((IClient)arguments[0], (Message)arguments[1]);
return true;
default:
throw new NotImplementedException("interfaceId="+interfaceId+",methodId="+methodId);
}
default:
throw new System.InvalidCastException("interfaceId="+interfaceId);
}
}
示例7: EA
private static string EA(IAddressable mem, ushort PC, int bytes)
{
byte lsb = mem[PC];
byte msb = 0;
if (bytes == 2)
msb = mem[(ushort)(PC + 1)];
ushort ea = (ushort)(lsb | (msb << 8));
if (bytes == 1)
return String.Format(CultureInfo.InvariantCulture, "${0:x2}", ea);
else
return String.Format(CultureInfo.InvariantCulture, "${0:x4}", ea);
}
示例8: OpCodeDecode
public static string OpCodeDecode(IAddressable mem, ushort PC)
{
int num_operands = InstructionLength(mem, PC) - 1;
ushort PC1 = (ushort)(PC + 1);
string addrmodeStr;
switch (addressingModeMatrix[mem[PC]]) {
case a.REL:
addrmodeStr = String.Format(CultureInfo.InvariantCulture,
"${0:x4}", (ushort)(PC + (sbyte)(mem[PC1]) + 2));
break;
case a.ZPG:
case a.ABS:
addrmodeStr = EA(mem, PC1, num_operands);
break;
case a.ZPX:
case a.ABX:
addrmodeStr = EA(mem, PC1, num_operands) + ",X";
break;
case a.ZPY:
case a.ABY:
addrmodeStr = EA(mem, PC1, num_operands) + ",Y";
break;
case a.IDX:
addrmodeStr = "(" + EA(mem, PC1, num_operands) + ",X)";
break;
case a.IDY:
addrmodeStr = "(" + EA(mem, PC1, num_operands) + "),Y";
break;
case a.IND:
addrmodeStr = "(" + EA(mem, PC1, num_operands) + ")";
break;
case a.IMM:
addrmodeStr = "#" + EA(mem, PC1, num_operands);
break;
default:
// a.IMP, a.ACC
addrmodeStr = "";
break;
}
return String.Format(CultureInfo.InvariantCulture,
"{0} {1}", mnemonicMatrix[mem[PC]], addrmodeStr);
}
示例9: MemDump
public static string MemDump(IAddressable mem, ushort atAddr, ushort untilAddr)
{
StringBuilder result = new StringBuilder();
int length = untilAddr - atAddr;
while (length-- >= 0) {
result.AppendFormat(CultureInfo.InvariantCulture, "{0:x4}: ", atAddr);
for (int i = 0; i < 8; ++i) {
result.AppendFormat(CultureInfo.InvariantCulture, "{0:x2} ", mem[atAddr++]);
if (i == 3)
result.Append(" ");
}
result.Append(Environment.NewLine);
}
if (result.Length > 0)
result.Length--; // Trim trailing newline
return result.ToString();
}
示例10: Disassemble
public static string Disassemble(IAddressable mem, ushort atAddr, ushort untilAddr)
{
StringBuilder result = new StringBuilder();
ushort dPC = atAddr;
while (atAddr < untilAddr) {
result.AppendFormat(CultureInfo.InvariantCulture, "{0:x4}: ", dPC);
int len = InstructionLength(mem, dPC);
for (int i = 0; i < 3; i++) {
if (i < len)
result.AppendFormat(CultureInfo.InvariantCulture, "{0:x2} ", mem[atAddr++]);
else
result.Append(" ");
}
result.AppendFormat(CultureInfo.InvariantCulture, "{0,-15:s}{1}",
OpCodeDecode(mem, dPC), Environment.NewLine);
dPC += (ushort)len;
}
if (result.Length > 0)
result.Length--; // Trim trailing newline
return result.ToString();
}
示例11: Invoke
/// <summary>
/// Invokes the appropriate grain or extension method for the request interface ID and method ID.
/// First each extension invoker is tried; if no extension handles the request, then the base
/// invoker is used to handle the request.
/// The base invoker will throw an appropriate exception if the request is not recognized.
/// </summary>
/// <param name="grain"></param>
/// <param name="interfaceId"></param>
/// <param name="methodId"></param>
/// <param name="arguments"></param>
/// <returns></returns>
public Task<object> Invoke(IAddressable grain, int interfaceId, int methodId, object[] arguments)
{
if (extensionMap == null || !extensionMap.ContainsKey(interfaceId))
throw new InvalidOperationException(
String.Format("Extension invoker invoked with an unknown inteface ID:{0}.", interfaceId));
var invoker = extensionMap[interfaceId].Item2;
var extension = extensionMap[interfaceId].Item1;
return invoker.Invoke(extension, interfaceId, methodId, arguments);
}
示例12: CreateObjectReference
public GrainReference CreateObjectReference(IAddressable obj, IGrainMethodInvoker invoker)
{
throw new InvalidOperationException("Cannot create a local object reference from a grain.");
}
示例13: DeleteObjectReference
public void DeleteObjectReference(IAddressable obj)
{
throw new InvalidOperationException("Cannot delete a local object reference from a grain.");
}
示例14: InstructionLength
private static int InstructionLength(IAddressable mem, ushort PC)
{
switch (addressingModeMatrix[mem[PC]]) {
case a.ACC:
case a.IMP:
return 1;
case a.REL:
case a.ZPG:
case a.ZPX:
case a.ZPY:
case a.IDX:
case a.IDY:
case a.IMM:
return 2;
case a.ABS:
case a.ABX:
case a.ABY:
case a.IND:
default:
return 3;
}
}
示例15: Invoke
public async System.Threading.Tasks.Task<Object> Invoke(IAddressable grain, int interfaceId, int methodId, object[] arguments)
{
if (grain == null) throw new System.ArgumentNullException("grain");
switch (interfaceId)
{
case -1248350959: // IDeviceGrain
switch (methodId)
{
case -1788431855:
await ((IDeviceGrain)grain).SetTemperature((Double)arguments[0]);
return true;
case 98774684:
return await ((IDeviceGrain)grain).GetTemperature();
default:
throw new NotImplementedException("interfaceId="+interfaceId+",methodId="+methodId);
}
default:
throw new System.InvalidCastException("interfaceId="+interfaceId);
}
}