Пример #1
0
 public override void Set(THolder holder, TElement[] value)
 {
     if (value == null)
     {
         Clear(holder);
     }
     else if (value.Length > 0)
     {
         base.Set(holder, value);
     }
     else
     {
         base.Set(holder, ArrayHelpers.GetEmptyArray <TElement>());
     }
 }
Пример #2
0
        public static IEnumerable <PropertyInfo> GetScriptableDefaultProperties(this Type type, BindingFlags bindFlags, Type accessContext, ScriptAccess defaultAccess)
        {
            if (type.IsArray)
            {
                var property = typeof(IList <>).MakeSpecificType(type.GetElementType()).GetProperty("Item");
                return((property != null) ? property.ToEnumerable() : ArrayHelpers.GetEmptyArray <PropertyInfo>());
            }

            var properties = type.GetProperties(bindFlags).AsEnumerable();

            if (type.IsInterface)
            {
                properties = properties.Concat(type.GetInterfaces().SelectMany(interfaceType => interfaceType.GetScriptableProperties(bindFlags, accessContext, defaultAccess)));
            }

            var defaultMembers = type.GetDefaultMembers();

            return(properties.Where(property => property.IsScriptable(accessContext, defaultAccess) && (defaultMembers.Contains(property) || property.IsDispID(SpecialDispIDs.Default))));
        }
Пример #3
0
 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
 {
     return(ArrayHelpers.GetEmptyArray <object>());
 }
Пример #4
0
 public override ParameterInfo[] GetIndexParameters()
 {
     return(ArrayHelpers.GetEmptyArray <ParameterInfo>());
 }
Пример #5
0
            public override object GetValue(object obj)
            {
                // This occurs during VB-based dynamic script item invocation. It was not observed
                // before script items gained an IReflect/IExpando implementation that exposes
                // script item properties as fields. Apparently VB's dynamic invocation support not
                // only recognizes IReflect/IExpando but actually favors it over DynamicObject.

                var reflect = obj as IReflect;

                if (reflect != null)
                {
                    return(reflect.InvokeMember(name, BindingFlags.GetField, null, obj, ArrayHelpers.GetEmptyArray <object>(), null, CultureInfo.InvariantCulture, null));
                }

                throw new InvalidOperationException("Invalid field retrieval");
            }
Пример #6
0
 public object GetProperty(int index)
 {
     return(dispatchEx.GetProperty(index.ToString(CultureInfo.InvariantCulture), false, ArrayHelpers.GetEmptyArray <object>()));
 }