Esempio n. 1
0
        public override void SetUp()
        {
            base.SetUp();

            objectRepository = new Dictionary <string, object>();

            codingStyle = BuildRoutine.CodingStyle().FromBasic()
                          .AddTypes(GetType().Assembly, t => t.IsPublic && t.Namespace != null && t.Namespace.StartsWith(RootNamespace))

                          .Initializers.Add(c => c.Constructors().When(t => t.IsValueType && t.Namespace?.StartsWith(RootNamespace) == true))
                          .Datas.Add(c => c.PublicProperties(m => !m.IsInherited()).When(t => t.Namespace?.StartsWith(RootNamespace) == true))
                          .Operations.Add(c => c.PublicMethods(m => !m.IsInherited()).When(t => t.Namespace?.StartsWith(RootNamespace) == true))

                          .IdExtractor.Set(c => c.IdByProperty(p => p.Returns <string>("Id")).When(t => t.Namespace != null && t.Namespace.StartsWith(RootNamespace)))
                          .Locator.Set(c => c.Locator(l => l.SingleBy(id => objectRepository[id])).When(t => t.Namespace != null && t.Namespace.StartsWith(RootNamespace) && t.Properties.Any(m => m.Returns <string>("Id"))))

                          .NextLayer()
            ;

            var cache = new DictionaryCache();

            ctx = new DefaultCoreContext(codingStyle, cache);

            testing = new ObjectService(ctx, cache);
        }
Esempio n. 2
0
        public ActionResult List(string id, bool query = false, int startIndex = 0, int length = 30)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(this.Content("Error Item Name"));
            }
            var svr  = ObjectService.GetObject <IDataManageService>();
            var item = svr.GetDataItem(id);

            if (item == null)
            {
                return(this.Content("Error Item"));
            }
            if (query || this.Request.HttpMethod == "POST")
            {
                var queryValues = GetDictionary(this.Request.Form);
                this.ViewBag.ItemColumns = item.GetListColumns();
                this.ViewBag.QueryValues = queryValues;
                this.ViewBag.ItemList    = item.GetList(queryValues, startIndex, length);
            }
            this.ViewBag.StartIndex   = startIndex;
            this.ViewBag.PageSize     = length;
            this.ViewBag.DataItem     = item;
            this.ViewBag.Title        = item.Title;
            this.ViewBag.QueryColumns = item.GetQueryColumns();
            return(this.View());
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            try {
                throw new NotImplementedException();
            } catch { }

            /*var test = DispatchProxy.Create<ITestService, MyDispatchProxy>();
             * test.Hello("");*/
            var test = ObjectService.GetObject <ITestService>();
            var str  = test.Hello("1234");

            Console.WriteLine(str);
            var a = test.Test(10);

            Console.WriteLine(a);
            var result = test.GetEntity();

            Console.WriteLine(result.ResultAttachObject.Name);
            var entity = test.GetRawEntity();

            Console.WriteLine(entity.Name + "." + entity.Age);
            entity = test.SetRawEntity(entity);
            Console.WriteLine(entity.Name + "." + entity.Age);
            Console.ReadLine();
        }
        protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)
        {
            var authorized = base.AuthorizeCore(httpContext);

            if (authorized)
            {
                var filterContext    = (AuthorizationContext)httpContext.Items[typeof(AuthorizationContext)];
                var actionDescriptor = filterContext.ActionDescriptor;
                var ps   = actionDescriptor.GetCustomAttributes(typeof(PermissionAttribute), true) as PermissionAttribute[];
                var list = new List <IPermissionObject> {
                    this
                };
                if (ps != null && ps.Length > 0)
                {
                    list.AddRange(ps);
                }
                ps = actionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(PermissionAttribute), true) as PermissionAttribute[];
                if (ps != null && ps.Length > 0)
                {
                    list.AddRange(ps);
                }
                var svr = ObjectService.GetObject <IPermissionClientService>();
                authorized = svr.Authorize(false, list.ToArray());
            }
            return(authorized);
        }
Esempio n. 5
0
        public void CorrectSubject()
        {
            var service = new ObjectService();
            var result  = service.GetObject(new List <OpenieTriple>(), new List <Token>(), SentenceType.Imperative);

            Assert.Null(result.Word);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            var svr = ObjectService.GetObject <ILogService>();

            Console.WriteLine(svr.ToString());
            Console.ReadLine();
        }
Esempio n. 7
0
        public override void ShouldLoadEntities()
        {
            Mapping mapping = Mapping.Load(Path.Combine(mappingFolder, "Composite/mapping.xml"));

            ObjectService os = new ObjectService(GetProvider(mapping));
            IObjectContext oc = os.CreateObjectContext();

            oc.InitializeRepository();

            oc.BeginTransaction();
            oc.Serialize(new Person() { FirstName = "test", Address = new Address() { City = "test" } });
            oc.CommitTransaction();

            oc.Clear();

            IList<Person> person = ((IInferrable<Person>)from Person p in oc select p).ToList();

            Assert.AreEqual(1, person.Count);

            Assert.IsNotNull(person.FirstOrDefault());

            Assert.AreEqual("test", person.First().FirstName);

            Assert.AreEqual(person.First().FirstName, person.First().LastName);

            Assert.IsNotNull(person.First().Address);

            Assert.AreEqual("test", person.First().Address.City);
        }
Esempio n. 8
0
        private async Task InitAsync(Access access)
        {
            await _semaphoreSlim.WaitAsync();

            try
            {
                if (_isInitialized)
                {
                    return;
                }

                _access       = access;
                BucketService = new BucketService(_access);
                ObjectService = new ObjectService(_access);
                Bucket        = await BucketService.GetBucketAsync("nutz-mich");

                _isInitialized = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _semaphoreSlim.Release();
            }
        }
Esempio n. 9
0
        private static Binding CreateBinding(IObjectSetting setting, string url)
        {
            string bindingName = null;
            var    bc          = setting.ConfigSetting["binding"];

            if (bc != null)
            {
                bindingName = bc.Value.Value;
            }
            if (string.IsNullOrEmpty(bindingName))
            {
                var uri = new Uri(url, UriKind.Absolute);
                bindingName = uri.Scheme;
            }
            if (string.IsNullOrEmpty(bindingName))
            {
                throw new RemotingException("Binding not found");
            }
            var binding = ObjectService.GetObject <Binding>("Wcf." + bindingName);

            if (binding == null)
            {
                throw new RemotingException("Binding not found");
            }
            return(binding);
        }
Esempio n. 10
0
        private List <UsedByRelation> PageRelation(SiteDb sitedb, string by, Guid PageId)
        {
            string baseurl = sitedb.WebSite.BaseUrl();

            byte consttype = ConstObjectType.GetByte(by);

            List <UsedByRelation> result = new List <UsedByRelation>();

            var relations = sitedb.Relations.GetRelations(PageId, consttype);

            foreach (var item in relations)
            {
                var objectinfo = ObjectService.GetObjectInfo(sitedb, item.objectYId, item.ConstTypeY);

                if (objectinfo != null)
                {
                    UsedByRelation relation = new UsedByRelation();
                    relation.Name = objectinfo.DisplayName;
                    relation.Url  = objectinfo.Url;
                    if (!string.IsNullOrEmpty(relation.Url))
                    {
                        relation.Url = Lib.Helper.UrlHelper.Combine(baseurl, relation.Url);
                    }
                    relation.ModelType = objectinfo.ModelType;
                    relation.ObjectId  = objectinfo.ObjectId;
                    relation.ConstType = objectinfo.ConstType;
                    result.Add(relation);
                }
            }
            return(result);
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            var svr = ObjectService.GetObject <IClassService>();

            Console.WriteLine(svr.HelloWorld());
            Console.ReadLine();
        }
Esempio n. 12
0
        public string GetControl(Model.ControlTypes controlType, string relationName, string relationFields, string name, string value)
        {
            string html = string.Empty;

            switch (controlType)
            {
            case Model.ControlTypes.Text:
                html = string.Format("<input type='text' name='{0}' value='{1}' />", name, value);
                break;

            case Model.ControlTypes.Select:
                var svr = ObjectService.GetObject <IManageServer>();
                svr.TableName = relationName;
                var           dt     = svr.GetDataList(null, null);
                var           fields = relationFields.Split(',');
                StringBuilder select = new StringBuilder();
                select.AppendFormat("<select name='{0}'>", name);
                foreach (DataRow dr in dt.Rows)
                {
                    var selValue = dr[fields[0]].ToString();
                    var selText  = dr[fields[1]].ToString();
                    select.AppendFormat("<option {2} value='{0}'>{1}</option>", selValue, selText, selValue == value ? "selected='selected'" : string.Empty);
                }
                select.Append("</select>");
                html = select.ToString();
                break;

            default:
                html = string.Format("<input type='hidden' name='{0}' value='{1}' />", name, value);
                break;
            }

            return(html);
        }
Esempio n. 13
0
        public ActionResult Login(string userName, string password, string returnUrl)
        {
            if (this.Request.IsAuthenticated)
            {
                return(this.RedirectTo(returnUrl));
            }
            if (string.IsNullOrEmpty(userName))
            {
                this.ViewBag.Message = "请输入用户名";
                return(this.View());
            }
            this.ViewBag.UserName = userName;
            if (string.IsNullOrEmpty(password))
            {
                this.ViewBag.Message = "请输入密码";
                return(this.View());
            }
            var svr    = ObjectService.GetObject <IPassportServerService>();
            var result = svr.Login(this.HttpContext, userName, password, null);

            if (result.ResultNo != 0)
            {
                this.ViewBag.Message = "登录失败:" + result.ResultDescription;
                return(this.View());
            }
            return(this.RedirectTo(returnUrl));
        }
Esempio n. 14
0
        /// <summary>
        /// Parse object
        /// </summary>
        /// <typeparam name="TObject"></typeparam>
        /// <typeparam name="TContext"></typeparam>
        /// <param name="conf"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static object ParseObject <TObject, TContext>(this DynamicObject conf, TObject obj) where TContext : EntitiesDbContext
        {
            var entity = conf.Type.Name;
            var res    = new ObjectService(entity).ParseObject(obj);

            return(res);
        }
Esempio n. 15
0
        public JsonResult SetScores(IEnumerable <ScoreEntity> scores)
        {
            var result = ObjectService.AddEntities <ScoreEntity>(scores);

            ScoreService.SetUpdateInfo();
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 16
0
        protected override void PublishService(RemotingServiceItemSetting setting)
        {
            var typeName = setting.TypeName;

            if (string.Compare(typeName, ":wcf", true) != 0)
            {
                base.PublishService(setting);
                return;
            }
            if (HttpContext.Current != null)             //ignore in iis
            {
                return;
            }
            var serviceTypeName = setting.ServiceTypeName;

            if (string.IsNullOrEmpty(serviceTypeName))
            {
                throw new RemotingException("serviceType is required in config file");
            }
            serviceTypeName = ObjectService.GetTypeName(setting.ServiceTypeName);
            var serviceType = TypeHelper.CreateType(serviceTypeName, true);
            var serviceHost = new ServiceHost(serviceType);

            serviceHost.Open();
        }
Esempio n. 17
0
        public StyleViewModel GetEdit(ApiCall call)
        {
            var style = call.WebSite.SiteDb().Styles.Get(call.ObjectId);

            if (style != null)
            {
                var model = new StyleViewModel();
                model.Id          = style.Id;
                model.Name        = style.Name;
                model.Body        = style.Body;
                model.DisplayName = style.DisplayName;
                model.FullUrl     = ObjectService.GetObjectRelativeUrl(call.WebSite.SiteDb(), style);

                model.Extension = style.Extension;

                if (model.Extension != null && model.Extension != "css" && model.Extension != ".css")
                {
                    model.SourceChange = style.SourceChange;
                    if (!string.IsNullOrEmpty(style.Source))
                    {
                        model.Body = style.Source;
                    }
                }
                return(model);
            }
            else
            {
                return(new StyleViewModel());
            }
        }
Esempio n. 18
0
        public JsonResult AddChallenges(IEnumerable <ChallengeEntity> challenges)
        {
            var validated = challenges.Except(challenges.Where(c => c.Date == DateTimeOffset.MinValue));
            var result    = ObjectService.AddEntities(validated);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 19
0
        /// <summary>
        /// Execute LoadCommand
        /// </summary>
        /// <returns>Return the result</returns>
        private async Task ExecuteLoadCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;

            try
            {
                var e = await ObjectService.GetAllAsync();

                Models.Clear();

                foreach (var i in e)
                {
                    Models.Add(i);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally { IsBusy = false; }
        }
Esempio n. 20
0
        public ActionResult State()
        {
            var svr    = ObjectService.GetObject <PerformanceService>();
            var result = svr.GetPerformanceResult();

            return(this.Content(string.Format("|{0}|{1}|", result.ResultNo, result.ResultDescription)));
        }
Esempio n. 21
0
        public object CreateObject(IObjectSetting setting, params object[] parameters)
        {
            if (setting == null)
            {
                return(null);
            }
            var typeName   = ObjectService.GetTypeName(setting.TypeName);
            var objectType = TypeHelper.CreateType(typeName, false);

            if (objectType == null)
            {
                return(null);
            }
            if (!typeof(IEventStorageInternal).IsAssignableFrom(objectType))
            {
                throw new Exception("Create Redis Event Storage Only.");
            }
            var storage = (IEventStorageInternal)ObjectService.Current.ObjectBuilder.CreateObject((HTB.DevFx.Core.Config.IObjectSetting)setting, parameters);

            if (storage == null)
            {
                return(null);
            }
            storage.ConnectionStringName = setting.Name;
            return(storage);
        }
Esempio n. 22
0
File: Link.cs Progetto: xhute/Kooboo
        public LinkViewModel All(ApiCall call)
        {
            LinkViewModel model = new LinkViewModel();

            var allpageroutes = call.WebSite.SiteDb().Routes.GetByType(ConstObjectType.Page);

            foreach (var item in allpageroutes)
            {
                if (item.objectId != default(Guid))
                {
                    LinkItem linkitem = new LinkItem();
                    linkitem.Url        = item.Name;
                    linkitem.Parameters = item.Parameters.Keys.ToList();
                    model.Pages.Add(linkitem);
                }
            }

            var allviews = call.WebSite.SiteDb().Views.All();

            foreach (var item in allviews)
            {
                LinkItem linkitem = new LinkItem();
                linkitem.Url = ObjectService.GetObjectRelativeUrl(call.WebSite.SiteDb(), item);
                //  linkitem.Parameters = Sites.Routing.PageRoute.GetViewParameters(call.SiteDb, item.Id);
                model.Views.Add(linkitem);
            }

            return(model);
        }
Esempio n. 23
0
        public async Task AccessShare_Creates_UsableSharedAccessForDownload()
        {
            string serializedAccess;
            string bucketname = "accessshare-creates-usablesharedaccessfordownload";

            byte[] bytesToUpload = ObjectServiceTest.GetRandomBytes(2048);

            using (Access scope = new Access(TestConstants.SATELLITE_URL, TestConstants.VALID_API_KEY, TestConstants.ENCRYPTION_SECRET))
            {
                await _bucketService.CreateBucketAsync(bucketname);

                var bucket = await _bucketService.GetBucketAsync(bucketname);

                var uploadOperation = await _objectService.UploadObjectAsync(bucket, "test/test-file", new UploadOptions(), bytesToUpload, false);

                await uploadOperation.StartUploadAsync();

                Permission permission = new Permission();
                permission.AllowUpload   = false; //Should not change anything as we are downloading here
                permission.AllowDownload = true;
                List <SharePrefix> sharePrefixes = new List <SharePrefix>();
                sharePrefixes.Add(new SharePrefix()
                {
                    Bucket = bucketname, Prefix = "test/"
                });
                var restricted = scope.Share(permission, sharePrefixes);
                serializedAccess = restricted.Serialize();
            }

            await Task.Delay(SATELLITE_WAIT_DURATION); //Wait a bit so that some things can happen on the satellite

            Access restrictedEnv;

            try
            {
                restrictedEnv = new Access(serializedAccess);
            }
            catch
            {
                Assert.Fail("Failed to create restricted scope from serialized scope");
                return;
            }

            var restrictedObjectService = new ObjectService(restrictedEnv);
            var restrictedBucketService = new BucketService(restrictedEnv);
            var restrictedBucket        = await restrictedBucketService.GetBucketAsync(bucketname);

            var downloadOperation = await restrictedObjectService.DownloadObjectAsync(restrictedBucket, "test/test-file", new DownloadOptions(), false);

            await downloadOperation.StartDownloadAsync();

            Assert.IsTrue(downloadOperation.Completed);
            Assert.AreEqual(bytesToUpload.Length, downloadOperation.BytesReceived);

            for (int i = 0; i < bytesToUpload.Length; i++)
            {
                Assert.AreEqual(bytesToUpload[i], downloadOperation.DownloadedBytes[i], "DownloadedBytes are not equal at index " + i);
            }
        }
Esempio n. 24
0
 protected override IObjectContext CreateContext()
 {
     OData.ODataPersistenceProvider provider = new OData.ODataPersistenceProvider();
     provider.ConnectionString = new Uri("http://localhost:37770/Common.svc/");
     os = new ObjectService(provider);
     os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
     return os.CreateObjectContext();
 }
Esempio n. 25
0
 static ObjectContextTest()
 {
     IPersistenceProvider provider = new MemoryProvider();
     provider.RegisterMetaData(MetaData.LightMetaDataFactory.FromAssembly(typeof(ObjectContextTest).Assembly, "Evaluant.Uss.Test.Models"));
     provider.InitializeConfiguration();
     os = new ObjectService(provider);
     os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
 }
Esempio n. 26
0
        public object CreateObject(IObjectSettingLite setting, Type objectType, string uri, params object[] parameters)
        {
            var contentType = setting.ConfigSetting.GetSetting("contentType") ?? string.Empty;
            var factory     = ObjectService.GetObject <IHttpRealProxyFactory>();
            var instance    = factory.GetProxyObject(objectType, uri, contentType);

            return(instance);
        }
Esempio n. 27
0
        public JsonResult CreateTable()
        {
            ObjectService.Init();

            var jsonResult = new { Message = "Tables created", Status = "Success" };

            return(Json(jsonResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 28
0
        public void InitializeGameServer()
        {
            ObjectFactory = new ObjectService();

            InitComponentCache();

            Console.WriteLine(string.Format("[Lorule] {0} Server Components loaded.", Components.Count));
        }
Esempio n. 29
0
 public void Init(HttpApplication context)
 {
     this.currentModule = ObjectService.GetObject <HttpModuleWrapperInternal>();
     if (this.currentModule != null)
     {
         this.currentModule.Init(context);
     }
 }
Esempio n. 30
0
        static void Main(string[] args)
        {
            var svr = ObjectService.GetObject <IPeration>();
            var a   = svr.Add(3, 5);

            Console.WriteLine(a);
            Console.ReadKey();
        }
Esempio n. 31
0
        public ActionResult LogOn(string returnUrl)
        {
            returnUrl = WebHelper.UriCombine(this.Request.Url.GetLeftPart(UriPartial.Path), "~/Account/SignIn?returnUrl=" + this.Server.UrlEncode(returnUrl), true);
            var authService = ObjectService.GetObject <IAuthenticationService>();
            var url         = authService.GetAuthenticationUrl(this.HttpContext, returnUrl);

            return(this.Redirect(url));
        }
Esempio n. 32
0
        public ActionResult Login(string returnUrl)
        {
            returnUrl = WebHelper.GetReturnUrl(returnUrl: returnUrl, uriKind: UriKind.Absolute);
            var svr      = ObjectService.GetObject <IPassportAuthentication>();
            var loginUrl = svr.Setting.LoginUrl;

            return(this.Redirect(string.Format(loginUrl, this.Server.UrlEncode(returnUrl))));
        }
Esempio n. 33
0
        public DataTable GetDataList(Dictionary <string, string> search, Pager pager)
        {
            Dictionary <string, string> param;
            string sql = this.GetListSql(search, pager, out param);

            var svr = ObjectService.GetObject <IManageData>();

            return(svr.GetData(sql, param));
        }
Esempio n. 34
0
 protected override Evaluant.Uss.ObjectContext.Contracts.IObjectContext CreateContext()
 {
     if (os == null)
     {
         IPersistenceProvider provider = new MemoryProvider();
         provider.RegisterMetaData(MetaData.LightMetaDataFactory.FromAssembly(GetType().Assembly, "Evaluant.Uss.Tests.Model"));
         provider.InitializeConfiguration();
         os = new ObjectService(provider);
         os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
     }
     return (IPersistenceEngineObjectContext)os.CreateObjectContext();
 }
Esempio n. 35
0
 protected override Evaluant.Uss.ObjectContext.Contracts.IObjectContext CreateContext()
 {
     if (os == null)
     {
         IPersistenceProvider provider = new MongoPersistenceProvider();
         provider.RegisterMetaData(MetaData.MetaDataFactory.FromAssembly(GetType().Assembly, "Evaluant.Uss.Tests.Model"));
         ((MongoPersistenceProvider)provider).ConnectionString = "Server=127.0.0.1:27017;Database=euss";
         
         provider.InitializeConfiguration();
         os = new ObjectService(provider);
         os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
     }
     return (IPersistenceEngineObjectContext)os.CreateObjectContext();
 }
Esempio n. 36
0
 protected override IObjectContextAsync CreateContext()
 {
     if (provider == null)
     {
         provider = new OData.ODataPersistenceProvider();
         provider.ConnectionString = new Uri("http://localhost:37770/Common.svc/");
         provider.Initialized += ((AsyncUnitTestHarness)UnitTestHarness).EventRunDispatcher.DispatchRun;
         provider.EnsureConfigurationInitialized();
     }
     else if (provider.Metadata != null)
     {
         ((AsyncUnitTestHarness)UnitTestHarness).EventRunDispatcher.DispatchRun();
     }
     os = new ObjectService(provider);
     os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContextAsync).AssemblyQualifiedName;
     return os.CreateAsyncObjectContext();
 }
Esempio n. 37
0
        protected override Evaluant.Uss.ObjectContext.Contracts.IObjectContext CreateContext()
        {
            if (os == null)
            {
                IPersistenceProvider provider = new Uss.SqlMapper.SqlMapperProvider();
                ((Uss.SqlMapper.SqlMapperProvider)provider).ConnectionString = connectionString;
                ((Uss.SqlMapper.SqlMapperProvider)provider).UseDefaultMapping = true;
                ((Uss.SqlMapper.SqlMapperProvider)provider).Driver = GetDriver();
                ((Uss.SqlMapper.SqlMapperProvider)provider).Dialect = GetDialect();

                provider.RegisterMetaData(MetaData.MetaDataFactory.FromAssembly(GetType().Assembly, "Evaluant.Uss.Tests.Model"));
                provider.InitializeConfiguration();
                os = new ObjectService(provider);
                os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
            }
            return (IPersistenceEngineObjectContext)os.CreateObjectContext();
        }
Esempio n. 38
0
File: Basics.cs Progetto: npenin/uss
        public void ShouldWorkWithHighLayer()
        {
            IPersistenceProvider provider = new SqlMapper.SqlMapperProvider();
            ((SqlMapper.SqlMapperProvider)provider).ConnectionString = "Data Source=.;Initial Catalog=uss2;Integrated Security=true";
            ((SqlMapper.SqlMapperProvider)provider).UseDefaultMapping = true;
            provider.RegisterMetaData(MetaData.MetaDataFactory.FromAssembly(GetType().Assembly, "Evaluant.Uss.Tests.Model"));
            provider.InitializeConfiguration();
            ObjectService os = new ObjectService(provider);
            os.ObjectContextType = typeof(EntityResolver.Proxy.Dynamic.ObjectContext).AssemblyQualifiedName;
            IObjectContext context = os.CreateObjectContext();
            context.InitializeRepository();
            context.BeginTransaction();
            context.Serialize(new Address() { City = "Mulhouse" });
            context.CommitTransaction();

            context = os.CreateObjectContext();
            var addresses = context.Load<Address>();

            if (addresses.Count > 0)
            {
                Address a = addresses.First();
                Assert.AreEqual("Mulhouse", a.City);
            }

            var addresses2 = (from Address a in context select a).ToList();

            Assert.AreEqual(addresses.FirstOrDefault(), addresses2.FirstOrDefault());
        }
Esempio n. 39
0
 public ObjectContextAsync(ObjectService factory, IPersistenceEngineAsync engine)
     : base(factory, engine)
 {
     Resolver = new AnonymousTypeResolver(new EntityResolver(this));
 }