Ejemplo n.º 1
0
        CodeUnit CheckForPartialTypes(CodeUnit codeUnit)
        {
            CodeTypeDeclarationCollection types;
            CompileUnitPartialType        partialType;
            string partialTypeName;
            List <CompileUnitPartialType> tmp;
            Dictionary <string, List <CompileUnitPartialType> > partialTypes = PartialTypes;

            foreach (CodeNamespace ns in codeUnit.Unit.Namespaces)
            {
                if (ns == null)
                {
                    continue;
                }
                types = ns.Types;
                if (types == null || types.Count == 0)
                {
                    continue;
                }

                foreach (CodeTypeDeclaration type in types)
                {
                    if (type == null)
                    {
                        continue;
                    }

                    if (type.IsPartial)
                    {
                        partialType     = new CompileUnitPartialType(codeUnit.Unit, ns, type);
                        partialTypeName = partialType.TypeName;

                        if (!partialTypes.TryGetValue(partialTypeName, out tmp))
                        {
                            tmp = new List <CompileUnitPartialType> (1);
                            partialTypes.Add(partialTypeName, tmp);
                        }
                        tmp.Add(partialType);
                    }
                }
            }

            return(codeUnit);
        }
Ejemplo n.º 2
0
        void CompareTypes(CompileUnitPartialType source, CompileUnitPartialType target)
        {
            CodeTypeDeclaration      sourceType      = source.PartialType;
            CodeTypeMemberCollection targetMembers   = target.PartialType.Members;
            List <CodeTypeMember>    membersToRemove = new List <CodeTypeMember> ();

            foreach (CodeTypeMember member in targetMembers)
            {
                if (TypeHasMember(sourceType, member))
                {
                    membersToRemove.Add(member);
                }
            }

            foreach (CodeTypeMember member in membersToRemove)
            {
                targetMembers.Remove(member);
            }
        }
Ejemplo n.º 3
0
        void ProcessType(List <CompileUnitPartialType> typeList)
        {
            CompileUnitPartialType[] types = new CompileUnitPartialType [typeList.Count];
            int counter = 0;

            foreach (CompileUnitPartialType type in typeList)
            {
                if (counter == 0)
                {
                    types [0] = type;
                    counter++;
                    continue;
                }

                for (int i = 0; i < counter; i++)
                {
                    CompareTypes(types [i], type);
                }
                types [counter++] = type;
            }
        }
Ejemplo n.º 4
0
		void CompareTypes (CompileUnitPartialType source, CompileUnitPartialType target)
		{
			CodeTypeDeclaration sourceType = source.PartialType;
			CodeTypeMemberCollection targetMembers = target.PartialType.Members;
			List <CodeTypeMember> membersToRemove = new List <CodeTypeMember> ();
			
			foreach (CodeTypeMember member in targetMembers) {
				if (TypeHasMember (sourceType, member))
					membersToRemove.Add (member);
			}

			foreach (CodeTypeMember member in membersToRemove)
				targetMembers.Remove (member);
		}
Ejemplo n.º 5
0
		void ProcessType (List <CompileUnitPartialType> typeList)
		{
			CompileUnitPartialType[] types = new CompileUnitPartialType [typeList.Count];
			int counter = 0;
			
			foreach (CompileUnitPartialType type in typeList) {
				if (counter == 0) {
					types [0] = type;
					counter++;
					continue;
				}

				for (int i = 0; i < counter; i++)
					CompareTypes (types [i], type);
				types [counter++] = type;
			}
		}
Ejemplo n.º 6
0
		CodeUnit CheckForPartialTypes (CodeUnit codeUnit)
		{
			CodeTypeDeclarationCollection types;
			CompileUnitPartialType partialType;
			string partialTypeName;
			List <CompileUnitPartialType> tmp;
			Dictionary <string, List <CompileUnitPartialType>> partialTypes = PartialTypes;
			
			foreach (CodeNamespace ns in codeUnit.Unit.Namespaces) {
				if (ns == null)
					continue;
				types = ns.Types;
				if (types == null || types.Count == 0)
					continue;

				foreach (CodeTypeDeclaration type in types) {
					if (type == null)
						continue;

					if (type.IsPartial) {
						partialType = new CompileUnitPartialType (codeUnit.Unit, ns, type);
						partialTypeName = partialType.TypeName;
						
						if (!partialTypes.TryGetValue (partialTypeName, out tmp)) {
							tmp = new List <CompileUnitPartialType> (1);
							partialTypes.Add (partialTypeName, tmp);
						}
						tmp.Add (partialType);
					}
				}
			}
						
			return codeUnit;
		}