Ejemplo n.º 1
0
 /// <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;
         }
     }
 }
Ejemplo n.º 2
0
 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)));
 }
Ejemplo n.º 3
0
 public override int GetHashCode()
 {
     if (InnerValue != null)
     {
         return(InnerValue.GetHashCode());
     }
     return(unchecked (521 * typeof(T).GetHashCode()));
 }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
 /// <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;
            }
        }
Ejemplo n.º 7
0
        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)}>'.");
        }
Ejemplo n.º 8
0
 public Value(vec3 val)
 {
     InnerVal = new InnerValue(new vec4(val, 1.0f)); ValType = Type.VEC3;
 }
Ejemplo n.º 9
0
 public Value(mat4[] val, bool transpose = false)
 {
     InnerVal = new InnerValue(val.serialize()); ValType = transpose ? Type.MAT4_T_ARRAY : Type.MAT4_ARRAY;
 }
Ejemplo n.º 10
0
 public Value(vec4[] val)
 {
     InnerVal = new InnerValue(val.serialize()); ValType = Type.VEC4_ARRAY;
 }
Ejemplo n.º 11
0
 public Value(mat3 val, bool transpose = false)
 {
     InnerVal = new InnerValue(val.serialize()); ValType = transpose ? Type.MAT3_T : Type.MAT3;
 }
Ejemplo n.º 12
0
 public Value(uint val)
 {
     InnerVal = new InnerValue(val); ValType = Type.UINT;
 }
Ejemplo n.º 13
0
 /// <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());
 }
Ejemplo n.º 14
0
 public Value(float val)
 {
     InnerVal = new InnerValue(val); ValType = Type.FLOAT;
 }
Ejemplo n.º 15
0
 public Value(vec2 val)
 {
     InnerVal = new InnerValue(new vec4(val.x, val.y, 0.0f, 1.0f)); ValType = Type.VEC2;
 }
Ejemplo n.º 16
0
 public Value(Color val, bool rgb_only = false)
 {
     InnerVal = new InnerValue(val.vectorized); ValType = rgb_only ? Type.RGB : Type.RGBA;
 }
Ejemplo n.º 17
0
 public Value(float[] val)
 {
     InnerVal = new InnerValue(val); ValType = Type.FLOAT_ARRAY;
 }
Ejemplo n.º 18
0
 public Value(uint[] val)
 {
     InnerVal = new InnerValue(val); ValType = Type.UINT_ARRAY;
 }
Ejemplo n.º 19
0
 public Value(vec4 val)
 {
     InnerVal = new InnerValue(val); ValType = Type.VEC4;
 }
Ejemplo n.º 20
0
 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;
 }
Ejemplo n.º 21
0
 public override string ToString()
 {
     return(InnerValue.ToString());
 }
Ejemplo n.º 22
0
 protected override IDisposable SubscribeCore(IObserver <T> observer)
 {
     return(InnerValue.Subscribe(observer));
 }