Exemplo n.º 1
0
        void UpdateCells()
        {
            //!!!!!

            tableLayoutPanel1.Controls.Clear();

            if (SelectedType != null)
            {
                //add cells by EditorNewObjectSettingsAttribute
                {
                    //!!!!

                    var ar = SelectedType.GetNetType().GetCustomAttributes(typeof(EditorNewObjectSettingsAttribute), true);
                    if (ar.Length != 0 || IsFileCreation())
                    {
                        Type settingsClass = null;
                        if (ar.Length != 0)
                        {
                            settingsClass = ((EditorNewObjectSettingsAttribute)ar[0]).SettingsClass;
                        }
                        else
                        {
                            settingsClass = typeof(NewObjectSettings);
                        }

                        var cell = (NewObjectSettingsCell)AddCell(typeof(NewObjectSettingsCell));
                        if (!cell.Init(settingsClass, this))                           // IsFileCreation() );
                        {
                            tableLayoutPanel1.Controls.Remove(cell);
                        }
                    }

                    //var ar = SelectedType.GetNetType().GetCustomAttributes( typeof( EditorNewObjectSettingsAttribute ), true );
                    //if( ar.Length != 0 )
                    //{
                    //	Type settingsClass = ( (EditorNewObjectSettingsAttribute)ar[ 0 ] ).SettingsClass;
                    //	var cell = (NewObjectSettingsCell)AddCell( typeof( NewObjectSettingsCell ) );
                    //	if( !cell.Init( settingsClass, this ) )// IsFileCreation() );
                    //		tableLayoutPanel1.Controls.Remove( cell );
                    //}
                }

                //add cells by EditorNewObjectCellAttribute
                {
                    var ar = SelectedType.GetNetType().GetCustomAttributes(typeof(EditorNewObjectCellAttribute), true);
                    foreach (EditorNewObjectCellAttribute attr in ar)
                    {
                        AddCell(attr.CellClass);
                    }
                }

                //!!!!
                //change docking
                if (tableLayoutPanel1.Controls.Count == 1)
                {
                    tableLayoutPanel1.Controls[0].Size = new Size(30, 15);
                    tableLayoutPanel1.Controls[0].Dock = DockStyle.Fill;
                }
            }
        }
Exemplo n.º 2
0
        //!!!!new
        public static Metadata.TypeInfo GetUnreferencedType(Metadata.TypeInfo type)
        {
            var netType = type.GetNetType();

            if (IsReferenceType(netType))
            {
                return(MetadataManager.GetTypeOfNetType(GetUnderlyingType(netType)));
            }
            return(type);
        }
Exemplo n.º 3
0
        string GetExtension(Metadata.TypeInfo type)
        {
            //!!!!а как для своих типов расширения добавлять. нужно атрибуты уметь типу добавлять. тогда еще и свои типы атрибутов может быть

            var ar = type.GetNetType().GetCustomAttributes(typeof(ResourceFileExtensionAttribute), true);

            if (ar.Length != 0)
            {
                var attr = (ResourceFileExtensionAttribute)ar[0];
                return(attr.Extension);
            }

            //!!!!!
            return("UNKNOWN");
        }
Exemplo n.º 4
0
        string GetDefaultName()
        {
            //default object name from attribute
            var ar = selectedType.GetNetType().GetCustomAttributes(typeof(NewObjectDefaultNameAttribute), true);

            if (ar.Length != 0)
            {
                return(((NewObjectDefaultNameAttribute)ar[0]).Name);
            }

            if (IsFileCreation())
            {
                return("File.ext");
                //return Path.Combine( creationData.initFileCreationDirectory, "File.ext" );
            }
            else
            {
                //!!!!проверять валидность имени, т.к. слеши нельзя для компонент. для файлов можно

                return(selectedType.GetUserFriendlyNameForInstance(true));
            }
        }
Exemplo n.º 5
0
        internal static void LoadFileForType(Metadata.TypeInfo type)
        {
            try
            {
                var assembly = type.GetNetType().Assembly;
                if (assembly == null)
                {
                    return;
                }
                if (parsedAssemblies.Contains(assembly))
                {
                    return;
                }
                parsedAssemblies.Add(assembly);

                var fileName = Path.GetFileName(assembly.Location);
                if (!string.IsNullOrEmpty(fileName))
                {
                    var xmlFileName = Path.ChangeExtension(fileName, ".xml");
                    Load(xmlFileName);
                }
            }
            catch { }
        }
Exemplo n.º 6
0
        void Update()
        {
            //check disabled
            if (!Enabled)
            {
                Clear();
                return;
            }

            //!!!!slowly?
            //get actual member
            Metadata.Member newMemberObject = GetNeededMember();

            //check for updates
            if (!needUpdate && newMemberObject != memberObject)
            {
                needUpdate = true;
            }

            //nothing to update
            if (!needUpdate)
            {
                return;
            }

            //do update

            Clear();
            memberObject = newMemberObject;
            needUpdate   = false;

            if (memberObject != null)
            {
                //bool unableToInit = false;

                //method
                var method = memberObject as Metadata.Method;
                if (method != null)
                {
                    //This
                    if (!method.Static && !method.Constructor)
                    {
                        Metadata.TypeInfo creatorType = method.Owner as Metadata.TypeInfo;
                        if (creatorType == null)
                        {
                            creatorType = MetadataManager.MetadataGetType(method.Owner);
                        }

                        Type unrefNetType = creatorType.GetNetType();
                        var  refNetType   = typeof(Reference <>).MakeGenericType(unrefNetType);
                        var  type         = MetadataManager.GetTypeOfNetType(refNetType);

                        //string namePrefix = "__this_";
                        var p = new PropertyImpl(this, GetThisPropertyName() /* namePrefix + "This"*/, false, type, creatorType, new Metadata.Parameter[0], false, "Members", "This", true, null, false);
                        p.Description  = "";
                        p.Serializable = SerializeType.Enable;

                        properties.Add(p);
                        propertyBySignature[p.Signature] = p;
                        propertyThis = p;
                    }

                    //parameters
                    propertyMethodParameters = new List <PropertyImpl>();
                    for (int nParameter = 0; nParameter < method.Parameters.Length; nParameter++)
                    {
                        var parameter = method.Parameters[nParameter];

                        ////!!!!имя еще как-то фиксить?
                        //string name = null;
                        //!!!!
                        //if( parameter.ReturnValue )
                        //	name = "ReturnValue";
                        //if( name == null )
                        var name = parameter.Name.Substring(0, 1).ToUpper() + parameter.Name.Substring(1);

                        //!!!!поддержать ByReference. еще какие?
                        bool readOnly = parameter.Output || parameter.ReturnValue;

                        //!!!!
                        //var parameterType = GetOverrideParameterType( parameter, out bool error );
                        //if( error )
                        //{
                        //	unableToInit = true;
                        //	goto unableToInitLabel;
                        //}
                        //var parameterType = parameter.Type;

                        Metadata.TypeInfo type;
                        bool referenceSupport = !readOnly;
                        if (referenceSupport)
                        {
                            Type unrefNetType = parameter.Type.GetNetType();
                            var  refNetType   = typeof(Reference <>).MakeGenericType(unrefNetType);
                            type = MetadataManager.GetTypeOfNetType(refNetType);
                        }
                        else
                        {
                            type = parameter.Type;
                        }

                        bool invoke = parameter.ReturnValue || parameter.ByReference || parameter.Output;

                        string namePrefix  = "__parameter_";
                        string displayName = TypeUtility.DisplayNameAddSpaces(name);

                        var p = new PropertyImpl(this, namePrefix + name, false, type, parameter.Type, new Metadata.Parameter[0], readOnly, "Members", displayName, referenceSupport, parameter, invoke);
                        p.Description = "";
                        if (!readOnly)
                        {
                            p.Serializable = SerializeType.Enable;
                        }

                        properties.Add(p);
                        propertyBySignature[p.Signature] = p;

                        //!!!!так? если несколько?
                        if (parameter.ReturnValue)
                        {
                            propertyMethodReturnParameter = p;
                        }
                        else
                        {
                            propertyMethodParameters.Add(p);
                        }
                    }

                    //Constructor output
                    if (method.Constructor)
                    {
                        Metadata.TypeInfo creatorType = method.Owner as Metadata.TypeInfo;
                        if (creatorType == null)
                        {
                            creatorType = MetadataManager.MetadataGetType(method.Owner);
                        }

                        //"Output"
                        string namePrefix = "__returnvalue_";
                        var    p          = new PropertyImpl(this, namePrefix + "ReturnValue", false, creatorType, creatorType, new Metadata.Parameter[0], true, "Members", "Return Value", false, null, true);
                        p.Description = "";
                        //p.Serializable = true;

                        properties.Add(p);
                        propertyBySignature[p.Signature] = p;
                        propertyMethodReturnParameter    = p;
                    }
                }

                //property
                var property = memberObject as Metadata.Property;
                if (property != null)
                {
                    //This
                    if (!property.Static)
                    {
                        Metadata.TypeInfo creatorType = property.Owner as Metadata.TypeInfo;
                        if (creatorType == null)
                        {
                            creatorType = MetadataManager.MetadataGetType(property.Owner);
                        }

                        Type unrefNetType = creatorType.GetNetType();
                        var  refNetType   = typeof(Reference <>).MakeGenericType(unrefNetType);
                        var  type         = MetadataManager.GetTypeOfNetType(refNetType);

                        //string namePrefix = "__this_";
                        var p = new PropertyImpl(this, GetThisPropertyName() /* namePrefix + "This"*/, false, type, creatorType, new Metadata.Parameter[0], false, "Members", "This", true, null, false);
                        p.Description  = "";
                        p.Serializable = SerializeType.Enable;

                        properties.Add(p);
                        propertyBySignature[p.Signature] = p;
                        propertyThis = p;
                    }

                    //value
                    {
                        bool canSet = FlowSupport && !property.ReadOnly;

                        Metadata.TypeInfo type;
                        if (canSet)
                        {
                            Type unrefNetType = property.TypeUnreferenced.GetNetType();
                            var  refNetType   = typeof(Reference <>).MakeGenericType(unrefNetType);
                            type = MetadataManager.GetTypeOfNetType(refNetType);
                        }
                        else
                        {
                            type = property.TypeUnreferenced;
                        }

                        string namePrefix = "__value_";
                        var    p          = new PropertyImpl(this, namePrefix + "Value", false, type, property.TypeUnreferenced, new Metadata.Parameter[0], !canSet, "Members", "Value", canSet, null, true);
                        p.Description = "";
                        if (canSet)
                        {
                            p.Serializable = SerializeType.Enable;
                        }

                        properties.Add(p);
                        propertyBySignature[p.Signature] = p;
                        propertyPropertyValue            = p;
                    }

                    //!!!!Indexers
                }

                //!!!!другие

                //unableToInitLabel:
                //if( unableToInit )
                //{
                //	Clear();
                //	needUpdate = true;
                //}
            }
        }