示例#1
0
        public ClassCodeElement Build()
        {
            ClassCodeElement classCodeElement = new ClassCodeElement(className);

            if (!HasType())
            {
                return(classCodeElement);
            }
            Type type = obj.GetType();

            classCodeElement.NameSpace.Name = type.Namespace;
            CodeElementUtils.AddAttributes(classCodeElement.Attributes, type.GetCustomAttributes(false));
            PropertyInfo[]      propertyInfoArray = type.GetProperties(propertiesBinding);
            List <PropertyInfo> propertyInfos     = GetFilteredList(propertyInfoArray, propertyInfoFilter);

            CodeElementUtils.AddPropertyInfos(classCodeElement.Properties, propertyInfos);
            MethodInfo[]      methodInfoArray = type.GetMethods(methodBinding);
            List <MethodInfo> methodInfos     = GetFilteredList(methodInfoArray, methodInfoFilter);

            CodeElementUtils.AddMethodInfos(classCodeElement.Methods, methodInfos);
            FieldInfo[]      fieldInfoArray = type.GetFields(fieldBinding);
            List <FieldInfo> fieldInfos     = GetFilteredList(fieldInfoArray, fieldInfoFilter);

            CodeElementUtils.AddFieldInfos(classCodeElement.Fields, fieldInfos);
            return(classCodeElement);
        }
示例#2
0
        public static string GetCallParameterString(params object [] parameters)
        {
            string s = "";

            foreach (object p in parameters)
            {
                string paramString = CodeElementUtils.GetFormattedValue(p);
                if (string.IsNullOrEmpty(s))
                {
                    s = paramString;
                }
                else
                {
                    s += ", " + paramString;
                }
            }
            return(s);
        }
 public FieldCodeElement(string name, string init, AccessType access = AccessType.Public) :
     base(CodeElementUtils.GetFormattedType(typeof(T)), name, init, access)
 {
 }
 public ParameterCodeElement(Type type, string name, object defaultValue) :
     this(type, name)
 {
     DefaultValue = CodeElementUtils.GetFormattedValue(defaultValue);
 }
 public ParameterCodeElement(Type type, string name)
 {
     ParameterType = CodeElementUtils.GetFormattedType(type);
     Name          = name;
 }
 protected MemberCodeElement(Type type, string name, AccessType access = AccessType.Public) :
     this(CodeElementUtils.GetFormattedType(type), name, access)
 {
 }
示例#7
0
 /// <summary>
 /// Merges all those fields of other class into this one, that meet the filter condition.
 /// </summary>
 /// <param name="other">Other class whose fields will be merged into this class.</param>
 /// <param name="filter">Filter (optional), defines a subset of other's fields.</param>
 public void MergeFields(ClassCodeElement other, Predicate <GenericFieldCodeElement> filter = null)
 {
     CodeElementUtils.MergeElements <GenericFieldCodeElement> (Fields, other.Fields, filter);
 }
示例#8
0
 /// <summary>
 /// Merges all those properties of other class into this one, that meet the filter condition.
 /// </summary>
 /// <param name="other">Other class whose properties will be merged into this class.</param>
 /// <param name="filter">Filter (optional), defines a subset of other's properties.</param>
 public void MergeProperties(ClassCodeElement other, Predicate <GenericPropertyCodeElement> filter = null)
 {
     CodeElementUtils.MergeElements <GenericPropertyCodeElement> (Properties, other.Properties, filter);
 }
示例#9
0
 /// <summary>
 /// Merges all those methods of other class into this one, that meet the filter condition.
 /// </summary>
 /// <param name="other">Other class whose methods will be merged into this class.</param>
 /// <param name="filter">Filter (optional), defines a subset of other's methods.</param>
 public void MergeMethods(ClassCodeElement other, Predicate <GenericMethodCodeElement> filter = null)
 {
     CodeElementUtils.MergeElements <GenericMethodCodeElement> (Methods, other.Methods, filter);
 }
 public void AddParameter(bool parameter)
 {
     Parameters.Add(CodeElementUtils.GetFormattedValue(parameter));
 }