Exemplo n.º 1
0
        /// <summary>
        /// Finalize. This method is called on each copied element once all the elements and links are processed.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        public virtual void ModelFinalize(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                Guid elementID             = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelFinalize(elementP, groupMerger);
                }

                NodeShape shape = this.Store.ElementDirectory.FindElement(
                    groupMerger.GetIdMapping(protoElement.ElementId)) as NodeShape;

                // restore layout
                Store store = new Microsoft.VisualStudio.Modeling.Store(typeof(DiagramsDSLDomainModel));

                LayoutInfo info;
                using (Transaction t = store.TransactionManager.BeginTransaction())
                {
                    info = options.GetLayoutInfo(store);
                    t.Commit();
                }
                LayoutHelper.ApplyLayout(this, this.Diagram, info);
                store.Dispose();

                if (!shape.IsRelativeChildShape)
                {
                    shape.SetLocation(new PointD(RelativePastePoint.X + options.RelativeLocation.X,
                                                 RelativePastePoint.Y + options.RelativeLocation.Y));
                }
            }
        }
Exemplo n.º 2
0
        public PrecedenseOrderForm(nHydrateModel model, Microsoft.VisualStudio.Modeling.Store store)
            : this()
        {
            _model = model;
            _store = store;

            var list = PrecedenceUtil.GetAllPrecedenceItems(_model).ToList();

            list.Sort(new PrecedenseComparer());
            LoadGrid(list);
        }
Exemplo n.º 3
0
		public PrecedenseOrderForm(nHydrateModel model, Microsoft.VisualStudio.Modeling.Store store)
			: this()
		{
			_model = model;
			_store = store;

			var list = PrecedenceUtil.GetAllPrecedenceItems(_model).ToList();
			list.Sort(new PrecedenseComparer());
			LoadGrid(list);

		}
Exemplo n.º 4
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (this.store != null)
         {
             this.store.Dispose();
             this.store = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
Exemplo n.º 5
0
 public override void Initialize()
 {
     base.Initialize();
     if (!base.Errors.HasErrors)
     {
         IServiceProvider serviceProvider = this.ServiceProvider;
         if (serviceProvider != null)
         {
             this.store = new Microsoft.VisualStudio.Modeling.Store(serviceProvider, new Type[0]);
         }
         else
         {
             this.store = new Microsoft.VisualStudio.Modeling.Store(new Type[0]);
         }
         Type[] domainModelTypes = this.domainModels.ToArray();
         this.Store.LoadDomainModels(domainModelTypes);
     }
 }
Exemplo n.º 6
0
        private string CreateEmptyStateFile(string fileName)
        {
            string       savedFile;
            ProductState emptyStore;

            using (var dslStore = new Dsl.Store(typeof(Dsl.CoreDomainModel), typeof(ProductStateStoreDomainModel)))
            {
                using (var tx = dslStore.TransactionManager.BeginTransaction())
                {
                    emptyStore = dslStore.ElementFactory.CreateElement <ProductState>();
                    tx.Commit();
                }

                tracer.Verbose(Resources.PatternManager_TraceSavingDefaultEmptyState, fileName);
                savedFile = this.SaveModel(emptyStore, fileName);
            }

            return(savedFile);
        }
Exemplo n.º 7
0
        public static void LoadFromDisk(nHydrateModel model, string rootFolder, Microsoft.VisualStudio.Modeling.Store store, string modelName)
        {
            model.IsSaving = true;
            try
            {
                var modelFile = Path.Combine(rootFolder, modelName);
                var fi        = new FileInfo(modelFile);
                var showError = (fi.Length > 10); //New file is small so show no error if creating new

                var folderName  = modelName.Replace(".nhydrate", ".model");
                var modelFolder = GetModelFolder(rootFolder, folderName);

                //If the model folder does NOT exist
                if (showError && !Directory.Exists(modelFolder))
                {
                    //Try to use the ZIP file
                    var compressedFile = Path.Combine(rootFolder, modelName + ".zip");
                    if (!File.Exists(compressedFile))
                    {
                        MessageBox.Show("The model folder was not found and the ZIP file is missing. One of these must exist to continue.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //Unzip the whole file
                    //System.IO.Compression.ZipFile.ExtractToDirectory(compressedFile, rootFolder);
                    ExtractToDirectory(compressedFile, rootFolder, false);
                }

                nHydrate.Dsl.Custom.SQLFileManagement.LoadFromDisk(model.Views, model, modelFolder, store); //must come before entities
                nHydrate.Dsl.Custom.SQLFileManagement.LoadFromDisk(model.Entities, model, modelFolder, store);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                model.IsSaving = false;
            }
        }
Exemplo n.º 8
0
        public static void LoadFromDisk(nHydrateModel model, string rootFolder, Microsoft.VisualStudio.Modeling.Store store, string modelName)
        {
            model.IsSaving = true;
            try
            {
                bool wasLoaded;
                var  diskModel = FileManagement.Load(rootFolder, modelName, out wasLoaded);
                if (wasLoaded)
                {
                    model.EmitChangeScripts = diskModel.ModelProperties.EmitChangeScripts;
                    model.CompanyName       = diskModel.ModelProperties.CompanyName;
                    model.EmitSafetyScripts = diskModel.ModelProperties.EmitSafetyScripts;
                    model.DefaultNamespace  = diskModel.ModelProperties.DefaultNamespace;
                    model.ProjectName       = diskModel.ModelProperties.ProjectName;
                    model.UseUTCTime        = diskModel.ModelProperties.UseUTCTime;
                    model.Version           = diskModel.ModelProperties.Version;
                    //model.Id = new Guid(diskModel.ModelProperties.Id);
                    model.TenantColumnName           = diskModel.ModelProperties.TenantColumnName;
                    model.CreatedByColumnName        = diskModel.ModelProperties.CreatedByColumnName;
                    model.CreatedDateColumnName      = diskModel.ModelProperties.CreatedDateColumnName;
                    model.ModifiedByColumnName       = diskModel.ModelProperties.ModifiedByColumnName;
                    model.ModifiedDateColumnName     = diskModel.ModelProperties.ModifiedDateColumnName;
                    model.ConcurrencyCheckColumnName = diskModel.ModelProperties.ConcurrencyCheckColumnName;
                    model.GrantUser = diskModel.ModelProperties.GrantExecUser;

                    nHydrate.Dsl.Custom.SQLFileManagement.LoadFromDisk(model.Views, model, diskModel); //must come before entities
                    nHydrate.Dsl.Custom.SQLFileManagement.LoadFromDisk(model.Entities, model, diskModel);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                model.IsSaving = false;
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Reads the model into the given store and returns it.
 /// </summary>
 public static IProductState Read(Dsl.SerializationResult result, Dsl.Store store, string modelFile)
 {
     return(ProductStateStoreSerializationHelper.Instance.LoadModel(result, store, modelFile, null, null, null));
 }
Exemplo n.º 10
0
 public ImportColumns(IFieldContainer entity, Microsoft.VisualStudio.Modeling.Store store)
     : this()
 {
     _store  = store;
     _entity = entity;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Finalize. This method is called on each copied element once all the elements and links are processed.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and 
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        public virtual void ModelFinalize(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                Guid elementID = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelFinalize(elementP, groupMerger);
                }

                NodeShape shape = this.Store.ElementDirectory.FindElement(
                    groupMerger.GetIdMapping(protoElement.ElementId)) as NodeShape;

                // restore layout
                Store store = new Microsoft.VisualStudio.Modeling.Store(typeof(DiagramsDSLDomainModel));
                
                LayoutInfo info;
                using (Transaction t = store.TransactionManager.BeginTransaction())
                {
                    info = options.GetLayoutInfo(store);
                    t.Commit();
                }
                LayoutHelper.ApplyLayout(this, this.Diagram, info);
                store.Dispose();

                if (!shape.IsRelativeChildShape)
                {
                    shape.SetLocation(new PointD(RelativePastePoint.X + options.RelativeLocation.X,
                            RelativePastePoint.Y + options.RelativeLocation.Y));
                }
            }
        }
Exemplo n.º 12
0
        private static void LoadFromDisk(IEnumerable <View> list, nHydrateModel model, string rootFolder, Microsoft.VisualStudio.Modeling.Store store)
        {
            var folder = Path.Combine(rootFolder, FOLDER_VW);

            if (!Directory.Exists(folder))
            {
                return;
            }

            #region Load other parameter/field information
            var fList = Directory.GetFiles(folder, "*.configuration.xml");
            foreach (var f in fList)
            {
                var document = new XmlDocument();
                try
                {
                    document.Load(f);
                }
                catch (Exception ex)
                {
                    //Do Nothing
                    MessageBox.Show("The file '" + f + "' is not valid and could not be loaded!", "Load Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var fi     = new FileInfo(f);
                var name   = fi.Name.Substring(0, fi.Name.Length - ".configuration.xml".Length).ToLower();
                var itemID = XmlHelper.GetAttributeValue(document.DocumentElement, "id", Guid.Empty);
                var item   = list.FirstOrDefault(x => x.Id == itemID);
                if (item == null)
                {
                    item = new View(model.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, XmlHelper.GetAttributeValue(document.DocumentElement, "id", Guid.NewGuid())) });
                    model.Views.Add(item);
                }

                System.Windows.Forms.Application.DoEvents();

                item.Name                   = XmlHelper.GetAttributeValue(document.DocumentElement, "name", item.Name);
                item.CodeFacade             = XmlHelper.GetAttributeValue(document.DocumentElement, "codefacade", item.CodeFacade);
                item.Schema                 = XmlHelper.GetAttributeValue(document.DocumentElement, "schema", item.Schema);
                item.GeneratesDoubleDerived = XmlHelper.GetAttributeValue(document.DocumentElement, "generatesdoublederived", item.GeneratesDoubleDerived);
                item.Summary                = XmlHelper.GetNodeValue(document.DocumentElement, "summary", item.Summary);

                //Fields
                var fieldsNodes = document.DocumentElement.SelectSingleNode("//fieldset");
                if (fieldsNodes != null)
                {
                    var nameList = new List <string>();
                    foreach (XmlNode n in fieldsNodes.ChildNodes)
                    {
                        var subItemID = XmlHelper.GetAttributeValue(n, "id", Guid.Empty);
                        var field     = item.Fields.FirstOrDefault(x => x.Id == subItemID);
                        if (field == null)
                        {
                            field = new ViewField(item.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, XmlHelper.GetAttributeValue(n, "id", Guid.NewGuid())) });
                            item.Fields.Add(field);
                        }

                        field.Name       = XmlHelper.GetAttributeValue(n, "name", field.Name);
                        field.CodeFacade = XmlHelper.GetAttributeValue(n, "codefacade", field.CodeFacade);
                        nameList.Add(field.Name.ToLower());
                        field.Nullable = XmlHelper.GetAttributeValue(n, "nullable", field.Nullable);
                        var dtv = XmlHelper.GetAttributeValue(n, "datatype", field.DataType.ToString());
                        if (Enum.TryParse <DataTypeConstants>(dtv, true, out var dt))
                        {
                            field.DataType = dt;
                        }
                        field.Default      = XmlHelper.GetAttributeValue(n, "default", field.Default);
                        field.Length       = XmlHelper.GetAttributeValue(n, "length", field.Length);
                        field.Scale        = XmlHelper.GetAttributeValue(n, "scale", field.Scale);
                        field.Summary      = XmlHelper.GetNodeValue(n, "summary", field.Summary);
                        field.IsPrimaryKey = XmlHelper.GetAttributeValue(n, "isprimarykey", field.IsPrimaryKey);
                    }
                    if (item.Fields.Remove(x => !nameList.Contains(x.Name.ToLower())) > 0)
                    {
                        item.nHydrateModel.IsDirty = true;
                    }
                }
            }
            #endregion

            #region Load SQL
            fList = Directory.GetFiles(folder, "*.sql");
            foreach (var f in fList)
            {
                var fi = new FileInfo(f);
                if (fi.Name.ToLower().EndsWith(".sql"))
                {
                    var name = fi.Name.Substring(0, fi.Name.Length - 4).ToLower();
                    var item = list.FirstOrDefault(x => x.Name.ToLower() == name);
                    if (item != null)
                    {
                        item.SQL = File.ReadAllText(f);
                        System.Windows.Forms.Application.DoEvents();
                    }
                }
            }
            #endregion
        }
Exemplo n.º 13
0
        private static void LoadFromDisk(IEnumerable <Entity> list, nHydrateModel model, string rootFolder, Microsoft.VisualStudio.Modeling.Store store)
        {
            var folder = Path.Combine(rootFolder, FOLDER_ET);

            if (!Directory.Exists(folder))
            {
                return;
            }

            #region Load other parameter/field information
            var fList = Directory.GetFiles(folder, "*.configuration.xml");
            foreach (var f in fList)
            {
                var document = new XmlDocument();
                try
                {
                    document.Load(f);
                }
                catch (Exception ex)
                {
                    //Do Nothing
                    MessageBox.Show("The file '" + f + "' is not valid and could not be loaded!", "Load Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var fi     = new FileInfo(f);
                var name   = fi.Name.Substring(0, fi.Name.Length - ".configuration.xml".Length).ToLower();
                var itemID = XmlHelper.GetAttributeValue(document.DocumentElement, "id", Guid.Empty);
                var item   = list.FirstOrDefault(x => x.Id == itemID);
                if (item == null)
                {
                    item = new Entity(model.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, XmlHelper.GetAttributeValue(document.DocumentElement, "id", Guid.NewGuid())) });
                    model.Entities.Add(item);
                }

                System.Windows.Forms.Application.DoEvents();

                #region Properties

                item.Name                   = XmlHelper.GetAttributeValue(document.DocumentElement, "name", item.Name);
                item.AllowCreateAudit       = XmlHelper.GetAttributeValue(document.DocumentElement, "allowcreateaudit", item.AllowCreateAudit);
                item.AllowModifyAudit       = XmlHelper.GetAttributeValue(document.DocumentElement, "allowmodifyaudit", item.AllowModifyAudit);
                item.AllowTimestamp         = XmlHelper.GetAttributeValue(document.DocumentElement, "allowtimestamp", item.AllowTimestamp);
                item.CodeFacade             = XmlHelper.GetAttributeValue(document.DocumentElement, "codefacade", item.CodeFacade);
                item.Immutable              = XmlHelper.GetAttributeValue(document.DocumentElement, "immutable", item.Immutable);
                item.IsAssociative          = XmlHelper.GetAttributeValue(document.DocumentElement, "isassociative", item.IsAssociative);
                item.GeneratesDoubleDerived = XmlHelper.GetAttributeValue(document.DocumentElement, "generatesdoublederived", item.GeneratesDoubleDerived);
                item.IsTenant               = XmlHelper.GetAttributeValue(document.DocumentElement, "isTenant", item.IsTenant);

                var tev = XmlHelper.GetAttributeValue(document.DocumentElement, "typedentity", item.TypedEntity.ToString());
                if (Enum.TryParse <TypedEntityConstants>(tev, true, out var te))
                {
                    item.TypedEntity = te;
                }

                item.Schema  = XmlHelper.GetAttributeValue(document.DocumentElement, "schema", item.Schema);
                item.Summary = XmlHelper.GetNodeValue(document.DocumentElement, "summary", item.Summary);

                #endregion

                #region Fields

                var fieldsNodes = document.DocumentElement.SelectSingleNode("//fieldset");
                if (fieldsNodes != null)
                {
                    var nameList = new List <string>();
                    foreach (XmlNode n in fieldsNodes.ChildNodes)
                    {
                        var subItemID = XmlHelper.GetAttributeValue(n, "id", Guid.Empty);
                        var field     = item.Fields.FirstOrDefault(x => x.Id == subItemID);
                        if (field == null)
                        {
                            field = new Field(item.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, XmlHelper.GetAttributeValue(n, "id", Guid.NewGuid())) });
                            item.Fields.Add(field);
                        }
                        field.Name       = XmlHelper.GetAttributeValue(n, "name", string.Empty);
                        field.CodeFacade = XmlHelper.GetAttributeValue(n, "codefacade", field.CodeFacade);
                        nameList.Add(field.Name.ToLower());
                        field.Nullable = XmlHelper.GetAttributeValue(n, "nullable", field.Nullable);

                        var dtv = XmlHelper.GetAttributeValue(n, "datatype", field.DataType.ToString());
                        if (Enum.TryParse <DataTypeConstants>(dtv, true, out var dt))
                        {
                            field.DataType = dt;
                        }

                        var itv = XmlHelper.GetAttributeValue(n, "identity", field.Identity.ToString());
                        if (Enum.TryParse <IdentityTypeConstants>(itv, true, out var it))
                        {
                            field.Identity = it;
                        }

                        field.DataFormatString = XmlHelper.GetNodeValue(n, "dataformatstring", field.DataFormatString);
                        field.Default          = XmlHelper.GetAttributeValue(n, "default", field.Default);
                        field.DefaultIsFunc    = XmlHelper.GetAttributeValue(n, "defaultisfunc", field.DefaultIsFunc);
                        field.Formula          = XmlHelper.GetAttributeValue(n, "formula", field.Formula);
                        field.IsIndexed        = XmlHelper.GetAttributeValue(n, "isindexed", field.IsIndexed);
                        field.IsPrimaryKey     = XmlHelper.GetAttributeValue(n, "isprimarykey", field.IsPrimaryKey);
                        field.IsCalculated     = XmlHelper.GetAttributeValue(n, "Iscalculated", field.IsCalculated);
                        field.IsUnique         = XmlHelper.GetAttributeValue(n, "isunique", field.IsUnique);
                        field.Length           = XmlHelper.GetAttributeValue(n, "length", field.Length);
                        field.Scale            = XmlHelper.GetAttributeValue(n, "scale", field.Scale);
                        field.SortOrder        = XmlHelper.GetAttributeValue(n, "sortorder", field.SortOrder);
                        field.IsReadOnly       = XmlHelper.GetAttributeValue(n, "isreadonly", field.IsReadOnly);
                        field.Obsolete         = XmlHelper.GetAttributeValue(n, "obsolete", field.Obsolete);
                        field.Summary          = XmlHelper.GetNodeValue(n, "summary", field.Summary);
                    }
                    if (item.Fields.Remove(x => !nameList.Contains(x.Name.ToLower())) > 0)
                    {
                        item.nHydrateModel.IsDirty = true;
                    }
                }

                #endregion

                LoadEntityIndexes(folder, item);

                //Order fields (skip for model that did not have sort order when saved)
                var fc = new FieldOrderComparer();
                if (item.Fields.Count(x => x.SortOrder > 0) > 0)
                {
                    item.Fields.Sort(fc.Compare);
                }
            }

            //Must load relations AFTER ALL entities are loaded
            foreach (var item in model.Entities)
            {
                LoadEntityRelations(folder, item);
                LoadEntityStaticData(folder, item);
            }

            #endregion
        }
Exemplo n.º 14
0
        public virtual void Open(string storeFile, bool autoCreate = false)
        {
            Guard.NotNullOrEmpty(() => storeFile, storeFile);

            using (tracer.StartActivity(Resources.PatternManager_TraceOpeningStore, storeFile))
                using (new MouseCursor(System.Windows.Input.Cursors.Wait))
                {
                    if (this.IsOpen)
                    {
                        this.Close();
                    }

                    this.StoreFile = storeFile;
                    //tracer.TraceData(TraceEventType.Verbose, Resources.PatternManager_OpeningStoreEventId, storeFile);

                    if (autoCreate && (!File.Exists(storeFile) || new FileInfo(storeFile).Length == 0))
                    {
                        storeFile = CreateEmptyStateFile(storeFile);
                    }

                    //// Do NOT dispose the DSL state or it becomes null in the model elements!!
                    if (VerifyDslVersion(storeFile))
                    {
                        var result = new Dsl.SerializationResult();

                        var dslStore = new Dsl.Store(this.serviceProvider, typeof(Dsl.CoreDomainModel), typeof(ProductStateStoreDomainModel));

                        using (var tx = dslStore.TransactionManager.BeginTransaction(Resources.PatternManager_OpenTransactionDescription, true))
                        {
                            using (new StorePropertyBag(dslStore, ProductState.IsSerializingKey, true))
                            {
                                // Flag the state as being deserialized. This is
                                // required by the ProductState class to ignore
                                // element added events until deserialization is
                                // completed.

                                var store = ProductStateStoreSerializationHelper.Instance.LoadModel(result, dslStore, storeFile, null, null, null);

                                if (!result.Failed)
                                {
                                    this.productStore = store;
                                    tx.Commit();
                                }
                            }
                        }

                        if (!result.Failed)
                        {
                            this.IsOpen = true;

                            this.Store.TransactionCommited += this.OnTransactionCommitedDoSave;
                            this.Store.ElementInstantiated += this.OnElementInstantiated;
                            this.Store.ElementLoaded       += this.OnElementLoaded;
                            this.Store.ElementCreated      += this.OnElementCreated;
                            this.Store.ElementDeleted      += this.OnElementDeleted;
                            this.Store.ElementDeleting     += this.OnElementDeleting;

                            this.RaiseIsOpenChanged();

                            tracer.Info(Resources.PatternManager_OpenedStore, this.StoreFile);
                            //tracer.TraceData(TraceEventType.Verbose, Resources.PatternManager_OpenedStoreEventId, storeFile);
                        }
                        else
                        {
                            this.messageService.ShowError(
                                Properties.Resources.PatternManager_FailedToOpenStore);

                            tracer.Error(Properties.Resources.PatternManager_DeSerializationFailed, this.StoreFile);
                            result.ForEach(msg => tracer.Warn(msg.ToString()));
                        }
                    }
                }
        }
Exemplo n.º 15
0
            public void Initialize()
            {
                var serviceProvider = Mocks.Of <IServiceProvider>().First(provider =>
                                                                          provider.GetService(typeof(IPatternManager)) == Mocks.Of <IPatternManager>().First(manager =>
                                                                                                                                                             manager.InstalledToolkits == new IInstalledToolkitInfo[]
                {
                    Mocks.Of <IInstalledToolkitInfo>().First(toolkitInfo =>
                                                             toolkitInfo.Id == Ids.ValidExtensionToolkitId &&
                                                             toolkitInfo.Schema.Pattern.Id == Ids.ValidExtensionProductId &&
                                                             toolkitInfo.Schema.Pattern.ExtensionId == Ids.ValidExtensionToolkitId &&
                                                             toolkitInfo.Schema.Pattern.ProvidedExtensionPoints == new[]
                    {
                        Mocks.Of <IProvidedExtensionPointInfo>().First(extensionPoint => extensionPoint.ExtensionPointId == "ValidExtensionPointId")
                    }),
                    Mocks.Of <IInstalledToolkitInfo>().First(toolkitInfo =>
                                                             toolkitInfo.Id == Ids.InvalidExtensionToolkitId &&
                                                             toolkitInfo.Schema.Pattern.Id == Ids.InvalidExtensionProductId &&
                                                             toolkitInfo.Schema.Pattern.ExtensionId == Ids.InvalidExtensionToolkitId &&
                                                             toolkitInfo.Schema.Pattern.ProvidedExtensionPoints == new[]
                    {
                        Mocks.Of <IProvidedExtensionPointInfo>().First(extensionPoint => extensionPoint.ExtensionPointId == "InvalidExtensionPointId")
                    }),
                    Mocks.Of <IInstalledToolkitInfo>().First(toolkitInfo =>
                                                             toolkitInfo.Id == Ids.MainToolkitId &&
                                                             toolkitInfo.Schema.Pattern.Id == Ids.MainProductId &&
                                                             toolkitInfo.Schema.Pattern.Name == "Pattern" &&
                                                             toolkitInfo.Schema.Pattern.ExtensionId == Ids.MainToolkitId &&
                                                             toolkitInfo.Schema.Pattern.Views == new []
                    {
                        //  View
                        //      MainElement
                        //          MainCollection
                        //          MainExtensionPoint
                        Mocks.Of <IViewInfo>().First(view =>
                                                     view.Id == Ids.MainViewId &&
                                                     view.Name == "View" &&
                                                     view.Elements == new IAbstractElementInfo[]
                        {
                            Mocks.Of <IElementInfo>().First(element =>
                                                            element.Id == Ids.MainElementId &&
                                                            element.Name == "Element" &&
                                                            element.Cardinality == Cardinality.ZeroToMany &&
                                                            element.Elements == new IAbstractElementInfo[]
                            {
                                Mocks.Of <ICollectionInfo>().First(collection =>
                                                                   collection.Id == Ids.MainCollectionId &&
                                                                   collection.Name == "Collection" &&
                                                                   collection.Cardinality == Cardinality.ZeroToMany
                                                                   ),
                            } &&
                                                            element.ExtensionPoints == new IExtensionPointInfo[]
                            {
                                Mocks.Of <IExtensionPointInfo>().First(extensionPoint =>
                                                                       extensionPoint.Id == Ids.MainExtensionPointId &&
                                                                       extensionPoint.Name == "ExtensionPoint" &&
                                                                       extensionPoint.Cardinality == Cardinality.ZeroToMany &&
                                                                       extensionPoint.RequiredExtensionPointId == "ValidExtensionPointId"
                                                                       ),
                            }),
                        }),
                    }),
                })
                                                                          );

                using (var store = new Dsl.Store(serviceProvider, typeof(Dsl.CoreDomainModel), typeof(ProductStateStoreDomainModel)))
                    using (var tx = store.TransactionManager.BeginTransaction())
                    {
                        var productStore = store.ElementFactory.CreateElement <ProductState>();
                        productStore
                        .CreateProduct(p => { p.ExtensionId = Ids.MainToolkitId; p.DefinitionId = Ids.MainProductId; })
                        .CreateView(v => v.DefinitionId    = Ids.MainViewId)
                        .CreateElement(e => e.DefinitionId = Ids.MainElementId);

                        ProductStateStoreSerializationHelper.Instance.SaveModel(new Dsl.SerializationResult(), productStore, this.storeFilePath);
                        tx.Commit();
                    }

                this.store = new Dsl.Store(serviceProvider, typeof(Dsl.CoreDomainModel), typeof(ProductStateStoreDomainModel));
                using (var tx = this.store.TransactionManager.BeginTransaction("Loading", true))
                {
                    ProductStateStoreSerializationHelper.Instance.LoadModel(this.store, this.storeFilePath, null, null, null);
                    tx.Commit();

                    this.productStore = this.store.ElementDirectory.AllElements.OfType <ProductState>().First();
                }

                this.element = this.store.ElementDirectory.FindElements <Element>(true).First();
                this.view    = this.store.ElementDirectory.FindElements <View>(true).First();
            }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Property"/> class.
 /// </summary>
 /// <param name="store">Store where new element is to be created.</param>
 /// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
 public Property(Microsoft.VisualStudio.Modeling.Store store, params PropertyAssignment[] propertyAssignments)
     : this(store != null ? store.DefaultPartitionForClass(DomainClassId) : null, propertyAssignments)
 {
     this.propertyChangedSubscription = this.PropertyChanges.AddHandler(OnPropertyChanged);
 }
Exemplo n.º 17
0
            public void Initialize()
            {
                var serviceProvider = Mocks.Of<IServiceProvider>().First(provider =>
                    provider.GetService(typeof(IPatternManager)) == Mocks.Of<IPatternManager>().First(manager =>
                        manager.InstalledToolkits == new IInstalledToolkitInfo[]
                        {
                            Mocks.Of<IInstalledToolkitInfo>().First(toolkitInfo =>
                                toolkitInfo.Id == Ids.ValidExtensionToolkitId &&
                                toolkitInfo.Schema.Pattern.Id == Ids.ValidExtensionProductId &&
                                toolkitInfo.Schema.Pattern.ExtensionId == Ids.ValidExtensionToolkitId &&
                                toolkitInfo.Schema.Pattern.ProvidedExtensionPoints == new[]
                                {
                                    Mocks.Of<IProvidedExtensionPointInfo>().First(extensionPoint => extensionPoint.ExtensionPointId == "ValidExtensionPointId")
                                }),
                            Mocks.Of<IInstalledToolkitInfo>().First(toolkitInfo =>
                                toolkitInfo.Id == Ids.InvalidExtensionToolkitId &&
                                toolkitInfo.Schema.Pattern.Id == Ids.InvalidExtensionProductId &&
                                toolkitInfo.Schema.Pattern.ExtensionId == Ids.InvalidExtensionToolkitId &&
                                toolkitInfo.Schema.Pattern.ProvidedExtensionPoints == new[]
                                {
                                    Mocks.Of<IProvidedExtensionPointInfo>().First(extensionPoint => extensionPoint.ExtensionPointId == "InvalidExtensionPointId")
                                }),
                            Mocks.Of<IInstalledToolkitInfo>().First(toolkitInfo =>
                                toolkitInfo.Id == Ids.MainToolkitId &&
                                toolkitInfo.Schema.Pattern.Id == Ids.MainProductId &&
                                toolkitInfo.Schema.Pattern.Name == "Pattern" &&
                                toolkitInfo.Schema.Pattern.ExtensionId == Ids.MainToolkitId &&
                                toolkitInfo.Schema.Pattern.Views == new []
                                {
                                    Mocks.Of<IViewInfo>().First(view =>
                                        view.Id == Ids.MainViewId &&
                                        view.Name == "View" &&
                                        view.Elements == new IAbstractElementInfo[]
                                        {
                                            Mocks.Of<IElementInfo>().First(element =>
                                                element.Id == Ids.MainElementId &&
                                                element.Name == "Element" &&
                                                element.Cardinality == Cardinality.ZeroToMany &&
                                                element.ExtensionPoints == new []
                                                {
                                                    Mocks.Of<IExtensionPointInfo>().First(extensionPoint =>
                                                        extensionPoint.Id == Guid.NewGuid() &&
                                                        extensionPoint.Name == "ExtensionPoint" &&
                                                        extensionPoint.Cardinality == Cardinality.ZeroToMany &&
                                                        extensionPoint.RequiredExtensionPointId == "ValidExtensionPointId"
                                                        ),
                                                }),
                                            Mocks.Of<ICollectionInfo>().First(element =>
                                                element.Id == Ids.MainCollectionId &&
                                                element.Name == "Collection" &&
                                                element.Cardinality == Cardinality.ZeroToMany
                                                ),
                                        } &&
                                        view.ExtensionPoints == new []
                                        {
                                            Mocks.Of<IExtensionPointInfo>().First(extensionPoint =>
                                                extensionPoint.Id == Guid.NewGuid() &&
                                                extensionPoint.Name == "ExtensionPoint" &&
                                                extensionPoint.Cardinality == Cardinality.ZeroToMany &&
                                                extensionPoint.RequiredExtensionPointId == "ValidExtensionPointId"
                                                ),
                                        })
                                }),
                        })
                    );

                using (var store = new Dsl.Store(serviceProvider, typeof(Dsl.CoreDomainModel), typeof(ProductStateStoreDomainModel)))
                using (var tx = store.TransactionManager.BeginTransaction())
                {
                    var productStore = store.ElementFactory.CreateElement<ProductState>();
                    productStore
                        .CreateProduct(p => { p.ExtensionId = Ids.MainToolkitId; p.DefinitionId = Ids.MainProductId; })
                        .CreateView(v => v.DefinitionId = Ids.MainViewId);

                    ProductStateStoreSerializationHelper.Instance.SaveModel(new Dsl.SerializationResult(), productStore, this.storeFilePath);
                    tx.Commit();
                }

                this.store = new Dsl.Store(serviceProvider, typeof(Dsl.CoreDomainModel), typeof(ProductStateStoreDomainModel));
                using (var tx = this.store.TransactionManager.BeginTransaction("Loading", true))
                {
                    ProductStateStoreSerializationHelper.Instance.LoadModel(this.store, this.storeFilePath, null, null, null);
                    tx.Commit();
                }

                this.view = this.store.ElementDirectory.FindElements<ProductState>().First().Products.First().Views.First();
            }
Exemplo n.º 18
0
		public ImportColumns(IFieldContainer entity, Microsoft.VisualStudio.Modeling.Store store)
			: this()
		{
			_store = store;
			_entity = entity;
		}