public static PropertyDefinitionProxy FromPropertyDefinition(PropertyDefinition propertyDefinition)
 {
     return(new PropertyDefinitionProxy
     {
         Name = propertyDefinition.Name.Raw,
         Class = ClassProxy.FromClass(propertyDefinition.Class),
         Attributes = new List <AttributeProxy>(propertyDefinition.Attributes),
         IsLegal = propertyDefinition.IsLegal,
         IsEnabled = propertyDefinition.IsEnabled
     });
 }
        private static string GetClassString(ClassProxy @class)
        {
            var userDefined = @class as UserDefinedClassProxy;

            if (userDefined != null)
            {
                return("UserDefined:" + userDefined.DomPath);
            }

            var formattedDateTime = @class as FormattedDateTimeProxy;

            if (formattedDateTime != null)
            {
                return("FormattedDateTime:" + formattedDateTime.Format);
            }

            var nullableFormattedDateTime = @class as NullableFormattedDateTimeProxy;

            if (nullableFormattedDateTime != null)
            {
                return("NullableFormattedDateTime:" + nullableFormattedDateTime.Format);
            }

            var bcl = @class as BclClassProxy;

            if (bcl != null)
            {
                var typeName = bcl.TypeName;

                var type = Type.GetType(typeName);
                if (type != null && type.IsGenericType)
                {
                    var genericArgs = type.GetGenericArguments();
                    if (genericArgs.Length == 1 && type == typeof(Nullable <>).MakeGenericType(genericArgs[0]))
                    {
                        typeName = string.Format("Nullable({0})", genericArgs[0].FullName);
                    }
                }

                return("Bcl:" + bcl.TypeAlias + ":" + typeName);
            }

            var list = @class as ListClassProxy;

            if (list != null)
            {
                return("List:" + GetClassString(list.Class));
            }

            throw new InvalidOperationException("Invalid class type: " + @class.GetType());
        }
        private static string GetClassString(ClassProxy @class)
        {
            var userDefined = @class as UserDefinedClassProxy;
            if (userDefined != null)
            {
                return "UserDefined:" + userDefined.DomPath;
            }

            var formattedDateTime = @class as FormattedDateTimeProxy;
            if (formattedDateTime != null)
            {
                return "FormattedDateTime:" + formattedDateTime.Format;
            }

            var nullableFormattedDateTime = @class as NullableFormattedDateTimeProxy;
            if (nullableFormattedDateTime != null)
            {
                return "NullableFormattedDateTime:" + nullableFormattedDateTime.Format;
            }

            var bcl = @class as BclClassProxy;
            if (bcl != null)
            {
                var typeName = bcl.TypeName;

                var type = Type.GetType(typeName);
                if (type != null && type.IsGenericType)
                {
                    var genericArgs = type.GetGenericArguments();
                    if (genericArgs.Length == 1 && type == typeof(Nullable<>).MakeGenericType(genericArgs[0]))
                    {
                        typeName = string.Format("Nullable({0})", genericArgs[0].FullName);
                    }
                }

                return "Bcl:" + bcl.TypeAlias + ":" + typeName;
            }

            var list = @class as ListClassProxy;
            if (list != null)
            {
                return "List:" + GetClassString(list.Class);
            }

            throw new InvalidOperationException("Invalid class type: " + @class.GetType());
        }