本文整理汇总了C#中IDataDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# IDataDescriptor类的具体用法?C# IDataDescriptor怎么用?C# IDataDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDataDescriptor类属于命名空间,在下文中一共展示了IDataDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: OnDataContextValueChanged
void OnDataContextValueChanged(IDataDescriptor dd)
{
InitializeSubItemsSource();
}
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:4,代码来源:HeaderedItemsControl.cs
示例17: GetPendingOrCurrentValue
/// <summary>
/// Gets either the value of the given <paramref name="dataDescriptor"/> or, if there is a value to be set in the
/// render thread, that pending value.
/// </summary>
/// <param name="dataDescriptor">Data descriptor whose value should be returned.</param>
/// <param name="value">Pending value or current value.</param>
/// <returns><c>true</c>, if the returned value is pending to be set, else <c>false</c>.</returns>
public bool GetPendingOrCurrentValue(IDataDescriptor dataDescriptor, out object value)
{
Screen screen = Screen;
Animator animator = screen == null ? null : screen.Animator;
try
{
if (animator != null)
{
Monitor.Enter(animator.SyncObject);
if (animator.TryGetPendingValue(dataDescriptor, out value))
return true;
}
value = dataDescriptor.Value;
}
finally
{
if (animator != null)
Monitor.Exit(animator.SyncObject);
}
return false;
}
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:28,代码来源:UIElement.cs
示例18: Convert
/// <summary>
/// Evaluates a simple expression, given via the parameter <paramref name="parameter"/>.
/// </summary>
/// <remarks>
/// This converter will often be used in XAML files. Note that in XAML, an attribute beginning with a <c>'{'</c> character
/// is interpreted as an invocation of a markup extension. So the expression "{0} + 5" must be escaped like this:
/// <c>"{}{0} + 5"</c>. Note also that the boolean AND operator (<c>"&&"</c>) must be escaped too like this: <c>"{}{0} && true"</c>.
/// </remarks>
/// <param name="values">The values used for the variables {0} .. {n}.</param>
/// <param name="targetType">Type to that the evaluated result should be converted.</param>
/// <param name="parameter">String containing the expression. Variables can be accessed via numbers in
/// curly braces, for example "!({0} || {2})". The variables are mapped to the values specified by
/// the <paramref name="values"/> array.</param>
/// <param name="result">Will return the evaluated result of the given <paramref name="targetType"/>.</param>
public bool Convert(IDataDescriptor[] values, Type targetType, object parameter, out object result)
{
result = null;
string expression = parameter as string;
if (string.IsNullOrEmpty(expression))
return false;
try
{
// We're using an expression parser from "devilplusplus", "C# Eval function"
// See http://www.codeproject.com/KB/dotnet/Expr.aspx
// The parser was slightly adapted to our needs:
// - To access a variable, the variable identifier has to be written in curly braces, for example:
// {0} + {1}
Parser ep = new Parser();
Evaluator evaluator = new Evaluator();
ParameterVariableHolder pvh = new ParameterVariableHolder();
// The used expression parser supports access to static functions for those of the parameters whose type is a class.
// We could add classes here like the code commented out below. To access a static member on the string class,
// the expression could be for example: {string}.{Empty}
// For now, we don't need this functionality, so we don't add types (Albert, 2009-04-22).
//pvh.Parameters["char"] = new Parameter(typeof(char));
//pvh.Parameters["sbyte"] = new Parameter(typeof(sbyte));
//pvh.Parameters["byte"] = new Parameter(typeof(byte));
//pvh.Parameters["short"] = new Parameter(typeof(short));
//pvh.Parameters["ushort"] = new Parameter(typeof(ushort));
//pvh.Parameters["int"] = new Parameter(typeof(int));
//pvh.Parameters["uint"] = new Parameter(typeof(uint));
//pvh.Parameters["long"] = new Parameter(typeof(string));
//pvh.Parameters["ulong"] = new Parameter(typeof(ulong));
//pvh.Parameters["float"] = new Parameter(typeof(float));
//pvh.Parameters["double"] = new Parameter(typeof(double));
//pvh.Parameters["decimal"] = new Parameter(typeof(decimal));
//pvh.Parameters["DateTime"] = new Parameter(typeof(DateTime));
//pvh.Parameters["string"] = new Parameter(typeof(string));
//pvh.Parameters["Guid"] = new Parameter(typeof(Guid));
//pvh.Parameters["Convert"] = new Parameter(typeof(Convert));
//pvh.Parameters["Math"] = new Parameter(typeof(Math));
//pvh.Parameters["Array"] = new Parameter(typeof(Array));
//pvh.Parameters["Random"] = new Parameter(typeof(Random));
//pvh.Parameters["TimeZone"] = new Parameter(typeof(TimeZone));
// Add child binding values
for (int i = 0; i < values.Length; i++)
{
IDataDescriptor value = values[i];
Type type = value.DataType;
if (type != null && !pvh.Parameters.Contains(type.Name))
pvh.Parameters[type.Name] = new Parameter(type);
pvh.Parameters[i.ToString()] = new Parameter(value.Value, type);
}
evaluator.VariableHolder = pvh;
Tree tree = ep.Parse(expression);
result = evaluator.Eval(tree);
return TypeConverter.Convert(result, targetType, out result);
}
catch (Exception)
{
return false;
}
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:79,代码来源:ExpressionMultiValueConverter.cs
示例19: SetValueInRenderThread
public void SetValueInRenderThread(IDataDescriptor dataDescriptor, object value)
{
if (_elementState == ElementState.Disposing)
return;
Screen screen = Screen;
if (screen == null || _elementState == ElementState.Available || _elementState == ElementState.Preparing ||
Thread.CurrentThread == SkinContext.RenderThread)
dataDescriptor.Value = value;
else
screen.Animator.SetValue(dataDescriptor, value);
}
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:11,代码来源:UIElement.cs
示例20: FindContentProperty
public bool FindContentProperty(out IDataDescriptor dd)
{
return ReflectionHelper.FindMemberDescriptor(this, "Content", out dd);
}
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:4,代码来源:UIElement.cs
注:本文中的IDataDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论