Exemplo n.º 1
0
    // Search Parent Button Code
    protected void Button1_Click(object sender, EventArgs e)
    {
        string parentUserName = Membership.GetUserNameByEmail(ParentEmail.Text);

        //MembershipUser parent = Membership.GetUser(parentUserName);
        ParentAssociation.DataSource = Membership.FindUsersByEmail(ParentEmail.Text);
        ParentAssociation.DataBind();
    }
 public VisualisableTypeWithAssociationsDataAdaptor(
     IEnumerable<FieldAssociation> allAssociations, IEnumerable<ParentAssociation> thisTypeImplements, ParentAssociation parent, VisualisableTypeData persistentDataField)
 {
     this.parent = parent;
     this.persistentDataField = persistentDataField;
     this.thisTypeImplements = thisTypeImplements;
     this.allAssociations = allAssociations;
 }
Exemplo n.º 3
0
        public override Path GetXPathFull(bool followGeneralizations = true)
        {
            UnionPath unionPath = new UnionPath(PSMSchema);

            List <Path> nonRecursionPaths = new List <Path>();

            #region parent track
            if (ParentAssociation != null)
            {
                Path parentPath = ParentAssociation.GetXPathFull(followGeneralizations).DeepCopy();
                nonRecursionPaths.Add(parentPath);
                unionPath.ComponentPaths.Add(parentPath);
            }
            #endregion

            #region generalizations tracks
            if (followGeneralizations)
            {
                foreach (PSMGeneralization generalization in this.GeneralizationsAsGeneral)
                {
                    Path specificClassPath = generalization.Specific.GetXPathFull(followGeneralizations);
                    unionPath.ComponentPaths.Add(specificClassPath);
                    nonRecursionPaths.Add(specificClassPath);
                }
            }

            #endregion

            #region  first find cycles

            List <PSMComponent> componentsParticipatingInCycles = new List <PSMComponent>();
            Dictionary <PSMAssociation, List <ModelIterator.PSMCycle> > cyclesForAssociations
                = new Dictionary <PSMAssociation, List <ModelIterator.PSMCycle> >();
            foreach (PSMAssociation association in ChildPSMAssociations)
            {
                List <ModelIterator.PSMCycle> cycles = ModelIterator.GetPSMCyclesStartingInAssociation(association,
                                                                                                       followGeneralizationsWhereAsGeneral
                                                                                                       : false,
                                                                                                       followGeneralizationsWhereAsSpecific
                                                                                                       : true);
                cyclesForAssociations.Add(association, cycles);

                foreach (ModelIterator.PSMCycle cycle in cycles)
                {
                    componentsParticipatingInCycles.AddRange(cycle);
                }
            }

            #endregion

            #region process incoming NTAs, which then will be also used as prefixes for cycles

            foreach (PSMAssociation incomingNTA in GetIncomingNonTreeAssociations())
            {
                if (componentsParticipatingInCycles.Contains(incomingNTA))
                {
                    continue;
                }
                Path ntaPath = incomingNTA.GetXPathFull(followGeneralizations);
                unionPath.ComponentPaths.Add(ntaPath);
                nonRecursionPaths.Add(ntaPath);
            }

            #endregion

            #region process cycles

            List <string> usedDescendants = new List <string>();
            foreach (KeyValuePair <PSMAssociation, List <ModelIterator.PSMCycle> > kvp in cyclesForAssociations)
            {
                PSMAssociation association           = kvp.Key;
                List <ModelIterator.PSMCycle> cycles = kvp.Value;

                foreach (ModelIterator.PSMCycle cycle in cycles)
                {
                    PSMAssociation lastNamedAssociation = cycle.GetLastNamedAssociation();
                    string         descendant           = lastNamedAssociation != null ? lastNamedAssociation.Name : null;
                    if (descendant != null && !usedDescendants.Contains(descendant))
                    {
                        foreach (Path nonRecursionPath in nonRecursionPaths)
                        {
                            Path       path       = nonRecursionPath.DeepCopy();
                            SimplePath simplePath = path as SimplePath;
                            bool       optimized  = false;
                            if (simplePath != null && simplePath.Steps.Any())
                            {
                                Step laststep = simplePath.Steps.Last();
                                if (laststep.NodeTest == descendant && laststep.Axis == Axis.child)
                                {
                                    laststep.Axis = Axis.descendant;
                                    optimized     = true;
                                }
                            }
                            if (!optimized)
                            {
                                Step step = new Step {
                                    Axis = Axis.descendant, NodeTest = descendant
                                };
                                path.AddStep(step);
                            }
                            unionPath.ComponentPaths.Add(path);
                        }
                        usedDescendants.Add(descendant);
                    }
                }
            }

            #endregion

            if (unionPath.ComponentPaths.Count == 1)
            {
                return(unionPath.ComponentPaths[0]);
            }
            else
            {
                return(unionPath);
            }
        }
Exemplo n.º 4
0
        public override Path GetXPathFull(bool followGeneralizations)
        {
            Path result = ParentAssociation.GetXPathFull().DeepCopy();

            return(result);
        }
        private static ParentAssociationData ConvertAndCache(ParentAssociation parentAssociation)
        {
            if (parentAssociation == null)
            {
                throw new ArgumentNullResourceException("parentAssociation", Resources.General_Given_Parameter_Cannot_Be_Null);
            }

            VisualisableTypeDataContainer typeData;
            if (!FieldDataCache.TryGetValue(parentAssociation.AssociatedTo.Id, out typeData))
            {
                typeData = new VisualisableTypeDataContainer();
                FieldDataCache.Add(parentAssociation.AssociatedTo.Id, typeData);
                typeData.Data = parentAssociation.AssociatedTo.ExtractPersistentData(); // Stack Overflow potential, be sure to cache converted types to ensure no circular references.
            }

            var parentData = new ParentAssociationData { Name = parentAssociation.Name, AssociatedTo = typeData.Data };

            if (typeData.Data == null)
            {
                // Should be free from memory leaks being a private class
                typeData.DataReady += (s, e) => parentData.AssociatedTo = typeData.Data;
            }

            // This must be stored in the cache before ExtractPersistentData is called, which is a recursive call and could cause infinite recursion.
            return parentData;
        }