本文整理汇总了C#中Descriptor类的典型用法代码示例。如果您正苦于以下问题:C# Descriptor类的具体用法?C# Descriptor怎么用?C# Descriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Descriptor类属于命名空间,在下文中一共展示了Descriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Device
public Device(Descriptor descriptor, int baudRate)
{
Descriptor = descriptor;
port = new SerialPort(
portName: descriptor.Port,
baudRate: baudRate,
parity: Parity.None,
dataBits: 8,
stopBits: StopBits.One);
port.ErrorReceived += (s, e) =>
{
throw new ApplicationException(string.Format(
"Serial error: {0}", e.EventType));
};
port.DtrEnable = false;
port.Open();
Thread.Sleep(50);
port.DtrEnable = true;
reader = new BinaryReader(port.BaseStream);
writer = new BinaryWriter(port.BaseStream);
port.ReadTimeout = 5000;
byte r;
do r = reader.ReadByte();
while (r != ready);
port.ReadTimeout = 500;
}
示例2: TypeToolObject
public TypeToolObject(BinaryPSDReader reader)
: base(reader)
{
BinaryPSDReader r = this.GetDataReader();
ushort Version = r.ReadUInt16(); //1= Photoshop 5.0
this.Transform = new Matrix2D(r);
ushort TextDescriptorVersion = r.ReadUInt16(); //=50. For Photoshop 6.0.
if (true)
this.TxtDescriptor = new DynVal(r, true);
else
{
uint XTextDescriptorVersion = r.ReadUInt32(); //=16. For Photoshop 6.0.
this.TextDescriptor = new Descriptor(r);
}
this.Data = r.ReadBytes((int)r.BytesToEnd);
////ushort WarpDescriptorVersion = r.ReadUInt16(); //=50. For Photoshop 6.0.
////uint XWarpDescriptorVersion = r.ReadUInt32(); //=16. For Photoshop 6.0.
////Descriptor warpDescriptor = new Descriptor(r);
//this.WarpDescriptor = new DynVal(r, true);
//this.WarpRect = ERectangleF.FromLTRB((float)r.ReadPSDDouble(), (float)r.ReadPSDDouble(), (float)r.ReadPSDDouble(), (float)r.ReadPSDDouble());
////this.WarpRect.Left = r.ReadPSDDouble();
////double warpRectTop = r.ReadPSDDouble();
////double warpRectRight = r.ReadPSDDouble();
////double warpRectBottom = r.ReadPSDDouble();
//this.Data = null;
}
示例3: MBeanOperationInfo
/// <summary>
/// Creates new MBeanOperationInfo object.
/// </summary>
/// <param name="name">The name of the method.</param>
/// <param name="description">A human readable description of the operation.</param>
/// <param name="returnType">The type of the method's return value.</param>
/// <param name="signature">MBeanParameterInfo objects describing the parameters(arguments) of the method. It should be an empty list if operation has no parameters.</param>
/// <param name="impact">The impact of the method.</param>
/// <param name="descriptor">Initial descriptor values.</param>
public MBeanOperationInfo(string name, string description, string returnType, IEnumerable<MBeanParameterInfo> signature, OperationImpact impact, Descriptor descriptor)
: base(name, description, descriptor)
{
_returnType = returnType;
_signature = new List<MBeanParameterInfo>(signature).AsReadOnly();
_impact = impact;
}
示例4: SetDescriptorDistance
public void SetDescriptorDistance(Descriptor desc, double distance)
{
switch (desc)
{
case Descriptor.NONE:
break;
case Descriptor.CLD:
CLDDiff = distance;
break;
case Descriptor.DCD:
DCDDiff = distance;
break;
case Descriptor.EHD:
EHDDiff = distance;
break;
case Descriptor.SCD:
SCDDiff = distance;
break;
case Descriptor.CEDD:
CEDDDiff = distance;
break;
case Descriptor.FCTH:
FCTHDiff = distance;
break;
default:
break;
}
}
示例5: CreateMBeanAttributeInfo
public MBeanAttributeInfo CreateMBeanAttributeInfo(PropertyInfo info)
{
Descriptor descriptor = new Descriptor();
OpenType openType = OpenType.CreateOpenType(info.PropertyType);
descriptor.SetField(OpenTypeDescriptor.Field, openType);
object[] tmp = info.GetCustomAttributes(typeof(OpenMBeanAttributeAttribute), false);
if (tmp.Length > 0)
{
OpenMBeanAttributeAttribute attr = (OpenMBeanAttributeAttribute)tmp[0];
if (attr.LegalValues != null && (attr.MinValue != null || attr.MaxValue != null))
{
throw new OpenDataException("Cannot specify both min/max values and legal values.");
}
IComparable defaultValue = (IComparable)attr.DefaultValue;
OpenInfoUtils.ValidateDefaultValue(openType, defaultValue);
descriptor.SetField(DefaultValueDescriptor.Field, defaultValue);
if (attr.LegalValues != null)
{
OpenInfoUtils.ValidateLegalValues(openType, attr.LegalValues);
descriptor.SetField(LegalValuesDescriptor.Field, attr.LegalValues);
}
else
{
OpenInfoUtils.ValidateMinMaxValue(openType, defaultValue, attr.MinValue, attr.MaxValue);
descriptor.SetField(MinValueDescriptor.Field, attr.MinValue);
descriptor.SetField(MaxValueDescriptor.Field, attr.MaxValue);
}
}
return new MBeanAttributeInfo(info.Name, InfoUtils.GetDescrition(info, info, "MBean attribute"), openType.Representation.AssemblyQualifiedName,
info.CanRead, info.CanWrite, descriptor);
}
示例6: Default
/// <summary>Defaults.</summary>
/// <param name="d">The Descriptor to process.</param>
/// <param name="x">The Vector to process.</param>
/// <param name="y">The Vector to process.</param>
/// <param name="activation">The activation.</param>
/// <returns>A Network.</returns>
public static Network Default(Descriptor d, Matrix x, Vector y, IFunction activation)
{
var nn = new Network();
// set output to number of choices of available
// 1 if only two choices
var distinct = y.Distinct().Count();
var output = distinct > 2 ? distinct : 1;
// identity funciton for bias nodes
IFunction ident = new Ident();
// set number of hidden units to (Input + Hidden) * 2/3 as basic best guess.
var hidden = (int)Math.Ceiling((decimal)(x.Cols + output) * 2m / 3m);
// creating input nodes
nn.In = new Node[x.Cols + 1];
nn.In[0] = new Node { Label = "B0", Activation = ident };
for (var i = 1; i < x.Cols + 1; i++)
{
nn.In[i] = new Node { Label = d.ColumnAt(i - 1), Activation = ident };
}
// creating hidden nodes
var h = new Node[hidden + 1];
h[0] = new Node { Label = "B1", Activation = ident };
for (var i = 1; i < hidden + 1; i++)
{
h[i] = new Node { Label = string.Format("H{0}", i), Activation = activation };
}
// creating output nodes
nn.Out = new Node[output];
for (var i = 0; i < output; i++)
{
nn.Out[i] = new Node { Label = GetLabel(i, d), Activation = activation };
}
// link input to hidden. Note: there are
// no inputs to the hidden bias node
for (var i = 1; i < h.Length; i++)
{
for (var j = 0; j < nn.In.Length; j++)
{
Edge.Create(nn.In[j], h[i]);
}
}
// link from hidden to output (full)
for (var i = 0; i < nn.Out.Length; i++)
{
for (var j = 0; j < h.Length; j++)
{
Edge.Create(h[j], nn.Out[i]);
}
}
return nn;
}
示例7: DecisionTreeGenerator
/// <summary>Constructor.</summary>
/// <param name="descriptor">the descriptor.</param>
public DecisionTreeGenerator(Descriptor descriptor)
{
Depth = 5;
Width = 2;
Descriptor = descriptor;
ImpurityType = typeof(Entropy);
Hint = double.Epsilon;
}
示例8: SetFieldValuesFromDescriptor
private void SetFieldValuesFromDescriptor(Descriptor descriptor)
{
Field = new List<FeatureDescriptorTypeField>();
foreach (string fieldName in descriptor.GetFieldNames())
{
Field.Add(new FeatureDescriptorTypeField(fieldName, descriptor.GetFieldValue(fieldName)));
}
}
示例9: NotifyCompleted
public void NotifyCompleted(Descriptor descriptor)
{
running.Remove(descriptor);
if (running.Count == 0)
{
if (AllCompleted != null) AllCompleted(this, new EventArgs());
}
}
示例10: GetLabel
/// <summary>Gets a label.</summary>
/// <param name="n">The Node to process.</param>
/// <param name="d">The Descriptor to process.</param>
/// <returns>The label.</returns>
private static string GetLabel(int n, Descriptor d)
{
if (d.Label.Type.IsEnum)
return Enum.GetName(d.Label.Type, n);
else if (d.Label is StringProperty && ((StringProperty)d.Label).AsEnum)
return ((StringProperty)d.Label).Dictionary[n];
else return d.Label.Name;
}
示例11: Generate
/// <summary>Generates.</summary>
/// <param name="desc">The description.</param>
/// <param name="examples">The examples.</param>
/// <param name="linker">The linker.</param>
/// <returns>A Cluster.</returns>
public Cluster Generate(Descriptor desc, IEnumerable<object> examples, ILinker linker)
{
// Load data
var exampleArray = examples.ToArray();
Descriptor = desc;
Matrix X = Descriptor.Convert(examples).ToMatrix();
return GenerateClustering(X, linker, exampleArray);
}
示例12: IsParentNode
public static bool IsParentNode(Descriptor descriptor)
{
bool result = false;
if (descriptor.DescriptorType.DescriptorTypeName == "To")
{
result = true;
}
return result;
}
示例13: MBeanInfo
/// <summary>
/// Constructs an <see cref="NetMX.MBeanInfo"/>.
/// </summary>
/// <param name="className">Name of the MBean described by this MBeanInfo.</param>
/// <param name="description">Human readable description of the MBean. </param>
/// <param name="attributes">List of MBean attributes. It should be an empty list if MBean contains no attributes.</param>
/// <param name="constructors">List of MBean constructors. It should be an empty list if MBean contains no constructors.</param>
/// <param name="operations">List of MBean operations. It should be an empty list if MBean contains no operations.</param>
/// <param name="notifications">List of MBean notifications. It should be an empty list if MBean contains no notifications.</param>
/// <param name="descriptor">Initial descriptor values.</param>
public MBeanInfo(string className, string description, IEnumerable<MBeanAttributeInfo> attributes, IEnumerable<MBeanConstructorInfo> constructors, IEnumerable<MBeanOperationInfo> operations, IEnumerable<MBeanNotificationInfo> notifications, Descriptor descriptor)
{
_className = className;
_description = description;
_attributes = new List<MBeanAttributeInfo>(attributes).AsReadOnly();
_constructors = new List<MBeanConstructorInfo>(constructors).AsReadOnly();
_operations = new List<MBeanOperationInfo>(operations).AsReadOnly();
_notifications = new List<MBeanNotificationInfo>(notifications).AsReadOnly();
_descriptor = descriptor;
}
示例14: Generate
public Cluster Generate(Descriptor descriptor, IEnumerable<object> examples, int k, IDistance metric = null)
{
var data = examples.ToArray();
Descriptor = descriptor;
Matrix X = Descriptor.Convert(examples).ToMatrix();
var assignments = Generate(X, k, metric);
return GenerateClustering(X, assignments, data);
}
示例15: ReadFrom_FromAStreamWithNonHexadecimalCharacters_ThrowsException
public void ReadFrom_FromAStreamWithNonHexadecimalCharacters_ThrowsException()
{
var descriptorBytes = Encoding.ASCII.GetBytes("zz\0e82fe33199f25c242213ada825358e91c4261753\0b\03\0foo\0");
var expected = new Descriptor("e82fe33199f25c242213ada825358e91c4261753", DescriptorType.File, "foo");
using (var stream = new MemoryStream(descriptorBytes))
{
Assert.That(() => Descriptor.ReadFrom(stream), Throws.InstanceOf<InvalidOperationException>());
}
}