示例#1
0
        private void OnModelModified(object sender, EventArgs e)
        {
            //
            // Model has, ViewModel has not
            //
            foreach (var umlClass in Model.Classes)
            {
                if (GetDiagramClass(umlClass) == null)
                {
                    AddClassFromModel(umlClass);
                }
            }
            foreach (var umlRelation in Model.Relations)
            {
                if (GetDiagramRelation(umlRelation) == null)
                {
                    AddRelationFromModel(umlRelation);
                }
            }
            //
            // ViewModel has, Model has not
            //
            List <UmlDiagramClass> classesToRemove = new List <UmlDiagramClass>();

            foreach (var umlDiagramClass in Classes)
            {
                if (!Model.Classes.Contains(umlDiagramClass.Class))
                {
                    classesToRemove.Add(umlDiagramClass);
                }
            }
            foreach (var umlDiagramClass in classesToRemove)
            {
                RemoveDiagramClass(umlDiagramClass);
                // At this point, we know that the umlClass is not present in the Model.
                // Hence, at this point we should remove the name from the class list (autocompletebox).
                if (ClassNames.Contains(umlDiagramClass.Name))
                {
                    ClassNames.Remove(umlDiagramClass.Name);
                }
            }

            List <UmlDiagramRelation> relationsToRemove = new List <UmlDiagramRelation>();

            foreach (var umlDiagramRelation in Relations)
            {
                if (!Model.Relations.Contains(umlDiagramRelation.Relation))
                {
                    relationsToRemove.Add(umlDiagramRelation);
                }
            }
            foreach (var umlDiagramRelation in relationsToRemove)
            {
                RemoveDiagramRelation(umlDiagramRelation);
            }
        }
示例#2
0
 /// <summary>
 /// 未解決の参照のコピー
 /// </summary>
 /// <param name="desc">コピー対象</param>
 public void CopyUnknownReferences(ref AnalyzeResult desc)
 {
     foreach (var reference in UnknownReferences.Keys)
     {
         if (!ClassNames.Contains(reference))
         {
             desc.UnknownReferences.Add(reference, null);
         }
     }
 }
示例#3
0
 private void AddClass(UmlDiagramClass umlDiagramClass)
 {
     if (!classes.Contains(umlDiagramClass))
     {
         AddNode(umlDiagramClass);
         classes.Add(umlDiagramClass);
         if (!ClassNames.Contains(umlDiagramClass.Name))
         {
             ClassNames.Add(umlDiagramClass.Name);
         }
     }
 }
示例#4
0
    private TreeNode CreateTreeNode(CMS.DocumentEngine.TreeNode Node)
    {
        string tooltip    = null;
        string customName = null;

        if ((!string.IsNullOrWhiteSpace(ToolTipFormat) || !string.IsNullOrWhiteSpace(DisplayNameFormat)) && AllowedPageTypes.ToLower().Split(";,|".ToCharArray()).Contains(Node.NodeClassName.ToLower()))
        {
            MacroResolver NodeResolver = GetNodeMacroResolver(Node);
            if (!string.IsNullOrWhiteSpace(ToolTipFormat))
            {
                tooltip = NodeResolver.ResolveMacros(ToolTipFormat);
            }
            if (!string.IsNullOrWhiteSpace(DisplayNameFormat))
            {
                customName = NodeResolver.ResolveMacros(DisplayNameFormat);
            }
        }

        RelatedPage_Tree_CustomTreeNode newNode = new RelatedPage_Tree_CustomTreeNode((!string.IsNullOrWhiteSpace(customName) ? customName : Node.NodeName), Node.NodeID.ToString(), tooltip);

        if (AlreadySelectedNodes.Contains(Node.NodeID) || (FilterSelectableNodes && !SelectableSelectedNodes.Contains(Node.NodeID)))
        {
            newNode.SelectAction       = TreeNodeSelectAction.None;
            newNode.ShowCheckBox       = false;
            newNode.Text               = newNode.Text;
            newNode.CssClass           = "AlreadySelected";
            newNode.PossiblySelectable = AlreadySelectedNodes.Contains(Node.NodeID);
        }
        else
        {
            if ((AllowAllTypes || ClassNames.Contains(Node.ClassName)))
            {
                newNode.PossiblySelectable = true;
                newNode.CssClass           = "Selectable";
                if (SelectionMode == "Checkbox")
                {
                    newNode.ShowCheckBox = true;
                    newNode.SelectAction = TreeNodeSelectAction.None;
                }
                else
                {
                    newNode.SelectAction = TreeNodeSelectAction.Select;
                }
            }
            else
            {
                newNode.SelectAction = TreeNodeSelectAction.None;
                newNode.CssClass     = "NotSelectable";
            }
        }
        return(newNode);
    }
        public IEnumerable <TypeDefinition> FindTypesToProcess()
        {
            foreach (var type in ModuleDefinition.GetTypes())
            {
                if (!type.IsClass)
                {
                    continue;
                }

                if (type.IsAbstract)
                {
                    continue;
                }

                var dependencyChain = GetParentsChain(type);
                // dot not forget to add self type if it has no derived types
                dependencyChain.Add(type);

                var baseType = dependencyChain.FirstOrDefault(t => ClassNames.Contains(t.FullName));

                if (baseType == null)
                {
                    continue;
                }

                // process instance-only constructors
                var constructors = GetConstructorsToInject(type);

                // skip class with single constructor
                if (!constructors.Any())
                {
                    continue;
                }

                yield return(type);
            }
        }
示例#6
0
        private void CreateFunction(CommandSchema commandSchema)
        {
            Function function;
            string   key   = commandSchema.FullName;
            bool     isNew = !Database.Functions.Contains(key);

            if (isNew)
            {
                function = new Function(key);
                Database.Functions.Add(function);
            }
            else
            {
                function = Database.Functions[key];
            }

            //Function/@Method is safe to update
            if (string.IsNullOrEmpty(function.Method))
            {
                string methodName = ToLegalName(commandSchema.Name);
                if (ClassNames.Contains(methodName))
                {
                    methodName += "Procedure";
                }

                function.Method = MakeUnique(FunctionNames, methodName);
            }

            function.IsComposable = IsFunction(commandSchema);

            ParameterSchema returnParameter = null;

            function.Parameters.Clear();
            foreach (ParameterSchema p in commandSchema.Parameters)
            {
                if (p.Direction == System.Data.ParameterDirection.ReturnValue)
                {
                    returnParameter = p;
                }
                else
                {
                    CreateParameter(function, p);
                }
            }

            try
            {
                for (int i = 0; i < commandSchema.CommandResults.Count; i++)
                {
                    var    r           = commandSchema.CommandResults[i];
                    string defaultName = function.Method + "Result";
                    if (commandSchema.CommandResults.Count > 1)
                    {
                        defaultName += (i + 1).ToString();
                    }

                    CreateResult(function, r, defaultName, i);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error reading result schema: " + ex.Message);
            }

            function.HasMultipleResults = function.Types.Count > 1;
            function.IsProcessed        = true;

            if (function.Types.Count != 0)
            {
                return;
            }

            if (function.Return == null)
            {
                function.Return = new Return("System.Int32");
            }

            if (commandSchema.ReturnValueParameter != null)
            {
                function.Return.Type   = GetSystemType(commandSchema.ReturnValueParameter);
                function.Return.DbType = GetDbType(commandSchema.ReturnValueParameter);
            }
            else if (returnParameter != null)
            {
                function.Return.Type   = GetSystemType(returnParameter);
                function.Return.DbType = GetDbType(returnParameter);
            }
            else
            {
                function.Return.Type   = "System.Int32";
                function.Return.DbType = "int";
            }
        }
    /// <summary>
    /// Saves relationship.
    /// </summary>
    public void SaveRelationship()
    {
        if (TreeNode == null)
        {
            return;
        }

        // Check modify permissions
        if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
        {
            return;
        }

        bool currentNodeIsOnLeftSide = !DefaultSide;

        // Selected node Id
        int selectedNodeId = ValidationHelper.GetInteger(hdnSelectedNodeId.Value, 0);

        if (BindOnPrimaryNodeOnly)
        {
            selectedNodeId = RelHelper.GetPrimaryNodeID(selectedNodeId);
        }

        var relationshipName     = RelationshipName;
        var relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipName);

        int relationshipNameId;

        if (relationshipNameInfo != null)
        {
            relationshipNameId = relationshipNameInfo.RelationshipNameId;
        }
        else
        {
            throw new NullReferenceException("[RelatedDocuments.SaveRelationship]: Missing relationship name to use for relation.");
        }

        if ((selectedNodeId <= 0) || (relationshipNameId <= 0))
        {
            return;
        }

        try
        {
            // Test to make sure the selected page is a Right Side macro-allowed page or left side, and also matches the Page type limiter
            var SelectedTreeNode = (AllowAllTypes ? new DocumentQuery() : new DocumentQuery(AllowedPageTypes)).WhereEquals("NodeID", selectedNodeId).FirstOrDefault();

            // If null probably not an allowed page type, but we will need it to validate below
            if (SelectedTreeNode == null)
            {
                SelectedTreeNode = new DocumentQuery().WhereEquals("NodeID", selectedNodeId).FirstOrDefault();
            }
            var CurrentPageMacroResolver = MacroResolver.GetInstance();
            CurrentPageMacroResolver.SetNamedSourceData("CurrentDocument", TreeNode);
            var PageMacroResolver = MacroResolver.GetInstance();
            PageMacroResolver.SetNamedSourceData("CurrentDocument", SelectedTreeNode);

            // Left side
            if (currentNodeIsOnLeftSide)
            {
                if (!AllowAllTypes && !ClassNames.Contains(SelectedTreeNode.ClassName.ToLower()))
                {
                    AddError(ResHelper.LocalizeExpression("RelatedPages.BadPageType"));
                }
                else if (!ValidationHelper.GetBoolean(CurrentPageMacroResolver.ResolveMacros(IsLeftSideMacro), false) || !ValidationHelper.GetBoolean(PageMacroResolver.ResolveMacros(IsRightSideMacro), false))
                {
                    AddError(ResHelper.LocalizeExpression("RelatedPages.LeftSideRightSideInvalid"));
                }
                else if (TreeNode.NodeID == SelectedTreeNode.NodeID)
                {
                    AddError(ResHelper.LocalizeExpression("RelatedPages.CannotSelectSelf"));
                }
                else
                {
                    RelationshipInfoProvider.AddRelationship(TreeNode.NodeID, selectedNodeId, relationshipNameId);

                    if (RelHelper.IsStagingEnabled())
                    {
                        // Log synchronization
                        DocumentSynchronizationHelper.LogDocumentChange(TreeNode.NodeSiteName, TreeNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, TreeProvider);
                    }

                    ShowConfirmation(GetString("relationship.wasadded"));
                }
            }
            // Right side
            else
            {
                if (!AllowAllTypes && !ClassNames.Contains(SelectedTreeNode.ClassName.ToLower()))
                {
                    AddError(ResHelper.LocalizeExpression("RelatedPages.BadPageType"));
                }
                else if (!ValidationHelper.GetBoolean(CurrentPageMacroResolver.ResolveMacros(IsLeftSideMacro), false) || !ValidationHelper.GetBoolean(PageMacroResolver.ResolveMacros(IsRightSideMacro), false))
                {
                    AddError(ResHelper.LocalizeExpression("RelatedPages.LeftSideRightSideInvalid"));
                }
                else if (TreeNode.NodeID == SelectedTreeNode.NodeID)
                {
                    AddError(ResHelper.LocalizeExpression("RelatedPages.CannotSelectSelf"));
                }
                else
                {
                    RelationshipInfoProvider.AddRelationship(selectedNodeId, TreeNode.NodeID, relationshipNameId);

                    if (RelHelper.IsStagingEnabled())
                    {
                        // Log synchronization
                        DocumentSynchronizationHelper.LogDocumentChange(TreeNode.NodeSiteName, SelectedTreeNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, TreeProvider);
                    }

                    ShowConfirmation(GetString("relationship.wasadded"));
                }
            }
        }
        catch (Exception ex)
        {
            ShowError(ex.Message);
        }
    }