当前位置: 首页>>代码示例>>C#>>正文


C# AType.ToString方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:30,代码来源:Pack.cs

示例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());
     }
 }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:14,代码来源:StringSearchandReplace.cs

示例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];
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:18,代码来源:SystemVariables.cs

示例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;
            }
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:44,代码来源:LoadFile.cs

示例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;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:41,代码来源:ExecuteInContext.cs

示例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;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:21,代码来源:ContextSys.cs

示例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;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:22,代码来源:Execute.cs

示例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();
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:16,代码来源:StringConnection.cs

示例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;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:23,代码来源:RawConnection.cs


注:本文中的AType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。