Пример #1
0
        public void GetAdapterTest()
        {
            IAdapterFactory factory = new AdapterFactory();

            IAdapter actualAdapter = factory.GetAdapter(nameof(PingAdapter));

            Assert.AreEqual(typeof(PingAdapter), actualAdapter.GetType());
        }
Пример #2
0
        public void GetAdapterTest_UnknownAdapter()
        {
            IAdapterFactory factory = new AdapterFactory();

            Assert.ThrowsException <InvalidOperationException>(() => {
                IAdapter actualAdapter = factory.GetAdapter("UnknownAdapter");
            });
        }
Пример #3
0
        public void TestAttributesAdapterType()
        {
            TestInit();
            //todo:fix connection mock
            IAdapter <Document> adapter = AdapterFactory <Document> .GetAdapter(MapConfigEnum.ATTRIBUTESETTINGS, maps);

            Assert.IsTrue(typeof(AttributesAdapter <Document>).IsInstanceOfType(adapter));
        }
Пример #4
0
        public List <ProductEx> Consolidate <TProductType>(IQueryable <TProductType> products) where TProductType : class
        {
            var adapter = AdapterFactory.GetAdapter <TProductType>();

            products.ToList().ForEach(
                p => consolidatedProducts.Add(new ProductEx(adapter.Adapt(p), this)));

            return(consolidatedProducts);
        }
Пример #5
0
        public ItemTag(MpqArchive archive, MpqEntry mpqEntry, string archiveName = null)
        {
            MpqEntry           = mpqEntry;
            FileName           = mpqEntry.FileName;
            ArchiveName        = archiveName ?? string.Empty;
            OriginalFileStream = archive.OpenFile(mpqEntry);

            if (!OriginalFileStream.CanRead)
            {
                OriginalFileStream.Dispose();
                Status = MapFileStatus.Locked;
            }
            else
            {
                Adapter = AdapterFactory.GetAdapter(OriginalFileStream, FileName);
                Status  = Adapter is null ? MapFileStatus.Unknown : MapFileStatus.Pending;
            }
        }
Пример #6
0
        public async Task <HandleResult> Index(string code)
        {
            code = code.ToUpper();
            var ada     = _adapterFactory.GetAdapter(code);
            var handler = ada.GetHandler(code);

            if ("application/json".Equals(Request.ContentType, StringComparison.OrdinalIgnoreCase))
            {
                var model = await TryReadModelAsync(handler.ReqType);

                if (model == null)
                {
                    return(new HandleResult
                    {
                        State = HandleStates.InvalidData,
                        Msg = "Input error."
                    });
                }

                model.Code = code;
                return(await handler.Handle(model));
            }
            else
            {
                var model = handler.ObtainModel();
                await TryUpdateModelAsync(model, model.GetType(), string.Empty);

                if (Request.HasFormContentType &&
                    Request.ContentType.IndexOf("multipart/form-data", StringComparison.OrdinalIgnoreCase) >= 0 &&
                    Request.Form.Files.Count > 0)
                {
                    await TryFillFile(Request.Form.Files, model);
                }

                return(await handler.Handle(model));
            }
        }
Пример #7
0
 public void Start()
 {
     _adapter = AdapterFactory.GetAdapter(AdaptorTypeName);
     _adapter.Process();
 }