示例#1
0
        public static HistoryEntry Deserialize(string s, IRDMPPlatformRepositoryServiceLocator locator)
        {
            var e = new HistoryEntry();

            try
            {
                var helper = new PersistStringHelper();
                e.Date = DateTime.Parse(helper.GetExtraText(s));

                var objectString = s.Substring(0, s.IndexOf(PersistStringHelper.ExtraText));


                e.Object = helper.GetObjectCollectionFromPersistString(objectString, locator).Single();
            }
            catch (PersistenceException)
            {
                return(null);
            }

            return(e);
        }
        public DeserializeInstruction ShouldCreateObjectCollection(string persistString, IRDMPPlatformRepositoryServiceLocator repositoryLocator)
        {
            if (!persistString.StartsWith(PersistableObjectCollectionDockContent.Prefix))
            {
                return(null);
            }

            if (!persistString.Contains(PersistStringHelper.ExtraText))
            {
                throw new PersistenceException("Persistence string did not contain '" + PersistStringHelper.ExtraText);
            }

            //Looks something like this  RDMPObjectCollection:MyCoolControlUI:MyControlUIsBundleOfObjects:[CatalogueRepository:AggregateConfiguration:105,CatalogueRepository:AggregateConfiguration:102,CatalogueRepository:AggregateConfiguration:101]###EXTRA_TEXT###I've got a lovely bunch of coconuts
            var tokens = persistString.Split(PersistStringHelper.Separator);

            var uiType         = GetTypeByName(tokens[1], typeof(Control), repositoryLocator);
            var collectionType = GetTypeByName(tokens[2], typeof(IPersistableObjectCollection), repositoryLocator);

            ObjectConstructor            objectConstructor  = new ObjectConstructor();
            IPersistableObjectCollection collectionInstance = (IPersistableObjectCollection)objectConstructor.Construct(collectionType);

            if (collectionInstance.DatabaseObjects == null)
            {
                throw new PersistenceException("Constructor of Type '" + collectionType + "' did not initialise property DatabaseObjects");
            }

            var allObjectsString = _persistStringHelper.MatchCollectionInString(persistString);

            collectionInstance.DatabaseObjects.AddRange(_persistStringHelper.GetObjectCollectionFromPersistString(allObjectsString, repositoryLocator));

            var extraText = _persistStringHelper.GetExtraText(persistString);

            collectionInstance.LoadExtraText(extraText);

            return(new DeserializeInstruction(uiType, collectionInstance));
        }