public ActionInvocationFacetViaMethod(MethodInfo method, INakedObjectSpecification onType, INakedObjectSpecification returnType, IFacetHolder holder)
     : base(holder) {
     actionMethod = method;
     paramCount = method.GetParameters().Length;
     this.onType = onType;
     this.returnType = returnType;
 }
Exemple #2
0
        internal ProgrammableNakedObject(object poco, INakedObjectSpecification specification, IOid oid) {
            this.poco = poco;
            this.specification = specification;
            this.oid = oid;

            resolveState = new ResolveStateMachine(this);
        }
 protected NakedObjectAssociationAbstract(string fieldId, INakedObjectSpecification specification, IFacetHolder facetHolder)
     : base(fieldId, facetHolder) {
     if (specification == null) {
         throw new ArgumentException(string.Format(Resources.NakedObjects.MissingFieldType, fieldId));
     }
     this.specification = specification;
 }
Exemple #4
0
        public static INakedObjectAction GetOverloadedAction(string actionName, INakedObjectSpecification spec) {
            INakedObjectAction action = null;
            INakedObjectAction[] actions = spec.GetActionLeafNodes();
            Tuple<INakedObjectAction, string>[] overloadedActions = GetOverloadedActionsAndUIds(actions);

            if (overloadedActions.Any()) {
                Tuple<INakedObjectAction, string> matchingAction = overloadedActions.SingleOrDefault(oa => oa.Item1.Id + oa.Item2 == actionName);
                if (matchingAction != null) {
                    action = matchingAction.Item1;
                }
            }
            return action;
        }
 public IQueryable <ObjectData> GetInstances(INakedObjectSpecification specification)
 {
     return(null);
 }
Exemple #6
0
 public static void ClearDestroyedObjectsOfType(this HttpSessionStateBase session, INakedObjectSpecification spec, ObjectFlag flag = ObjectFlag.None) {
     Dictionary<string, CacheMemento> cache = session.GetCache(flag);
     List<string> toRemove = cache.Where(cm => cm.Value.Spec.IsOfType(spec)).Select(kvp => new { kvp.Key, no = SafeGetNakedObjectFromId(kvp.Key) }).Where(ao => ao.no.ResolveState.IsDestroyed()).Select(ao => ao.Key).ToList();
     toRemove.ForEach(k => cache.Remove(k));
 }
Exemple #7
0
 private static IEnumerable<INakedObject> GetAndTidyCachedNakedObjectsOfType(this HttpSessionStateBase session, INakedObjectSpecification spec, ObjectFlag flag) {
     session.ClearDestroyedObjectsOfType(spec, flag);
     return session.GetCache(flag).Where(cm => cm.Value.Spec.IsOfType(spec)).OrderBy(kvp => kvp.Value.Added).Select(kvp => FrameworkHelper.GetNakedObjectFromId(kvp.Key));
 }
 public CollectionData(INakedObjectSpecification type, IOid oid, IVersion version)
     : base(type, oid, version) {}
 public static INakedObject RecreateInstance(IOid oid, INakedObjectSpecification specification) {
     return NakedObjectsContext.ObjectPersistor.RecreateInstance(oid, specification);
 }
 public virtual void Cache(string className, INakedObjectSpecification spec) {
     lock (specs) {
         specs[className] = spec;
     }
 }
Exemple #11
0
 public DotNetNakedObjectActionParamPeer(INakedObjectSpecification specification) {
     this.specification = specification;
 }
Exemple #12
0
 public static Tuple<INakedObjectAction, string>[] GetActionsandUidFromSpec(INakedObjectSpecification spec) {
     INakedObjectAction[] actions = spec.GetActionLeafNodes();
     return actions.Select(action => new Tuple<INakedObjectAction, string>(action, GetOverloadedUId(action, spec))).ToArray();
 }
Exemple #13
0
 protected Data(INakedObjectSpecification type, IOid oid, IVersion version)
 {
     this.type    = type.FullName;
     this.oid     = oid;
     this.version = version;
 }
Exemple #14
0
 private object GetCompletionData(INakedObject nakedObject, INakedObjectSpecification spec) {
     string label = nakedObject.TitleString();
     string value = nakedObject.TitleString();
     string link = spec.IsParseable ? label : FrameworkHelper.GetObjectId(nakedObject);
     string src = GetIconSrc(nakedObject);
     string alt = GetIconAlt(nakedObject);
     return new {label, value, link, src, alt};
 }
Exemple #15
0
        private static INakedObject GetValue(string[] values, INakedObjectSpecification spec) {
            if (!values.Any()) {
                return null;
            }
         
            if (spec.IsParseable) {
                return spec.GetFacet<IParseableFacet>().ParseTextEntry(values.First());
            }
            if (spec.IsCollection) {
                return FrameworkHelper.GetTypedCollection(spec, values);
            }

            return FrameworkHelper.GetNakedObjectFromId(values.First());
        }
 public ViewModelOid(INakedObjectSpecification specification) {
     IsTransient = false;
     TypeName = TypeNameUtils.EncodeTypeName(specification.FullName);
     Keys = new[] {System.Guid.NewGuid().ToString()};
     CacheState();
 }
 public CollectionData(INakedObjectSpecification type, IOid oid, IVersion version)
     : base(type, oid, version)
 {
 }
Exemple #18
0
 public void AddSpecification(INakedObjectSpecification specification) {
     specs[specification.FullName] = specification;
 }
Exemple #19
0
 public override void AddSubclass(INakedObjectSpecification specification) {}
Exemple #20
0
 public void SetupSubclasses(INakedObjectSpecification[] subclasses) {
     this.subclasses = subclasses;
 }
Exemple #21
0
 public static string GetOverloadedUId(INakedObjectAction action, INakedObjectSpecification spec) {
     INakedObjectAction[] actions = spec.GetActionLeafNodes();
     Tuple<INakedObjectAction, string>[] overloadedActions = GetOverloadedActionsAndUIds(actions);
     return overloadedActions.Where(oa => oa.Item1 == action).Select(oa => oa.Item2).SingleOrDefault();
 }
 protected Data(INakedObjectSpecification type, IOid oid, IVersion version) {
     this.type = type.FullName;
     this.oid = oid;
     this.version = version;
 }
Exemple #23
0
 public override bool IsOfType(INakedObjectSpecification specification) {
     return specification == this;
 }
Exemple #24
0
        public static Tuple<INakedObjectAction, string> GetActionandUidFromSpec(INakedObjectSpecification spec, string actionName, string typeName) {
            INakedObjectAction[] actions = spec.GetActionLeafNodes();
            INakedObjectAction action = actions.SingleOrDefault(p => p.Id == actionName) ?? GetOverloadedAction(actionName, spec);

            if (action == null) {
                throw new TypeActionResourceNotFoundNOSException(actionName, typeName);
            }

            string uid = GetOverloadedUId(action, spec);
            return new Tuple<INakedObjectAction, string>(action, uid);
        }
Exemple #25
0
 public void SetupSpecification(INakedObjectSpecification spec) {
     specification = spec;
 }
 public NotContributedActionFacetImpl(IFacetHolder holder, INakedObjectSpecification[] notContributedToTypes) : base(holder, notContributedToTypes) {}
 public static INakedObject CreateTransientInstance(INakedObjectSpecification specification) {
     return NakedObjectsContext.ObjectPersistor.CreateInstance(specification);
 }
 private static IQueryable<IOid> LoadInstances(INakedObjectSpecification spec) {
     List<IOid> instances = LoadInstances(spec.FullName).ToList();
     foreach (INakedObjectSpecification subSpec in spec.Subclasses) {
         instances.AddRange(LoadInstances(subSpec).ToList());
     }
     return instances.AsQueryable();
 }
 public IQueryable<ObjectData> GetInstances(INakedObjectSpecification specification) {
     return null;
 }
 public virtual IQueryable<ObjectData> GetInstances(INakedObjectSpecification specification) {
     EnsureTypesLoaded();
     return from instance in LoadInstances(specification)
            select (ObjectData) LoadData(instance);
 }
Exemple #31
0
 public static IEnumerable<object> CachedObjectsOfType(this HttpSessionStateBase session, INakedObjectSpecification spec, ObjectFlag flag = ObjectFlag.None) {
     return session.GetAndTidyCachedNakedObjectsOfType(spec, flag).Select(no => no.Object);
 }
        public void LoadNode(XElement Node, ref CollectionData collection, ref ObjectData objectData, ref string fieldName)
        {
            string tag = Node.Name.LocalName;

            if (objectData != null)
            {
                if (tag.Equals("value"))
                {
                    fieldName = Node.Attribute("field").Value;
                    objectData.SetField(fieldName, Node.Value);
                }
                else if (tag.Equals("inline"))
                {
                    CollectionData sinkCollection   = null;
                    ObjectData     inlineObjectData = null;
                    string         sinkName         = "";
                    fieldName = Node.Attribute("field").Value;
                    LoadNode(Node.Element("naked-object"), ref sinkCollection, ref inlineObjectData, ref sinkName);
                    objectData.SetField(fieldName, inlineObjectData);
                }
                else if (tag.Equals("association"))
                {
                    fieldName = Node.Attribute("field").Value;
                    long id = Convert.ToInt64(Node.Attribute("ref").Value, 16);
                    objectData.SetField(fieldName, SerialOid.CreatePersistent(id, Node.Attribute("Type").Value));
                }
                else if (tag.Equals("element"))
                {
                    long id = Convert.ToInt64(Node.Attribute("ref").Value, 16);
                    objectData.AddElement(fieldName, SerialOid.CreatePersistent(id, Node.Attribute("Type").Value));
                }
                else if (tag.Equals("multiple-association"))
                {
                    fieldName = Node.Attribute("field").Value;
                    objectData.InitCollection(fieldName);
                }
            }
            else if (collection != null)
            {
                if (tag.Equals("element"))
                {
                    long id = Convert.ToInt64(Node.Attribute("ref").Value, 16);
                    collection.AddElement(SerialOid.CreatePersistent(id, Node.Attribute("Type").Value));
                }
            }
            else
            {
                if (tag.Equals("naked-object"))
                {
                    string   type    = Node.Attribute("Type").Value;
                    string   user    = Node.Attribute("user").Value;
                    IVersion version = GetVersion(Node, user);
                    IOid     oid     = GetOid(Node, type);
                    INakedObjectSpecification spec = NakedObjectsContext.Reflector.LoadSpecification(type);

                    objectData = new ObjectData(spec, oid, version);
                }
                else if (tag.Equals("collection"))
                {
                    string type    = Node.Attribute("Type").Value;
                    long   version = Convert.ToInt64(Node.Attribute("ver").Value, 16);
                    string user    = Node.Attribute("user").Value;
                    long   id      = Convert.ToInt64(Node.Attribute("id").Value, 16);
                    INakedObjectSpecification spec = NakedObjectsContext.Reflector.LoadSpecification(type);
                    IOid oid = SerialOid.CreatePersistent(id, type);
                    collection = new CollectionData(spec, oid, new FileVersion(user, version));
                }
                else
                {
                    throw new XmlException("Invalid data");
                }
            }
        }
Exemple #33
0
 public ProgrammableNakedObject(object  poco, INakedObjectSpecification specification) {
     this.poco = poco;
     this.specification = specification;
 }
Exemple #34
0
 public INakedObject CreateCollectionAdapter(object collection, INakedObjectSpecification elementSpecification) {
     return null;
 }