Beispiel #1
0
		public static AssemblyDom Build(AssemblyDoc asmDoc, Assembly asm, Func<MemberDom, bool> filterMembers, FindOptions findOptions)
		{
			var ret = new AssemblyDom { _name = asmDoc.Name, ReflectionAssembly = asm };
			asmDoc.MergeWithReflection(asm, findOptions, out ret.ErrorUnboundTypes, out ret.ErrorUnboundMembers);
			ret.AllTypes = asmDoc.Types.Select(_ => TypeDom.Build(_, ret, filterMembers)).ToArray();
			ret.FillNamespaces();
			ret.FillNestedTypes();
			return ret;			
		}
Beispiel #2
0
		public static SolutionDom Build(string name, string[] assemblyFiles, string[] xmlDocFiles, string xmlNamespaceProjectFile = null, Func<MemberDom, bool> filterMembers = null, FindOptions findOptions = null)
		{
			if (findOptions == null)
				findOptions = new FindOptions(); //использовать значения по умолчанию

			IEnumerable<AssemblyDoc> docs = ParseDocfiles(xmlDocFiles);
			var asmsDict= AssemblyUtils.LoadAllAssemblies(assemblyFiles)
				.ToDictionary(_=>_.GetName().Name);
			var asmDoms = new List<AssemblyDom>();
			var errors = new List<WarningOrError>();
			foreach (var doc in docs)
			{
				AssemblyDom asmDom = null;
				try
				{
					asmDom = AssemblyDom.Build(doc, asmsDict[doc.Name], filterMembers, findOptions );
				}
				catch (Exception ex)
				{
					errors.Add(new WarningOrError{AssemblyName = doc.Name, InnerException = ex, ErrorType =WarningOrError.ErrorTypeEn.BindingWithReflection}); 
				}
				if (asmDom != null)
				{
					asmDoms.Add(asmDom);
					var error=GetUnboundError(asmDom);
					if(error!=null)
						errors.Add(error);
				}
			}
			var ret = new SolutionDom {Assemblies = asmDoms.ToArray(), Errors = errors, Name = name };
			ret.Namespaces = MergeNamespaces(ret.Assemblies.SelectMany(_ => _.Namespaces));
			ret.AllTypes = ret.Assemblies.SelectMany(_ => _.AllTypes).ToArray();
				//ret.Namespaces.SelectMany(_ => _.Types).ToArray();

			PopulateExtentionMethods.Populate(ret.AllTypes);
			MergeDocWithBaseClasses.Merge(ret.AllTypes);

			//namespaces
			if (xmlNamespaceProjectFile != null)
			{
				var comm = NamespaceCommentsParser.Parse(XDocument.Load(xmlNamespaceProjectFile).Root);

				foreach (var ns in ret.Namespaces)
				{
					NamespaceComments c;
					if (comm.TryGetValue(ns.Name, out c))
						ns.DocInfo = c.Comments;
				}
			}

			foreach (var type in ret.AllTypes)
				type.FillOverrideIndex();
			return ret;
		}
Beispiel #3
0
		//public string FileName
		//{
		//	get { return Path.GetFileName(ReflectionAssembly.Location); }
		//}


		public static AssemblyDom Build(XElement doc, Assembly asm, Func<MemberDom, bool> filterMembers, FindOptions findOptions)
		{
			var asmDoc=AssemblyDoc.Parse(doc);
			return Build(asmDoc, asm, filterMembers, findOptions);
		}
Beispiel #4
0
        public static AssemblyDom Build(AssemblyDoc asmDoc, Assembly asm, Func <MemberDom, bool> filterMembers, FindOptions findOptions)
        {
            var ret = new AssemblyDom {
                _name = asmDoc.Name, ReflectionAssembly = asm
            };

            asmDoc.MergeWithReflection(asm, findOptions, out ret.ErrorUnboundTypes, out ret.ErrorUnboundMembers);
            ret.AllTypes = asmDoc.Types.Select(_ => TypeDom.Build(_, ret, filterMembers)).ToArray();
            ret.FillNamespaces();
            ret.FillNestedTypes();
            return(ret);
        }
Beispiel #5
0
        //public string FileName
        //{
        //	get { return Path.GetFileName(ReflectionAssembly.Location); }
        //}


        public static AssemblyDom Build(XElement doc, Assembly asm, Func <MemberDom, bool> filterMembers, FindOptions findOptions)
        {
            var asmDoc = AssemblyDoc.Parse(doc);

            return(Build(asmDoc, asm, filterMembers, findOptions));
        }
Beispiel #6
0
        public static SolutionDom Build(string name, string[] assemblyFiles, string[] xmlDocFiles, string xmlNamespaceProjectFile = null, Func <MemberDom, bool> filterMembers = null, FindOptions findOptions = null)
        {
            if (findOptions == null)
            {
                findOptions = new FindOptions();                 //использовать значения по умолчанию
            }
            IEnumerable <AssemblyDoc> docs = ParseDocfiles(xmlDocFiles);
            var asmsDict = AssemblyUtils.LoadAllAssemblies(assemblyFiles)
                           .ToDictionary(_ => _.GetName().Name);
            var asmDoms = new List <AssemblyDom>();
            var errors  = new List <WarningOrError>();

            foreach (var doc in docs)
            {
                AssemblyDom asmDom = null;
                try
                {
                    asmDom = AssemblyDom.Build(doc, asmsDict[doc.Name], filterMembers, findOptions);
                }
                catch (Exception ex)
                {
                    errors.Add(new WarningOrError {
                        AssemblyName = doc.Name, InnerException = ex, ErrorType = WarningOrError.ErrorTypeEn.BindingWithReflection
                    });
                }
                if (asmDom != null)
                {
                    asmDoms.Add(asmDom);
                    var error = GetUnboundError(asmDom);
                    if (error != null)
                    {
                        errors.Add(error);
                    }
                }
            }
            var ret = new SolutionDom {
                Assemblies = asmDoms.ToArray(), Errors = errors, Name = name
            };

            ret.Namespaces = MergeNamespaces(ret.Assemblies.SelectMany(_ => _.Namespaces));
            ret.AllTypes   = ret.Assemblies.SelectMany(_ => _.AllTypes).ToArray();
            //ret.Namespaces.SelectMany(_ => _.Types).ToArray();

            PopulateExtentionMethods.Populate(ret.AllTypes);
            MergeDocWithBaseClasses.Merge(ret.AllTypes);

            //namespaces
            if (xmlNamespaceProjectFile != null)
            {
                var comm = NamespaceCommentsParser.Parse(XDocument.Load(xmlNamespaceProjectFile).Root);

                foreach (var ns in ret.Namespaces)
                {
                    NamespaceComments c;
                    if (comm.TryGetValue(ns.Name, out c))
                    {
                        ns.DocInfo = c.Comments;
                    }
                }
            }

            foreach (var type in ret.AllTypes)
            {
                type.FillOverrideIndex();
            }
            return(ret);
        }