本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例12: FindContentProperty
public virtual bool FindContentProperty(out IDataDescriptor dd)
{
dd = new SimplePropertyDataDescriptor(this, GetType().GetProperty("BindingValue"));
return true;
}
示例13: LoadData
public override IClusteringProblemData LoadData(IDataDescriptor descriptor) {
throw new NotImplementedException();
}
示例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;
}
示例15: OnTargetChanged
protected void OnTargetChanged(IDataDescriptor target)
{
UpdateSource();
}