예제 #1
0
        public void AddItemToBuilder(IItem item, string name, SolutionMessage.Builder builder)
        {
            DateTimeValue date = (item as DateTimeValue);

            if (date != null)
            {
                SolutionMessage.Types.StringVariable.Builder var = SolutionMessage.Types.StringVariable.CreateBuilder();
                var.SetName(name).SetData(date.Value.ToString("yyyy-MM-dd HH:mm:sszzz"));
                builder.AddStringVars(var.Build());
            }
            else
            {
                throw new ArgumentException(ItemName + ": Item is not of a supported type.", "item");
            }
        }
예제 #2
0
        public void AddItemToBuilder(IItem item, string name, SolutionMessage.Builder builder)
        {
            IStringConvertibleValue value = (item as IStringConvertibleValue);

            if (value != null)
            {
                SolutionMessage.Types.StringVariable.Builder var = SolutionMessage.Types.StringVariable.CreateBuilder();
                var.SetName(name).SetData(value.GetValue());
                builder.AddStringVars(var.Build());
            }
            else
            {
                IStringConvertibleArray array = (item as IStringConvertibleArray);
                if (array != null)
                {
                    SolutionMessage.Types.StringArrayVariable.Builder var = SolutionMessage.Types.StringArrayVariable.CreateBuilder();
                    var.SetName(name).SetLength(array.Length);
                    for (int i = 0; i < array.Length; i++)
                    {
                        var.AddData(array.GetValue(i));
                    }
                    builder.AddStringArrayVars(var.Build());
                }
                else
                {
                    IStringConvertibleMatrix matrix = (item as IStringConvertibleMatrix);
                    if (matrix != null)
                    {
                        SolutionMessage.Types.StringArrayVariable.Builder var = SolutionMessage.Types.StringArrayVariable.CreateBuilder();
                        var.SetName(name).SetLength(matrix.Columns);
                        for (int i = 0; i < matrix.Rows; i++)
                        {
                            for (int j = 0; j < matrix.Columns; j++)
                            {
                                var.AddData(matrix.GetValue(i, j));
                            }
                        }
                        builder.AddStringArrayVars(var.Build());
                    }
                    else
                    {
                        throw new ArgumentException(ItemName + ": Item is not of a supported type.", "item");
                    }
                }
            }
        }