Example #1
0
 public ICompositePredicate AddInstanceof(IAssociationType association, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new AllorsPredicateAssociationInstanceofSql(this.extent, association, type, new List <IClass>(type.Classes).ToArray());
     return(this);
 }
 public IEnumerable <T> SelectMany <T>(IComposite <T> composite)
 {
     foreach (T item in composite.Items.SelectMany <T, T>(SelectMany))
     {
         yield return(item);
     }
 }
Example #3
0
        private static IPropertyType Resolve(IComposite composite, string propertyName)
        {
            var lowerCasePropertyName = propertyName.ToLowerInvariant();

            foreach (var roleType in composite.RoleTypes)
            {
                if (roleType.SingularName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    roleType.SingularFullName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    roleType.PluralName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    roleType.PluralFullName.ToLowerInvariant().Equals(lowerCasePropertyName))
                {
                    return(roleType);
                }
            }

            foreach (var associationType in composite.AssociationTypes)
            {
                if (associationType.SingularName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    associationType.SingularFullName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    associationType.SingularPropertyName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    associationType.PluralName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    associationType.PluralFullName.ToLowerInvariant().Equals(lowerCasePropertyName) ||
                    associationType.PluralPropertyName.ToLowerInvariant().Equals(lowerCasePropertyName))
                {
                    return(associationType);
                }
            }

            return(null);
        }
Example #4
0
        public static bool TryParse(IComposite composite, string fetchString, out Fetch fetch)
        {
            var propertyType = Resolve(composite, fetchString);

            fetch = propertyType == null ? null : new Fetch(propertyType);
            return(fetch != null);
        }
Example #5
0
        public bool ContainsConcreteClass(IComposite objectType, IObjectType concreteClass)
        {
            object concreteClassOrClasses;

            if (!this.concreteClassesByObjectType.TryGetValue(objectType, out concreteClassOrClasses))
            {
                if (objectType.ExistExclusiveClass)
                {
                    concreteClassOrClasses = objectType.ExclusiveClass;
                    this.concreteClassesByObjectType[objectType] = concreteClassOrClasses;
                }
                else
                {
                    concreteClassOrClasses = new HashSet <IObjectType>(objectType.Classes);
                    this.concreteClassesByObjectType[objectType] = concreteClassOrClasses;
                }
            }

            if (concreteClassOrClasses is IObjectType)
            {
                return(concreteClass.Equals(concreteClassOrClasses));
            }

            var concreteClasses = (HashSet <IObjectType>)concreteClassOrClasses;

            return(concreteClasses.Contains(concreteClass));
        }
Example #6
0
        /// <summary> Encodes a Composite in XML by looping through it's components, creating new
        /// children for each of them (with the appropriate names) and populating them by
        /// calling encode(Type, Element) using these children.  Returns true if at least
        /// one component contains a value.
        /// </summary>
        private bool EncodeComposite(IComposite datatypeObject, XmlElement datatypeElement)
        {
            var components = datatypeObject.Components;
            var hasValue   = false;

            for (var i = 0; i < components.Length; i++)
            {
                var name              = MakeElementName(datatypeObject, i + 1);
                var newNode           = datatypeElement.OwnerDocument.CreateElement(name);
                var componentHasValue = Encode(components[i], newNode);
                if (componentHasValue)
                {
                    try
                    {
                        datatypeElement.AppendChild(newNode);
                    }
                    catch (Exception e)
                    {
                        throw new DataTypeException("DOMException encoding Composite: ", e);
                    }

                    hasValue = true;
                }
            }

            return(hasValue);
        }
Example #7
0
 public ICompositePredicate AddInstanceof(IAssociationType association, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new AssociationInstanceOf(this.extent, association, type, CompositePredicate.GetConcreteSubClasses(type));
     return(this);
 }
Example #8
0
        public void AddItem(string path, IComposite item)
        {
            IComposite composite = this;

            var names = path.Split('/');

            foreach (var name in names)
            {
                var child = composite.GetItem(name);

                if (child == null)
                {
                    var itemType = item.GetType();

                    child      = (IComposite)Activator.CreateInstance(itemType);
                    child.Name = name;

                    composite.AddItem(child);
                }

                composite = child;
            }

            composite.AddItem(item);
        }
Example #9
0
 public ICompositePredicate AddInstanceof(IRoleType role, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new AllorsPredicateRoleInstanceofSql(this.extent, role, type, new List <IClass>(type.Classes).ToArray());
     return(this);
 }
Example #10
0
 public ICompositePredicate AddInstanceof(IRoleType role, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new RoleInstanceof(this.extent, role, type, CompositePredicate.GetConcreteSubClasses(type));
     return(this);
 }
Example #11
0
 public Composite(string inputDesc, string inputKey, IObservable inputObs)
 {
     desc     = inputDesc;
     key      = inputKey;
     obs      = inputObs;
     sonsList = new List <IComposite>();
     Parent   = null;
 }
Example #12
0
        internal RoleInstanceof(ExtentFiltered extent, IRoleType roleType, IComposite objectType)
        {
            extent.CheckForRoleType(roleType);
            PredicateAssertions.ValidateRoleInstanceOf(roleType, objectType);

            this.roleType = roleType;
            this.objectType = objectType;
        }
Example #13
0
        private void addDiagrams(IComposite leaf)
        {
            DiagramCreationContext context = new DiagramCreationContext();

            foreach (String i in utiliti.fm.GetFiles(leaf.GetPath()))
            {
                leaf.Add((IComposite)context.CreateDiagram(i));
            }
        }
        private static void TestLastResult(IComposite composite)
        {
            FakeProcesses.CreateNodes(composite, NodeStatus.Running, NodeStatus.Running, NodeStatus.Success);

            TestHelper.AssertResult(composite, NodeStatus.Running);
            TestHelper.AssertResult(composite, NodeStatus.Running);
            TestHelper.AssertResult(composite, NodeStatus.Success);
            TestHelper.AssertResult(composite, NodeStatus.Success);
        }
Example #15
0
        /// <summary>
        /// produces an enumerable from the composite by traversing the composite's tree
        /// in a depth-first preorder fashion
        /// </summary>
        /// <typeparam name="T">the type contained in the composite</typeparam>
        /// <param name="composite">the given composite</param>
        /// <returns>an enumerable from the composite by traversing the composite's tree
        /// in a depth-first preorder fashion</returns>
        public static IEnumerable <T> PreOrdered <T>(this IComposite <T> composite)
        {
            yield return(composite.Content);

            foreach (var t in composite.Children.SelectMany(child => child.PreOrdered()))
            {
                yield return(t);
            }
        }
        public void SetTree(IComposite root)
        {
            this.root = root;
            ContainerTreeNode node = CreateContainerNode(root, true);

            RefreshImagesIndexes(node, false);
            treeView1.Nodes.Add(node);
            node.ContextMenuStrip = rootMenuStrip;
            BuildBranch(new ContainerTreeNode(root), true);
        }
 /// <summary>
 /// Called when a model is removed from a model composite
 /// </summary>
 private void OnModelRemoved( IComposite<IPlanetEnvironmentModel> composite, IPlanetEnvironmentModel component )
 {
     IPlanetEnvironmentRenderer[] renderers;
     if ( !m_RendererMap.TryGetValue( component, out renderers ) )
     {
         return;
     }
     foreach ( IPlanetEnvironmentRenderer renderer in renderers )
     {
         renderer.PlanetRenderer = null;
     }
     m_RendererMap.Remove( component );
 }
 /// <summary>
 /// Called when a model is added to a model composite
 /// </summary>
 private void OnModelAdded( IComposite<IPlanetEnvironmentModel> composite, IPlanetEnvironmentModel component )
 {
     IPlanetEnvironmentRenderer[] renderers = m_RendererFactory.CreateModelRenderer( component );
     if ( renderers == null )
     {
         return;
     }
     foreach ( IPlanetEnvironmentRenderer renderer in renderers )
     {
         renderer.PlanetRenderer = m_Planet.Renderer;
     }
     m_RendererMap.Add( component, renderers );
 }
Example #19
0
        internal static bool EqualsByValueInternal(this IComposite self, IComposite other, IDictionary<IComposite, object> path)
        {
            if (self == null && other == null) return true;
            if (self == null || other == null) return false;

            if (self.GetMembers().Count() != other.GetMembers().Count())
            {
                return false;
            }

            path.Add(self, null);

            foreach (var member in self.GetMembers())
            {
                var value = self.GetProperty(member);
                var otherValue = other.GetProperty(member);

                var composite = value as IComposite;
                if (composite != null && path.ContainsKey(composite)) continue; // prevent circular refs

                var otherComposite = otherValue as IComposite;
                // Composite property
                if (composite != null && otherComposite != null && !composite.EqualsByValueInternal(otherComposite, path))
                {
                    return false;
                }
                var compositeList = value as IEnumerable<IComposite>;
                var otherCompositeList = otherValue as IEnumerable<IComposite>;
                // Composite list
                if (compositeList != null && otherCompositeList != null)
                {
                    if (compositeList.Count() != otherCompositeList.Count())
                    {
                        return false;
                    }
                    for (var i = 0; i < compositeList.Count(); i++)
                    {
                        var item = compositeList.ElementAt(i);
                        if (path.ContainsKey(item)) continue; // prevent circular refs
                        if (!item.EqualsByValueInternal(otherCompositeList.ElementAt(i), path)) return false;
                    }
                }
                // Simple property
                if (composite == null && compositeList == null && !Equals(value, otherValue))
                {
                    return false;
                }
            }
            return true;
        }
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="workspace">Current workspace</param>
 /// <param name="viewFactory">View factory used by the controller to create dependent views</param>
 /// <param name="view">View to control</param>
 /// <param name="composite">Composite object to show</param>
 /// <exception cref="ArgumentNullException">Thrown if view or template is null</exception>
 public EditableCompositeViewController( IWorkspace workspace, IViewFactory viewFactory, IEditableCompositeView view, IComposite composite )
 {
     Arguments.CheckNotNull( workspace, "workspace" );
     Arguments.CheckNotNull( viewFactory, "viewFactory" );
     Arguments.CheckNotNull( view, "view" );
     Arguments.CheckNotNull( composite, "composite" );
     view.EditComposition += OnEditComposition;
     view.ComponentSelected += OnComponentSelected;
     view.Composite = composite;
     m_Workspace = workspace;
     m_View = view;
     m_Composite = composite;
     m_ViewFactory = viewFactory;
 }
 /// <summary>
 /// Changes the owner of any IComponent
 /// </summary>
 public static void ChangeOwner( IComponent component, ref IComposite currentOwner, IComposite newOwner )
 {
     if ( currentOwner == newOwner )
     {
         return;
     }
     IComposite oldOwner = currentOwner;
     currentOwner = null;
     if ( oldOwner != null )
     {
         oldOwner.Remove( component );
     }
     if ( newOwner != null )
     {
         currentOwner = newOwner;
         newOwner.Add( component );
     }
 }
        /// <summary>
        /// Setup constructor
        /// </summary>
        /// <param name="view">View to control</param>
        /// <param name="componentTypeCategories">Categories that component types can fall into</param>
        /// <param name="types">Composite types available for use</param>
        /// <param name="composite">Current composite</param>
        /// <exception cref="ArgumentNullException">Thrown if any argument is null</exception>
        public ComponentCompositionEditorController( IComponentCompositionEditorView view, ComponentTypeCategory[] componentTypeCategories, ComponentType[] types, IComposite composite )
        {
            Arguments.CheckNotNull( view, "view" );
            Arguments.CheckNotNull( types, "types" );
            Arguments.CheckNotNull( composite, "composite" );
            Arguments.CheckNotNull( componentTypeCategories, "componentTypeCategories" );

            view.Categories = componentTypeCategories;
            view.Types = types;
            view.CompositeView.Composite = composite;

            view.AddComponentType += OnAddComponentType;
            view.RemoveComponent += OnRemoveComponent;

            composite.ComponentAdded += OnCompositeChanged;
            composite.ComponentRemoved += OnCompositeChanged;

            m_Composite = composite;
            m_View = view;
            m_Types = types;
        }
Example #23
0
        public Cache(IComposite[] transientObjectTypes)
        {
            this.cachedObjectByObjectId = new ConcurrentDictionary<ObjectId, CachedObject>();
            this.objectTypeByObjectId = new ConcurrentDictionary<ObjectId, IClass>();

            if (transientObjectTypes != null)
            {
                this.transientConcreteClasses = new HashSet<IClass>();
                foreach (var transientObjectType in transientObjectTypes)
                {
                    foreach (var transientConcreteClass in transientObjectType.Classes)
                    {
                        this.transientConcreteClasses.Add(transientConcreteClass);
                    }
                }

                if (this.transientConcreteClasses.Count == 0)
                {
                    this.transientConcreteClasses = null;
                }
            }
        }
Example #24
0
 public ICompositePredicate AddInstanceof(IAssociationType association, IComposite type)
 {
     this.CheckUnarity();
     this.predicate = new AssociationInstanceOf(this.extent, association, type);
     this.extent.Invalidate();
     return this;
 }
Example #25
0
 public ICompositePredicate AddInstanceof(IComposite type)
 {
     this.CheckUnarity();
     this.predicate = new Instanceof(type);
     this.extent.Invalidate();
     return this;
 }
Example #26
0
 public ICompositePredicate AddInstanceof(IRoleType role, IComposite type)
 {
     this.CheckUnarity();
     this.predicate = new RoleInstanceof(this.extent, role, type);
     this.extent.Invalidate();
     return this;
 }
Example #27
0
		/// <summary> Populates a Composite type by looping through it's children, finding corresponding 
		/// Elements among the children of the given Element, and calling parse(Type, Element) for
		/// each.
		/// </summary>
		private void ParseComposite(IComposite datatypeObject, XmlElement datatypeElement)
		{
			if (datatypeObject is GenericComposite)
			{
				//elements won't be named GenericComposite.x
				XmlNodeList children = datatypeElement.ChildNodes;
				int compNum = 0;
				for (int i = 0; i < children.Count; i++)
				{
					if (Convert.ToInt16(children.Item(i).NodeType) == (short) XmlNodeType.Element)
					{
						Parse(datatypeObject[compNum], (XmlElement) children.Item(i));
						compNum++;
					}
				}
			}
			else
			{
				IType[] children = datatypeObject.Components;
				for (int i = 0; i < children.Length; i++)
				{
					XmlNodeList matchingElements = datatypeElement.GetElementsByTagName(MakeElementName(datatypeObject, i + 1));
					if (matchingElements.Count > 0)
					{
						Parse(children[i], (XmlElement) matchingElements.Item(0)); //components don't repeat - use 1st
					}
				}
			}
		}
Example #28
0
		/// <summary> Encodes a Composite in XML by looping through it's components, creating new 
		/// children for each of them (with the appropriate names) and populating them by 
		/// calling encode(Type, Element) using these children.  Returns true if at least 
		/// one component contains a value.  
		/// </summary>
		private bool EncodeComposite(IComposite datatypeObject, XmlElement datatypeElement)
		{
			IType[] components = datatypeObject.Components;
			bool hasValue = false;
			for (int i = 0; i < components.Length; i++)
			{
				String name = MakeElementName(datatypeObject, i + 1);
				XmlElement newNode = datatypeElement.OwnerDocument.CreateElement(name);
				bool componentHasValue = Encode(components[i], newNode);
				if (componentHasValue)
				{
					try
					{
						datatypeElement.AppendChild(newNode);
					}
					catch (Exception e)
					{
						throw new DataTypeException("DOMException encoding Composite: ", e);
					}
					hasValue = true;
				}
			}
			return hasValue;
		}
Example #29
0
 internal ExtentFiltered(Session session, IComposite objectType)
     : base(session)
 {
     this.objectType = objectType;
 }
Example #30
0
 private IObject[] GetExtent(ISession session, IComposite objectType)
 {
     return session.Extent(objectType);
 }
Example #31
0
 public ICompositePredicate AddInstanceof(IRoleType role, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new AllorsPredicateRoleInstanceofSql(this.extent, role, type, new List<IClass>(type.Classes).ToArray());
     return this;
 }
Example #32
0
 public ICompositePredicate AddInstanceof(IAssociationType association, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new AllorsPredicateAssociationInstanceofSql(this.extent, association, type, new List<IClass>(type.Classes).ToArray());
     return this;
 }
Example #33
0
 public ICompositePredicate AddInstanceof(IAssociationType association, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new AssociationInstanceOf(this.extent, association, type, CompositePredicate.GetConcreteSubClasses(type));
     return this;
 }
 /// <summary>
 /// Creates all dependencies of this type in a composite
 /// </summary>
 private void CreateDependencies( IComposite composite )
 {
     foreach ( ComponentType dependency in Dependencies )
     {
         dependency.Create( composite );
     }
 }
Example #35
0
 public ICompositePredicate AddInstanceof(IRoleType role, IComposite type)
 {
     this.CheckUnarity();
     this.extent.FlushCache();
     this.filter = new RoleInstanceof(this.extent, role, type, CompositePredicate.GetConcreteSubClasses(type));
     return this;
 }
Example #36
0
 internal ExtentFiltered(Session session, IComposite objectType)
 {
     this.session = session;
     this.objectType = objectType;
 }
Example #37
0
		/// <summary>Returns the expected XML element name for the given child of the given Composite </summary>
		private String MakeElementName(IComposite composite, int child)
		{
			return composite.TypeName + "." + child;
		}
Example #38
0
 public ICompositePredicate AddInstanceof(IRoleType role, IComposite type)
 {
     this.Extent.FlushCache();
     this.Filters.Add(new RoleInstanceof(this.Extent, role, type, GetConcreteSubClasses(type)));
     return this;
 }
Example #39
0
        public bool ContainsConcreteClass(IComposite objectType, IObjectType concreteClass)
        {
            object concreteClassOrClasses;
            if (!this.concreteClassesByObjectType.TryGetValue(objectType, out concreteClassOrClasses))
            {
                if (objectType.ExistExclusiveClass)
                {
                    concreteClassOrClasses = objectType.ExclusiveClass;
                    this.concreteClassesByObjectType[objectType] = concreteClassOrClasses;
                }
                else
                {
                    concreteClassOrClasses = new HashSet<IObjectType>(objectType.Classes);
                    this.concreteClassesByObjectType[objectType] = concreteClassOrClasses;
                }
            }

            if (concreteClassOrClasses is IObjectType)
            {
                return concreteClass.Equals(concreteClassOrClasses);
            }

            var concreteClasses = (HashSet<IObjectType>)concreteClassOrClasses;
            return concreteClasses.Contains(concreteClass);
        }
Example #40
0
 public ICompositePredicate AddInstanceof(IAssociationType association, IComposite type)
 {
     this.Extent.FlushCache();
     this.Filters.Add(new AssociationInstanceOf(this.Extent, association, type, GetConcreteSubClasses(type)));
     return this;
 }
Example #41
0
 // ISession.Extent for Repositories and
 // IWorkspaceSession.WorkspaceExtent for Workspaces.
 protected virtual Extent LocalExtent(IComposite objectType)
 {
     return this.Session.Extent(objectType);
 }
Example #42
0
 internal ExtentFiltered(StrategyExtent extent)
     : base(extent.Session)
 {
     this.objectType = extent.ObjectType;
     extent.UpgradeTo(this);
 }
Example #43
0
 public static bool EqualsByValue(this IComposite self, IComposite other)
 {
     return self.EqualsByValueInternal(other, new Dictionary<IComposite, object>());
 }
        /// <summary>
        /// Creates an instance of this type, and any dependencies
        /// </summary>
        public virtual void Create( IComposite composite )
        {
            Arguments.CheckNotNull( composite, "composite" );

            //	Remove existing model component in category
            //IModelTemplate existingTemplate = component.GetModelTemplate( m_Category.BaseType );
            //if ( existingTemplate != null )
            //{
            //    composite.Remove( existingTemplate );
            //}
            if ( CompositeUtils.GetComponent( composite, m_Type ) != null )
            {
                //	This type of component already exists in the composite
                return;
            }
            composite.Add( Activator.CreateInstance( m_Type ) );
            CreateDependencies( composite );
        }
Example #45
0
 public ICompositePredicate AddInstanceof(IComposite type)
 {
     this.predicates.Add(new Instanceof(type));
     this.extent.Invalidate();
     return this;
 }