GetXsdName() 공개 정적인 메소드

public static GetXsdName ( MemberInfo member ) : string
member System.Reflection.MemberInfo
리턴 string
예제 #1
0
        private void WriteAttributeForEach(ParameterInfo[] allParameters)
        {
            ParameterInfo[] parameters = allParameters.Where(p => MagickScriptTypes.GetXsdAttributeType(p) != null).ToArray();
            if (parameters.Length == 0)
            {
                return;
            }

            parameters = parameters.OrderBy(p => p.Name).ToArray();

            WriteLine("foreach (XmlAttribute attribute in element.Attributes)");
            WriteStartColon();

            if (parameters.DistinctBy(p => GetName(p)).Count() == 1)
            {
                Write("arguments[attribute.Name] = GetValue<");
                Write(GetName(parameters[0]));
                WriteLine(">(attribute);");
            }
            else
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    string xsdName = MagickScriptTypes.GetXsdName(parameters[i]);

                    if (i > 0)
                    {
                        Write("else ");
                    }

                    Write("if (attribute.Name == \"");
                    Write(xsdName);
                    WriteLine("\")");
                    Indent++;
                    Write("arguments[\"");
                    Write(xsdName);
                    Write("\"] = ");
                    WriteGetAttributeValue(GetName(parameters[i]));
                    Indent--;
                }
            }

            WriteEndColon();
        }
예제 #2
0
        private void WriteElementForEach(ParameterInfo[] allParameters)
        {
            ParameterInfo[] parameters = allParameters.Where(p => MagickScriptTypes.GetXsdAttributeType(p) == null).ToArray();
            if (parameters.Length == 0)
            {
                return;
            }

            WriteLine("foreach (XmlElement elem in element.SelectNodes(\"*\"))");
            WriteStartColon();

            if (parameters.DistinctBy(p => GetName(p)).Count() == 1)
            {
                Write("arguments[elem.Name] = ");
                WriteCreateMethod(GetName(parameters[0]));
                WriteLine("(elem);");
            }
            else
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    string xsdName = MagickScriptTypes.GetXsdName(parameters[i]);

                    if (i > 0)
                    {
                        Write("else ");
                    }

                    Write("if (elem.Name == \"");
                    Write(xsdName);
                    WriteLine("\")");
                    Indent++;
                    Write("arguments[\"");
                    Write(xsdName);
                    Write("\"] = ");
                    WriteCreateMethod(GetName(parameters[i]));
                    WriteLine("(elem);");
                    Indent--;
                }
            }

            WriteEndColon();
        }
예제 #3
0
        private void AddClassElements(XElement complexType, IEnumerable <PropertyInfo> properties, IEnumerable <MethodInfo> methods)
        {
            XElement sequence = new XElement(_Namespace + "sequence");

            foreach (var property in from property in properties
                     let typeName = MagickScriptTypes.GetXsdElementType(property)
                                    where typeName != null
                                    let name = MagickScriptTypes.GetXsdName(property)
                                               orderby name
                                               select new
            {
                Name = name,
                TypeName = typeName
            })
            {
                XElement element = new XElement(_Namespace + "element",
                                                new XAttribute("name", property.Name),
                                                new XAttribute("minOccurs", "0"));

                element.Add(new XAttribute("type", property.TypeName));

                sequence.Add(element);
            }

            if (methods.Count() > 0)
            {
                foreach (MethodBase method in methods)
                {
                    XElement element = new XElement(_Namespace + "element",
                                                    new XAttribute("name", MagickScriptTypes.GetXsdName(method)),
                                                    new XAttribute("minOccurs", "0"),
                                                    new XAttribute("maxOccurs", "unbounded"));
                    AddMethods(element, new MethodBase[] { method });
                    sequence.Add(element);
                }
            }

            if (sequence.HasElements)
            {
                complexType.Add(sequence);
            }
        }
예제 #4
0
        private void WriteExecute()
        {
            Write("private ");
            Write(ReturnType);
            Write(" Execute");
            Write(ExecuteName);
            Write("(XmlElement element, ");
            Write(ExecuteArgument);
            WriteLine(")");
            WriteStartColon();

            IEnumerable <string> names = (from property in Properties
                                          select MagickScriptTypes.GetXsdName(property)).Concat(
                from method in Methods
                select MagickScriptTypes.GetXsdName(method[0])).Concat(
                CustomMethods);

            WriteSwitch(names);
            WriteEndColon();
        }
예제 #5
0
        protected sealed override void WriteCase(string name)
        {
            MemberInfo member = (from property in Properties
                                 where MagickScriptTypes.GetXsdName(property).Equals(name, StringComparison.OrdinalIgnoreCase)
                                 select property).FirstOrDefault();

            if (member == null)
            {
                member = (from overloads in Methods
                          let method = overloads[overloads.Length - 1]
                                       where MagickScriptTypes.GetXsdName(method).Equals(name, StringComparison.OrdinalIgnoreCase)
                                       select method).FirstOrDefault();
            }


            if (ReturnType != "void")
            {
                Write("return ");
            }
            Write("Execute");
            if (member == null)
            {
                Write(char.ToUpper(name[0], CultureInfo.InvariantCulture));
                Write(name.Substring(1));
            }
            else
            {
                Write(GetName(member));
            }
            Write("(");
            if (member == null || !HasParameters(member))
            {
                Write("element, ");
            }
            Write(ExecuteArgument.Split(' ').Last());
            WriteLine(");");
            if (ReturnType == "void")
            {
                WriteLine("return;");
            }
        }
예제 #6
0
        private void WriteExecute()
        {
            WriteLine("[SuppressMessage(\"Microsoft.Maintainability\", \"CA1502:AvoidExcessiveComplexity\")]");
            WriteLine("[SuppressMessage(\"Microsoft.Maintainability\", \"CA1505:AvoidUnmaintainableCode\")]");
            Write("private ");
            Write(ReturnType);
            Write(" Execute");
            Write(ExecuteName);
            Write("(XmlElement element, ");
            Write(ExecuteArgument);
            WriteLine(")");
            WriteStartColon();

            IEnumerable <string> names = (from property in Properties
                                          select MagickScriptTypes.GetXsdName(property)).Concat(
                from method in Methods
                select MagickScriptTypes.GetXsdName(method[0])).Concat(
                CustomMethods);

            WriteSwitch(names);
            WriteEndColon();
        }
예제 #7
0
 private void WriteInvalidCombinations(MethodBase[] methods)
 {
     WriteLine("else");
     Indent++;
     Write("throw new ArgumentException(\"Invalid argument combination for '" + MagickScriptTypes.GetXsdName(methods[0]) + "', allowed combinations are:");
     foreach (MethodBase method in methods)
     {
         Write(" [");
         ParameterInfo[] parameters = method.GetParameters();
         for (int i = 0; i < parameters.Length; i++)
         {
             Write(parameters[i].Name);
             if (i != parameters.Length - 1)
             {
                 Write(", ");
             }
         }
         Write("]");
     }
     WriteLine("\");");
     Indent--;
 }