示例#1
0
        public void testInitialize()
        {
            _goPro   = new GoProDuskWhite();
            _storage = new GenericStorage();

            _service = new TakePicture(_goPro, _storage);
        }
示例#2
0
        public void GenericMethodInStaticProtoTest()
        {
            GenericStorage<int>.StaticPrototype.SetMeAnd2Objects_2<string,int>((x, y, z) => { return "test"; });
            GenericStorage<int> test = new GenericStorage<int>(10);

            Assert.That(test.MeAnd2Objects<string, int>(10, "a") == "test");
        }
示例#3
0
 public void GemericMethodsTest()
 {
     GenericStorage<int> a = new GenericStorage<int>(5);
     a.GenericStorage_1Prototype.SetMeAnd2Objects_2<int, int>((x, y, z) =>
                                                              	{ return "Hi, together we are "+(x.Data + y + z).ToString(); });
     Assert.That(a.MeAnd2Objects<int, int>(10, 20) == "Hi, together we are 35");
 }
示例#4
0
 public CachedStorage(IServiceProvider services, CachedStorageOptions options, IRedisClient redis, ILogger <CachedStorage> logger, RecyclableMemoryStreamManager memory)
 {
     _impl    = new GenericStorage(services, options.Inner);
     _options = options;
     _redis   = redis;
     _logger  = logger;
     _memory  = memory;
 }
示例#5
0
        private void CalculateMovements()
        {
            GenericStorage <double> wqueue = Const.OpcDatasource.WalkingQueue_Plc, yqueue = Const.OpcDatasource.YawQueue_Plc;

            //Const.OpcDatasource.WalkingSpeed_Plc = wqueue == null ? 0 : Math.Round(wqueue.ElementAt(2) - wqueue.ElementAt(1), 3);
            Const.OpcDatasource.WalkingAcce_Plc = wqueue == null ? 0 : Math.Round(wqueue.ElementAt(0) - 2 * wqueue.ElementAt(1) + wqueue.ElementAt(2), 3);
            //Const.OpcDatasource.YawSpeed_Plc = yqueue == null ? 0 : Math.Round(yqueue.ElementAt(1) - yqueue.ElementAt(0), 3);
        }
 /// <summary>
 /// 构造器
 /// </summary>
 public OpcDataSource()
 {
     PlcReadable      = true;
     PlcWritable      = true;
     WalkingQueue_Plc = new GenericStorage <double>(3);
     YawQueue_Plc     = new GenericStorage <double>(2);
     WalkingQueue_Plc.FillEmptyShells();
     YawQueue_Plc.FillEmptyShells();
 }
示例#7
0
        public void InstancePrototypeCallTest()
        {
            GenericStorage<string> a = new GenericStorage<string>("test_failed");
            a.GenericStorage_1Prototype.get_Data = (self) => "test_completed";
            Assert.That(a.Data == "test_completed");

            GenericStorage<int> b = new GenericStorage<int>(10);
            GenericStorage<int>.StaticPrototype.IntroduceItselfStatic = () => "static_test_completed";
            Assert.That(GenericStorage<int>.IntroduceItselfStatic() == "static_test_completed");
        }
示例#8
0
 public void CtorTest()
 {
     GenericStorage<string>.StaticPrototype.Ctor_T = (self, value) =>
                                                         {
                                                             self.Info = "cerated_by_test";
                                                             self.xCtor(value);
                                                         };
     var a = new GenericStorage<string>("abc");
     Assert.That(a.Info == "cerated_by_test");
     Assert.That(a.Data == "abc");
 }
示例#9
0
        public void CrazyTest()
        {
            GenericStorage<GenericStorage<string>>.StaticPrototype.SetMeAnd2Objects_2<GenericStorage<bool>,GenericStorage<GenericStorage<int>>>(
                (x,y,z) => { return x.Data.Data.ToString() + y.Data.Data.ToString() + z.Data.ToString(); }
                );
            GenericStorage<GenericStorage<string>> a = new GenericStorage<GenericStorage<string>>(new GenericStorage<string>("Yes! I am string!"));

            var result =
                a.MeAnd2Objects<GenericStorage<bool>, GenericStorage<GenericStorage<int>>>(
                    new GenericStorage<GenericStorage<int>>(new GenericStorage<int>(2)), new GenericStorage<bool>(true));
            Assert.That(result == "Yes! I am string!2True");
        }
示例#10
0
		static bool TryGet(string key, out string value)
		{
			GenericStorage<string> emptyItem = new GenericStorage<string>(key);
			RelayClient.Instance.GetObject(emptyItem);
			if (emptyItem.DataSource == DataSource.Cache)
			{
				value = emptyItem.Payload;
				return true;
			}
			value = String.Empty;
			return false;
		}
示例#11
0
        static bool TryGet(string key, out string value)
        {
            GenericStorage <string> emptyItem = new GenericStorage <string>(key);

            RelayClient.Instance.GetObject(emptyItem);
            if (emptyItem.DataSource == DataSource.Cache)
            {
                value = emptyItem.Payload;
                return(true);
            }
            value = String.Empty;
            return(false);
        }
示例#12
0
        public async Task CreateAndReadSchemaAsync()
        {
            var personSchemaAsString =
                "  { \"title\": \"Person\" , \"type\": \"object\", \"eav-primary-key\":\"myid\", \"properties\": { \"myid\": { }, \"firstName\": { }, \"lastName\": { }, } } ";

            var personSchema = JObject.Parse(personSchemaAsString);
            var eav          = new EavMemoryStorage();
            var service      = new GenericStorage(eav);
            await service.Schema.CreateWithSpecifiedIdAsync((string)personSchema["title"], personSchema);

            var readSchema = await service.Schema.ReadAsync((string)personSchema["title"]);

            Assert.IsNotNull(readSchema);
            Assert.AreEqual(5, readSchema.Count);
        }
示例#13
0
        public async Task CreateAndReadSchemaAsync_WithAttributeType()
        {
            var personSchemaAsString =
                " { \"title\": \"Person\" , \"type\": \"object\", \"eav-primary-key\":\"myid\", \"properties\": { \"myid\": { \"type\": \"Guid\"}, \"firstName\": { \"type\": \"string\" }, \"lastName\": { \"type\": \"string\"  },  \"age\": { \"type\": \"number\"  } } } ";

            var personSchema = JObject.Parse(personSchemaAsString);

            var eav     = new EavMemoryStorage();
            var service = new GenericStorage(eav);
            await service.Schema.CreateWithSpecifiedIdAsync((string)personSchema["title"], personSchema);

            var personObjectAsString = " {\"firstName\" : \"Lars\", \"lastName\": \"Lindberg\" , \"age\": 47 } ";

            var personObject = JObject.Parse(personObjectAsString);
            var objectId     = await service.Object.CreateAsync((string)personSchema["title"], personObject);

            var readData = await service.Object.ReadAsync((string)personSchema["title"], objectId);

            Assert.IsNotNull(readData);
            Assert.AreEqual(3, readData.Count);
        }
示例#14
0
        public async Task CreateAndReadSchema_Withid()
        {
            var personSchemaAsString =
                " { \"$id\": \"https://example.com/person.schema.json \", " +
                " \"$schema\": \"http://json-schema.org/draft-07/schema# \", " +
                " \"title\": \"Person\" , " +
                " \"type\": \"object\", " +
                " \"eav-primary-key\":\"myid\",  " +
                " \"properties\": { \"myid\": { \"type\": \"Guid\"}, \"firstName\": { \"type\": \"string\" }, \"lastName\": { \"type\": \"string\"  },  \"age\": { \"type\": \"number\"  } } } ";

            var personSchema = JObject.Parse(personSchemaAsString);

            // Memory Storage
            var eav     = new EavMemoryStorage();
            var service = new GenericStorage(eav);
            await service.Schema.CreateWithSpecifiedIdAsync((string)personSchema["title"], personSchema);

            var readSchema = await service.Schema.ReadAsync((string)personSchema["title"]);

            Assert.IsNotNull(readSchema);
            Assert.AreEqual(6, readSchema.Count);
        }
示例#15
0
        public async Task CreateAndReadSchema_AttributeType_String()
        {
            var personSchemaAsString =
                " { \"title\": \"Person\" , \"type\": \"object\", \"eav-primary-key\":\"myid\", \"properties\": { \"myid\": { \"type\": \"Guid\"}, \"firstName\": { \"type\": \"string\" }, \"lastName\": { \"type\": \"string\"  },  \"age\": { \"type\": \"integer\"  } } } ";

            var personSchema = JObject.Parse(personSchemaAsString);

            var eav     = new EavMemoryStorage();
            var service = new GenericStorage(eav);
            await service.Schema.CreateWithSpecifiedIdAsync((string)personSchema["title"], personSchema);

            var readSchema = await service.Schema.ReadAsync((string)personSchema["title"]);

            Assert.IsNotNull(readSchema);
            Assert.AreEqual(5, readSchema.Count);
            int result = 0;

            // Looping the Properties schema
            var propertySchema = readSchema["properties"];

            Assert.IsNotNull(propertySchema);
            Assert.AreEqual(4, propertySchema.Count());

            foreach (var rSchema in propertySchema)
            {
                Assert.IsNotNull(rSchema);
                Assert.AreEqual(1, rSchema.Count());

                foreach (var attributeType in rSchema)
                {
                    if (attributeType["type"].ToString() == "string")
                    {
                        result = result + 1;
                    }
                }
            }
            Assert.AreEqual(2, result);
        }
示例#16
0
		static void Save(string key, string value)
		{
			GenericStorage<string> item = new GenericStorage<string>(key, value);
			RelayClient.Instance.SaveObject(item);
		}
示例#17
0
        static void Delete(string key)
        {
            GenericStorage <string> emptyItem = new GenericStorage <string>(key);

            RelayClient.Instance.DeleteObject(emptyItem);
        }
 public ContactsController(IMyDatabase myDatabase)
 {
     _myDatabase = myDatabase;
     _storage    = new GenericStorage();
 }
示例#19
0
        static void Save(string key, string value)
        {
            GenericStorage <string> item = new GenericStorage <string>(key, value);

            RelayClient.Instance.SaveObject(item);
        }
示例#20
0
 public void StaticPrototypeCallTest()
 {
     GenericStorage<int>.StaticPrototype.IntroduceItself = (self) => { return "test"; };
     GenericStorage<int> a = new GenericStorage<int>(10);
     Assert.That(a.IntroduceItself() == "test");
 }
示例#21
0
 public AgendaController()
 {
     _storage = new GenericStorage();
 }
 public TakePicture(GoProDuskWhite goPro, GenericStorage storage)
 {
     _goPro   = goPro;
     _storage = storage;
 }
示例#23
0
 public MoveRover(GenericStorage storage)
 {
     _storage = storage;
 }
示例#24
0
 public ContactsController()
 {
     _storage = new GenericStorage();
 }
示例#25
0
        public void testInitialize()
        {
            _storage = new GenericStorage();

            _service = new MoveRover(_storage);
        }
示例#26
0
 public void MicedGenericInGenericTest()
 {
     GenericStorage<GenericStorage<string>> a =
         new GenericStorage<GenericStorage<string>>(new GenericStorage<string>("Something to do here..."));
     a.Data.GenericStorage_1Prototype.get_Data = (self) => "nothing to do here!";
     Assert.That(a.Data.Data == "nothing to do here!");
 }
示例#27
0
        public void StaticAndDynamicProtoOverrideTest()
        {
            GenericStorage<int> test = new GenericStorage<int>();
            test.GenericStorage_1Prototype = new GenericStorage<int>.PrototypeClass();

            test.GenericStorage_1Prototype.SetMakeMeSome_2<int,string>((x, y, z) => { return 30; });
            GenericStorage<int>.StaticPrototype.SetMakeMeSome_2<int, string>((x, y, z) => { return 20; });

            Assert.That(test.MakeMeSome<int, string>("s", 10) == 30);
        }
 public CountryController()
 {
     _storage = new GenericStorage();
 }
示例#29
0
		static void Delete(string key)
		{
			GenericStorage<string> emptyItem = new GenericStorage<string>(key);
			RelayClient.Instance.DeleteObject(emptyItem);
		}
 public GenericStorageTests()
 {
     _storage = new GenericStorage <int, string>();
 }
示例#31
0
 public void SimplePrototypeCallTest()
 {
     GenericStorage<int> a = new GenericStorage<int>(10);
     string[] strs = {
                         a.IntroduceItself(),
                         a.IntroduceItself("Hello, i am"),
                         a.xIntroduceItself(),
                         a.xIntroduceItself("Hello, i am")
                     };
     Assert.That(strs.All(s => s == "Hello, i am System.Int32"));
 }
 public SensordatasController()
 {
     _storage = new GenericStorage();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public ProductsController()
 {
     _storage = new GenericStorage();
 }
示例#34
0
 public void GenericInGenericTest()
 {
     GenericStorage<List<int>> TestLists = new GenericStorage<List<int>>();
     TestLists.GenericStorage_1Prototype.get_Data = (self) => { return new List<int> { 1, 2, 3 }; };
     Assert.That(TestLists.Data.ToArray().All(e => e == TestLists.Data.IndexOf(e) + 1));
 }
 public SQLiteProductStorage(StorageContext context)
 {
     _productStorage      = new GenericStorage <ProductDto, StorageContext>(context);
     _productTypeStorage  = new GenericStorage <ProductTypeDto, StorageContext>(context);
     _productBrandStorage = new GenericStorage <ProductBrandDto, StorageContext>(context);
 }
 public SqlMapConfigProvider()
 {
     _sqlMapConfigs = new GenericStorage <string, SqlMapConfig>();
 }
示例#37
0
 public ContactsController()
 {
     _storage = new GenericStorage();
 }
示例#38
0
 public VideoGameController()
 {
     _storage = new GenericStorage();
 }