/// <summary> /// 初始化插件 /// </summary> /// <param name="part"></param> /// <param name="definition"></param> public PlugIn(ComposablePart part, ExportDefinition definition) { part.NotNull()?.Throw(nameof(part)); definition.NotNull()?.Throw(nameof(definition)); Name = definition.ContractName; Metadata = definition.Metadata; InnerValue = part.GetExportedValue(definition); Priority = GetMetadata("Priority", 0); TypeIdentity = GetMetadata <string>("ExportTypeIdentity", null); IsMethod = InnerValue is ExportedDelegate; if (IsMethod) { InnerValue = typeof(ExportedDelegate).GetField("_method", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(InnerValue); } else if (InnerValue != null) { var type = InnerValue.GetType(); if (TypeIdentity != null) { Type = type.Module.GetType(TypeIdentity, false, false) ?? type; } else { Type = type; } } }
public override void Write(XElement root) { if (root == null) throw new ArgumentNullException(nameof(root)); var @string = InnerValue.ToString(CultureInfo.InvariantCulture); root.Add(new XElement(m_name, new XAttribute("value", @string))); }
public override int GetHashCode() { if (InnerValue != null) { return(InnerValue.GetHashCode()); } return(unchecked (521 * typeof(T).GetHashCode())); }
/// <summary> /// Determines if this terminal is equal to the given other terminal. /// </summary> /// <param name="terminal"></param> /// <returns></returns> public virtual bool Equals(ITerminal <T> terminal) { if (terminal != null) { if (InnerValue != null && terminal.InnerValue != null) { return(InnerValue.Equals(terminal.InnerValue)); } return((object)InnerValue == (object)terminal.InnerValue); } return((object)InnerValue == terminal); }
/// <summary> /// Returns this object as a string represented by the inner value. /// </summary> /// <returns></returns> public override string ToString() { if (InnerValue != null) { if (Negated) { return(string.Format("Not {0}", InnerValue)); } return(InnerValue.ToString()); } if (!Negated) { return("END_OF_INPUT"); } return("Anything"); }
void ReleaseDesignerOutlets() { if (InnerSlider != null) { InnerSlider.Dispose(); InnerSlider = null; } if (InnerValue != null) { InnerValue.Dispose(); InnerValue = null; } if (OuterSlider != null) { OuterSlider.Dispose(); OuterSlider = null; } if (OuterValue != null) { OuterValue.Dispose(); OuterValue = null; } if (StreamlinedCheckbox != null) { StreamlinedCheckbox.Dispose(); StreamlinedCheckbox = null; } if (HeadCheckbox != null) { HeadCheckbox.Dispose(); HeadCheckbox = null; } if (TailCheckbox != null) { TailCheckbox.Dispose(); TailCheckbox = null; } }
public IEnumerable <T> Get(IContext context) { var result = InnerValue.Get(context); if (result is T t) { return(new[] { t }); } if (result is IEnumerable <T> enumerable) { return(enumerable); } if (result is IEnumerable <object> nonGeneric) { return(nonGeneric.OfType <T>().ToList()); } throw new InvalidOperationException($"Invalid type returned from a value. Expected 'IEnumerable<{typeof(T)}>'."); }
public Value(vec3 val) { InnerVal = new InnerValue(new vec4(val, 1.0f)); ValType = Type.VEC3; }
public Value(mat4[] val, bool transpose = false) { InnerVal = new InnerValue(val.serialize()); ValType = transpose ? Type.MAT4_T_ARRAY : Type.MAT4_ARRAY; }
public Value(vec4[] val) { InnerVal = new InnerValue(val.serialize()); ValType = Type.VEC4_ARRAY; }
public Value(mat3 val, bool transpose = false) { InnerVal = new InnerValue(val.serialize()); ValType = transpose ? Type.MAT3_T : Type.MAT3; }
public Value(uint val) { InnerVal = new InnerValue(val); ValType = Type.UINT; }
/// <summary> /// Serves as a hash function for a <see cref="VKS.Measures.Mass"/> object. /// </summary> /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.</returns> public override int GetHashCode() { return(InnerValue.GetHashCode()); }
public Value(float val) { InnerVal = new InnerValue(val); ValType = Type.FLOAT; }
public Value(vec2 val) { InnerVal = new InnerValue(new vec4(val.x, val.y, 0.0f, 1.0f)); ValType = Type.VEC2; }
public Value(Color val, bool rgb_only = false) { InnerVal = new InnerValue(val.vectorized); ValType = rgb_only ? Type.RGB : Type.RGBA; }
public Value(float[] val) { InnerVal = new InnerValue(val); ValType = Type.FLOAT_ARRAY; }
public Value(uint[] val) { InnerVal = new InnerValue(val); ValType = Type.UINT_ARRAY; }
public Value(vec4 val) { InnerVal = new InnerValue(val); ValType = Type.VEC4; }
public Value(Color[] val, bool rgb_only = false) { InnerVal = new InnerValue(val.serialize(null, rgb_only)); ValType = rgb_only ? Type.RGB_ARRAY : Type.RGBA_ARRAY; }
public override string ToString() { return(InnerValue.ToString()); }
protected override IDisposable SubscribeCore(IObserver <T> observer) { return(InnerValue.Subscribe(observer)); }