public IEntityGraph <IEntityTypeDefinition> GetAll()
        {
            var elements = PackageXml.Element("umbPackage").Element("DocumentTypes").Elements("DocumentType");

            var returnVal = new EntityGraph <IEntityTypeDefinition>();

            foreach (var xElement in elements)
            {
                var xml = xElement;
                var id  = new StringIdentifier((string)xml.Element("Info").Element("Alias"), this.GetType().FullName);
                returnVal.Add(id, new Lazy <IEntityTypeDefinition>(() =>
                {
                    var info = xml.Element("Info");
                    var entityTypeDefinition = new DocType();
                    var root = new TypedEntityVertex().SetupRoot();
                    entityTypeDefinition.SetupTypeDefinition((string)info.Element("Alias"), (string)info.Element("Name"), root);
                    entityTypeDefinition.Id = id;

                    //find all the tabs so we can get the ID's off them
                    var tabs = xml.Element("Tabs").Elements("Tab");
                    foreach (var tab in tabs)
                    {
                        //get the repo to create the ID
                        var groupId = attributeGroupRepository.ResolveIdentifier((string)tab.Element("Caption"));
                        //resolve the group from the repo based on the ID schema
                        var group = attributeGroupRepository.Get(groupId);

                        //add the group to the attribute schema
                        entityTypeDefinition.AttributeSchema.AttributeGroupDefinitions.Add(group);
                    }

                    var properties = xml.Element("GenericProperties").Elements("GenericProperty");
                    foreach (var property in properties)
                    {
                        //TODO: Make this lazy, currently we're resolving all the attributes (and all its sub-graph) immediately...

                        //get the ID of the property using the repo to generate it
                        var attributeId = attributeRepository.ResolveIdentifier(entityTypeDefinition.Alias + "/" + (string)property.Element("Alias"));
                        //resolve the attribute
                        var attribute = attributeRepository.Get(attributeId);
                        //find the group that this attribute is associated with
                        var groupId = attributeGroupRepository.ResolveIdentifier((string)property.Element("Tab"));
                        var group   = attributeGroupRepository.Get(groupId);
                        //add this attribute to the group

                        group.AttributeDefinitions.Add(attribute);
                    }

                    return(entityTypeDefinition);
                }));
            }

            return(returnVal);
        }
        public TEntity Get(long id)
        {
            var entity = _readerDelegate.Get(id);

            _publisher.Publish(new DataEvent <TEntity>(entity, EventName <TEntity> .Read));
            return(entity);
        }
        public TEntity Get(long id)
        {
            var callerInfo = LoggingExtensions.Caller();

            return(_profiler.Profile(
                       () => _readerDelegate.Get(id),
                       $"{callerInfo} - id=[{id}]"
                       ));
        }
Esempio n. 4
0
 public TEntity Get(long id)
 {
     return(ReaderDelegate.Get(id));
 }