Example #1
0
        public IEnumerable <object> Enumerate(IEnumerationContext context, IncomingMessage incomingMessage, OutgoingMessage outgoingMessage)
        {
            var name = context.Selectors.ExtractObjectName();

            if (_server.IsRegistered(name))
            {
                yield return(ObjectNameSelector.CreateEndpointAddress(name));
            }
        }
        public EndpointReference HandleCreate(ExtractBodyDelegate extractBodyCallback)
        {
            var request = (DynamicMBeanResourceConstructor)extractBodyCallback(typeof(DynamicMBeanResourceConstructor));

            var objectName = request.ResourceEPR.ExtractObjectName();
            var arguments  = request.RegistrationParameters.Select(x => x.Deserialize()).ToArray();

            var instance = _server.CreateMBean(request.ResourceClass, objectName, arguments);

            return(ObjectNameSelector.CreateEndpointAddress(instance.ObjectName));
        }
        public ObjectInstance CreateMBean(string className, ObjectName name, object[] arguments)
        {
            var request = new DynamicMBeanResourceConstructor
            {
                RegistrationParameters =
                    arguments.Select(x => new ParameterType(null, x)).ToArray(),
                ResourceClass = className,
                ResourceEPR   = ObjectNameSelector.CreateEndpointAddress(name)
            };
            var objectName = _manClient.Create(Schema.MBeanServerResourceUri, request).ExtractObjectName();

            return(new ObjectInstance(objectName, null));
        }
Example #4
0
 public GenericValueType(object value)
 {
     if (value == null)
     {
         Item            = new NullType();
         ItemElementName = ItemChoiceType.Null;
     }
     else
     {
         Type valueType = value.GetType();
         if (valueType == typeof(byte[]))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Base64Binary;
         }
         else if (valueType == typeof(bool))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Boolean;
         }
         else if (valueType == typeof(sbyte))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Byte;
         }
         else if (valueType == typeof(ushort))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Character;
         }
         else if (valueType == typeof(DateTime))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.DateTime;
         }
         else if (valueType == typeof(float))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Float;
         }
         else if (valueType == typeof(decimal))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Decimal;
         }
         else if (valueType == typeof(double))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Double;
         }
         else if (valueType == typeof(int))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Int;
         }
         else if (valueType == typeof(long))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Long;
         }
         else if (valueType == typeof(short))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.Short;
         }
         else if (valueType == typeof(string))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.String;
         }
         else if (valueType == typeof(Uri))
         {
             Item            = value.ToString();
             ItemElementName = ItemChoiceType.URI;
         }
         else if (valueType == typeof(Guid))
         {
             Item            = value.ToString();
             ItemElementName = ItemChoiceType.UUID;
         }
         else if (valueType == typeof(TimeSpan))
         {
             Item            = value.ToString();
             ItemElementName = ItemChoiceType.Duration;
         }
         else if (valueType.GetInterface("IDictionary`2") != null)
         {
             Item            = new TypedMapType((IDictionary)value);
             ItemElementName = ItemChoiceType.TypedMap;
         }
         else if (typeof(IDictionary).IsAssignableFrom(valueType))
         {
             Item            = new MapType((IDictionary)value);
             ItemElementName = ItemChoiceType.Map;
         }
         else if (valueType.GetInterface("ICollection`1") != null)
         {
             Item            = new TypedMultipleValueType((ICollection)value);
             ItemElementName = ItemChoiceType.TypedList;
         }
         else if (typeof(ICollection).IsAssignableFrom(valueType))
         {
             Item            = new MultipleValueType((ICollection)value);
             ItemElementName = ItemChoiceType.List;
         }
         else if (valueType == typeof(XmlQualifiedName))
         {
             Item            = value;
             ItemElementName = ItemChoiceType.QName;
         }
         else if (valueType == typeof(ObjectName))
         {
             Item            = ObjectNameSelector.CreateEndpointAddress((ObjectName)value);
             ItemElementName = ItemChoiceType.EndpointReference;
         }
         else if (valueType == typeof(RoleInfo))
         {
             Item            = new ManagedResourceRoleInfo((RoleInfo)value);
             ItemElementName = ItemChoiceType.ManagedResourceRoleInfo;
         }
         else if (valueType == typeof(RoleResult))
         {
             Item            = new ManagedResourceRoleResult((RoleResult)value);
             ItemElementName = ItemChoiceType.ManagedResourceRoleResult;
         }
         else if (typeof(ITabularData).IsAssignableFrom(valueType))
         {
             Item            = new TabularDataValueType((ITabularData)value);
             ItemElementName = ItemChoiceType.TabularDataValue;
         }
         else if (typeof(ICompositeData).IsAssignableFrom(valueType))
         {
             Item            = new CompositeDataValueType((ICompositeData)value);
             ItemElementName = ItemChoiceType.CompositeDataValue;
         }
         else if (typeof(OpenType).IsAssignableFrom(valueType))
         {
             Item = OpenDataType_Type.Serialize(value, out itemElementNameField);
         }
         else
         {
             throw new NotSupportedException("Not supported type in serialization: " + valueType);
         }
     }
 }