本文整理汇总了C#中AType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# AType.ToString方法的具体用法?C# AType.ToString怎么用?C# AType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AType
的用法示例。
在下文中一共展示了AType.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compute
/// <summary>
/// Convert Character constant array to symbol array.
/// </summary>
/// <param name="argument"></param>
/// <returns></returns>
private AType Compute(AType argument)
{
//If argument is character constant or character constant vector then we convert it symbol,
//and cut blanks from end.
if (argument.Rank <= 1)
{
return ASymbol.Create(argument.ToString().TrimEnd());
}
else
{
AType result = AArray.Create(ATypes.ASymbol);
foreach (AType item in argument)
{
result.AddWithNoUpdate(Compute(item));
}
result.Length = argument.Length;
result.Shape = new List<int>();
result.Shape.AddRange(argument.Shape.GetRange(0, argument.Shape.Count - 1));
result.Rank = argument.Rank - 1;
return result;
}
}
示例2: ExtractRows
private static void ExtractRows(AType argument, Queue<string> rows)
{
if (argument.Rank > 1)
{
foreach (AType item in argument)
{
ExtractRows(item, rows);
}
}
else
{
rows.Enqueue(argument.ToString());
}
}
示例3: GetSystemVariable
internal static AType GetSystemVariable(Aplus environment, AType input)
{
ATypes type = input.Type;
if (type != ATypes.ASymbol && type != ATypes.AChar)
{
throw new Error.Type("_gsv");
}
string name = (type == ATypes.ASymbol) ? input.asString : input.ToString();
if(!environment.SystemVariables.Contains(name))
{
throw new Error.Domain("_gsv");
}
return environment.SystemVariables[name];
}
示例4: Loadfile
internal static AType Loadfile(Aplus environment, AType filename)
{
string fileName = filename.ToString();
if (filename.Type != ATypes.AChar)
{
throw new Error.Type("_loadfile");
}
if (!File.Exists(fileName))
{
throw new Error.Invalid("_loadfile");
}
AType result = AArray.Create(ATypes.AChar);
using (FileStream fileStream = new FileStream(fileName, FileMode.Open))
{
int blockReadSize = 5 * 1024; // 5 KiB
long totalSize = fileStream.Length;
int readLength = blockReadSize < totalSize ? blockReadSize : (int)totalSize;
byte[] filePartialContent = new byte[readLength];
int sum = 0; // total number of bytes read
int count; // current number of bytes read
// read until Read method returns 0 (end of the stream has been reached)
while ((count = fileStream.Read(filePartialContent, 0, readLength)) > 0)
{
sum += count; // sum is a buffer offset for next reading
// build the array from the bytes that was read
for (int i = 0; i < count; i++)
{
result.Add(AChar.Create((char)filePartialContent[i]));
}
// calculate the next size of the read block
long leftover = totalSize - sum;
readLength = blockReadSize < leftover ? blockReadSize : (int)leftover;
}
return result;
}
}
示例5: Execute
public override AType Execute(AType right, AType left, Aplus environment)
{
// Environment is required!
Assert.NotNull(environment);
if (right.Type != ATypes.AChar)
{
throw new Error.Type(this.TypeErrorText);
}
if (right.Rank > 1)
{
throw new Error.Rank(this.RankErrorText);
}
string sourceCode = right.ToString();
AType result;
if(left.Type == ATypes.ASymbol)
{
AType symbol;
if(left.TryFirstScalar(out symbol))
{
result = ExecuteWithContextSwitch(environment, sourceCode, symbol.asString);
}
else
{
result = ProtectedExecute(environment, sourceCode);
}
}
else if (left.Type == ATypes.AInteger || left.Type == ATypes.ANull)
{
result = ProtectedExecute(environment, sourceCode);
}
else
{
throw new Error.Type(this.TypeErrorText);
}
return result;
}
示例6: FileSize
public static AType FileSize(Aplus environment, AType argument)
{
if (argument.Type != ATypes.AChar)
{
throw new Error.Type("sys.filesize");
}
AType result;
string fileName = argument.ToString();
if (File.Exists(fileName))
{
result = Utils.CreateATypeResult((new FileInfo(fileName)).Length);
}
else
{
result = AInteger.Create(-1);
}
return result;
}
示例7: Execute
public override AType Execute(AType argument, Aplus environment)
{
// Environment is required!
Assert.NotNull(environment);
if (argument.Type != ATypes.AChar)
{
throw new Error.Type(this.TypeErrorText);
}
if (argument.Rank > 1)
{
throw new Error.Rank(this.RankErrorText);
}
DLR.Expression<Func<Aplus, AType>> lambda = BuildExecuteMethod(argument.ToString(), environment);
Func<Aplus, AType> method = lambda.Compile();
AType result = method(environment);
return result;
}
示例8: ConvertToByte
protected override byte[] ConvertToByte(AType message)
{
if (message.Type != ATypes.AChar)
{
throw new ADAPException(ADAPExceptionType.Export);
}
byte[] messageBody = ASCIIEncoder.GetBytes(message.ToString());
byte[] messageHeader = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(messageBody.Length));
List<byte> result = new List<byte>();
result.AddRange(messageHeader);
result.AddRange(messageBody);
return result.ToArray();
}
示例9: ConvertToByte
protected override byte[] ConvertToByte(AType message)
{
if (message.Type != ATypes.AChar)
{
throw new ADAPException(ADAPExceptionType.Export);
}
byte[] result;
try
{
result = ASCIIEncoder.GetBytes(message.ToString());
}
catch (ArgumentNullException)
{
throw new ADAPException(ADAPExceptionType.Export);
}
catch (EncoderFallbackException)
{
throw new ADAPException(ADAPExceptionType.Export);
}
return result;
}