Ejemplo n.º 1
0
        public In(string[] aValues, Type[] aParameterConverterTypeArr)
        {
            Value_Converters = new List <Value_Converter>();
            if (aValues == null || aParameterConverterTypeArr == null || aValues.Length != aParameterConverterTypeArr.Length)
            {
                throw new ArgumentException("Parámetros incorrectos en el Atributo IN, posible causa : los arreglos son NULL o no tienen la misma cantidad de elementos");
            }

            for (int i = 0; i < aParameterConverterTypeArr.Length; i++)
            {
                Type _interf = aParameterConverterTypeArr[i].GetInterface("IParameterCoverter");
                if (_interf == null || !aParameterConverterTypeArr[i].IsPublic)
                {
                    throw new ArgumentException("El parámetro del Atributo IN no implementa la interface IParameterCoverter o el tipo no es PUBLIC.");
                }
                else
                {
                    Value_Converters.Add(new Value_Converter()
                    {
                        Converter = ReflectionTools.GetInstance <IParameterCoverter>(aParameterConverterTypeArr[i].FullName), Value = aValues[i]
                    });
                }
            }

            IsMultipleSelection = true;
        }
Ejemplo n.º 2
0
        public In(Type parameterConverterType)
        {
            Type interf = parameterConverterType.GetInterface("IParameterCoverter");

            if (interf == null || !parameterConverterType.IsPublic)
            {
                throw new ArgumentException("El parámetro del Atributo IN no implementa la interface IParameterCoverter o el tipo no es PUBLIC.");
            }

            Converter = ReflectionTools.GetInstance <IParameterCoverter>(parameterConverterType.FullName);

            IsMultipleSelection = false;
        }
        private void bt_Run_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (HasSelectedMeasures)
                {
                    List <PartitionInfo> _partitionsInfo = this.uctrl_ListClusterAlgVisualizerClustEnsemble.GetSelected();
                    string             _Error            = "";
                    List <MeasureInfo> _MeasuresChecked  = GetMeasuresChecked();
                    if (_MeasuresChecked == null || _MeasuresChecked.Count == 0)
                    {
                        _Error = "You must select at least one Validation Index.";
                        MessageBox.Show(_Error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    if (_partitionsInfo == null || _partitionsInfo.Count == 0)
                    {
                        _Error = "You must select at least one Structuring to apply an Validation Index.";
                        MessageBox.Show(_Error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    Structuring          _realpartition  = RealPartitionBuilder.BuildRealPartition(Enviroment.Set, Att_objetive);
                    List <MeasureOutput> _measuresOutput = new List <MeasureOutput>();
                    List <Measure>       _measures       = new List <Measure>();

                    ReflectionTools _rct = new ReflectionTools();
                    for (int i = 0; i < _MeasuresChecked.Count; i++)
                    {
                        Measure _TempMeasure = ReflectionTools.GetInstance <Measure>(_MeasuresChecked[i].Tree.Value.FullName);
                        _measures.Add(_TempMeasure);
                        foreach (CEDS.Property _p in _MeasuresChecked[i].Tree.Value.InProperties)
                        {
                            _rct.SetProperty(_MeasuresChecked[i].Tree.Value.FullName, _TempMeasure, _p);
                        }
                    }

                    Run _run = RunMethod;
                    _run.BeginInvoke(_partitionsInfo, _measures, _realpartition, _measuresOutput, _MeasuresChecked, RunFinish, _run);
                }
                else
                {
                    MessageBox.Show("You must first select a Validation Index.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception _ex)
            {
                GeneralTools.Tools.WriteToLog(_ex);
            }
        }
Ejemplo n.º 4
0
        protected FieldDescriptor NewFieldDescriptor(FieldDescriptor wrappedFD, String wrapperTag,
                                                     Type fieldDescriptorClass)
        {
            if (fieldDescriptorClass == null)
            {
                return(new FieldDescriptor(this, wrappedFD, wrapperTag));
            }

            Object[] args = new Object[3];
            args[0] = this;
            args[1] = wrappedFD;
            args[2] = wrapperTag;

            return(ReflectionTools.GetInstance <FieldDescriptor>(fieldDescriptorClass, args));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aparameter">Nombre de la clase a instanciar</param>
        /// <param name="aresult"></param>
        /// <returns></returns>
        public bool TryConvert(string aparameter, out object aresult)
        {
            GenericDistances _temp = ReflectionTools.GetInstance <GenericDistances>("ClusterEnsemble.ClusterEnsemble." + aparameter);

            if (_temp != null)
            {
                aresult = _temp;
                return(true);
            }
            else
            {
                aresult = null;
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aparameter">Nombre de la clase a instanciar, esta clase debe heredar de ClusterAlgorithm</param>
        /// <param name="aresult"></param>
        /// <returns></returns>
        public bool TryConvert(string aparameter, out object aresult)
        {
            ReductionFunction _temp = ReflectionTools.GetInstance <ReductionFunction>("ClusterEnsemble.ReductionFunctions." + aparameter);

            if (_temp != null)
            {
                aresult = _temp;
                return(true);
            }
            else
            {
                aresult = null;
                return(false);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aparameter">Nombre de la clase a instanciar, esta clase debe heredar de ClusterAlgorithm</param>
        /// <param name="aresult"></param>
        /// <returns></returns>
        public bool TryConvert(string aparameter, out object aresult)
        {
            ClusterAlgorithm _temp = ReflectionTools.GetInstance <ClusterAlgorithm>("ClusterEnsemble.Clusters." + aparameter);

            if (_temp != null)
            {
                aresult = _temp;
                return(true);
            }
            else
            {
                aresult = null;
                return(false);
            }
        }
Ejemplo n.º 8
0
        private void bt_Run_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (HasSelectedAlgorithm)
                {
                    string _Error = "";
                    if (!Enviroment.CanRunAlgorithm(out _Error, AlgorithmType.Clustering))
                    {
                        MessageBox.Show(_Error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    ReflectionTools  _rct        = new ReflectionTools();
                    ClusterAlgorithm _ClusterAlg = ReflectionTools.GetInstance <ClusterAlgorithm>(Tree.Value.FullName);

                    foreach (CEDS.Property _p in Tree.Value.InProperties)
                    {
                        _rct.SetProperty(Tree.Value.FullName, _ClusterAlg, _p);
                    }


                    if (!VisualUtils.SetGlobalInProperties(_rct, _ClusterAlg, Tree, out _Error, this.chbx_AttrRnd.IsChecked.Value))
                    {
                        MessageBox.Show(_Error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    Run _run = RunMethod;

                    _run.BeginInvoke(_ClusterAlg, RunFinish, new DataThread()
                    {
                        Run = _run, ClusterAlgorithm = _ClusterAlg
                    });
                }
                else
                {
                    MessageBox.Show("You must first select a Clustering algorithm.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception _ex)
            {
                GeneralTools.Tools.WriteToLog(_ex);
            }
        }
Ejemplo n.º 9
0
        private FieldDescriptor NewFieldDescriptor(FieldInfo thatField, Int16 annotationType, Type fieldDescriptorClass)
        {
            if (fieldDescriptorClass == null)
            {
                return(new FieldDescriptor(this, thatField, annotationType));
            }

            Object[] args = new Object[3];
            args[0] = this;
            args[1] = thatField;
            args[2] = annotationType;

            //TODO: WAT?
            if (annotationType == 6)
            {
                annotationType += 0;
            }

            return(ReflectionTools.GetInstance <FieldDescriptor>(fieldDescriptorClass, args));
        }
        private void UpdateProximities(Tree aTree)
        {
            try
            {
                if (!aTree.Value.IsAbstract)
                {
                    List <Proximity> _dissTemp = (CurrentProximities != null) ? CurrentProximities : new List <Proximity>();

                    ClusterAlgorithm _ClusterAlgorithm = ReflectionTools.GetInstance <ClusterAlgorithm>(aTree.Value.FullName);

                    List <Proximity> _source = new List <Proximity>();

                    foreach (Proximity _prox in _dissTemp)
                    {
                        if (_ClusterAlgorithm.ProximityType == ProximityType.Both || VerifyProximity(_ClusterAlgorithm.ProximityType, _prox))
                        {
                            _source.Add(_prox);
                        }
                    }

                    this.cb_Proximities.ItemsSource       = null;
                    this.cb_Proximities.ItemsSource       = _source;
                    this.cb_Proximities.DisplayMemberPath = "Name";
                    if (_source.Count > 0)
                    {
                        this.cb_Proximities.SelectedIndex = 0;
                    }
                    else
                    {
                        Enviroment.Proximity = null;
                    }

                    this.cb_Proximities.IsEnabled = _ClusterAlgorithm.ProximityType != ProximityType.None;
                }
            }
            catch (Exception _ex)
            {
                GeneralTools.Tools.WriteToLog(_ex);
            }
        }
Ejemplo n.º 11
0
        public MetadataNS.Metadata ConstructMetadata(SimplTypesScope metadataTScope = null)
        {
            if (metadataTScope == null)
            {
                metadataTScope = Repository.MetadataTScope;
            }

            MetadataNS.Metadata result = null;
            Type metadataClass         = GetMetadataClass(metadataTScope);

            if (metadataClass != null)
            {
                Type[]   argClasses = new Type[] { typeof(MetaMetadataCompositeField) };
                object[] argObjects = new object[] { this };
                //result = metadataClass.GetConstructor(argClasses).Invoke(argObjects) as Metadata.Metadata;

                //result = SemanticsPlatformSpecifics.Get().InvokeInstance(metadataClass, argClasses, argObjects) as MetadataNS.Metadata;
                result = ReflectionTools.GetInstance <Metadata>(metadataClass, argObjects);
                // TODO handle mixins.
            }
            return(result);
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     Returns the <c>ClassDescriptor</c> associated with the class type.
        ///     Uses the global class descriptor map to fetch the <c>ClassDescriptor</c>.
        ///     If it is being for the first time it recusively generate <c>ClassDescriptors</c>
        ///     and resolve annotations.
        /// </summary>
        /// <param name="thatClass">
        ///     <c>Type</c> of the class
        /// </param>
        /// <returns>
        ///     <c>ClassDescripor</c> for the paramater class or <c>null</c>
        ///     if there is no associated class descriptor.
        /// </returns>
        public static ClassDescriptor GetClassDescriptor(Type thatClass)
        {
            String className = thatClass.FullName; // for generic classes, className could be null!


            //generics
            while (thatClass.GetTypeInfo().IsGenericParameter)
            //e.g. where X : Media \n where I : X \n ... List<I> field;
            {
                Type[] thatClassConstraints = thatClass.GetTypeInfo().GetGenericParameterConstraints();

                if (thatClassConstraints == null || thatClassConstraints.Length == 0)
                {
                    thatClass = typeof(Object);
                }
                else
                {
                    thatClass = thatClassConstraints[0];
                }

                className = thatClass.FullName;
            }

            if (thatClass.GetTypeInfo().IsGenericType) //can also be a generic parameter that extends a generic type
            {
                if (thatClass.FullName == null)
                {
                    className = thatClass.GetGenericTypeDefinition().FullName;
                }
            }

            ClassDescriptor result = null;

            if (!GlobalClassDescriptorsMap.TryGetValue(className, out result) || !result.IsGetAndOrganizeComplete)
            {
                lock (GlobalClassDescriptorsMap)
                {
                    if (!GlobalClassDescriptorsMap.TryGetValue(className, out result))
                    {
                        var descriptorsAnnotation = XmlTools.GetAnnotation <SimplDescriptorClasses>(thatClass,
                                                                                                    considerInheritedAnnotations
                                                                                                    : true);

                        if (descriptorsAnnotation == null)
                        {
                            result = new ClassDescriptor(thatClass);
                        }
                        else
                        {
                            //First class is the type of the class descriptor, the second the type of the fieldDescriptor.
                            Type classDescriptorClass = descriptorsAnnotation.Classes[0];
                            result = ReflectionTools.GetInstance <ClassDescriptor>(classDescriptorClass,
                                                                                   new object[] { thatClass });
                            result.fieldDescriptorClass = descriptorsAnnotation.Classes[1];
                        }

                        GlobalClassDescriptorsMap[className] = result;

                        ClassDescriptor superCD = result.SuperClass;
                        if (superCD == null || superCD.IsGetAndOrganizeComplete)
                        {
                            result.DeriveAndOrganizeFieldsRecursive(thatClass);
                            result.IsGetAndOrganizeComplete = true;
                            result.HandleFieldDescriptorsDerivedEvent();
                        }
                        else
                        {
                            ClassDescriptor resultFinalCopy = result;
                            superCD.FieldDescriptorsDerived += (sender, args) =>
                            {
                                resultFinalCopy.DeriveAndOrganizeFieldsRecursive(thatClass);
                                resultFinalCopy.IsGetAndOrganizeComplete = true;
                                resultFinalCopy.HandleFieldDescriptorsDerivedEvent();
                            };
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 13
0
        private void bt_Run_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (HasSelectedAlgorithm)
                {
                    string _Error = "";
                    if (!Enviroment.CanRunAlgorithm(out _Error, AlgorithmType.Ensemble))
                    {
                        MessageBox.Show(_Error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    ReflectionTools   _rcet        = new ReflectionTools();
                    ConsensusFunction _EnsembleAlg = ReflectionTools.GetInstance <ConsensusFunction>(Tree.Value.FullName);

                    foreach (CEDS.Property _p in Tree.Value.InProperties)
                    {
                        _rcet.SetProperty(Tree.Value.FullName, _EnsembleAlg, _p);
                    }

                    List <Structuring> _structuringsParams = GetSelectedStructurings();
                    if (_structuringsParams == null || _structuringsParams.Count == 0)
                    {
                        MessageBox.Show("You must select at least one Structuring to apply an Ensemble algorithm.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    VisualUtils.SetGlobalInProperties(_rcet, _EnsembleAlg, Tree, _structuringsParams);

                    #region OLD CODE
                    //Structuring _structuring = _EnsembleAlg.BuildStructuring();

                    //PartitionInfo _partInfo = new PartitionInfo()
                    //{
                    //    AlgorithmName = this.tb_SelectEnsembleAlg.Text,
                    //    ConsensusFunction = _EnsembleAlg,
                    //    Partition = _structuring,
                    //    AlgorithmType = AlgorithmType.Ensemble,
                    //    Index = -1
                    //};
                    //this.uctrl_ListClusterAlgVisualizerEnsemble.AddPartitionInfo(_partInfo);


                    //if (NewStructuringEventHandler != null)
                    //{
                    //    NewStructuringEventHandler(this, new NewStructuringEventArgs(_partInfo));
                    //}
                    #endregion

                    Run _run = RunMethod;
                    _run.BeginInvoke(_EnsembleAlg, RunFinish, new DataThread()
                    {
                        ConsensusFunction = _EnsembleAlg, Run = _run
                    });
                }
                else
                {
                    MessageBox.Show("You must first select an Ensemble algorithm.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception _ex)
            {
                GeneralTools.Tools.WriteToLog(_ex);
            }
        }