예제 #1
0
        public void LinkClasses(Context context)
        {
            Console.WriteLine("\t>> Linking classes for package " + this.Name);
            foreach (var child in this.Children)
            {
                child.LinkClasses(context);
            }
            foreach (KeyValuePair <string, Class> cpair in this.Classes)
            {
                foreach (Method method in cpair.Value.Methods)
                {
                    context.LinkCTSTypes(cpair.Value, method.ReturnType);

                    foreach (KeyValuePair <int, Parameter> pair in method.Parameters)
                    {
                        context.LinkCTSTypes(cpair.Value, pair.Value.ParameterType);
                        if (pair.Value.ParameterType.Class != null)
                        {
                            if (pair.Value.ParameterType.CollectionType == "Vector")
                            {
                                pair.Value.ParameterType.Class.HasVector = true;
                            }
                            else if (pair.Value.ParameterType.CollectionType == "Matrix")
                            {
                                pair.Value.ParameterType.Class.HasMatrix = true;
                            }
                            else if (pair.Value.ParameterType.CollectionType == "Cube")
                            {
                                pair.Value.ParameterType.Class.HasCube = true;
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
파일: Class.cs 프로젝트: rfrerebe/Cephei
        public Class(Element element, Package root, Context context)
        {
            _context             = context;
            Name                 = element.Name;
            Notes                = element.Note ?? "";
            Guid                 = element.GUID;
            Id                   = element.Id;
            FileName             = element.GenFile;
            Package              = (root == null ? null : root.GetById(element.PackageId.Value));
            FilledFromRepository = false;
            Element              = element;
            var isTemplate = (element.PDATA3 != null && element.PDATA3.Contains("<PRM1>"));

            // Convert nested classes and template classes to spec classes
            IsSpec   = (element.IsSpec || isTemplate || element.Name.Contains("<") || element.ParentID != 0 || element.Name == "engine");
            ParentID = (element.ObjectType == "Enumeration" ? element.ParentID.Value : 0);
            if (element.Abstract == "1")
            {
                _IsAbstract = true;
            }
            IsEnum    = (element.ObjectType == "Enumeration");
            _IsStruct = (element.Stereotype == "struct");
            _IsActive = !(element.IsActive);    // used to flag QuantLib classes that rely on evaluation date
            if (!IsEnum)
            {
                foreach (var method in element.Operations)
                {
                    if (method.Scope == "Public" && method.Synchronized == "0")
                    {
                        Methods.Add(new Method(method, context, element, this));
                    }
                }
            }
            else
            {
                int c = 0;
                foreach (var attribute in element.Attributes)
                {
                    Attributes.Add(attribute.Pos ?? c, new Attribute(attribute.Name, attribute.Default, attribute.Pos ?? c));
                    c++;
                }
            }
            _BaseClasses = new List <Class>();
            foreach (Element be in Element.BaseClasses(_context.Repository))
            {
                Class cclass = root.FindClassByElement(be);
                if (cclass != null)
                {
                    _BaseClasses.Add(cclass);
                }
                else if (be.ParentID == 0              // no nested classes
                                                       //                            && be.Subtype != 1             // no parameterised interfaces
                         && be.Stereotype != "typedef" // in this context all typedefs are templates.. so exlcude
                                                       //                            && !be.Name.Contains ("<")
                                                       //                            && be.Name != "engine"
                         && be.Name != "arguments" &&
                         be.Name != "results" &&
                         be.Name != "Point"
                         )
                {
                    try
                    {
                        cclass = new Class(be, root, context);
                        cclass.Package.Classes[cclass.Name] = cclass;
                        _BaseClasses.Add(cclass);

                        foreach (Method method in cclass.Methods)
                        {
                            context.LinkCTSTypes(cclass, method.ReturnType);

                            foreach (KeyValuePair <int, Parameter> pair in method.Parameters)
                            {
                                context.LinkCTSTypes(cclass, pair.Value.ParameterType);
                            }
                        }
                    }
                    catch (Exception)
                    {
                        Debugger.Break();
                    }
                }
            }
        }