Beispiel #1
0
        public async Task ReadAsync_RoundTripsBytes_Generic()
        {
            const string tableName = "BytesType";

            ResetDatabase(tableName);

            var store = new MobileServiceSQLiteStore(TestDbName);

            store.DefineTable <BytesType>();

            var hijack = new TestHttpHandler();
            IMobileServiceClient service = await CreateClient(hijack, store);

            IMobileServiceSyncTable <BytesType> table = service.GetSyncTable <BytesType>();

            byte[] theData = { 0, 128, 255 };

            BytesType inserted = new BytesType {
                Data = theData
            };

            await table.InsertAsync(inserted);

            Assert.Equal(inserted.Data, theData);

            BytesType rehydrated = await table.LookupAsync(inserted.Id);

            Assert.Equal(rehydrated.Data, theData);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="columnFamily"></param>
        /// <param name="columns"></param>
        internal FluentSuperColumnFamily(BytesType key, string columnFamily, IEnumerable <IFluentSuperColumn <CompareWith, CompareSubcolumnWith> > columns)
        {
            Key        = key;
            FamilyName = columnFamily;

            _columns = new FluentColumnList <IFluentSuperColumn <CompareWith, CompareSubcolumnWith> >(GetSelf(), columns);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="columnFamily"></param>
        public FluentSuperColumnFamily(BytesType key, string columnFamily)
        {
            Key        = key;
            FamilyName = columnFamily;

            _columns = new FluentColumnList <IFluentSuperColumn <CompareWith, CompareSubcolumnWith> >(GetSelf());
        }
 public CassandraKeyRange(BytesType startKey, BytesType endKey, string startToken, string endToken, int count)
 {
     StartKey = startKey;
     EndKey = endKey;
     StartToken = startToken;
     EndToken = endToken;
     Count = count;
 }
Beispiel #5
0
 public CassandraKeyRange(BytesType startKey, BytesType endKey, string startToken, string endToken, int count)
 {
     StartKey   = startKey;
     EndKey     = endKey;
     StartToken = startToken;
     EndToken   = endToken;
     Count      = count;
 }
Beispiel #6
0
 public InsertColumn(BytesType key, CassandraType name, BytesType value, DateTimeOffset timestamp, int timeToLive)
 {
     Key         = key;
     ColumnName  = name;
     ColumnValue = value;
     Timestamp   = timestamp;
     TimeToLive  = timeToLive;
 }
Beispiel #7
0
        public void BytesTest()
        {
            var bytes = "000000000000000000000000000000000000000000000000000000000000002e516d5074633431505661375945585a7359524448586a6332525753474c47794b396774787a524e6543354b4e5641000000000000000000000000000000000000";

            var bytesType = new BytesType();
            var bytesArray = bytes.HexToByteArray();
            var decoded = (byte[])bytesType.Decode(bytesArray, typeof(byte[]));
            var stringValue = (string)bytesType.Decode(bytesArray, typeof(string));
        }
        public void Implicit_Double_Cast()
        {
            // arrange
            double expected = 100.0001D;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (double)actual);
        }
        public void Implicit_String_Cast()
        {
            // arrange
            string expected = "The quick brown fox jumps over the lazy dog.";

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (string)actual);
        }
        public void Implicit_Char_Cast()
        {
            // arrange
            char expected = 'x';

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (char)actual);
        }
        public void Implicit_Boolean_False_Cast()
        {
            // arrange
            bool expected = false;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (bool)actual);
        }
        public void Implicit_SByte_Cast()
        {
            // arrange
            sbyte expected = 100;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (sbyte)actual);
        }
Beispiel #13
0
        public void BytesTest()
        {
            var original = "0x000000000000000000000000223aea5cf8c5a21859171edb2d01d2ceab0336780000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e516d5074633431505661375945585a7359524448586a6332525753474c47794b396774787a524e6543354b4e5641000000000000000000000000000000000000";

            var bytes = "000000000000000000000000000000000000000000000000000000000000002e516d5074633431505661375945585a7359524448586a6332525753474c47794b396774787a524e6543354b4e5641000000000000000000000000000000000000";

            var bytesType   = new BytesType();
            var bytesArray  = bytes.HexToByteArray();
            var decoded     = (byte[])bytesType.Decode(bytesArray, typeof(byte[]));
            var stringValue = (string)bytesType.Decode(bytesArray, typeof(string));
        }
        public void Implicit_DateTimeOffset_Cast()
        {
            // arrange
            DateTimeOffset expected = DateTimeOffset.Now;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (DateTimeOffset)actual);
        }
        public void Implicit_Decimal_Cast()
        {
            // arrange
            decimal expected = 100.0001M;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (decimal)actual);
        }
        public void Implicit_Int64_Cast()
        {
            // arrange
            long expected = 100;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (long)actual);
        }
        public void Implicit_Single_Cast()
        {
            // arrange
            float expected = 100.0001F;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (float)actual);
        }
        public void Implicit_Int16_Cast()
        {
            // arrange
            short expected = 100;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (short)actual);
        }
        public void Implicit_Guid_Cast()
        {
            // arrange
            Guid expected = new Guid("38400000-8cf0-11bd-b23e-10b96e4ef00d");

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (Guid)actual);
        }
        public void Implicit_Int32_Cast()
        {
            // arrange
            int expected = 100;

            // act
            BytesType actual = expected;

            // assert
            Assert.AreEqual(expected, (int)actual);
        }
        public void Operator_NotEqualTo()
        {
            // arrange
            long      value = 100L;
            BytesType type  = value;

            // act
            bool actual = type != value;

            // assert
            Assert.IsFalse(actual);
        }
        public void Implicit_ByteArray_Cast()
        {
            // arrange
            byte[] expected = new byte[] { 0, 32, 0, 16, 0, 0, 64, 128 };

            // act
            BytesType actualType = expected;

            byte[] actual = actualType;

            // assert
            Assert.IsTrue(expected.SequenceEqual(actual));
        }
        public void CassandraType_Cast()
        {
            // arranage
            byte[]    expected   = new byte[] { 0, 32, 0, 16, 0, 0, 64, 128 };
            BytesType actualType = expected;

            // act
            CassandraType actualCassandraType = actualType;

            byte[] actual = actualCassandraType;

            // assert
            Assert.IsTrue(expected.SequenceEqual(actual));
        }
        public void Implicit_ByteArray_Cast()
        {
            // arrange
            string value = "The quick brown fox jumps over the lazy dog.";

            byte[] expected = Encoding.UTF8.GetBytes(value);

            // act
            BytesType actualType = expected;

            byte[] actual = actualType;

            // assert
            Assert.IsTrue(expected.SequenceEqual(actual));
        }
Beispiel #25
0
 public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value)
 {
     InsertColumn(family, key, superColumnName, name, value, DateTimePrecise.UtcNow, null);
 }
 public RemoveKey(BytesType key)
 {
     Key = key;
 }
 public static void AddBytes(this CompositeType type, BytesType value)
 {
     type.Add(value);
 }
 public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue)
 {
     InsertColumn(family, key, columnName, columnValue, DateTimePrecise.UtcNow, null);
 }
 public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue)
 {
     InsertColumn(family, key, columnName, columnValue, TimestampHelper.UtcNow(), null);
 }
 public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value)
 {
     InsertColumn(family, key, superColumnName, name, value, DateTimeOffset.UtcNow, null);
 }
        public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue, DateTimeOffset timestamp, int?timeToLive)
        {
            var op = new InsertColumn(key, columnName, columnValue, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
 public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue)
 {
     InsertColumn(family, key, columnName, columnValue, TimestampHelper.UtcNow(), null);
 }
		public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value)
		{
			InsertColumn(family, key, superColumnName, name, value, TimestampHelper.UtcNow(), null);
		}
Beispiel #34
0
 public GetColumnFamilySlice(BytesType key, CassandraSlicePredicate columnSlicePredicate)
 {
     Key            = key;
     SlicePredicate = columnSlicePredicate;
 }
Beispiel #35
0
 public GetSuperColumnSlice(BytesType key, CassandraType superColumnName, CassandraSlicePredicate columnSlicePredicate)
 {
     Key             = key;
     SuperColumnName = superColumnName;
     SlicePredicate  = columnSlicePredicate;
 }
		public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value, DateTimeOffset timestamp, int? timeToLive)
		{
			var op = new InsertColumn(key, superColumnName, name, value, timestamp, timeToLive);
			family.ExecuteOperation(op);
		}
    public static IEnumerable <Finding> InspectFile(string projectId, string filePath, BytesType fileType)
    {
        // Instantiate a client.
        var dlp = DlpServiceClient.Create();

        // Get the bytes from the file.
        ByteString fileBytes;

        using (Stream f = new FileStream(filePath, FileMode.Open))
        {
            fileBytes = ByteString.FromStream(f);
        }

        // Construct a request.
        var request = new InspectContentRequest
        {
            Parent = new LocationName(projectId, "global").ToString(),
            Item   = new ContentItem
            {
                ByteItem = new ByteContentItem()
                {
                    Data = fileBytes,
                    Type = fileType
                }
            },
            InspectConfig = new InspectConfig
            {
                // The info types of information to match
                InfoTypes =
                {
                    new InfoType {
                        Name = "PHONE_NUMBER"
                    },
                    new InfoType {
                        Name = "EMAIL_ADDRESS"
                    },
                    new InfoType {
                        Name = "CREDIT_CARD_NUMBER"
                    }
                },
                // The minimum likelihood before returning a match
                MinLikelihood = Likelihood.Unspecified,
                // Whether to include the matching string
                IncludeQuote = true,
                Limits       = new InspectConfig.Types.FindingLimits
                {
                    // The maximum number of findings to report per request
                    // (0 = server maximum)
                    MaxFindingsPerRequest = 0
                }
            }
        };

        // Execute request
        var response = dlp.InspectContent(request);

        // Inspect response
        var findings = response.Result.Findings;

        if (findings.Any())
        {
            Console.WriteLine("Findings:");
            foreach (var finding in findings)
            {
                Console.WriteLine($"Quote: {finding.Quote}");
                Console.WriteLine($"InfoType: {finding.InfoType}");
                Console.WriteLine($"Likelihood: {finding.Likelihood}");
            }
        }
        else
        {
            Console.WriteLine("No findings.");
        }
        return(findings);
    }