public static PropertyContextFacade GetPropertyByName(this IFrameworkFacade frameworkFacade, string domainType, string instanceId, string propertyName, ArgumentsContextFacade argsContext)
        {
            var link = frameworkFacade.OidTranslator.GetOidTranslation(domainType, instanceId);
            var obj  = frameworkFacade.GetObject(link);

            return(frameworkFacade.GetPropertyWithCompletions(obj.Target, propertyName, argsContext));
        }
        private static MapRepresentation GetMap(IOidStrategy oidStrategy, IFrameworkFacade frameworkFacade, HttpRequest req, ContextFacade context, RestControlFlags flags)
        {
            MapRepresentation value;

            // All reasons why we cannot create a link representation
            if (context.Specification.IsCollection && context.ElementSpecification != null && !context.ElementSpecification.IsParseable)
            {
                var proposedObjectFacade = frameworkFacade.GetObject(context.ProposedValue);
                var coll = proposedObjectFacade.ToEnumerable().Select(no => CreateObjectRef(oidStrategy, req, no, flags)).ToArray();
                value = CreateMap(context, coll);
            }
            else if (context.Specification.IsParseable ||
                     context.ProposedValue == null ||
                     context.ProposedObjectFacade == null ||
                     context.ProposedObjectFacade.Specification.IsParseable)
            {
                value = CreateMap(context, context.ProposedValue);
            }
            else
            {
                value = CreateMap(context, RefValueRepresentation.Create(oidStrategy, new ObjectRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, context.ProposedObjectFacade)), flags));
            }

            return(value);
        }
 private object GetObjectByHref(string href, IFrameworkFacade facade, UriMtHelper helper, IOidStrategy oidStrategy) {
     string[] oids = helper.GetObjectId(href);
     if (oids != null) {
         var oid = facade.OidTranslator.GetOidTranslation(oids[0] + "/" + oids[1]);
         return facade.GetObject(oid).Target?.Object;
     }
     string typeName = helper.GetTypeId(href);
     return facade.GetDomainType(typeName);
 }
 private static IObjectFacade SafeGetNakedObjectFromId(string id, IFrameworkFacade facade)
 {
     try {
         var oid = facade.OidTranslator.GetOidTranslation(id);
         return(facade.GetObject(oid).Target);
     }
     catch (Exception) {
         return(null);
     }
 }
        private static IObjectFacade GetNakedObjectFromId(string id, IFrameworkFacade facade)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }

            var oid = facade.OidTranslator.GetOidTranslation(id);

            return(facade.GetObject(oid).Target);
        }
        private object GetObjectByHref(string href, IFrameworkFacade facade, UriMtHelper helper, IOidStrategy oidStrategy)
        {
            string[] oids = helper.GetObjectId(href);
            if (oids != null)
            {
                var oid = facade.OidTranslator.GetOidTranslation(oids[0] + "/" + oids[1]);
                return(facade.GetObject(oid).Target?.Object);
            }
            string typeName = helper.GetTypeId(href);

            return(facade.GetDomainType(typeName));
        }
        private static object GetObjectByHref(string href, IFrameworkFacade facade, UriMtHelper helper, IOidStrategy oidStrategy)
        {
            var oids = UriMtHelper.GetObjectId(href);

            if (oids != null)
            {
                var oid = facade.OidTranslator.GetOidTranslation($"{oids.Value.type}/{oids.Value.key}");
                return(facade.GetObject(oid).Target?.Object);
            }

            var typeName = UriMtHelper.GetTypeId(href);

            return(facade.GetDomainType(typeName));
        }
        public ParameterContext[] GetParameterContexts(IFrameworkFacade facade)
        {
            if (parameterContexts == null)
            {
                parameterContexts = Action.Parameters.Where(Filter).Select(p => new ParameterContext(IdHelper, EmbeddedInObject, Target, Action, p, true)).ToArray();

                if (ParameterValues != null)
                {
                    foreach (ParameterContext pc in parameterContexts)
                    {
                        object value;
                        if (ParameterValues.TryGetValue(pc.Parameter.Id, out value))
                        {
                            pc.IsHidden    = true;
                            pc.CustomValue = facade.GetObject(value);
                        }
                    }
                }
            }

            return(parameterContexts);
        }
        public IObjectFacade GetNakedObject(IFrameworkFacade facade)
        {
            if (objectFacade == null)
            {
                var link = facade.OidTranslator.GetOidTranslation(Id);

                var objectContextFacade = facade.GetObject(link);

                if (objectContextFacade.RedirectedUrl != null)
                {
                    throw new RedirectException(objectContextFacade.RedirectedUrl);
                }

                objectFacade = objectContextFacade.Target;

                if (objectFacade == null)
                {
                    throw new ObjectNotFoundException();
                }
            }

            return(objectFacade);
        }
        public static ObjectContextFacade GetObjectByName(this IFrameworkFacade frameworkFacade, string domainType, string instanceId)
        {
            var oidTranslation = frameworkFacade.OidTranslator.GetOidTranslation(domainType, instanceId);

            return(frameworkFacade.GetObject(oidTranslation));
        }
        public static string GetObjectTypeName(this IFrameworkFacade surface, object model)
        {
            var nakedObject = surface.GetObject(model);

            return(nakedObject.Specification.ShortName);
        }
        private static IObjectFacade GetNakedObjectFromId(IFrameworkFacade surface, string id)
        {
            var oid = surface.OidTranslator.GetOidTranslation(id);

            return(surface.GetObject(oid).Target);
        }
Ejemplo n.º 13
0
        public static string GetObjectTypeShortName(this IFrameworkFacade facade, object model)
        {
            var objectFacade = facade.GetObject(model);

            return(objectFacade.Specification.ShortName);
        }
Ejemplo n.º 14
0
        private static IObjectFacade GetObjectFacadeFromId(IFrameworkFacade facade, string id)
        {
            var oid = facade.OidTranslator.GetOidTranslation(id);

            return(facade.GetObject(oid).Target);
        }
        public static void AddOrUpdateInCache(this HttpSessionStateBase session, IFrameworkFacade facade, object domainObject, string url, ObjectFlag flag = ObjectFlag.None)
        {
            var nakedObject = facade.GetObject(domainObject);

            session.AddOrUpdateInCache(facade, nakedObject, url, flag);
        }
        public static void RemoveFromCache(this HttpSessionStateBase session, IFrameworkFacade facade, object domainObject, ObjectFlag flag = ObjectFlag.None)
        {
            var nakedObject = facade.GetObject(domainObject);

            session.RemoveFromCache(facade, nakedObject, flag);
        }
        public static void AddObjectToSession <T>(this HttpSessionStateBase session, IFrameworkFacade facade, string key, T domainObject) where T : class
        {
            var nakedObject = facade.GetObject(domainObject);

            session.Add(key, (nakedObject.IsTransient ? (object)domainObject : facade.OidTranslator.GetOidTranslation(nakedObject).Encode()));
        }
 private static IObjectFacade GetNakedObject(IFrameworkFacade facade, object domainObject)
 {
     return(facade.GetObject(domainObject));
 }
        public IObjectFacade GetNakedObject(IFrameworkFacade facade) {
            if (objectFacade == null) {
                var link = facade.OidTranslator.GetOidTranslation(Id);

                var objectContextFacade = facade.GetObject(link);

                if (objectContextFacade.RedirectedUrl != null) {
                    throw new RedirectException(objectContextFacade.RedirectedUrl);
                }

                objectFacade = objectContextFacade.Target;

                if (objectFacade == null) {
                    throw new ObjectNotFoundException();
                }
            }

            return objectFacade;
        }