Ejemplo n.º 1
0
        private static void TryAddMember(List <TypedMemberBase> members, Dictionary <string, string> untypedMembers, List <string> membersAlreadyAdded, string memberName, Type type, string classType)
        {
            string toAdd = memberName;

            if (!string.IsNullOrEmpty(memberName) && toAdd.Contains("="))
            {
                toAdd = toAdd.Substring(0, toAdd.IndexOf("=")).Trim();
            }

            if (!string.IsNullOrEmpty(toAdd) && !membersAlreadyAdded.Contains(toAdd))
            {
                membersAlreadyAdded.Add(toAdd);



                if (type == null)
                {
                    untypedMembers.Add(memberName, classType);
                }
                else
                {
                    TypedMemberBase typedMemberBase = TypedMemberBase.GetTypedMemberUnequatable(
                        memberName,
                        type);

                    members.Add(typedMemberBase);
                }
            }
        }
Ejemplo n.º 2
0
        public static TypedMemberBase GetTypedMemberBase(string typeString, string memberName)
        {
            // make the typeString proper
            Type type = TypeManager.GetTypeFromString(typeString);

            // At one time this was using GetTypedMember, but I don't know why we need them
            // to be equatable
            //TypedMemberBase typedMemberBase = TypedMemberBase.GetTypedMember(memberName, type);
            TypedMemberBase typedMemberBase = TypedMemberBase.GetTypedMemberUnequatable(memberName, type);

            return(typedMemberBase);
        }
Ejemplo n.º 3
0
        private static void UpdateTypedMembers(this NamedObjectSave instance)
        {
            if (instance.SourceType == SourceType.Entity)
            {
                if (string.IsNullOrEmpty(instance.SourceClassType) || instance.SourceClassType == "<NONE>")
                {
                    instance.TypedMembers.Clear();
                }
                else
                {
                    EntitySave entitySave = ObjectFinder.Self.GetEntitySave(
                        instance.SourceClassType);
                    if (entitySave != null)
                    {
                        instance.TypedMembers.Clear();
                        // This is null if a property that calls
                        // UpdateProperties is called before the project
                        // is loaded - as is the case when the GLUX is
                        // deserialized.
                        instance.TypedMembers.AddRange(entitySave.GetTypedMembers());
                    }
                }
            }
            else if (string.IsNullOrEmpty(instance.ClassType) || instance.ClassType.Contains("PositionedObjectList<"))
            {
                instance.TypedMembers.Clear();
            }
            else if (instance.IsList)
            {
                // do nothing.
            }
            else
            {
                instance.TypedMembers.Clear();
                // We used to only include members in the
                // ATI.  Now we want to include every possible
                // variable so that they all show up in the PropertyGrid.
                //AssetTypeInfo ati = instance.GetAssetTypeInfo();

                //if (ati == null)
                //{
                //    throw new NullReferenceException("Could not find an AssetType for the type " +
                //        instance.SourceClassType + ".  This either means that your ContenTypes CSV is corrupt, out of date, missing, or that you have not loaded a content types CSV if you are using teh GluxViewManager in a custom app.");
                //    instance.TypedMembers.Clear();
                //}
                //else
                //{
                //    instance.TypedMembers.Clear();
                //    instance.TypedMembers.AddRange(ati.GetTypedMembers());
                //}

                List <MemberWithType> variables = ExposedVariableManager.GetExposableMembersFor(instance);

                foreach (var member in variables)
                {
                    int errorCode = 0;
                    try
                    {
                        errorCode = 0;
                        string memberType = member.Type;
                        errorCode  = 1;
                        memberType = TypeManager.ConvertToCommonType(memberType);
                        errorCode  = 2;

                        Type type = TypeManager.GetTypeFromString(memberType);
                        errorCode = 3;
                        // Glue can't do anything with generic properties (yet)
                        // Update: I'm adding support for it now
                        //if (type != null && type.IsGenericType == false)
                        TypedMemberBase typedMember = null;

                        if (type != null)
                        {
                            typedMember = TypedMemberBase.GetTypedMemberUnequatable(member.Member, type);
                        }
                        else
                        {
                            typedMember = TypedMemberBase.GetTypedMemberUnequatable(member.Member, typeof(object));
                            typedMember.CustomTypeName = memberType;
                        }
                        instance.TypedMembers.Add(typedMember);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Error trying to fix member " + member + " in object " + instance + ". Error code: " + errorCode + "Additional info:\n\n\n" + e.ToString(), e);
                    }
                }

                var ati = instance.GetAssetTypeInfo();

                if (ati != null)
                {
                    foreach (var member in ati.VariableDefinitions)
                    {
                        // Only consider this if it's not already handled:
                        bool isAlreadyHandled = instance.TypedMembers.Any(item => item.MemberName == member.Name);

                        if (!isAlreadyHandled)
                        {
                            string memberType = member.Type;
                            memberType = TypeManager.ConvertToCommonType(memberType);

                            Type type = TypeManager.GetTypeFromString(memberType);
                            // Glue can't do anything with generic properties (yet)
                            // Update: I'm adding support for it now
                            //if (type != null && type.IsGenericType == false)
                            TypedMemberBase typedMember = null;

                            if (type != null)
                            {
                                typedMember = TypedMemberBase.GetTypedMemberUnequatable(member.Name, type);
                            }
                            else
                            {
                                typedMember = TypedMemberBase.GetTypedMemberUnequatable(member.Name, typeof(object));
                                typedMember.CustomTypeName = memberType;
                            }
                            instance.TypedMembers.Add(typedMember);
                        }
                    }
                }
            }
        }