예제 #1
0
        public void GenerateCodeTypeDeclaration(CodeDomProvider provider, CodeGeneratorOptions generatorOptions,
                                                string wrapperName, out CodeTypeDeclaration ctd, out string ns)
        {
            var registerAtt = new CodeTypeReference(wrapperName + ".Foundation.RegisterAttribute");

            ctd = new System.CodeDom.CodeTypeDeclaration()
            {
                IsPartial = true,
            };

            if (Outlets.Any(o => o.IsDesigner) || Actions.Any(a => a.IsDesigner))
            {
                AddWarningDisablePragmas(ctd, provider);
            }

            var dotIdx = CliName.LastIndexOf('.');

            if (dotIdx > 0)
            {
                ns       = CliName.Substring(0, dotIdx);
                ctd.Name = CliName.Substring(dotIdx + 1);
            }
            else
            {
                ctd.Name = CliName;
                ns       = null;
            }
            if (IsRegisteredInDesigner)
            {
                AddAttribute(ctd.CustomAttributes, registerAtt, ObjCName);
            }

            GenerateActionsOutlets(provider, ctd, wrapperName);
        }
예제 #2
0
        public HashSet <string> GetNamespaces()
        {
            HashSet <string> namespaces = new HashSet <string> ();
            string           ignore     = null;
            int dot;

            if ((dot = CliName.LastIndexOf('.')) != -1)
            {
                ignore = CliName.Substring(0, dot);
            }

            AddNamespaceForCliType(namespaces, ignore, BaseCliType);

            foreach (var outlet in Outlets)
            {
                AddNamespaceForCliType(namespaces, ignore, outlet.CliType);
            }

            foreach (var action in Actions)
            {
                foreach (var param in action.Parameters)
                {
                    AddNamespaceForCliType(namespaces, ignore, param.CliType);
                }
            }

            return(namespaces);
        }
예제 #3
0
        /// <summary>
        /// Creates descriptions of parameters from the public property members of an
        /// object.
        /// </summary>
        /// <typeparam name="T">The object type to inspect.</typeparam>
        /// <param name="pOptions">The parser option</param>
        /// <param name="pInfos">Collection of properties</param>
        /// <returns>Parameter descriptions in syntax format.</returns>
        private static string ReflectDescriptions <T>(CliOptions pOptions, IEnumerable <PropertyInfo> pInfos)
            where T : class, new()
        {
            List <string> desc = new List <string>();

            foreach (PropertyInfo info in pInfos)
            {
                eROLE  role = eROLE.PASSED;
                string name = info.Name.ToLower();

                CliName attrName = Attribute <CliName>(info);
                if (attrName != null)
                {
                    role = attrName.Role;
                    name = attrName.Name ?? name;
                }

                string str = string.Format(
                    "{0}{1}:{2}",
                    role == eROLE.NAMED ? pOptions.Prefix : "",
                    name,
                    info.PropertyType.Name.ToLower()
                    );

                CliOptional attrOptional = Attribute <CliOptional>(info);
                if (attrOptional != null)
                {
                    str = string.Format("[{0}]", str);
                }

                desc.Add(str);
            }
            return(string.Join(" ", desc));
        }
예제 #4
0
        public void CliName()
        {
            CliName name = new CliName();
            Assert.AreEqual(eROLE.NAMED, name.Role);
            Assert.IsNull(name.Name);

            name = new CliName(eROLE.PASSED);
            Assert.AreEqual(eROLE.PASSED, name.Role);
            Assert.IsNull(name.Name);

            name = new CliName(eROLE.PASSED,"width");
            Assert.AreEqual(eROLE.PASSED, name.Role);
            Assert.AreEqual("width", name.Name);
        }
예제 #5
0
        public void CliName()
        {
            CliName name = new CliName();

            Assert.AreEqual(eROLE.NAMED, name.Role);
            Assert.IsNull(name.Name);

            name = new CliName(eROLE.PASSED);
            Assert.AreEqual(eROLE.PASSED, name.Role);
            Assert.IsNull(name.Name);

            name = new CliName(eROLE.PASSED, "width");
            Assert.AreEqual(eROLE.PASSED, name.Role);
            Assert.AreEqual("width", name.Name);
        }
예제 #6
0
        public void GenerateCodeTypeDeclaration(CodeDomProvider provider, CodeGeneratorOptions generatorOptions,
                                                string wrapperName, out CodeTypeDeclaration ctd, out string ns)
        {
            var registerAtt = new CodeTypeReference(wrapperName + ".Foundation.RegisterAttribute");
            var connectAtt  = new CodeTypeReference(wrapperName + ".Foundation.ConnectAttribute");
            var exportAtt   = new CodeTypeReference(wrapperName + ".Foundation.ExportAttribute");

            ctd = new System.CodeDom.CodeTypeDeclaration()
            {
                IsPartial = true,
            };

            if (Outlets.Any(o => o.IsDesigner) || Actions.Any(a => a.IsDesigner))
            {
                AddWarningDisablePragmas(ctd, provider);
            }

            var dotIdx = CliName.LastIndexOf('.');

            if (dotIdx > 0)
            {
                ns       = CliName.Substring(0, dotIdx);
                ctd.Name = CliName.Substring(dotIdx + 1);
            }
            else
            {
                ctd.Name = CliName;
                ns       = null;
            }
            AddAttribute(ctd.CustomAttributes, registerAtt, ObjCName);

            foreach (var a in Actions)
            {
                if (a.IsDesigner)
                {
                    GenerateAction(exportAtt, ctd, a, provider, generatorOptions);
                }
            }

            foreach (var o in Outlets)
            {
                if (o.IsDesigner)
                {
                    AddOutletProperty(connectAtt, ctd, o.CliName, new CodeTypeReference(o.CliType));
                }
            }
        }