当前位置: 首页>>代码示例>>C#>>正文


C# IDataDescriptor类代码示例

本文整理汇总了C#中IDataDescriptor的典型用法代码示例。如果您正苦于以下问题:C# IDataDescriptor类的具体用法?C# IDataDescriptor怎么用?C# IDataDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IDataDescriptor类属于命名空间,在下文中一共展示了IDataDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadData

    public override IRegressionProblemData LoadData(IDataDescriptor id) {
      var descriptor = (ResourceRegressionDataDescriptor)id;

      var instanceArchiveName = GetResourceName(FileName + @"\.zip");
      using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) {
        var entry = instancesZipFile.GetEntry(descriptor.ResourceName);
        NumberFormatInfo numberFormat;
        DateTimeFormatInfo dateFormat;
        char separator;
        using (Stream stream = entry.Open()) {
          TableFileParser.DetermineFileFormat(stream, out numberFormat, out dateFormat, out separator);
        }

        TableFileParser csvFileParser = new TableFileParser();
        using (Stream stream = entry.Open()) {
          csvFileParser.Parse(stream, numberFormat, dateFormat, separator, true);
        }

        Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
        if (!descriptor.CheckVariableNames(csvFileParser.VariableNames)) {
          throw new ArgumentException("Parsed file contains variables which are not in the descriptor.");
        }

        return descriptor.GenerateRegressionData(dataset);
      }
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:26,代码来源:ResourceRegressionInstanceProvider.cs

示例2: LoadData

 public override IRegressionProblemData LoadData(IDataDescriptor descriptor) {
   var frfDescriptor = descriptor as FriedmanRandomFunction;
   if (frfDescriptor == null) throw new ArgumentException("FriedmanRandomFunctionInstanceProvider expects an FriedmanRandomFunction data descriptor.");
   // base call generates a regression problem data
   var problemData = base.LoadData(frfDescriptor);
   return problemData;
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:7,代码来源:FriedmanRandomFunctionInstanceProvider.cs

示例3: LoadData

 public override IRegressionProblemData LoadData(IDataDescriptor descriptor) {
   var varNetwork = descriptor as VariableNetwork;
   if (varNetwork == null) throw new ArgumentException("VariableNetworkInstanceProvider expects an VariableNetwork data descriptor.");
   // base call generates a regression problem data
   var problemData = base.LoadData(varNetwork);
   problemData.Description = varNetwork.Description + Environment.NewLine + varNetwork.NetworkDefinition;
   return problemData;
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:8,代码来源:VariableNetworkInstanceProvider.cs

示例4: Convert

 public bool Convert (IDataDescriptor[] values, Type targetType, object parameter, out object result)
 {
   foreach (IDataDescriptor dataDescriptor in values)
   {
     if (dataDescriptor !=  null)
     {
       result = dataDescriptor.Value;
       return true;
     }
   }
   result = false;
   return false;
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:13,代码来源:PriorityBindingConverter.cs

示例5: Convert

 public bool Convert(IDataDescriptor[] values, Type targetType, object parameter, out object result)
 {
   var enumerable = values[1].Value as IEnumerable;
   if (enumerable != null)
   {
     var collection = new List<object>(enumerable.OfType<object>());
     var itemIndex = collection.IndexOf(values[0].Value);
     int indexOffset;
     // Support offset, usually "1" to show "1/50" instead "0/50"
     if (int.TryParse(parameter as string, out indexOffset))
       itemIndex += indexOffset;
     result = itemIndex;
   }
   else
   {
     result = -1;
   }
   return true;
 }
开发者ID:aspik,项目名称:MediaPortal-2,代码行数:19,代码来源:GetIndexMultiConverter.cs

示例6: LoadData

    public override IRegressionProblemData LoadData(IDataDescriptor descriptor) {
      var featureSelectionDescriptor = descriptor as FeatureSelection;
      if (featureSelectionDescriptor == null) throw new ArgumentException("FeatureSelectionInstanceProvider expects an FeatureSelection data descriptor.");
      // base call generates a regression problem data
      var regProblemData = base.LoadData(featureSelectionDescriptor);
      var problemData =
        new FeatureSelectionRegressionProblemData(
          regProblemData.Dataset, regProblemData.AllowedInputVariables, regProblemData.TargetVariable,
          featureSelectionDescriptor.SelectedFeatures, featureSelectionDescriptor.Weights,
          featureSelectionDescriptor.OptimalRSquared);

      // copy values from regProblemData to feature selection problem data
      problemData.Name = regProblemData.Name;
      problemData.Description = regProblemData.Description;
      problemData.TrainingPartition.Start = regProblemData.TrainingPartition.Start;
      problemData.TrainingPartition.End = regProblemData.TrainingPartition.End;
      problemData.TestPartition.Start = regProblemData.TestPartition.Start;
      problemData.TestPartition.End = regProblemData.TestPartition.End;

      return problemData;
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:21,代码来源:FeatureSelectionInstanceProvider.cs

示例7: Convert

    public bool Convert(IDataDescriptor[] values, Type targetType, object parameter, out object result)
    {
      result = false;
      if (values.Length != 2)
      {
        ServiceRegistration.Get<ILogger>().Error("MediaItemAspectToBoolConverter: invalid number of arguments (expects MediaItem and Guid)");
        return false;
      }
      MediaItem mediaItem = values[0].Value as MediaItem;
      if (mediaItem == null || values[1].Value == null)
        return true;

      string aspectIdString = values[1].Value as string;
      Guid aspectId;
      if (values[1].Value is Guid)
        aspectId = (Guid)values[1].Value;
      else if (!Guid.TryParse(aspectIdString, out aspectId))
        return true;

      result = mediaItem.Aspects.ContainsKey(aspectId);
      return true;
    }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:22,代码来源:MediaItemAspectToBoolConverter.cs

示例8: LoadData

    public override CFGData LoadData(IDataDescriptor id) {
      CFGArtificialDataDescriptor descriptor = (CFGArtificialDataDescriptor)id;
      CFGData cfgData = descriptor.GenerateData();
      var instanceArchiveName = GetResourceName(FileName + @"\.zip");
      using (var instancesZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) {
        IEnumerable<ZipArchiveEntry> entries = instancesZipFile.Entries.Where(e => e.FullName.StartsWith(descriptor.Identifier) && !String.IsNullOrWhiteSpace(e.Name));

        var bnfEntry = entries.Where(x => x.Name.EndsWith(".bnf")).FirstOrDefault();
        if (bnfEntry != null) {
          using (var stream = new StreamReader(bnfEntry.Open())) {
            cfgData.Grammar = stream.ReadToEnd();
          }
        }

        var embedEntry = entries.Where(x => x.Name.EndsWith("Embed.txt")).FirstOrDefault();
        if (embedEntry != null) {
          using (var stream = new StreamReader(embedEntry.Open())) {
            cfgData.Embed = stream.ReadToEnd();
          }
        }
      }
      return cfgData;
    }
开发者ID:t-h-e,项目名称:HeuristicLab.CFGGP,代码行数:23,代码来源:CFGArtificialInstanceProvider.cs

示例9: BindingDependency

 /// <summary>
 /// Creates a new <see cref="BindingDependency"/> object.
 /// </summary>
 /// <param name="sourceDd">Souce data descriptor for the dependency.</param>
 /// <param name="targetDd">Target data descriptor for the dependency.</param>
 /// <param name="autoAttachToSource">If set to <c>true</c>, the new dependency object will be
 /// automatically attached to the <paramref name="sourceDd"/> data descriptor. This means it will
 /// capture changes from it and reflect them on the <paramref name="targetDd"/> data descriptor.</param>
 /// <param name="updateSourceTrigger">This parameter controls, which target object event makes this
 /// binding dependency copy the target value to the <paramref name="sourceDd"/> data descriptor.
 /// If set to <see cref="UpdateSourceTrigger.PropertyChanged"/>, the new binding dependency object
 /// will automatically attach to property changes of the <paramref name="targetDd"/> data descriptor and
 /// reflect the changed value to the <paramref name="sourceDd"/> data descriptor. If set to
 /// <see cref="UpdateSourceTrigger.LostFocus"/>, the new binding dependency will attach to the
 /// <see cref="UIElement.EventOccured"/> event of the <paramref name="parentUiElement"/> object.
 /// If set to <see cref="UpdateSourceTrigger.Explicit"/>, the new binding dependency won't attach to
 /// the target at all.</param>
 /// <param name="parentUiElement">The parent <see cref="UIElement"/> of the specified <paramref name="targetDd"/>
 /// data descriptor. This parameter is only used to attach to the lost focus event if
 /// <paramref name="updateSourceTrigger"/> is set to <see cref="UpdateSourceTrigger.LostFocus"/>.</param>
 /// <param name="customValueConverter">Set a custom value converter with this parameter. If this parameter
 /// is set to <c>null</c>, the default <see cref="TypeConverter"/> will be used.</param>
 /// <param name="customValueConverterParameter">Parameter to be used in the custom value converter, if one is
 /// set.</param>
 public BindingDependency(IDataDescriptor sourceDd, IDataDescriptor targetDd, bool autoAttachToSource,
     UpdateSourceTrigger updateSourceTrigger, UIElement parentUiElement,
     IValueConverter customValueConverter, object customValueConverterParameter)
 {
   _sourceDd = sourceDd;
   _targetDd = targetDd;
   _targetObject = _targetDd.TargetObject as DependencyObject;
   _sourceObject = _sourceDd.TargetObject as DependencyObject;
   _valueConverter = customValueConverter;
   _converterParameter = customValueConverterParameter;
   if (autoAttachToSource && sourceDd.SupportsChangeNotification)
   {
     sourceDd.Attach(OnSourceChanged);
     _attachedToSource = true;
   }
   if (targetDd.SupportsChangeNotification)
   {
     if (updateSourceTrigger == UpdateSourceTrigger.PropertyChanged)
     {
       targetDd.Attach(OnTargetChanged);
       _attachedToTarget = true;
     }
     else if (updateSourceTrigger == UpdateSourceTrigger.LostFocus)
     {
       if (parentUiElement != null)
         parentUiElement.EventOccured += OnTargetElementEventOccured;
       _attachedToLostFocus = parentUiElement;
     }
   }
   // Initially update endpoints
   if (autoAttachToSource)
     UpdateTarget();
   if (updateSourceTrigger != UpdateSourceTrigger.Explicit &&
       !autoAttachToSource) // If we are attached to both, only update one direction
     UpdateSource();
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:60,代码来源:BindingDependency.cs

示例10: HandleMemberAssignment

    public void HandleMemberAssignment(IDataDescriptor dd, object value)
    {
      IBinding binding = value as IBinding;
      if (binding != null && dd.DataType != typeof(IBinding)) // In case the property descriptor's type is IBinding, we want to assign the binding directly instead of binding it to the property
      {
        binding.SetTargetDataDescriptor(dd);
        return;
      }

      IEvaluableMarkupExtension evaluableMarkupExtension = value as IEvaluableMarkupExtension;
      if (evaluableMarkupExtension != null)
      {
        evaluableMarkupExtension.Initialize(this);
        if (!evaluableMarkupExtension.Evaluate(out value))
        {
          _deferredMarkupExtensionActivations.Add(new EvaluatableMarkupExtensionActivator(this, evaluableMarkupExtension, dd));
          return;
        }
      }

      AssignValue(dd, value);
    }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:22,代码来源:Parser.cs

示例11: GetEnumerationEntryByIndex

 /// <summary>
 /// Returns a data descriptor for the access to a collection-like instance
 /// <paramref name="maybeCollection"/> with an <paramref name="index"/>.
 /// </summary>
 /// <param name="maybeCollection">Instance which may be collection-like, like an
 /// <see cref="IList{T}"/>, <see cref="ICollection{T}"/> or <see cref="IEnumerable{T}"/>.
 /// The returned data descriptor will allow to read the value, and for an
 /// <see cref="IList{T}"/> it will also be writeable.</param>
 /// <param name="index">Index to access the collection-like instance.</param>
 /// <param name="result">Returns the data descriptor for the access to the
 /// <paramref name="index"/>th entry in <paramref name="maybeCollection"/>.</param>
 /// <returns><c>true</c>, if <paramref name="maybeCollection"/> is a collection-like
 /// instance and could be accessed by the specified <paramref name="index"/>, else
 /// <c>false</c>.</returns>
 public static bool GetEnumerationEntryByIndex(object maybeCollection, int index,
     out IDataDescriptor result)
 {
   if (maybeCollection is IList)
   {
     result = new IndexerDataDescriptor(maybeCollection, new object[] { index });
     return true;
   }
   if (maybeCollection is IEnumerable)
   {
     int i = 0;
     foreach (object o in (IEnumerable)maybeCollection)
     {
       if (i++ == index)
       {
         result = new ValueDataDescriptor(o);
         return true;
       }
     }
     throw new XamlBindingException("Index '{0}' is out of range (# elements={1})", index, i);
   }
   result = null;
   return false;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:38,代码来源:ReflectionHelper.cs

示例12: FindContentProperty

 public virtual bool FindContentProperty(out IDataDescriptor dd)
 {
   dd = new SimplePropertyDataDescriptor(this, GetType().GetProperty("BindingValue"));
   return true;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:5,代码来源:LateBoundValue.cs

示例13: LoadData

 public override IClusteringProblemData LoadData(IDataDescriptor descriptor) {
   throw new NotImplementedException();
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:3,代码来源:ClusteringCSVInstanceProvider.cs

示例14: FindMemberDescriptor

 /// <summary>
 /// Given the instance <paramref name="obj"/> and the <paramref name="memberName"/>,
 /// this method searches the best matching member on the instance. It first searches
 /// a property with name [PropertyName]Property, casts it to
 /// <see cref="AbstractProperty"/> and returns a <see cref="DependencyPropertyDataDescriptor"/>
 /// for it in the parameter <paramref name="dd"/>. If there is no such property, this method
 /// searches a simple property with the given name, returning a property descriptor for it.
 /// Then, the method will search for a field with the specified name, returning a
 /// <see cref="FieldDataDescriptor"/> for it.
 /// If there is no member found with the given name, this method returns false and a
 /// <c>null</c> value in <paramref name="dd"/>.
 /// </summary>
 /// <param name="obj">The object where to search the member with the
 /// specified <paramref name="memberName"/>.</param>
 /// <param name="memberName">The name of the member to be searched.</param>
 /// <param name="dd">Data descriptor which will be returned for the property or member,
 /// if it was found, else a <c>null</c> value will be returned.</param>
 /// <returns><c>true</c>, if a member with the specified name was found, else <c>false</c>.</returns>
 public static bool FindMemberDescriptor(object obj, string memberName, out IDataDescriptor dd)
 {
   if (obj == null)
     throw new NullReferenceException("Property target object 'null' is not supported");
   DependencyPropertyDataDescriptor dpdd;
   if (DependencyPropertyDataDescriptor.CreateDependencyPropertyDataDescriptor(
         obj, memberName, out dpdd))
   {
     dd = dpdd;
     return true;
   }
   SimplePropertyDataDescriptor spdd;
   if (SimplePropertyDataDescriptor.CreateSimplePropertyDataDescriptor(
       obj, memberName, out spdd))
   {
     dd = spdd;
     return true;
   }
   FieldDataDescriptor fdd;
   if (FieldDataDescriptor.CreateFieldDataDescriptor(obj, memberName, out fdd))
   {
     dd = fdd;
     return true;
   }
   dd = null;
   return false;
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:45,代码来源:ReflectionHelper.cs

示例15: OnTargetChanged

 protected void OnTargetChanged(IDataDescriptor target)
 {
   UpdateSource();
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:4,代码来源:BindingDependency.cs


注:本文中的IDataDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。