Esempio n. 1
0
        public void GetFieldRequestObject()
        {
            moq::Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock <FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetFieldRequest request = new GetFieldRequest
            {
                FieldName = FieldName.FromProjectDatabaseCollectionField("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"),
            };
            Field expectedResponse = new Field
            {
                FieldName   = FieldName.FromProjectDatabaseCollectionField("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"),
                IndexConfig = new Field.Types.IndexConfig(),
            };

            mockGrpcClient.Setup(x => x.GetField(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null);
            Field response = client.GetField(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        [TestMethod] public void GenerateDeclarationWithDefault()
        {
            // Arrange
            var name         = new FieldName("Government");
            var nullability  = IsNullable.No;
            var enums        = new DBValue[] { DBValue.Create("Monarchy"), DBValue.Create("Democracy") };
            var defaultValue = enums[1];
            var mockBuilder  = new Mock <IFieldDeclBuilder>();
            var field        = new EnumField(name, nullability, Option.Some(defaultValue), enums);

            // Act
            _ = field.GenerateSqlDeclaration(mockBuilder.Object);

            // Assert
            mockBuilder.Verify(builder => builder.SetName(name));
            mockBuilder.Verify(builder => builder.SetDataType(DBType.Enumeration));
            mockBuilder.Verify(builder => builder.SetNullability(nullability));
            mockBuilder.Verify(builder => builder.SetDefaultValue(defaultValue));
            mockBuilder.Verify(builder => builder.SetAllowedValues(Arg.IsSameSequence <IEnumerable <DBValue> >(enums)));
            mockBuilder.Verify(builder => builder.Build());
            mockBuilder.VerifyNoOtherCalls();
        }
Esempio n. 3
0
        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            var  t    = GetText();
            bool flag = false;
            var  json = JObject.Parse(t);

            foreach (var item in FieldName.Split('.'))
            {
                if (json.Properties().Where(n => n.Name == item).Any())
                {
                    if (json.Property(item).Value.Type == JTokenType.Object)
                    {
                        json = JObject.Parse(json.Property(item).Value.ToString());
                    }
                    else
                    {
                        Data.DataWrite(this, FieldName, json.Property(item).Value.ToString(), this.WriteType, DataAttributeType.Text);
                        flag = true;
                    }
                }
                else
                {
                    break;
                }
            }
            if (json.Type == JTokenType.Object && flag == false)
            {
                Data.DataWrite(this, FieldName, json.ToString(), this.WriteType, DataAttributeType.Text);
            }
            if (flag == false)
            {
                if (ErrorThrow)
                {
                    ReportManage.ErrReport(this, "FieldName:「" + FieldName + "」がありません。");
                }
            }
            base.Run(runChildren);
        }
Esempio n. 4
0
        public override bool Equals(object obj)
        {
            if (obj == null || (GetType() != obj.GetType() && !(obj is String)))
            {
                return(false);
            }

            OrderBy result = null;

            //
            // aqui não podemos usar o ToString diretamente pois o mesmo é sobrescrito e retorna o
            // DESC caso seja ordenação descendente
            //
            if (obj is String)
            {
                result = obj.ToString();
            }
            else
            {
                result = obj as OrderBy;
            }

            return(FieldName.Equals(result.FieldName, StringComparison.InvariantCultureIgnoreCase));
        }
Esempio n. 5
0
        private Res GetInBlock(Res res, bool set)
        {
            foreach (string str in query.GetResData().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (str.Contains("레코드명:") && str.Contains("InBlock"))
                {
                    res.InBlock = str.Replace("*", string.Empty).Replace("레코드명:", string.Empty).Trim();

                    continue;
                }
                else if (str.Contains("레코드명:") && str.Contains("OutBlock"))
                {
                    OutBlock  = str.Replace("*", string.Empty).Replace("레코드명:", string.Empty).Trim();
                    FieldName = new List <string>();
                    set       = false;

                    continue;
                }
                else if (str.Contains("No,한글명,필드명,영문명,"))
                {
                    continue;
                }

                var temp = str.Split(',');

                if (set)
                {
                    res.Filed       = temp[2];
                    res.OccursIndex = int.Parse(temp[6]);

                    continue;
                }
                FieldName.Add(temp[2]);
            }
            return(res);
        }
        public void TestReturnWithFieldNames()
        {
            Client cl = GetClient();
            Schema sc = new Schema().AddTextField("a").AddTextField("b").AddTextField("c");

            Assert.True(cl.CreateIndex(sc, new ConfiguredIndexOptions()));

            var doc = new Dictionary <string, RedisValue>
            {
                { "a", "value1" },
                { "b", "value2" },
                { "c", "value3" }
            };

            Assert.True(cl.AddDocument("doc", doc));

            // Query
            SearchResult res = cl.Search(new Query("*").ReturnFields(FieldName.Of("b").As("d"), FieldName.Of("a")));

            Assert.Equal(1, res.TotalResults);
            Assert.Equal("doc", res.Documents[0].Id);
            Assert.Equal("value1", res.Documents[0]["a"]);
            Assert.Equal("value2", res.Documents[0]["d"]);
        }
Esempio n. 7
0
        public override bool Validate(out Dictionary <string, string> errors)
        {
            errors = new Dictionary <string, string>();
            if (string.IsNullOrEmpty(fieldName))
            {
                errors.Add(nameof(FieldName), "Field name is mandatory.");
            }
            if (string.IsNullOrEmpty(fieldCaption))
            {
                errors.Add(nameof(FieldCaption), "Field caption is mandatory.");
            }

            if (FieldName.HasTrailingSpaces())
            {
                errors.Add(nameof(FieldName), "Trailing spaces are not allowed.");
            }
            if (FieldCaption.HasTrailingSpaces())
            {
                errors.Add(nameof(FieldCaption), "Trailing spaces are not allowed.");
            }


            return(errors.Count == 0);
        }
Esempio n. 8
0
 public SpecificationParameters(FieldName fieldName, string expression)
 {
     FieldName  = fieldName;
     Expression = expression;
 }
Esempio n. 9
0
        private DataTable BuildTable()
        {
            IList <Item> items = mAccountant.ItemMgr.FindAllCollection();
            DataTable    table = new DataTable();

            List <FieldName> names = new List <FieldName>();

            foreach (FieldName fn in FieldOrder.Keys)
            {
                names.Add(fn);
            }
            for (int i = 0; i < names.Count - 1; ++i)
            {
                for (int j = i + 1; j < names.Count; ++j)
                {
                    if (FieldOrder[names[i]] > FieldOrder[names[j]])
                    {
                        FieldName temp = names[i];
                        names[i] = names[j];
                        names[j] = temp;
                    }
                }
            }

            for (int i = 0; i < names.Count; ++i)
            {
                FieldName fn = names[i];
                if (fn == FieldName.ItemNumber && DisplayItemNumber)
                {
                    table.Columns.Add("Item #");
                }
                else if (fn == FieldName.ItemName && DisplayItemName)
                {
                    table.Columns.Add("Name");
                }
                else if (fn == FieldName.BatchNumber && DisplayBatchNumber)
                {
                    table.Columns.Add("Batch #");
                }
                else if (fn == FieldName.SerialNumber && DisplaySerialNumber)
                {
                    table.Columns.Add("Serial #");
                }
                else if (fn == FieldName.ExpiryDate && DisplayExpiryDate)
                {
                    table.Columns.Add("Expiry Date");
                }
                else if (fn == FieldName.Brand && DisplayBrand)
                {
                    table.Columns.Add("Brand");
                }
                else if (fn == FieldName.Color && DisplayColor)
                {
                    table.Columns.Add("Color");
                }
                else if (fn == FieldName.Gender && DisplayGender)
                {
                    table.Columns.Add("Gender");
                }
                else if (fn == FieldName.Size && DisplaySize)
                {
                    table.Columns.Add("Size");
                }

                else if (fn == FieldName.SaleAmount && DisplaySaleAmount)
                {
                    table.Columns.Add("Sales");
                }
                else if (fn == FieldName.CostOfSalesAmount && DisplayCostOfSalesAmount)
                {
                    table.Columns.Add("Cost of Sales");
                }
                else if (fn == FieldName.GrossProfit && DisplayGrossProfit)
                {
                    table.Columns.Add("Gross Profit");
                }
                else if (fn == FieldName.ProfitMargin && DisplayProfitMargin)
                {
                    table.Columns.Add("%Margin");
                }
                else if (fn == FieldName.UnitsSold && DisplayUnitsSold)
                {
                    table.Columns.Add("Units Sold");
                }
                else if (fn == FieldName.AverageCost && DisplayAverageCost)
                {
                    table.Columns.Add("Average Cost");
                }
            }



            double  TotalSaleAmount        = 0;
            double  TotalCostOfSalesAmount = 0;
            double  TotalGrossProfit       = 0;
            double  TotalProfitMargin      = 0;
            DataRow row = null;

            foreach (Item item in items)
            {
                row = table.NewRow();

                double SaleAmount        = 0;
                double ProfitMargin      = 0;
                double GrossProfit       = 0;
                double CostOfSalesAmount = 0;

                List <ItemSalesHistory> itemSalesHistories = mAccountant.ItemSalesHistoryMgr.List(item.ItemID, YearFrom, YearTo);
                SaleAmount = 0;
                if (DisplaySaleAmount || DisplayGrossProfit)
                {
                    foreach (ItemSalesHistory history in itemSalesHistories)
                    {
                        SaleAmount += history.SaleAmount;
                    }
                }

                CostOfSalesAmount = 0;
                if (DisplayCostOfSalesAmount || DisplayGrossProfit)
                {
                    foreach (ItemSalesHistory history in itemSalesHistories)
                    {
                        CostOfSalesAmount += history.CostOfSalesAmount;
                    }
                }

                GrossProfit = SaleAmount - CostOfSalesAmount;

                ProfitMargin = 0;
                if (SaleAmount != 0)
                {
                    ProfitMargin = GrossProfit * 100 / SaleAmount;
                }

                for (int i = 0; i < names.Count; ++i)
                {
                    FieldName fn = names[i];
                    if (fn == FieldName.ItemNumber && DisplayItemNumber)
                    {
                        row["Item #"] = item.ItemNumber;
                    }
                    if (fn == FieldName.ItemName && DisplayItemName)
                    {
                        row["Name"] = item.ItemName;
                    }
                    if (fn == FieldName.BatchNumber && DisplayBatchNumber)
                    {
                        row["Batch #"] = item.ItemAddOn.BatchNumber;
                    }
                    if (fn == FieldName.SerialNumber && DisplaySerialNumber)
                    {
                        row["Serial #"] = item.ItemAddOn.SerialNumber;
                    }
                    if (fn == FieldName.ExpiryDate && DisplayExpiryDate)
                    {
                        if (item.ItemAddOn.ExpiryDate != null)
                        {
                            row["Expiry Date"] = item.ItemAddOn.ExpiryDate.Value.ToString("yyyy-MMM-dd");
                        }
                        else
                        {
                            row["Expiry Date"] = "";
                        }
                    }
                    if (fn == FieldName.Brand && DisplayBrand)
                    {
                        row["Brand"] = item.ItemAddOn.Brand;
                    }
                    if (fn == FieldName.Color && DisplayColor)
                    {
                        row["Color"] = item.ItemAddOn.Color;
                    }
                    if (fn == FieldName.Gender && DisplayGender)
                    {
                        row["Gender"] = item.ItemAddOn.Gender;
                    }
                    if (fn == FieldName.Size && DisplaySize)
                    {
                        row["Size"] = item.ItemAddOn.ItemSize;
                    }



                    if (fn == FieldName.SaleAmount && DisplaySaleAmount)
                    {
                        row["Sales"] = mAccountant.CurrencyMgr.Format(SaleAmount);
                    }



                    if (fn == FieldName.CostOfSalesAmount && DisplayCostOfSalesAmount)
                    {
                        row["Cost of Sales"] = mAccountant.CurrencyMgr.Format(CostOfSalesAmount);
                    }


                    if (fn == FieldName.GrossProfit && DisplayGrossProfit)
                    {
                        row["Gross Profit"] = mAccountant.CurrencyMgr.Format(GrossProfit);
                    }


                    if (fn == FieldName.ProfitMargin && DisplayProfitMargin)
                    {
                        row["%Margin"] = mAccountant.CurrencyMgr.FormatPercent(ProfitMargin);
                    }

                    if (fn == FieldName.UnitsSold && DisplayUnitsSold)
                    {
                        double UnitsSold = 0;
                        foreach (ItemSalesHistory history in itemSalesHistories)
                        {
                            UnitsSold += history.UnitsSold;
                        }
                        row["Units Sold"] = UnitsSold;
                    }
                    if (fn == FieldName.AverageCost && DisplayAverageCost)
                    {
                        row["Average Cost"] = mAccountant.CurrencyMgr.Format(item.PositiveAverageCost);
                    }
                }

                TotalSaleAmount        += SaleAmount;
                TotalProfitMargin      += ProfitMargin;
                TotalGrossProfit       += GrossProfit;
                TotalCostOfSalesAmount += CostOfSalesAmount;

                table.Rows.Add(row);
            }

            int itemCount = items.Count;

            row = table.NewRow();
            if (DisplaySaleAmount)
            {
                row["Sales"] = mAccountant.CurrencyMgr.Format(TotalSaleAmount / itemCount);
            }
            if (DisplayCostOfSalesAmount)
            {
                row["Cost of Sales"] = mAccountant.CurrencyMgr.Format(TotalCostOfSalesAmount / itemCount);
            }
            if (DisplayProfitMargin)
            {
                row["%Margin"] = mAccountant.CurrencyMgr.FormatPercent(TotalProfitMargin / itemCount);
            }
            if (DisplayGrossProfit)
            {
                row["Gross Profit"] = mAccountant.CurrencyMgr.Format(TotalGrossProfit / itemCount);
            }
            table.Rows.Add(row);

            return(table);
        }
Esempio n. 10
0
 private static extern int GetIntField(IntPtr tiff, FieldName fieldName, ref UInt16 fieldValue);
Esempio n. 11
0
 private static extern void SetIntField(IntPtr tiff, FieldName fieldName, int fieldValue);
Esempio n. 12
0
 /// <summary>
 /// Creates a <see cref="MissingFieldExpression"/> that represents a missing field.
 /// </summary>
 /// <param name="fieldName">The field name.</param>
 /// <param name="componentIndex">The component index.</param>
 /// <returns>A <see cref="MissingFieldExpression"/> that represents a missing field.</returns>
 public static MissingFieldExpression Missing(FieldName fieldName, int?componentIndex)
 {
     return(new MissingFieldExpression(fieldName, componentIndex));
 }
Esempio n. 13
0
 /// <summary>
 /// Creates a <see cref="StringExpression"/> that represents ends with operation.
 /// </summary>
 /// <param name="fieldName">The field name.</param>
 /// <param name="componentIndex">The component index.</param>
 /// <param name="value">The value.</param>
 /// <param name="ignoreCase">A flag indicating whether it's case and accent sensitive or not.</param>
 /// <returns>A <see cref="StringExpression"/> that represents ends with operation.</returns>
 public static StringExpression EndsWith(FieldName fieldName, int?componentIndex, string value, bool ignoreCase)
 {
     return(new StringExpression(StringOperator.EndsWith, fieldName, componentIndex, value, ignoreCase));
 }
Esempio n. 14
0
        public Queue<decimal> WarmUp(string symbol, FieldName fn)
        {
            Queue<decimal> q;
            int symbolN = Array.IndexOf(symbols, symbol);

            if (fn == FieldName.downwardRuns) q = new Queue<decimal>(_downwardRuns[symbolN]);
            else q = new Queue<decimal>(_upwardRuns[symbolN]);
            return q;
        }
Esempio n. 15
0
 public static BinaryExpression GreaterThan(FieldName fieldName, int?componentIndex, object value)
 {
     return(new BinaryExpression(BinaryOperator.GreaterThan, fieldName, componentIndex, value));
 }
Esempio n. 16
0
            /// <summary>
            /// Given the object value runs the accessors in the field name (if any) against the object.
            /// </summary>
            private object DoAccessors(FieldName fieldName, object argValue) {
                foreach (FieldAccessor accessor in fieldName.Accessors) {
                    // then do any accesses against the object
                    int intVal;
                    if (accessor.IsField) {
                        argValue = PythonOps.GetBoundAttr(
                            _context.SharedContext,
                            argValue,
                            SymbolTable.StringToId(accessor.AttributeName)
                        );
                    } else if (Int32.TryParse(accessor.AttributeName, out intVal)) {
                        argValue = PythonOps.GetIndex(
                            _context.SharedContext,
                            argValue,
                            ScriptingRuntimeHelpers.Int32ToObject(intVal)
                        );
                    } else {
                        argValue = PythonOps.GetIndex(
                            _context.SharedContext,
                            argValue,
                            accessor.AttributeName
                        );
                    }
                }

                return argValue;
            }
Esempio n. 17
0
            /// <summary>
            /// Gets the initial object represented by the field name - e.g. the 0 or
            /// keyword name.
            /// </summary>
            private object GetUnaccessedObject(FieldName fieldName) {
                int argIndex;
                object argValue;

                // get the object
                if (Int32.TryParse(fieldName.ArgumentName, out argIndex)) {
                    argValue = _args[argIndex];
                } else {
                    argValue = _kwArgs[SymbolTable.StringToId(fieldName.ArgumentName)];
                }

                return argValue;
            }
Esempio n. 18
0
 /// <summary>
 /// Given the field name gets the object from our arguments running
 /// any of the member/index accessors.
 /// </summary>
 private object GetArgumentValue(FieldName fieldName) {
     return DoAccessors(fieldName, GetUnaccessedObject(fieldName));
 }
Esempio n. 19
0
    public IEnumerable<ElementNode> GetExpansion(StateNode state, Model.Element elt)
    {
      List<ElementNode> result = new List<ElementNode>();

      if (elt.Kind != Model.ElementKind.Uninterpreted)
        return result;

      // Perhaps elt is a known datatype value
      Model.FuncTuple fnTuple;
      if (DatatypeValues.TryGetValue(elt, out fnTuple)) {
        // elt is a datatype value
        int i = 0;
        foreach (var arg in fnTuple.Args) {
          var edgname = new EdgeName(this, i.ToString());
          result.Add(new FieldNode(state, edgname, arg));
          i++;
        }
        return result;
      }

      // Perhaps elt is a sequence
      var seqLen = f_seq_length.AppWithArg(0, elt);
      if (seqLen != null) {
        // elt is a sequence
        foreach (var tpl in f_seq_index.AppsWithArg(0, elt)) {
          var edgname = new EdgeName(this, "[%0]", tpl.Args[1]);
          result.Add(new FieldNode(state, edgname, Unbox(tpl.Result)));
        }
        return result;
      }

      // Perhaps elt is a set
      foreach (var tpl in f_set_select.AppsWithArg(0, elt)) {
        var setElement = tpl.Args[1];
        var containment = tpl.Result;
        var edgname = new EdgeName(this, "[%0]", Unbox(setElement));
        result.Add(new FieldNode(state, edgname, containment));
      }
      if (result.Count != 0)
        return result;  // elt is a set

      // It seems elt is an object or array
      Model.Element[] lengths;
      if (ArrayLengths.TryGetValue(elt, out lengths)) {
        int i = 0;
        foreach (var len in lengths) {
          var name = lengths.Length == 1 ? "Length" : "Length" + i;
          var edgname = new EdgeName(this, name);
          result.Add(new FieldNode(state, edgname, len));
          i++;
        }
      }
      var heap = state.State.TryGet("$Heap");
      if (heap != null) {
        foreach (var tpl in f_heap_select.AppsWithArgs(0, heap, 1, elt)) {
          var field = new FieldName(tpl.Args[2], this);
          if (field.NameFormat != "alloc") {
            var edgname = new EdgeName(this, field.NameFormat, field.NameArgs);
            result.Add(new FieldNode(state, edgname, Unbox(tpl.Result)));
          }
        }
      }
      return result;
    }
Esempio n. 20
0
            /// <summary>
            /// Gets the initial object represented by the field name - e.g. the 0 or
            /// keyword name.
            /// </summary>
            private object GetUnaccessedObject(FieldName fieldName) {
                int argIndex;
                object argValue;

                // get the object
                if (fieldName.ArgumentName.Length == 0) {
                    // auto-numbering of format specifiers
                    if (_autoNumberedIndex == -1) {
                        throw PythonOps.ValueError("cannot switch from manual field specification to automatic field numbering");
                    }
                    argValue = _args[_autoNumberedIndex++];
                } else if (Int32.TryParse(fieldName.ArgumentName, out argIndex)) {
                    if (_autoNumberedIndex > 0) {
                        throw PythonOps.ValueError("cannot switch from automatic field numbering to manual field specification");
                    }
                    _autoNumberedIndex = -1;
                    argValue = _args[argIndex];
                } else {
                    argValue = _kwArgs[fieldName.ArgumentName];
                }

                return argValue;
            }
Esempio n. 21
0
 public RuntimeIshtarField(VeinClass owner, FieldName fullName, FieldFlags flags, VeinClass fieldType) :
     base(owner, fullName, flags, fieldType)
 {
 }
Esempio n. 22
0
        /// <summary>
        /// Get the number of a field.
        /// </summary>
        /// <param name="fieldName">The name of the field.</param>
        /// <returns>The number of the field or -1 if the field name is undefined.</returns>
        public static int GetField(FieldName fieldName)
        {
            if (parserParameters == null)
                return (-1);

            foreach (ParserParameter parserParameter in parserParameters)
            {
                if (parserParameter.FieldName == fieldName)
                    return (parserParameter.FieldNumber);
            }

            return (-1);
        }
Esempio n. 23
0
 public static BinaryExpression LessThanOrEqual(FieldName fieldName, int?componentIndex, object value)
 {
     return(new BinaryExpression(BinaryOperator.LessThanOrEqual, fieldName, componentIndex, value));
 }
Esempio n. 24
0
 internal int?GetArgumentIndex(FieldName @ref)
 => getArg(@ref)?.idx;
Esempio n. 25
0
 /// <summary>
 /// Creates a <see cref="StringExpression"/> that represents not contains operation.
 /// </summary>
 /// <param name="fieldName">The field name.</param>
 /// <param name="componentIndex">The component index.</param>
 /// <param name="value">The value.</param>
 /// <param name="ignoreCase">A flag indicating whether it's case and accent sensitive or not.</param>
 /// <returns>A <see cref="StringExpression"/> that represents not contains operation.</returns>
 public static StringExpression NotContains(FieldName fieldName, int?componentIndex, string value, bool ignoreCase)
 {
     return(new StringExpression(StringOperator.NotContains, fieldName, componentIndex, value, ignoreCase));
 }
Esempio n. 26
0
 internal int?GetLocalIndex(FieldName @ref)
 => getLocal(@ref)?.idx;
Esempio n. 27
0
 /// <summary>
 /// Given the field name gets the object from our arguments running
 /// any of the member/index accessors.
 /// </summary>
 private object GetArgumentValue(FieldName fieldName)
 {
     return(DoAccessors(fieldName, GetUnaccessedObject(fieldName)));
 }
Esempio n. 28
0
 private (int idx, VeinArgumentRef arg)? getLocal(FieldName @ref)
 {
     var(key, value) = Locals
                       .FirstOrDefault(x
                                       => x.Value.Name.Equals(@ref.Name, StringComparison.CurrentCultureIgnoreCase));
     return(value != null ? (key, value) : default);
Esempio n. 29
0
 private static extern void SetFloatField(IntPtr tiff, FieldName fieldName, double fieldValue);
        private string this[FieldName index]
        {
            get
            {
                switch (index)
                {
                case FieldName.ActionTime:
                    return(this.ActionTime.ToString());

                case FieldName.ActionType:
                    return(this.ActionType.ToString());

                case FieldName.FullPath:
                    return(this.FullPath);

                case FieldName.LastWriteTime:
                    return(this.LastWriteTime.ToString());

                case FieldName.StorageName:
                    return(this.StorageName);

                case FieldName.Comment:
                    return(this.Comment);

                default:
                    throw new IndexOutOfRangeException();
                }
            }

            set
            {
                if (!Parsers.ContainsKey(index))
                {
                    throw new NotImplementedException($"Can't find out parser for field '{index.ToString()}'.");
                }

                var  parser = Parsers[index];
                bool isOK   = false;

                var result = parser?.Invoke(value, out isOK);
                if (!isOK)
                {
                    this.ParseIsValid = false;
                    return;
                }

                switch (index)
                {
                case FieldName.ActionTime:
                    this.ActionTime = (long)result;
                    break;

                case FieldName.ActionType:
                    this.ActionType = (ActionType)result;
                    break;

                case FieldName.FullPath:
                    this.FullPath = (string)result;
                    break;

                case FieldName.LastWriteTime:
                    this.LastWriteTime = (long)result;
                    break;

                case FieldName.StorageName:
                    this.StorageName = (string)result;
                    break;

                case FieldName.Comment:
                    this.Comment = (string)result;
                    break;

                default:
                    throw new IndexOutOfRangeException();
                }

                this.ParseIsValid = true;
            }
        }
Esempio n. 31
0
 public bool IsKey()
 {
     return(FieldName.ToLower().Equals("objectname") ||
            FieldName.ToLower().Equals("timestamp"));
 }
Esempio n. 32
0
 public override int GetHashCode()
 {
     return(FieldName.GetHashCode() * 37 + DeclaringType.GetHashCode());
 }
Esempio n. 33
0
     : SnippetFieldPart(FieldName, DefaultText, EditIndex)
 {
Esempio n. 34
0
        public void GivenADateWithComparatorOfSingleBinaryOperator_WhenBuilt_ThenCorrectExpressionShouldBeCreated(string prefix, string dateTimeInput, FieldName fieldName, BinaryOperator binaryOperator, bool expectStartTimeValue)
        {
            var partialDateTime     = PartialDateTime.Parse(dateTimeInput);
            var dateTimeSearchValue = new DateTimeSearchValue(partialDateTime);

            Validate(
                CreateSearchParameter(SearchParamType.Date),
                null,
                prefix + dateTimeInput,
                e => ValidateDateTimeBinaryOperatorExpression(
                    e,
                    fieldName,
                    binaryOperator,
                    expectStartTimeValue ? dateTimeSearchValue.Start : dateTimeSearchValue.End));
        }
Esempio n. 35
0
 public override int GetHashCode()
 {
     return(FieldName.ToLower().GetHashCode());
 }
Esempio n. 36
0
        protected static SearchParameterQueryGeneratorContext VisitMissingFieldImpl(MissingFieldExpression expression, SearchParameterQueryGeneratorContext context, FieldName expectedFieldName, Column column)
        {
            if (expression.FieldName != expectedFieldName)
            {
                throw new InvalidOperationException($"Unexpected missing field {expression.FieldName}");
            }

            AppendColumnName(context, column, expression).Append(" IS NULL");
            return(context);
        }
Esempio n. 37
0
        /// <summary>
        /// Deserializes an object from a binary source.
        /// </summary>
        /// <param name="Reader">Binary deserializer.</param>
        /// <param name="DataType">Optional datatype. If not provided, will be read from the binary source.</param>
        /// <param name="Embedded">If the object is embedded into another.</param>
        /// <returns>Deserialized object.</returns>
        public override object Deserialize(IBsonReader Reader, BsonType?DataType, bool Embedded)
        {
            BsonReaderBookmark Bookmark    = Reader.GetBookmark();
            BsonType?          DataTypeBak = DataType;

            if (!DataType.HasValue)
            {
                DataType = Reader.ReadBsonType();
            }

            switch (DataType.Value)
            {
            case BsonType.Document:
                break;

            case BsonType.Boolean:
                return(Reader.ReadBoolean());

            case BsonType.Int32:
                return(Reader.ReadInt32());

            case BsonType.Int64:
                return(Reader.ReadInt64());

            case BsonType.Decimal128:
                return((decimal)Reader.ReadDecimal128());

            case BsonType.Double:
                return(Reader.ReadDouble());

            case BsonType.DateTime:
                return(ObjectSerializer.UnixEpoch.AddMilliseconds(Reader.ReadDateTime()));

            case BsonType.String:
            case BsonType.Symbol:
            case BsonType.JavaScript:
            case BsonType.JavaScriptWithScope:
                return(Reader.ReadString());

            case BsonType.Binary:
                return(Reader.ReadBytes());

            case BsonType.Null:
                Reader.ReadNull();
                return(null);

            default:
                throw new Exception("Object or value expected.");
            }

            LinkedList <KeyValuePair <string, object> > Properties = new LinkedList <KeyValuePair <string, object> >();
            LinkedList <KeyValuePair <string, object> > LowerCase  = null;
            string   TypeName       = string.Empty;
            Guid     ObjectId       = Guid.Empty;
            string   CollectionName = string.Empty;
            string   FieldName;
            BsonType ValueType;
            object   Value;

            Reader.ReadStartDocument();

            while (Reader.State == BsonReaderState.Type)
            {
                ValueType = Reader.ReadBsonType();
                if (ValueType == BsonType.EndOfDocument)
                {
                    break;
                }

                FieldName = Reader.ReadName();

                switch (ValueType)
                {
                case BsonType.Array:
                    Value = GeneratedObjectSerializerBase.ReadArray(null, this.Provider, Reader, ValueType);
                    break;

                case BsonType.Binary:
                    Value = Reader.ReadBytes();
                    break;

                case BsonType.Boolean:
                    Value = Reader.ReadBoolean();
                    break;

                case BsonType.DateTime:
                    Value = ObjectSerializer.UnixEpoch.AddMilliseconds(Reader.ReadDateTime());
                    break;

                case BsonType.Decimal128:
                    Value = (decimal)Reader.ReadDecimal128();
                    break;

                case BsonType.Document:
                    Value = this.Deserialize(Reader, ValueType, true);
                    break;

                case BsonType.Double:
                    Value = Reader.ReadDouble();
                    break;

                case BsonType.Int32:
                    Value = Reader.ReadInt32();
                    break;

                case BsonType.Int64:
                    Value = Reader.ReadInt64();
                    break;

                case BsonType.JavaScript:
                    Value = Reader.ReadJavaScript();
                    break;

                case BsonType.JavaScriptWithScope:
                    Value = Reader.ReadJavaScriptWithScope();
                    break;

                case BsonType.Null:
                    Value = null;
                    Reader.ReadNull();
                    break;

                case BsonType.ObjectId:
                    Value = Reader.ReadObjectId();
                    break;

                case BsonType.String:
                    Value = Reader.ReadString();
                    break;

                case BsonType.Symbol:
                    Value = Reader.ReadSymbol();
                    break;

                default:
                    throw new Exception("Unrecognized data type: " + ValueType.ToString());
                }

                switch (FieldName)
                {
                case "_id":
                    if (Value is Guid Guid)
                    {
                        ObjectId = Guid;
                    }
                    else if (Value is string s)
                    {
                        ObjectId = new Guid(s);
                    }
                    else if (Value is byte[] A)
                    {
                        ObjectId = new Guid(A);
                    }
                    else if (Value is ObjectId ObjId)
                    {
                        ObjectId = GeneratedObjectSerializerBase.ObjectIdToGuid(ObjId);
                    }
                    else
                    {
                        throw new Exception("Unrecognized Object ID type: " + Value.GetType().FullName);
                    }
                    break;

                case "_type":
                    TypeName = Value?.ToString();

                    if (this.returnTypedObjects && !string.IsNullOrEmpty(TypeName))
                    {
                        Type DesiredType = Types.GetType(TypeName);
                        if (DesiredType is null)
                        {
                            DesiredType = typeof(GenericObject);
                        }

                        if (DesiredType != typeof(GenericObject))
                        {
                            IObjectSerializer Serializer2 = this.provider.GetObjectSerializer(DesiredType);
                            Reader.ReturnToBookmark(Bookmark);
                            return(Serializer2.Deserialize(Reader, DataTypeBak, Embedded));
                        }
                    }
                    break;

                case "_collection":
                    CollectionName = Value?.ToString();
                    break;

                default:
                    if (FieldName.EndsWith("_L"))
                    {
                        string s      = FieldName.Substring(0, FieldName.Length - 2);
                        bool   Ignore = false;

                        foreach (KeyValuePair <string, object> P in Properties)
                        {
                            if (P.Key == s)
                            {
                                Ignore = true;
                                break;
                            }
                        }

                        if (!Ignore)
                        {
                            if (LowerCase is null)
                            {
                                LowerCase = new LinkedList <KeyValuePair <string, object> >();
                            }

                            LowerCase.AddLast(new KeyValuePair <string, object>(s, Value));
                        }
                    }
                    else
                    {
                        Properties.AddLast(new KeyValuePair <string, object>(FieldName, Value));
                    }
                    break;
                }
            }

            if (!(LowerCase is null))
            {
                foreach (KeyValuePair <string, object> P in LowerCase)
                {
                    bool Ignore = false;

                    foreach (KeyValuePair <string, object> P2 in Properties)
                    {
                        if (P2.Key == P.Key)
                        {
                            Ignore = true;
                            break;
                        }
                    }

                    if (!Ignore)
                    {
                        Properties.AddLast(new KeyValuePair <string, object>(P.Key + "_L", P.Value));
                    }
                }
            }

            Reader.ReadEndDocument();

            return(new GenericObject(CollectionName, TypeName, ObjectId, Properties));
        }
Esempio n. 38
0
 protected override IEnumerable <Command> OnDrop(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context)
 {
     yield return(new Command()
                  .Append($"DROP DOMAIN {FieldName.AsSqlIndentifier()}"));
 }
Esempio n. 39
0
 /// <summary>
 /// Obtains an instance used to obtain an observable value of the index,
 /// specifying the source of observable market data.
 /// </summary>
 /// <param name="index">  the index </param>
 /// <param name="fieldName">  the name of the field in the market data record holding the data </param>
 /// <param name="obsSource">  the source of observable market data </param>
 /// <returns> the identifier </returns>
 public static IndexQuoteId of(Index index, FieldName fieldName, ObservableSource obsSource)
 {
     return(new IndexQuoteId(index, fieldName, obsSource));
 }
Esempio n. 40
0
        public virtual int UpdateData(IEnumerable <T> valueList, params string[] FieldName)
        {
            if (valueList.Count <T>() == 0)
            {
                return(0);
            }
            PropertyInfo[]        properties = typeof(T).GetProperties();
            StringBuilder         builder    = new StringBuilder();
            int                   num        = 0;
            List <MySqlParameter> objList    = new List <MySqlParameter>();

            foreach (T local in valueList)
            {
                builder.Append("UPDATE " + this.Dal.TableName + " SET ");
                string       str  = "";
                PropertyInfo info = null;
                foreach (PropertyInfo info2 in properties)
                {
                    if (info2.Name.ToLower() != this.Dal.PrimaryKeyName.ToLower())
                    {
                        if ((info2.Name.ToLower() != "_id") && ((FieldName.Length == 0) || FieldName.Contains <string>(info2.Name)))
                        {
                            str = str + string.Format("{0}=?{1},", info2.Name, info2.Name + num);
                            objList.Add(new MySqlParameter("?" + info2.Name + num, info2.GetValue(local, null)));
                            num++;
                        }
                    }
                    else
                    {
                        info = info2;
                    }
                }
                builder.Append(str.TrimEndComma());
                builder.AppendFormat(" WHERE {0}=?{1};", this.Dal.PrimaryKeyName, this.Dal.PrimaryKeyName + num);
                objList.Add(new MySqlParameter("?" + this.Dal.PrimaryKeyName + num, info.GetValue(local, null)));
                num++;
            }
            return(this.Dal.ExecuteNonQuery(builder.ToString(), objList.ConvertListToArray <MySqlParameter>()));
        }