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